Move Modbus indicators to tool page, Support for Sunfar E300 VFD.
authorJoseph Coffland <joseph@cauldrondevelopment.com>
Thu, 26 Sep 2019 09:04:01 +0000 (02:04 -0700)
committerJoseph Coffland <joseph@cauldrondevelopment.com>
Thu, 26 Sep 2019 09:04:01 +0000 (02:04 -0700)
CHANGELOG.md
src/avr/src/spindle.h
src/avr/src/vfd_spindle.c
src/js/main.js
src/pug/templates/control-view.pug
src/pug/templates/indicators.pug
src/pug/templates/tool-view.pug
src/resources/config-template.json

index bee4016bdf3d3e53219f63839c517677b47e70e5..dfff0aa9e5f6505d0bf4e338d155e67df7208e5b 100644 (file)
@@ -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
index 615e1b2698c952346208ca3066af34dd7411e2ab..b3f83953754a0d036043977b8942eed20b143028 100644 (file)
@@ -55,6 +55,7 @@ typedef enum {
   SPINDLE_TYPE_DELTA_VFD015M21A,
   SPINDLE_TYPE_YL600,
   SPINDLE_TYPE_FR_D700,
+  SPINDLE_TYPE_SUNFAR_E300,
 } spindle_type_t;
 
 
index 6e603bd67b601dc81ac7cbcaa294e64dab7bc1c2..7c9530c23dfeed312276a1f92cfffb513ac7f689 100644 (file)
@@ -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;
   }
 
index c3ebf6c96430b657d1d579a4565f8e012a01c222..d3694096655d6ae4bdec02c8e0da1430ef0fefdd 100644 (file)
@@ -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)
   });
 
index 3f7b1a6059ee9f908f5e844c91fe6ff15dd197f8..3ff1d3ac77a64eb629ce474f1f46c229ae5a9075 100644 (file)
@@ -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)") &nbsp;({{state.s | fixed 0}})
           = ' RPM'
-      tr
+      tr(title="Load switch states.")
         th Loads
         td
           span(:class="state['1oa'] ? 'load-on' : ''")
index 6839e5a414c8ad5a7d72e1e0d4e3cddc921a2fb7..84146808d8c5cb6b4c001214ad4ec12f46f754dc 100644 (file)
@@ -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")
 
index 3840732e9f1d929fb39a0def0559ecf1e1dea845..7440094f16b80a0eb2f714e21647440b6a522f3a 100644 (file)
@@ -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.
index 1bc4a6a1103eab4d9ab2a0ad1586e25913450292..0da3b9a5d649a508a0d3b860295d60e978a8daff 100644 (file)
       "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"
     },