From 49f9c607b7e918d9dc3a3c280cefb7b137cdc194 Mon Sep 17 00:00:00 2001 From: Joseph Coffland Date: Thu, 26 Sep 2019 02:04:01 -0700 Subject: [PATCH] Move Modbus indicators to tool page, Support for Sunfar E300 VFD. --- CHANGELOG.md | 2 ++ src/avr/src/spindle.h | 1 + src/avr/src/vfd_spindle.c | 14 ++++++++ src/js/main.js | 3 +- src/pug/templates/control-view.pug | 10 +++--- src/pug/templates/indicators.pug | 41 +++++---------------- src/pug/templates/tool-view.pug | 58 ++++++++++++++++++++++++++++-- src/resources/config-template.json | 3 +- 8 files changed, 90 insertions(+), 42 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bee4016..dfff0aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ Buildbotics CNC Controller Firmware Changelog - Save more log files in bug report. - Fixed indicators low-side units. - Support for YL600, YL620 & YL620-A VFDs. + - Move Modbus indicators to tool page. + - Support for Sunfar E300 VFD. ## v0.4.10 - Fix demo password check diff --git a/src/avr/src/spindle.h b/src/avr/src/spindle.h index 615e1b2..b3f8395 100644 --- a/src/avr/src/spindle.h +++ b/src/avr/src/spindle.h @@ -55,6 +55,7 @@ typedef enum { SPINDLE_TYPE_DELTA_VFD015M21A, SPINDLE_TYPE_YL600, SPINDLE_TYPE_FR_D700, + SPINDLE_TYPE_SUNFAR_E300, } spindle_type_t; diff --git a/src/avr/src/vfd_spindle.c b/src/avr/src/vfd_spindle.c index 6e603bd..7c9530c 100644 --- a/src/avr/src/vfd_spindle.c +++ b/src/avr/src/vfd_spindle.c @@ -139,6 +139,19 @@ const vfd_reg_t fr_d700_regs[] PROGMEM = { }; +const vfd_reg_t sunfar_e300_regs[] PROGMEM = { + {REG_CONNECT_WRITE, 0x1001, 32}, // Reset all errors + {REG_MAX_FREQ_READ, 0xf004, 0}, // Max frequency F0.4 + {REG_FREQ_SET, 0x1002, 0}, // Frequency + {REG_STOP_WRITE, 0x1001, 3}, // Stop drive + {REG_FWD_WRITE, 0x1001, 1}, // Forward + {REG_REV_WRITE, 0x1001, 2}, // Reverse + {REG_FREQ_READ, 0xd000, 0}, // Output freq d.0 + {REG_STATUS_READ, 0x2000, 0}, // Status + {REG_DISABLED}, +}; + + static vfd_reg_t regs[VFDREG]; static vfd_reg_t custom_regs[VFDREG]; @@ -355,6 +368,7 @@ void vfd_spindle_init() { case SPINDLE_TYPE_DELTA_VFD015M21A: _load(delta_vfd015m21a_regs); break; 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; default: break; } diff --git a/src/js/main.js b/src/js/main.js index c3ebf6c..d369409 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -86,6 +86,7 @@ $(function() { }); Vue.filter('percent', function (value, precision) { + if (typeof value == 'undefined') return ''; if (typeof precision == 'undefined') precision = 2; return (value * 100.0).toFixed(precision) + '%'; }); @@ -97,7 +98,7 @@ $(function() { }); Vue.filter('fixed', function (value, precision) { - if (typeof value == 'undefined') return ''; + if (typeof value == 'undefined') return '0'; return parseFloat(value).toFixed(precision) }); diff --git a/src/pug/templates/control-view.pug b/src/pug/templates/control-view.pug index 3f7b1a6..3ff1d3a 100644 --- a/src/pug/templates/control-view.pug +++ b/src/pug/templates/control-view.pug @@ -118,13 +118,13 @@ script#control-view-template(type="text/x-template") tr th Message td.reason(:class="{attention: highlight_reason}") {{reason}} - tr(title="Currently active machine units") + tr(title="Active machine units") th Units td.mach_units select(v-model="mach_units", :disabled="!is_idle") option(value="METRIC") METRIC option(value="IMPERIAL") IMPERIAL - tr + tr(title="Active tool") th Tool td {{state.tool || 0}} @@ -136,18 +136,18 @@ script#control-view-template(type="text/x-template") unit-value(:value="state.v", precision="2", unit="", iunit="", scale="0.0254") | {{metric ? ' m/min' : ' IPM'}} - tr + tr(title="Programmed feed rate.") th Feed td unit-value(:value="state.feed", precision="2", unit="", iunit="") | {{metric ? ' mm/min' : ' IPM'}} - tr + tr(title="Programed and actual speed.") th Speed td | {{state.speed || 0 | fixed 0}} span(v-if="!isNaN(state.s)")  ({{state.s | fixed 0}}) = ' RPM' - tr + tr(title="Load switch states.") th Loads td span(:class="state['1oa'] ? 'load-on' : ''") diff --git a/src/pug/templates/indicators.pug b/src/pug/templates/indicators.pug index 6839e5a..8414680 100644 --- a/src/pug/templates/indicators.pug +++ b/src/pug/templates/indicators.pug @@ -84,6 +84,15 @@ script#indicators-template(type="text/x-template") td 22 th Probe + tr(v-if="false") + td {{state['1ai'] | percent 0}} + td 24 + th Analog 1 + th.separator + td {{state['2ai'] | percent 0}} + td 18 + th Analog 2 + table.outputs tr th.header(colspan=7) Outputs @@ -248,38 +257,6 @@ script#indicators-template(type="text/x-template") | {{state.rpi_temp | fixed 0}} ℃ th RPi Temp - tr - td {{state['1ai'] | percent 0}} A - th Analog 1 - th.separator - td {{state['2ai'] | percent 0}} A - th Analog 2 - - table.modbus - tr - th.header(colspan=5) Modbus VFD - - tr - td {{modbus_status}} - th Status - th.separator - td {{state.hz}} Hz - th Frequency - - tr - td {{state.s}} RPM - th Speed - th.separator - td {{state.hc}} A - th Current - - tr - td {{state.ss}} - th VFD Status - th.separator - td - th - h2 DB25 breakout box img(src="images/DB25_breakout_box.png") diff --git a/src/pug/templates/tool-view.pug b/src/pug/templates/tool-view.pug index 3840732..7440094 100644 --- a/src/pug/templates/tool-view.pug +++ b/src/pug/templates/tool-view.pug @@ -48,13 +48,22 @@ script#tool-view-template(type="text/x-template") fieldset(v-if="is_modbus") h2 Modbus Configuration - .pure-control-group - label status - tt {{modbus_status}} ({{state.ss || 0}}) templated-input(v-for="templ in template['modbus-spindle']", :name="$key", :model.sync="config['modbus-spindle'][$key]", :template="templ", v-if="show_modbus_field($key)") + h2 Modbus Status + .pure-control-group(title="VFD connection status") + label connection + tt {{modbus_status}} + .pure-control-group(title="Numerical status reported by VFD") + label status + tt {{state.ss || 0}} + .pure-control-group(title="Speed reported by VFD") + label speed + tt {{state.s | fixed}} + label.units RPM + fieldset.modbus-program( v-if="is_modbus && this.tool_type != 'HUANYANG VFD'") h2 Active Modbus Program @@ -281,3 +290,46 @@ script#tool-view-template(type="text/x-template") target="_blank") YL600 VFD manual | | and spindle type. + + .notes(v-if="tool_type.startsWith('SUNFAR')") + h2 Notes + p Set the following using the VFD's frontpanel. + table.modbus-regs.fixed-regs + tr + th Address + th Value + th Meaning + th Description + tr + td.reg-addr F0.0 + td.reg-value 2 + td Serial communication + td Frequency source + tr + td.reg-addr F0.2 + td.reg-value 1002 + td Serial communication + td Control source + tr + td.reg-addr F4.0 + td.reg-value 0104 + td Modbus, no parity, 9600 baud + td Must match #[tt parity] and #[tt baud] above + tr + td.reg-addr F4.1 + td.reg-value 1 + td Bus ID + td Must match #[tt bus-id] above + tr + td.reg-addr F4.4 + td.reg-value 3 + td Seconds + td Communication timeout + + p + | Other settings according to the + | + a(href="https://buildbotics.com/upload/vfd/Sunfar-E300.pdf", + target="_blank") Sunfar E300 VFD manual + | + | and spindle type. diff --git a/src/resources/config-template.json b/src/resources/config-template.json index 1bc4a6a..0da3b9a 100644 --- a/src/resources/config-template.json +++ b/src/resources/config-template.json @@ -193,7 +193,8 @@ "type": "enum", "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)"], + "YL600, YL620, YL620-A VFD (Beta)", "FR-D700 (Beta)", + "Sunfar E300 (Beta)"], "default": "Disabled", "code": "st" }, -- 2.27.0