From f78eebcebf00319ac2901a6b54430e78d800e837 Mon Sep 17 00:00:00 2001 From: Elijah Insua Date: Sun, 14 Sep 2014 14:43:10 -0700 Subject: [PATCH 01/10] add MOTION_MODE_PROBE_NO_ERROR --- gcode.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gcode.h b/gcode.h index 8a29aab..fc28d32 100644 --- a/gcode.h +++ b/gcode.h @@ -71,8 +71,9 @@ #define MOTION_MODE_LINEAR 1 // G1 #define MOTION_MODE_CW_ARC 2 // G2 #define MOTION_MODE_CCW_ARC 3 // G3 -#define MOTION_MODE_PROBE 4 // G38.2 -#define MOTION_MODE_NONE 5 // G80 +#define MOTION_MODE_PROBE 4 // G38.2, G38.4 +#define MOTION_MODE_PROBE_NO_ERROR 5 // G38.3, G38.5 +#define MOTION_MODE_NONE 6 // G80 // Modal Group G2: Plane select #define PLANE_SELECT_XY 0 // G17 (Default: Must be zero) From 0f7806938d0325da15faffc7c23fe1e5ed8d0319 Mon Sep 17 00:00:00 2001 From: Elijah Insua Date: Sun, 14 Sep 2014 15:36:25 -0700 Subject: [PATCH 02/10] install G38.{3,4,5} --- gcode.c | 22 +++++++++++++++++----- motion_control.c | 2 +- probe.c | 6 ++++-- system.h | 1 + 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/gcode.c b/gcode.c index 1977d83..f1f4e97 100644 --- a/gcode.c +++ b/gcode.c @@ -210,11 +210,23 @@ uint8_t gc_execute_line(char *line) case 3: gc_block.modal.motion = MOTION_MODE_CCW_ARC; break; // G3 case 38: switch(mantissa) { - case 20: gc_block.modal.motion = MOTION_MODE_PROBE; break; // G38.2 - // NOTE: If G38.3+ are enabled, change mantissa variable type to uint16_t. - // case 30: gc_block.modal.motion = MOTION_MODE_PROBE_NO_ERROR; break; // G38.3 Not supported. - // case 40: // Not supported. - // case 50: // Not supported. + case 20: + sys.probe_away = false; + gc_block.modal.motion = MOTION_MODE_PROBE; + break; // G38.2 + case 30: + sys.probe_away = false; + gc_block.modal.motion = MOTION_MODE_PROBE_NO_ERROR; + break; // G38.3 + case 40: + sys.probe_away = true; + gc_block.modal.motion = MOTION_MODE_PROBE; + break; // G38.4 + case 50: + sys.probe_away = true; + gc_block.modal.motion = MOTION_MODE_PROBE_NO_ERROR; + break; // G38.5 + default: FAIL(STATUS_GCODE_UNSUPPORTED_COMMAND); // [Unsupported G38.x command] } mantissa = 0; // Set to zero to indicate valid non-integer G command. diff --git a/motion_control.c b/motion_control.c index 66633d1..01fa0f2 100644 --- a/motion_control.c +++ b/motion_control.c @@ -289,7 +289,7 @@ void mc_homing_cycle() 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()) { + if ((sys.probe_away << PROBE_BIT) ^ probe_get_state()) { bit_true_atomic(sys.execute, EXEC_CRIT_EVENT); protocol_execute_runtime(); } diff --git a/probe.c b/probe.c index 00dde47..581f9f1 100644 --- a/probe.c +++ b/probe.c @@ -37,6 +37,8 @@ void probe_init() PROBE_PORT |= PROBE_MASK; // Enable internal pull-up resistors. Normal high operation. probe_invert_mask = PROBE_MASK; } + + sys.probe_away = false; } @@ -49,8 +51,8 @@ uint8_t probe_get_state() { return((PROBE_PIN & PROBE_MASK) ^ probe_invert_mask) // NOTE: This function must be extremely efficient as to not bog down the stepper ISR. void probe_state_monitor() { - if (sys.probe_state == PROBE_ACTIVE) { - if (probe_get_state()) { + if (sys.probe_state == PROBE_ACTIVE) { + if ((sys.probe_away << PROBE_BIT) ^ probe_get_state()) { sys.probe_state = PROBE_OFF; memcpy(sys.probe_position, sys.position, sizeof(float)*N_AXIS); bit_true(sys.execute, EXEC_FEED_HOLD); diff --git a/system.h b/system.h index 93ab2b9..ddd7625 100644 --- a/system.h +++ b/system.h @@ -79,6 +79,7 @@ typedef struct { uint8_t auto_start; // Planner auto-start flag. Toggled off during feed hold. Defaulted by settings. volatile uint8_t probe_state; // Probing state value. Used to coordinate the probing cycle with stepper ISR. int32_t probe_position[N_AXIS]; // Last probe position in machine coordinates and steps. + uint8_t probe_away; // probe away from work by reversing the switch direction (G38.4, G38.5) } system_t; extern system_t sys; From b89d194466e7f69d7d184a5f8c0df794b8b41682 Mon Sep 17 00:00:00 2001 From: Elijah Insua Date: Sun, 14 Sep 2014 15:42:31 -0700 Subject: [PATCH 03/10] utilize MOTION_MODE_PROBE_NO_ERROR --- gcode.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gcode.c b/gcode.c index f1f4e97..27ed4e4 100644 --- a/gcode.c +++ b/gcode.c @@ -982,6 +982,7 @@ uint8_t gc_execute_line(char *line) #endif break; case MOTION_MODE_PROBE: + case MOTION_MODE_PROBE_NO_ERROR: // NOTE: gc_block.values.xyz is returned from mc_probe_cycle with the updated position value. So // upon a successful probing cycle, the machine position and the returned value should be the same. #ifdef USE_LINE_NUMBERS From 5406fa939a1fd669fd58b5509e7a9a46ee975d47 Mon Sep 17 00:00:00 2001 From: Elijah Insua Date: Mon, 22 Sep 2014 13:29:02 -0700 Subject: [PATCH 04/10] cleanup global var and push probe mode into probe_get_state --- gcode.c | 34 ++++++++++++++++------------------ gcode.h | 5 ++--- motion_control.c | 9 +++++---- motion_control.h | 4 ++-- probe.c | 12 ++++++------ probe.h | 8 +++++++- system.h | 1 - 7 files changed, 38 insertions(+), 35 deletions(-) diff --git a/gcode.c b/gcode.c index 27ed4e4..9d0f81d 100644 --- a/gcode.c +++ b/gcode.c @@ -124,7 +124,7 @@ uint8_t gc_execute_line(char *line) float value; uint8_t int_value = 0; uint8_t mantissa = 0; // NOTE: For mantissa values > 255, variable type must be changed to uint16_t. - + uint8_t probe_mode = 0; while (line[char_counter] != 0) { // Loop until no more g-code words in line. @@ -210,22 +210,21 @@ uint8_t gc_execute_line(char *line) case 3: gc_block.modal.motion = MOTION_MODE_CCW_ARC; break; // G3 case 38: switch(mantissa) { - case 20: - sys.probe_away = false; + case 20: // G38.2 gc_block.modal.motion = MOTION_MODE_PROBE; - break; // G38.2 - case 30: - sys.probe_away = false; - gc_block.modal.motion = MOTION_MODE_PROBE_NO_ERROR; - break; // G38.3 - case 40: - sys.probe_away = true; + break; + case 30: // G38.3 gc_block.modal.motion = MOTION_MODE_PROBE; - break; // G38.4 - case 50: - sys.probe_away = true; - gc_block.modal.motion = MOTION_MODE_PROBE_NO_ERROR; - break; // G38.5 + probe_mode = PROBE_NO_ERROR; + break; + case 40: // G38.4 + gc_block.modal.motion = MOTION_MODE_PROBE; + probe_mode = PROBE_AWAY; + break; + case 50: // G38.5 + gc_block.modal.motion = MOTION_MODE_PROBE; + probe_mode = PROBE_AWAY | PROBE_NO_ERROR; + break; default: FAIL(STATUS_GCODE_UNSUPPORTED_COMMAND); // [Unsupported G38.x command] } @@ -982,13 +981,12 @@ uint8_t gc_execute_line(char *line) #endif break; case MOTION_MODE_PROBE: - case MOTION_MODE_PROBE_NO_ERROR: // NOTE: gc_block.values.xyz is returned from mc_probe_cycle with the updated position value. So // upon a successful probing cycle, the machine position and the returned value should be the same. #ifdef USE_LINE_NUMBERS - mc_probe_cycle(gc_block.values.xyz, gc_state.feed_rate, gc_state.modal.feed_rate, gc_block.values.n); + mc_probe_cycle(gc_block.values.xyz, gc_state.feed_rate, gc_state.modal.feed_rate, probe_mode, gc_block.values.n); #else - mc_probe_cycle(gc_block.values.xyz, gc_state.feed_rate, gc_state.modal.feed_rate); + mc_probe_cycle(gc_block.values.xyz, gc_state.feed_rate, gc_state.modal.feed_rate, probe_mode); #endif } diff --git a/gcode.h b/gcode.h index fc28d32..98efe23 100644 --- a/gcode.h +++ b/gcode.h @@ -71,9 +71,8 @@ #define MOTION_MODE_LINEAR 1 // G1 #define MOTION_MODE_CW_ARC 2 // G2 #define MOTION_MODE_CCW_ARC 3 // G3 -#define MOTION_MODE_PROBE 4 // G38.2, G38.4 -#define MOTION_MODE_PROBE_NO_ERROR 5 // G38.3, G38.5 -#define MOTION_MODE_NONE 6 // G80 +#define MOTION_MODE_PROBE 4 // G38.2, G38.3, G38.4, G38.5 +#define MOTION_MODE_NONE 5 // G80 // Modal Group G2: Plane select #define PLANE_SELECT_XY 0 // G17 (Default: Must be zero) diff --git a/motion_control.c b/motion_control.c index 01fa0f2..b069267 100644 --- a/motion_control.c +++ b/motion_control.c @@ -276,9 +276,9 @@ void mc_homing_cycle() // Perform tool length probe cycle. Requires probe switch. // NOTE: Upon probe failure, the program will be stopped and placed into ALARM state. #ifdef USE_LINE_NUMBERS - void mc_probe_cycle(float *target, float feed_rate, uint8_t invert_feed_rate, int32_t line_number) + void mc_probe_cycle(float *target, float feed_rate, uint8_t invert_feed_rate, uint8_t mode, int32_t line_number) #else - void mc_probe_cycle(float *target, float feed_rate, uint8_t invert_feed_rate) + void mc_probe_cycle(float *target, float feed_rate, uint8_t invert_feed_rate, uint8_t mode) #endif { // TODO: Need to update this cycle so it obeys a non-auto cycle start. @@ -289,7 +289,7 @@ void mc_homing_cycle() 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 ((sys.probe_away << PROBE_BIT) ^ probe_get_state()) { + if (probe_get_state(mode)) { bit_true_atomic(sys.execute, EXEC_CRIT_EVENT); protocol_execute_runtime(); } @@ -303,7 +303,7 @@ void mc_homing_cycle() #endif // Activate the probing monitor in the stepper module. - sys.probe_state = PROBE_ACTIVE; + sys.probe_state = PROBE_ACTIVE | mode; // Perform probing cycle. Wait here until probe is triggered or motion completes. bit_true_atomic(sys.execute, EXEC_CYCLE_START); @@ -314,6 +314,7 @@ void mc_homing_cycle() // 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); } + 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 diff --git a/motion_control.h b/motion_control.h index 5a1d8c9..54aa1e5 100644 --- a/motion_control.h +++ b/motion_control.h @@ -58,9 +58,9 @@ void mc_homing_cycle(); // Perform tool length probe cycle. Requires probe switch. #ifdef USE_LINE_NUMBERS -void mc_probe_cycle(float *target, float feed_rate, uint8_t invert_feed_rate, int32_t line_number); +void mc_probe_cycle(float *target, float feed_rate, uint8_t invert_feed_rate, uint8_t motion, int32_t line_number); #else -void mc_probe_cycle(float *target, float feed_rate, uint8_t invert_feed_rate); +void mc_probe_cycle(float *target, float feed_rate, uint8_t invert_feed_rate, uint8_t motion); #endif // Performs system reset. If in motion state, kills all motion and sets system alarm. diff --git a/probe.c b/probe.c index 581f9f1..5a65939 100644 --- a/probe.c +++ b/probe.c @@ -37,22 +37,22 @@ void probe_init() PROBE_PORT |= PROBE_MASK; // Enable internal pull-up resistors. Normal high operation. probe_invert_mask = PROBE_MASK; } - - sys.probe_away = false; } // Returns the probe pin state. Triggered = true. Called by gcode parser and probe state monitor. -uint8_t probe_get_state() { return((PROBE_PIN & PROBE_MASK) ^ probe_invert_mask); } - +uint8_t probe_get_state(uint8_t mode) { + mode = ((mode >> PROBE_AWAY_BIT) & 1) << PROBE_BIT; + return mode ^ ((PROBE_PIN & PROBE_MASK) ^ probe_invert_mask); +} // Monitors probe pin state and records the system position when detected. Called by the // stepper ISR per ISR tick. // NOTE: This function must be extremely efficient as to not bog down the stepper ISR. void probe_state_monitor() { - if (sys.probe_state == PROBE_ACTIVE) { - if ((sys.probe_away << PROBE_BIT) ^ probe_get_state()) { + if (sys.probe_state != PROBE_OFF) { + if (probe_get_state(sys.probe_state)) { sys.probe_state = PROBE_OFF; memcpy(sys.probe_position, sys.position, sizeof(float)*N_AXIS); bit_true(sys.execute, EXEC_FEED_HOLD); diff --git a/probe.h b/probe.h index 81fb55b..5986d86 100644 --- a/probe.h +++ b/probe.h @@ -25,12 +25,18 @@ #define PROBE_OFF 0 // No probing. (Must be zero.) #define PROBE_ACTIVE 1 // Actively watching the input pin. +// Probe direction and error modes +#define PROBE_AWAY 2 // G38.4, G38.5 +#define PROBE_NO_ERROR 4 // G38.3, G38.5 + +#define PROBE_AWAY_BIT 1 +#define PROBE_NO_ERROR_BIT 2 // Probe pin initialization routine. void probe_init(); // Returns probe pin state. -uint8_t probe_get_state(); +uint8_t probe_get_state(uint8_t mode); // Monitors probe pin state and records the system position when detected. Called by the // stepper ISR per ISR tick. diff --git a/system.h b/system.h index ddd7625..93ab2b9 100644 --- a/system.h +++ b/system.h @@ -79,7 +79,6 @@ typedef struct { uint8_t auto_start; // Planner auto-start flag. Toggled off during feed hold. Defaulted by settings. volatile uint8_t probe_state; // Probing state value. Used to coordinate the probing cycle with stepper ISR. int32_t probe_position[N_AXIS]; // Last probe position in machine coordinates and steps. - uint8_t probe_away; // probe away from work by reversing the switch direction (G38.4, G38.5) } system_t; extern system_t sys; From 5c07acd9fae3f231f59a363cd721f3b41c6bc34e Mon Sep 17 00:00:00 2001 From: Elijah Insua Date: Mon, 22 Sep 2014 13:39:51 -0700 Subject: [PATCH 05/10] test only for & PROBE_ACTIVE --- motion_control.c | 1 - 1 file changed, 1 deletion(-) diff --git a/motion_control.c b/motion_control.c index b069267..b74bb7c 100644 --- a/motion_control.c +++ b/motion_control.c @@ -313,7 +313,6 @@ void mc_homing_cycle() } while ((sys.state != STATE_IDLE) && (sys.state != STATE_QUEUED)); // 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); } 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 From b920838109c89941776dd266d8a6e804a8634ea2 Mon Sep 17 00:00:00 2001 From: Elijah Insua Date: Mon, 22 Sep 2014 14:05:35 -0700 Subject: [PATCH 06/10] bump mantissa to uint16_t to enable G38.5 --- gcode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcode.c b/gcode.c index 9d0f81d..4afa027 100644 --- a/gcode.c +++ b/gcode.c @@ -123,7 +123,7 @@ uint8_t gc_execute_line(char *line) char letter; float value; uint8_t int_value = 0; - uint8_t mantissa = 0; // NOTE: For mantissa values > 255, variable type must be changed to uint16_t. + uint16_t mantissa = 0; // NOTE: For mantissa values > 255, variable type must be changed to uint16_t. uint8_t probe_mode = 0; while (line[char_counter] != 0) { // Loop until no more g-code words in line. From 3392a8b2c89ce28967af52ee365d38c97ef925c3 Mon Sep 17 00:00:00 2001 From: Elijah Insua Date: Mon, 22 Sep 2014 14:12:25 -0700 Subject: [PATCH 07/10] add/install probe_errors_enabled in mc_probe_cycle --- motion_control.c | 6 ++++-- probe.c | 4 ++++ probe.h | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/motion_control.c b/motion_control.c index b74bb7c..66cb9ac 100644 --- a/motion_control.c +++ b/motion_control.c @@ -289,7 +289,7 @@ void mc_homing_cycle() 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(mode)) { + if (probe_get_state(mode) && probe_errors_enabled(mode)) { bit_true_atomic(sys.execute, EXEC_CRIT_EVENT); protocol_execute_runtime(); } @@ -313,7 +313,9 @@ void mc_homing_cycle() } while ((sys.state != STATE_IDLE) && (sys.state != STATE_QUEUED)); // 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); } + if (sys.probe_state & PROBE_ACTIVE && probe_errors_enabled(mode)) { + 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 diff --git a/probe.c b/probe.c index 5a65939..7d45fe6 100644 --- a/probe.c +++ b/probe.c @@ -46,6 +46,10 @@ uint8_t probe_get_state(uint8_t mode) { return mode ^ ((PROBE_PIN & PROBE_MASK) ^ probe_invert_mask); } +uint8_t probe_errors_enabled(uint8_t mode) { + return !(mode & PROBE_NO_ERROR); +} + // Monitors probe pin state and records the system position when detected. Called by the // stepper ISR per ISR tick. // NOTE: This function must be extremely efficient as to not bog down the stepper ISR. diff --git a/probe.h b/probe.h index 5986d86..5a2006d 100644 --- a/probe.h +++ b/probe.h @@ -38,6 +38,8 @@ void probe_init(); // Returns probe pin state. uint8_t probe_get_state(uint8_t mode); +uint8_t probe_errors_enabled(uint8_t mode); + // Monitors probe pin state and records the system position when detected. Called by the // stepper ISR per ISR tick. void probe_state_monitor(); From 5f1eece67deeb06dc6cdbb969af575edda054066 Mon Sep 17 00:00:00 2001 From: Elijah Insua Date: Mon, 22 Sep 2014 14:35:12 -0700 Subject: [PATCH 08/10] hop over probe pull-off sequence after probe miss and while "no errors" is enabled (G38.3, G38.5) --- motion_control.c | 48 ++++++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/motion_control.c b/motion_control.c index 66cb9ac..f4b66cb 100644 --- a/motion_control.c +++ b/motion_control.c @@ -287,7 +287,8 @@ void mc_homing_cycle() // 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 - + uint8_t perform_pull_off = 1; + // After syncing, check if probe is already triggered. If so, halt and issue alarm. if (probe_get_state(mode) && probe_errors_enabled(mode)) { bit_true_atomic(sys.execute, EXEC_CRIT_EVENT); @@ -313,8 +314,13 @@ void mc_homing_cycle() } while ((sys.state != STATE_IDLE) && (sys.state != STATE_QUEUED)); // Probing motion complete. If the probe has not been triggered, error out. - if (sys.probe_state & PROBE_ACTIVE && probe_errors_enabled(mode)) { - bit_true_atomic(sys.execute, EXEC_CRIT_EVENT); + if (sys.probe_state & PROBE_ACTIVE) { + + if (probe_errors_enabled(mode)) { + bit_true_atomic(sys.execute, EXEC_CRIT_EVENT); + } else { + perform_pull_off = 0; + } } protocol_execute_runtime(); // Check and execute run-time commands if (sys.abort) { return; } // Check for system abort @@ -323,24 +329,26 @@ 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. - - // 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 Date: Mon, 22 Sep 2014 14:40:21 -0700 Subject: [PATCH 09/10] add probe_finalize to keep things DRY this allows the PRB report to be valid when in "no errors" mode and the probe fails --- motion_control.c | 1 + probe.c | 10 +++++++--- probe.h | 2 ++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/motion_control.c b/motion_control.c index f4b66cb..f6b7037 100644 --- a/motion_control.c +++ b/motion_control.c @@ -320,6 +320,7 @@ void mc_homing_cycle() bit_true_atomic(sys.execute, EXEC_CRIT_EVENT); } else { perform_pull_off = 0; + probe_finalize(); } } protocol_execute_runtime(); // Check and execute run-time commands diff --git a/probe.c b/probe.c index 7d45fe6..3623f7b 100644 --- a/probe.c +++ b/probe.c @@ -50,6 +50,12 @@ uint8_t probe_errors_enabled(uint8_t mode) { return !(mode & PROBE_NO_ERROR); } +void probe_finalize() { + sys.probe_state = PROBE_OFF; + memcpy(sys.probe_position, sys.position, sizeof(float)*N_AXIS); + bit_true(sys.execute, EXEC_FEED_HOLD); +} + // Monitors probe pin state and records the system position when detected. Called by the // stepper ISR per ISR tick. // NOTE: This function must be extremely efficient as to not bog down the stepper ISR. @@ -57,9 +63,7 @@ void probe_state_monitor() { if (sys.probe_state != PROBE_OFF) { if (probe_get_state(sys.probe_state)) { - sys.probe_state = PROBE_OFF; - memcpy(sys.probe_position, sys.position, sizeof(float)*N_AXIS); - bit_true(sys.execute, EXEC_FEED_HOLD); + probe_finalize(); } } } diff --git a/probe.h b/probe.h index 5a2006d..194e56e 100644 --- a/probe.h +++ b/probe.h @@ -40,6 +40,8 @@ uint8_t probe_get_state(uint8_t mode); uint8_t probe_errors_enabled(uint8_t mode); +void probe_finalize(); + // Monitors probe pin state and records the system position when detected. Called by the // stepper ISR per ISR tick. void probe_state_monitor(); From 297f4d1dd6a3e89b3715b904a8e0209799aaa510 Mon Sep 17 00:00:00 2001 From: Elijah Insua Date: Mon, 22 Sep 2014 20:32:47 -0700 Subject: [PATCH 10/10] report probe_succeeded with probe status --- motion_control.c | 2 +- probe.c | 5 +++-- probe.h | 2 +- report.c | 4 +++- system.h | 1 + 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/motion_control.c b/motion_control.c index f6b7037..79fd30d 100644 --- a/motion_control.c +++ b/motion_control.c @@ -320,7 +320,7 @@ void mc_homing_cycle() bit_true_atomic(sys.execute, EXEC_CRIT_EVENT); } else { perform_pull_off = 0; - probe_finalize(); + probe_finalize(0); } } protocol_execute_runtime(); // Check and execute run-time commands diff --git a/probe.c b/probe.c index 3623f7b..12fcc63 100644 --- a/probe.c +++ b/probe.c @@ -50,8 +50,9 @@ uint8_t probe_errors_enabled(uint8_t mode) { return !(mode & PROBE_NO_ERROR); } -void probe_finalize() { +void probe_finalize(uint8_t probe_succeeded) { sys.probe_state = PROBE_OFF; + sys.probe_succeeded = probe_succeeded; memcpy(sys.probe_position, sys.position, sizeof(float)*N_AXIS); bit_true(sys.execute, EXEC_FEED_HOLD); } @@ -63,7 +64,7 @@ void probe_state_monitor() { if (sys.probe_state != PROBE_OFF) { if (probe_get_state(sys.probe_state)) { - probe_finalize(); + probe_finalize(1); } } } diff --git a/probe.h b/probe.h index 194e56e..17028eb 100644 --- a/probe.h +++ b/probe.h @@ -40,7 +40,7 @@ uint8_t probe_get_state(uint8_t mode); uint8_t probe_errors_enabled(uint8_t mode); -void probe_finalize(); +void probe_finalize(uint8_t probe_succeeded); // Monitors probe pin state and records the system position when detected. Called by the // stepper ISR per ISR tick. diff --git a/report.c b/report.c index 32720eb..ca93efe 100644 --- a/report.c +++ b/report.c @@ -235,7 +235,9 @@ void report_probe_parameters() print_position[i] = sys.probe_position[i]/settings.steps_per_mm[i]; printFloat_CoordValue(print_position[i]); if (i < (N_AXIS-1)) { printPgmString(PSTR(",")); } - } + } + printPgmString(PSTR(":")); + print_uint8_base10(sys.probe_succeeded); printPgmString(PSTR("]\r\n")); } diff --git a/system.h b/system.h index 93ab2b9..3263af8 100644 --- a/system.h +++ b/system.h @@ -79,6 +79,7 @@ typedef struct { uint8_t auto_start; // Planner auto-start flag. Toggled off during feed hold. Defaulted by settings. volatile uint8_t probe_state; // Probing state value. Used to coordinate the probing cycle with stepper ISR. int32_t probe_position[N_AXIS]; // Last probe position in machine coordinates and steps. + uint8_t probe_succeeded; } system_t; extern system_t sys;