From 50c77ab444c537352a036ac2fd471f02bc629368 Mon Sep 17 00:00:00 2001 From: Joseph Coffland Date: Sat, 25 Jan 2020 13:43:58 -0800 Subject: [PATCH] Beta support for OMRON MX2 VFD. --- CHANGELOG.md | 3 ++ package.json | 2 +- src/avr/src/modbus.c | 4 +- src/avr/src/spindle.h | 1 + src/avr/src/vfd_spindle.c | 15 ++++++ src/pug/templates/tool-view.pug | 79 ++++++++++++++++++++++++++++-- src/resources/config-template.json | 2 +- 7 files changed, 97 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59708e6..2b18574 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ Buildbotics CNC Controller Firmware Changelog ============================================= +## v0.4.13 + - Beta support for OMRON MX2 VFD. + ## v0.4.12 - Segments straddle arc in linearization. - Control max-arc-error with GCode var. diff --git a/package.json b/package.json index 2d06ce8..2c79e85 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bbctrl", - "version": "0.4.12", + "version": "0.4.13", "homepage": "http://buildbotics.com/", "repository": "https://github.com/buildbotics/bbctrl-firmware", "license": "GPL-3.0+", diff --git a/src/avr/src/modbus.c b/src/avr/src/modbus.c index ef1d792..2e63c1e 100644 --- a/src/avr/src/modbus.c +++ b/src/avr/src/modbus.c @@ -120,8 +120,8 @@ static void _set_rxc_interrupt(bool enable) { static void _write_word(uint8_t *dst, uint16_t value, bool little_endian) { - dst[!little_endian] = value; - dst[little_endian] = value >> 8; + dst[!little_endian] = value; + dst[little_endian] = value >> 8; } diff --git a/src/avr/src/spindle.h b/src/avr/src/spindle.h index 556a512..61f17bb 100644 --- a/src/avr/src/spindle.h +++ b/src/avr/src/spindle.h @@ -56,6 +56,7 @@ typedef enum { SPINDLE_TYPE_YL600, SPINDLE_TYPE_FR_D700, SPINDLE_TYPE_SUNFAR_E300, + SPINDLE_TYPE_OMRON_MX2, } spindle_type_t; diff --git a/src/avr/src/vfd_spindle.c b/src/avr/src/vfd_spindle.c index 40cdf4a..d7234bb 100644 --- a/src/avr/src/vfd_spindle.c +++ b/src/avr/src/vfd_spindle.c @@ -154,6 +154,20 @@ const vfd_reg_t sunfar_e300_regs[] PROGMEM = { }; +const vfd_reg_t omron_mx2_regs[] PROGMEM = { + {REG_CONNECT_WRITE, 0x1201, 3}, // A001 Frequency reference modbus + {REG_CONNECT_WRITE, 0x1202, 3}, // A002 Run command modbus + {REG_MAX_FREQ_READ, 0x1204, 0}, // A004 Max frequency + {REG_FREQ_SET, 0x0001, 0}, // F001 Frequency + {REG_STOP_WRITE, 0x1e01, 0}, // Stop drive + {REG_FWD_WRITE, 0x1e01, 2}, // Forward + {REG_REV_WRITE, 0x1e01, 6}, // Reverse + {REG_FREQ_READ, 0x1001, 0}, // D001 Output freq + {REG_STATUS_READ, 0x0005, 0}, // Status A + {REG_DISABLED}, +}; + + static vfd_reg_t regs[VFDREG]; static vfd_reg_t custom_regs[VFDREG]; @@ -371,6 +385,7 @@ void vfd_spindle_init() { case SPINDLE_TYPE_YL600: _load(yl600_regs); break; case SPINDLE_TYPE_FR_D700: _load(fr_d700_regs); break; case SPINDLE_TYPE_SUNFAR_E300: _load(sunfar_e300_regs); break; + case SPINDLE_TYPE_OMRON_MX2: _load(omron_mx2_regs); break; default: break; } diff --git a/src/pug/templates/tool-view.pug b/src/pug/templates/tool-view.pug index 7440094..a3ef3a1 100644 --- a/src/pug/templates/tool-view.pug +++ b/src/pug/templates/tool-view.pug @@ -109,7 +109,7 @@ script#tool-view-template(type="text/x-template") .notes(v-if="tool_type == 'HUANYANG VFD'") h2 Notes - p Set the following using the VFD's frontpanel. + p Set the following using the VFD's front panel. table.modbus-regs.fixed-regs tr th Address @@ -157,7 +157,7 @@ script#tool-view-template(type="text/x-template") .notes(v-if="tool_type.startsWith('NOWFOREVER VFD')") h2 Notes - p Set the following using the VFD's frontpanel. + p Set the following using the VFD's front panel. table.modbus-regs.fixed-regs tr th Address @@ -197,7 +197,7 @@ script#tool-view-template(type="text/x-template") .notes(v-if="tool_type.startsWith('DELTA VFD015M21A')") h2 Notes - p Set the following using the VFD's frontpanel. + p Set the following using the VFD's front panel. table.modbus-regs.fixed-regs tr th Address @@ -245,7 +245,7 @@ script#tool-view-template(type="text/x-template") .notes(v-if="tool_type.startsWith('YL600')") h2 Notes - p Set the following using the VFD's frontpanel. + p Set the following using the VFD's front panel. table.modbus-regs.fixed-regs tr th Address @@ -293,7 +293,7 @@ script#tool-view-template(type="text/x-template") .notes(v-if="tool_type.startsWith('SUNFAR')") h2 Notes - p Set the following using the VFD's frontpanel. + p Set the following using the VFD's front panel. table.modbus-regs.fixed-regs tr th Address @@ -333,3 +333,72 @@ script#tool-view-template(type="text/x-template") target="_blank") Sunfar E300 VFD manual | | and spindle type. + + .notes(v-if="tool_type.startsWith('OMRON')") + h2 Notes + p Set the following using the VFD's front panel. + table.modbus-regs.fixed-regs + tr + th Address + th Value + th Meaning + th Description + tr + td.reg-addr C071 + td.reg-value 5 + td 9600 BAUD + td Must match #[tt baud] above + tr + td.reg-addr C072 + td.reg-value 1 + td Bus ID 1 + td Must match #[tt bus-id] above + tr + td.reg-addr C074 + td.reg-value 0 + td No parity + td Must match #[tt parity] above + tr + td.reg-addr C075 + td.reg-value 2 + td 2 stop bits + td Serial stop bits + tr + td.reg-addr C076 + td.reg-value 4 + td Deceleration stop + td Communication error action + tr + td.reg-addr C077 + td.reg-value 500 + td 0.5 seconds + td Communication error timeout + tr + td.reg-addr C077 + td.reg-value 1 + td 1 milisecond + td Communication wait time + tr + td.reg-addr C096 + td.reg-value 0 + td Modbus-RTU + td Communication mode + tr + td.reg-addr P200 + td.reg-value 0 + td Standard + td Modbus mapping + tr + td.reg-addr P400 + td.reg-value 0 + td Big endian + td Communication byte order + + p + | Other settings according to the + | + a(href="https://buildbotics.com/upload/vfd/omron_i570_mx2.pdf", + target="_blank") OMRON MX2 VFD manual + | + | and spindle type. The VFD must be rebooted after changing + | the above settings. diff --git a/src/resources/config-template.json b/src/resources/config-template.json index e16bfb8..9e4d808 100644 --- a/src/resources/config-template.json +++ b/src/resources/config-template.json @@ -205,7 +205,7 @@ "values": ["Disabled", "PWM Spindle", "Huanyang VFD", "Custom Modbus VFD", "AC-Tech VFD", "Nowforever VFD", "Delta VFD015M21A (Beta)", "YL600, YL620, YL620-A VFD (Beta)", "FR-D700 (Beta)", - "Sunfar E300 (Beta)"], + "Sunfar E300 (Beta)", "OMRON MX2 (Beta)"], "default": "Disabled", "code": "st" }, -- 2.27.0