From 15cac84dafa785f049b58eb887b3675557539887 Mon Sep 17 00:00:00 2001 From: Joseph Coffland Date: Tue, 12 Jun 2018 14:17:00 -0700 Subject: [PATCH] Fixed Huanyang spindle restart after stop. --- CHANGELOG.md | 1 + src/avr/src/huanyang.c | 12 ++++-------- src/avr/src/vfd_spindle.c | 5 +++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc6b56d..2b264aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/src/avr/src/huanyang.c b/src/avr/src/huanyang.c index e5e4619..838ddbf 100644 --- a/src/avr/src/huanyang.c +++ b/src/avr/src/huanyang.c @@ -28,6 +28,7 @@ #include "huanyang.h" #include "config.h" #include "modbus.h" +#include "estop.h" #include #include @@ -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;} diff --git a/src/avr/src/vfd_spindle.c b/src/avr/src/vfd_spindle.c index 9ad6460..cfae168 100644 --- a/src/avr/src/vfd_spindle.c +++ b/src/avr/src/vfd_spindle.c @@ -29,6 +29,7 @@ #include "modbus.h" #include "rtc.h" #include "config.h" +#include "estop.h" #include "pgmspace.h" #include @@ -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; } -- 2.27.0