Fixed Huanyang spindle restart after stop.
authorJoseph Coffland <joseph@cauldrondevelopment.com>
Tue, 12 Jun 2018 21:17:00 +0000 (14:17 -0700)
committerJoseph Coffland <joseph@cauldrondevelopment.com>
Tue, 12 Jun 2018 21:17:00 +0000 (14:17 -0700)
CHANGELOG.md
src/avr/src/huanyang.c
src/avr/src/vfd_spindle.c

index dc6b56d0bbf7c2511eb0236d5f40eb2af66d2a58..2b264aa2b512193463f197c98e48123d65ee839b 100644 (file)
@@ -6,6 +6,7 @@ Buildbotics CNC Controller Firmware Changelog
  - Ignore soft limits of max <= min.
  - Fixed problem with restarting program in imperial units mode.
  - Handle GCode with infinite or very long loops correctly.
+ - Fixed Huanyang spindle restart after stop.
 
 ## v0.3.23
  - Fix for modbus read operation.
index e5e46192938e7ae5270d2263055e18a742f7556a..838ddbf2d02d43af87a409c725a3bb37f198b7a4 100644 (file)
@@ -28,6 +28,7 @@
 #include "huanyang.h"
 #include "config.h"
 #include "modbus.h"
+#include "estop.h"
 
 #include <string.h>
 #include <math.h>
@@ -175,7 +176,7 @@ static void _next_command();
 
 
 static bool _shutdown() {
-  if (!hy.shutdown) return false;
+  if (!hy.shutdown && !estop_triggered()) return false;
   modbus_deinit();
   if (hy.deinit_cb) hy.deinit_cb();
   return true;
@@ -232,7 +233,7 @@ static void _next_command() {
   switch (hy.state) {
   case 0: { // Update direction
     hy_ctrl_state_t state = HUANYANG_STOP;
-    if (!hy.shutdown) {
+    if (!hy.shutdown && !estop_triggered()) {
       if (0 < hy.speed)
         state = (hy_ctrl_state_t)(HUANYANG_RUN | HUANYANG_FORWARD);
       else if (hy.speed < 0)
@@ -286,12 +287,7 @@ void huanyang_set(float speed) {
 
 
 float huanyang_get() {return hy.actual_freq / hy.max_freq;}
-
-
-void huanyang_stop() {
-  huanyang_set(0);
-  hy.shutdown = true;
-}
+void huanyang_stop() {huanyang_set(0);}
 
 
 float get_hy_freq() {return hy.actual_freq;}
index 9ad646038dea711baa91afb6502e4fdfb40857ca..cfae16866f4214c93c0edd7e543066dec1abaf9f 100644 (file)
@@ -29,6 +29,7 @@
 #include "modbus.h"
 #include "rtc.h"
 #include "config.h"
+#include "estop.h"
 #include "pgmspace.h"
 
 #include <string.h>
@@ -156,7 +157,7 @@ static bool _next_state() {
     break;
 
   case REG_FREQ_ACTECH_READ:
-    if (vfd.shutdown) vfd.state = REG_DISCONNECT_WRITE;
+    if (vfd.shutdown || estop_triggered()) vfd.state = REG_DISCONNECT_WRITE;
 
     else if (vfd.changed) {
       // Update frequency and state
@@ -210,7 +211,7 @@ static void _connect() {
 static void _modbus_cb(bool ok, uint16_t addr, uint16_t value) {
   // Handle error
   if (!ok) {
-    if (vfd.shutdown) _disconnected();
+    if (vfd.shutdown || estop_triggered()) _disconnected();
     else _connect();
     return;
   }