From 469399fcd5b2c38d1df95ba3e05311098cbe2f79 Mon Sep 17 00:00:00 2001 From: Sonny Jeon Date: Sun, 3 Aug 2014 21:10:27 -0600 Subject: [PATCH] Probing cycle and view build info bug fixes. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Probing cycle would drop into a QUEUED state, if multiple G38.2 are sent. It would not honor the auto cycle start flags. To fix, the auto cycle start state is saved at the beginning of the probing cycle and restored at the end, since the feed hold it uses to stop a triggered probe will disable the auto start flag. For now it’s a patch, rather than a permanent fix. - protocol_buffer_synchronize() also has a failure case. Auto cycle start does not get executed when the system is waiting in here, so if it’s in a QUEUED state already, it won’t resume. Patched here, but not fully resolved. - Fixed a problem with the “view build info” command. The EEPROM write would do weird things and corrupt the EEPROM. Not sure exactly what caused it, but it’s likely a compiler problem with an improperly defined EEPROM address. It didn’t have enough room to store a full string. To fix, the build info EEPROM range was increased and the max number of STARTUP_BLOCKS was reduced to 2 from 3. - Lastly, when a $I view build info is used for the first time, it would normally show an EEPROM read error, since it wasn’t cleared or wasn’t therein the first place. It will now not show that error. A patch rather than a permanent fix again. --- config.h | 4 ++-- motion_control.c | 33 ++++++++++----------------------- protocol.c | 2 ++ settings.c | 19 ++++++++----------- settings.h | 8 ++++---- system.c | 7 ++----- 6 files changed, 28 insertions(+), 45 deletions(-) diff --git a/config.h b/config.h index 000d233..4630aa5 100644 --- a/config.h +++ b/config.h @@ -86,10 +86,10 @@ // #define HOMING_FORCE_SET_ORIGIN // Uncomment to enable. // Number of blocks Grbl executes upon startup. These blocks are stored in EEPROM, where the size -// and addresses are defined in settings.h. With the current settings, up to 3 startup blocks may +// and addresses are defined in settings.h. With the current settings, up to 2 startup blocks may // be stored and executed in order. These startup blocks would typically be used to set the g-code // parser state depending on user preferences. -#define N_STARTUP_LINE 2 // Integer (1-3) +#define N_STARTUP_LINE 2 // Integer (1-2) // Number of floating decimal points printed by Grbl for certain value types. These settings are // determined by realistic and commonly observed values in CNC machines. For example, position diff --git a/motion_control.c b/motion_control.c index a07af59..bac1f14 100644 --- a/motion_control.c +++ b/motion_control.c @@ -276,8 +276,12 @@ void mc_homing_cycle() void mc_probe_cycle(float *target, float feed_rate, uint8_t invert_feed_rate) #endif { + // TODO: Need to update this cycle so it obeys a non-auto cycle start. + if (sys.state == STATE_CHECK_MODE) { return; } + // Finish all queued commands and empty planner buffer before starting probe cycle. protocol_buffer_synchronize(); + uint8_t auto_start_state = sys.auto_start; // Store run state // After syncing, check if probe is already triggered. If so, halt and issue alarm. if (probe_get_state()) { @@ -292,11 +296,10 @@ void mc_homing_cycle() #else mc_line(target, feed_rate, invert_feed_rate); #endif - - // Activate the probing monitor in the stepper module. - // NOTE: Parser error-checking ensures the probe isn't already closed/triggered. - sys.probe_state = PROBE_ACTIVE; + // Activate the probing monitor in the stepper module. + sys.probe_state = PROBE_ACTIVE; + // Perform probing cycle. Wait here until probe is triggered or motion completes. bit_true_atomic(sys.execute, EXEC_CYCLE_START); do { @@ -304,7 +307,7 @@ void mc_homing_cycle() if (sys.abort) { return; } // Check for system abort } while ((sys.state != STATE_IDLE) && (sys.state != STATE_QUEUED)); - // If motion completes without probe triggering, error out. + // Probing motion complete. If the probe has not been triggered, error out. if (sys.probe_state == PROBE_ACTIVE) { bit_true_atomic(sys.execute, EXEC_CRIT_EVENT); } protocol_execute_runtime(); // Check and execute run-time commands if (sys.abort) { return; } // Check for system abort @@ -313,24 +316,8 @@ void mc_homing_cycle() st_reset(); // Reest step segment buffer. plan_reset(); // Reset planner buffer. Zero planner positions. Ensure probing motion is cleared. plan_sync_position(); // Sync planner position to current machine position. - - // Probing motion is complete, but we'll pull-off triggered probe to the trigger location since - // we had to decelerate a little beyond it to stop the machine in a controlled manner. - uint8_t idx; - for(idx=0; idx