static uint8_t _probing_init() { float start_position[AXES]; // so optimistic... ;) // NOTE: it is *not* an error condition for the probe not to trigger. // it is an error for the limit or homing switches to fire, or for some other configuration error. cm.probe_state = PROBE_FAILED; cm.machine_state = MACHINE_CYCLE; cm.cycle_state = CYCLE_PROBE; // save relevant non-axis parameters from Gcode model pb.saved_coord_system = cm_get_coord_system(ACTIVE_MODEL); pb.saved_distance_mode = cm_get_distance_mode(ACTIVE_MODEL); // set working values cm_set_distance_mode(ABSOLUTE_MODE); cm_set_coord_system(ABSOLUTE_COORDS); // probing is done in machine coordinates // initialize the axes - save the jerk settings & switch to the jerk_homing settings for( uint8_t axis=0; axis<AXES; axis++ ) { pb.saved_jerk[axis] = cm_get_axis_jerk(axis); // save the max jerk value cm_set_axis_jerk(axis, cm.a[axis].jerk_high); // use the high-speed jerk for probe start_position[axis] = cm_get_absolute_position(ACTIVE_MODEL, axis); } // error if the probe target is too close to the current position if (get_axis_vector_length(start_position, pb.target) < MINIMUM_PROBE_TRAVEL) { _probing_error_exit(-2); } // error if the probe target requires a move along the A/B/C axes for ( uint8_t axis=AXIS_A; axis<AXES; axis++ ) { // if (fp_NE(start_position[axis], pb.target[axis])) { // old style if (fp_TRUE(pb.flags[axis])) { // if (pb.flags[axis]) { // will reduce to this once flags are booleans _probing_error_exit(axis); } } // initialize the probe switch pb.probe_input = 5; // TODO -- for now we hard code it to zmin gpio_set_probing_mode(pb.probe_input, true); // turn off spindle and start the move cm_spindle_optional_pause(true); // pause the spindle if it's on return (_set_pb_func(_probing_start)); // start the probe move }
static void _probe_restore_settings() { mp_flush_planner(); // if (cm.hold_state == FEEDHOLD_HOLD); // cm_end_hold(); cm_end_hold(); // ends hold if on is in effect gpio_set_probing_mode(pb.probe_input, false); // restore axis jerk for (uint8_t axis=0; axis<AXES; axis++) { cm.a[axis].jerk_max = pb.saved_jerk[axis]; } // restore coordinate system and distance mode cm_set_coord_system(pb.saved_coord_system); cm_set_distance_mode(pb.saved_distance_mode); // update the model with actual position cm_set_motion_mode(MODEL, MOTION_MODE_CANCEL_MOTION_MODE); cm_canned_cycle_end(); }
static void _probe_restore_settings() { // flush queue and end feedhold (if any) cm_queue_flush(); // set input back to normal operation gpio_set_probing_mode(pb.probe_input, false); // restore axis jerk for (uint8_t axis=0; axis<AXES; axis++) { cm.a[axis].jerk_max = pb.saved_jerk[axis]; } // restore coordinate system and distance mode cm_set_coord_system(pb.saved_coord_system); cm_set_distance_mode(pb.saved_distance_mode); // restart spindle if it was paused cm_spindle_resume(spindle.dwell_seconds); // cancel the feed modes used during probing cm_set_motion_mode(MODEL, MOTION_MODE_CANCEL_MOTION_MODE); cm_canned_cycle_end(); }