// Prints Grbl NGC parameters (coordinate offsets, probing) void report_ngc_parameters() { float coord_data[N_AXIS]; uint8_t coord_select, i; for (coord_select = 0; coord_select <= SETTING_INDEX_NCOORD; coord_select++) { if (!(settings_read_coord_data(coord_select,coord_data))) { report_status_message(STATUS_SETTING_READ_FAIL); return; } printPgmString(PSTR("[G")); switch (coord_select) { case 6: printPgmString(PSTR("28")); break; case 7: printPgmString(PSTR("30")); break; default: print_uint8_base10(coord_select+54); break; // G54-G59 } printPgmString(PSTR(":")); for (i=0; i<N_AXIS; i++) { printFloat_CoordValue(coord_data[i]); if (i < (N_AXIS-1)) { printPgmString(PSTR(",")); } else { printPgmString(PSTR("]\r\n")); } } } printPgmString(PSTR("[G92:")); // Print G92,G92.1 which are not persistent in memory for (i=0; i<N_AXIS; i++) { printFloat_CoordValue(gc_state.coord_offset[i]); if (i < (N_AXIS-1)) { printPgmString(PSTR(",")); } else { printPgmString(PSTR("]\r\n")); } } printPgmString(PSTR("[TLO:")); // Print tool length offset value printFloat_CoordValue(gc_state.tool_length_offset); printPgmString(PSTR("]\r\n")); report_probe_parameters(); // Print probe parameters. Not persistent in memory. }
// Prints Grbl NGC parameters (coordinate offsets, probing) void report_ngc_parameters() { float coord_data[N_AXIS]; uint8_t coord_select, i; for (coord_select = 0; coord_select <= SETTING_INDEX_NCOORD; coord_select++) { if (!(settings_read_coord_data(coord_select,coord_data))) { report_status_message(STATUS_SETTING_READ_FAIL); return; } printPgmString(PSTR("[G")); switch (coord_select) { case 0: printPgmString(PSTR("54:")); break; case 1: printPgmString(PSTR("55:")); break; case 2: printPgmString(PSTR("56:")); break; case 3: printPgmString(PSTR("57:")); break; case 4: printPgmString(PSTR("58:")); break; case 5: printPgmString(PSTR("59:")); break; case 6: printPgmString(PSTR("28:")); break; case 7: printPgmString(PSTR("30:")); break; // case 8: printPgmString(PSTR("92:")); break; // G92.2, G92.3 not supported. Hence not stored. } for (i=0; i<N_AXIS; i++) { if (bit_istrue(settings.flags,BITFLAG_REPORT_INCHES)) { printFloat(coord_data[i]*INCH_PER_MM); } else { printFloat(coord_data[i]); } if (i < (N_AXIS-1)) { printPgmString(PSTR(",")); } else { printPgmString(PSTR("]\r\n")); } } } printPgmString(PSTR("[G92:")); // Print G92,G92.1 which are not persistent in memory for (i=0; i<N_AXIS; i++) { if (bit_istrue(settings.flags,BITFLAG_REPORT_INCHES)) { printFloat(gc.coord_offset[i]*INCH_PER_MM); } else { printFloat(gc.coord_offset[i]); } if (i < (N_AXIS-1)) { printPgmString(PSTR(",")); } else { printPgmString(PSTR("]\r\n")); } } report_probe_parameters(); // Print probe parameters. Not persistent in memory. }
void mc_probe_cycle(float *target, float feed_rate, uint8_t invert_feed_rate, uint8_t is_probe_away, uint8_t is_no_error) #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(); // Initialize probing control variables sys.probe_succeeded = false; // Re-initialize probe history before beginning cycle. probe_configure_invert_mask(is_probe_away); // After syncing, check if probe is already triggered. If so, halt and issue alarm. // NOTE: This probe initialization error applies to all probing cycles. if ( probe_get_state() ) { // Check probe pin state. bit_true_atomic(sys_rt_exec_alarm, EXEC_ALARM_PROBE_FAIL); protocol_execute_realtime(); } if (sys.abort) { return; } // Return if system reset has been issued. // Setup and queue probing motion. Auto cycle-start should not start the cycle. #ifdef USE_LINE_NUMBERS mc_line(target, feed_rate, invert_feed_rate, line_number); #else mc_line(target, feed_rate, invert_feed_rate); #endif // Activate the probing state 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_rt_exec_state, EXEC_CYCLE_START); do { protocol_execute_realtime(); if (sys.abort) { return; } // Check for system abort } while (sys.state != STATE_IDLE); // Probing cycle complete! // Set state variables and error out, if the probe failed and cycle with error is enabled. if (sys_probe_state == PROBE_ACTIVE) { if (is_no_error) { memcpy(sys.probe_position, sys.position, sizeof(float)*N_AXIS); } else { bit_true_atomic(sys_rt_exec_alarm, EXEC_ALARM_PROBE_FAIL); } } else { sys.probe_succeeded = true; // Indicate to system the probing cycle completed successfully. } sys_probe_state = PROBE_OFF; // Ensure probe state monitor is disabled. protocol_execute_realtime(); // Check and execute run-time commands if (sys.abort) { return; } // Check for system abort // Reset the stepper and planner buffers to remove the remainder of the probe motion. 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. // TODO: Update the g-code parser code to not require this target calculation but uses a gc_sync_position() call. // NOTE: The target[] variable updated here will be sent back and synced with the g-code parser. system_convert_array_steps_to_mpos(target, sys.position); #ifdef MESSAGE_PROBE_COORDINATES // All done! Output the probe position as message. report_probe_parameters(); #endif }
// Perform tool length probe cycle. Requires probe switch. // NOTE: Upon probe failure, the program will be stopped and placed into ALARM state. uint8_t mc_probe_cycle(float *target, plan_line_data_t *pl_data, uint8_t parser_flags) { // TODO: Need to update this cycle so it obeys a non-auto cycle start. if (sys.state == STATE_CHECK_MODE) { return(GC_PROBE_CHECK_MODE); } // Finish all queued commands and empty planner buffer before starting probe cycle. protocol_buffer_synchronize(); if (sys.abort) { return(GC_PROBE_ABORT); } // Return if system reset has been issued. // Initialize probing control variables uint8_t is_probe_away = bit_istrue(parser_flags,GC_PARSER_PROBE_IS_AWAY); uint8_t is_no_error = bit_istrue(parser_flags,GC_PARSER_PROBE_IS_NO_ERROR); sys.probe_succeeded = false; // Re-initialize probe history before beginning cycle. probe_configure_invert_mask(is_probe_away); // After syncing, check if probe is already triggered. If so, halt and issue alarm. // NOTE: This probe initialization error applies to all probing cycles. if ( probe_get_state() ) { // Check probe pin state. system_set_exec_alarm(EXEC_ALARM_PROBE_FAIL_INITIAL); protocol_execute_realtime(); probe_configure_invert_mask(false); // Re-initialize invert mask before returning. return(GC_PROBE_FAIL_INIT); // Nothing else to do but bail. } // Setup and queue probing motion. Auto cycle-start should not start the cycle. mc_line(target, pl_data); // Activate the probing state monitor in the stepper module. sys_probe_state = PROBE_ACTIVE; // Perform probing cycle. Wait here until probe is triggered or motion completes. system_set_exec_state_flag(EXEC_CYCLE_START); do { protocol_execute_realtime(); if (sys.abort) { return(GC_PROBE_ABORT); } // Check for system abort } while (sys.state != STATE_IDLE); // Probing cycle complete! // Set state variables and error out, if the probe failed and cycle with error is enabled. if (sys_probe_state == PROBE_ACTIVE) { if (is_no_error) { memcpy(sys_probe_position, sys_position, sizeof(sys_position)); } else { system_set_exec_alarm(EXEC_ALARM_PROBE_FAIL_CONTACT); } } else { sys.probe_succeeded = true; // Indicate to system the probing cycle completed successfully. } sys_probe_state = PROBE_OFF; // Ensure probe state monitor is disabled. probe_configure_invert_mask(false); // Re-initialize invert mask. protocol_execute_realtime(); // Check and execute run-time commands // Reset the stepper and planner buffers to remove the remainder of the probe motion. st_reset(); // Reset 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. #ifdef MESSAGE_PROBE_COORDINATES // All done! Output the probe position as message. report_probe_parameters(); #endif if (sys.probe_succeeded) { return(GC_PROBE_FOUND); } // Successful probe cycle. else { return(GC_PROBE_FAIL_END); } // Failed to trigger probe within travel. With or without error. }
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()) { bit_true_atomic(sys.execute, EXEC_CRIT_EVENT); protocol_execute_runtime(); } if (sys.abort) { return; } // Return if system reset has been issued. // Setup and queue probing motion. Auto cycle-start should not start the cycle. #ifdef USE_LINE_NUMBERS mc_line(target, feed_rate, invert_feed_rate, line_number); #else mc_line(target, feed_rate, invert_feed_rate); #endif // 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 { protocol_execute_runtime(); if (sys.abort) { return; } // Check for system abort } 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); } protocol_execute_runtime(); // Check and execute run-time commands if (sys.abort) { return; } // Check for system abort // Reset the stepper and planner buffers to remove the remainder of the probe motion. 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<N_AXIS; idx++){ // NOTE: The target[] variable updated here will be sent back and synced with the g-code parser. target[idx] = (float)sys.probe_position[idx]/settings.steps_per_deg[idx]; } #ifdef USE_LINE_NUMBERS mc_line(target, feed_rate, invert_feed_rate, line_number); #else mc_line(target, feed_rate, invert_feed_rate); #endif // Execute pull-off motion and wait until it completes. bit_true_atomic(sys.execute, EXEC_CYCLE_START); protocol_buffer_synchronize(); if (sys.abort) { return; } // Return if system reset has been issued. sys.auto_start = auto_start_state; // Restore run state before returning #ifdef MESSAGE_PROBE_COORDINATES // All done! Output the probe position as message. report_probe_parameters(); #endif }