From 6262fa43ea470fb69aa163ffea1819f973a49d10 Mon Sep 17 00:00:00 2001 From: Barbour Smith Date: Mon, 11 Dec 2017 13:42:37 -0800 Subject: [PATCH] Fix for z not retracting before moving home What's happening is that since checkForStopCommand() is not called unless the machine is moving a stop sent when the machine is not running causes issues. The stop command (!) will sit in the buffer until a move command is sent. As soon as the move command is processed, the stop is detected and the line is not executed. The solution is to also check for the stop command when the machine is not moving. --- cnc_ctrl_v1/CNC_Functions.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cnc_ctrl_v1/CNC_Functions.h b/cnc_ctrl_v1/CNC_Functions.h index 18254c1f..099e460a 100644 --- a/cnc_ctrl_v1/CNC_Functions.h +++ b/cnc_ctrl_v1/CNC_Functions.h @@ -46,8 +46,8 @@ bool zAxisAuto = false; #define MILLIMETERS 1 #define INCHES 25.4 #define MAXFEED 1000 //The maximum allowable feedrate in mm/min -#define MAXZROTMIN 12.60 // the maximum z rotations per minute -#define LOOPINTERVAL 10000 // What is the frequency of the PID loop in microseconds +#define MAXZROTMIN 12.60 // the maximum z rotations per minute +#define LOOPINTERVAL 10000 // What is the frequency of the PID loop in microseconds int ENCODER1A; int ENCODER1B; @@ -373,6 +373,14 @@ bool checkForStopCommand(){ } void holdPosition(){ + /* + + This function is called every time the main loop runs. When the machine is executing a move it is not called, but when the machine is + not executing a line it is called regularly and causes the motors to hold their positions. + + */ + checkForStopCommand(); + leftAxis.hold(); rightAxis.hold(); zAxis.hold();