Example #1
0
static stat_t _verify_position(int8_t axis)
{
	// abort if we aren't in the expected position (e.g. due to a user-initiated feedhold)
	if (fp_NE(cm_get_absolute_position(MODEL, axis), hm.target_position)) {
		_set_homing_func(_homing_abort);
		return STAT_EAGAIN;
	}
	return STAT_OK;
}
Example #2
0
static uint8_t _probing_init()
{
    // 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
        pb.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(pb.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(pb.start_position[axis], pb.target[axis])) {
			_probing_error_exit(axis);
        }
	}

	// initialize the probe switch

    // Get the probe input
    // TODO -- for now we hard code it to zmin
    pb.probe_input = 5;

    // Set the input into probing mode
    gpio_set_probing_mode(pb.probe_input, true);
	cm_spindle_control(SPINDLE_OFF);
	return (_set_pb_func(_probing_start));							// start the move
}
Example #3
0
stat_t write_persistent_value(nvObj_t *nv)
{
	if (cm.cycle_state != CYCLE_OFF)
        return(rpt_exception(STAT_FILE_NOT_OPEN));	// can't write when machine is moving

/* not needed
	if (nv->valuetype == TYPE_FLOAT) {
		if (isnan((double)nv->value)) return(rpt_exception(STAT_FLOAT_IS_NAN));		// bad floating point value
		if (isinf((double)nv->value)) return(rpt_exception(STAT_FLOAT_IS_INFINITE));// bad floating point value
	}
*/
	nvm.tmp_value = nv->value;
	ritorno(read_persistent_value(nv));
	if ((isnan((double)nv->value)) || (isinf((double)nv->value)) || (fp_NE(nv->value, nvm.tmp_value))) {
		memcpy(&nvm.byte_array, &nvm.tmp_value, NVM_VALUE_LEN);
		nvm.address = nvm.profile_base + (nv->index * NVM_VALUE_LEN);
		(void)EEPROM_WriteBytes(nvm.address, nvm.byte_array, NVM_VALUE_LEN);
	}
	nv->value =nvm.tmp_value;		// always restore value
	return (STAT_OK);
}