コード例 #1
0
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
}
コード例 #2
0
ファイル: cycle_homing.cpp プロジェクト: kitling/g2
stat_t cm_homing_cycle_start(void)
{
	// save relevant non-axis parameters from Gcode model
	hm.saved_units_mode = cm_get_units_mode(ACTIVE_MODEL);
	hm.saved_coord_system = cm_get_coord_system(ACTIVE_MODEL);
	hm.saved_distance_mode = cm_get_distance_mode(ACTIVE_MODEL);
//	hm.saved_feed_rate_mode = cm_get_feed_rate_mode(ACTIVE_MODEL);
	hm.saved_feed_rate = cm_get_feed_rate(ACTIVE_MODEL);
	hm.target_position = 0;

	// set working values
	cm_set_units_mode(MILLIMETERS);
	cm_set_distance_mode(INCREMENTAL_MODE);
	cm_set_coord_system(ABSOLUTE_COORDS);	// homing is done in machine coordinates
//	cm_set_feed_rate_mode(UNITS_PER_MINUTE_MODE);
	hm.set_coordinates = true;

	hm.axis = -1;							// set to retrieve initial axis
	hm.func = _homing_axis_start; 			// bind initial processing function
	cm.cycle_state = CYCLE_HOMING;
	cm.homing_state = HOMING_NOT_HOMED;
	return (STAT_OK);
}