Exemplo n.º 1
0
static stat_t _probing_finish()
{
    int8_t probe = gpio_read_input(pb.probe_input);
	cm.probe_state = (probe==true) ? PROBE_SUCCEEDED : PROBE_FAILED;

	for (uint8_t axis=0; axis<AXES; axis++ ) {
		// if we got here because of a feed hold we need to keep the model position correct
		cm_set_position(axis, cm_get_work_position(RUNTIME, axis));

		// store the probe results
		cm.probe_results[axis] = cm_get_absolute_position(ACTIVE_MODEL, axis);
	}

	// If probe was successful the 'e' word == 1, otherwise e == 0 to signal an error
	printf_P(PSTR("{\"prb\":{\"e\":%i"), (int)cm.probe_state);
	if (fp_TRUE(pb.flags[AXIS_X])) printf_P(PSTR(",\"x\":%0.3f"), cm.probe_results[AXIS_X]);
	if (fp_TRUE(pb.flags[AXIS_Y])) printf_P(PSTR(",\"y\":%0.3f"), cm.probe_results[AXIS_Y]);
	if (fp_TRUE(pb.flags[AXIS_Z])) printf_P(PSTR(",\"z\":%0.3f"), cm.probe_results[AXIS_Z]);
	if (fp_TRUE(pb.flags[AXIS_A])) printf_P(PSTR(",\"a\":%0.3f"), cm.probe_results[AXIS_A]);
	if (fp_TRUE(pb.flags[AXIS_B])) printf_P(PSTR(",\"b\":%0.3f"), cm.probe_results[AXIS_B]);
	if (fp_TRUE(pb.flags[AXIS_C])) printf_P(PSTR(",\"c\":%0.3f"), cm.probe_results[AXIS_C]);
	printf_P(PSTR("}}\n"));

	return (_set_pb_func(_probing_finalize_exit));
}
Exemplo n.º 2
0
static stat_t _probing_start()
{
	// initial probe state, don't probe if we're already contacted!
    int8_t probe = gpio_read_input(pb.probe_input);

    // false is SW_OPEN in old code, and INPUT_INACTIVE in new
	if ( probe == INPUT_INACTIVE ) {
		cm_straight_feed(pb.target, pb.flags);
        return (_set_pb_func(_probing_backoff));
	}

    cm.probe_state = PROBE_SUCCEEDED;
    return (_set_pb_func(_probing_finish));
}
Exemplo n.º 3
0
static stat_t _probing_start()
{
	// initial probe state, don't probe if we're already contacted!
    int8_t probe = gpio_read_input(pb.probe_input);

    // INPUT_INACTIVE means switch is OPEN
	if ( probe == INPUT_INACTIVE ) {
		cm_straight_feed(pb.target, pb.flags);
        return (_set_pb_func(_probing_backoff));

	} else {
        cm.probe_state = PROBE_SUCCEEDED;
        return (_set_pb_func(_probing_finish));
    }
}
Exemplo n.º 4
0
/*
 * _probing_backoff()
 */
static stat_t _probing_backoff()
{
    // If we've contacted, back off & then record position
    int8_t probe = gpio_read_input(pb.probe_input);

    /* true is SW_CLOSED in old code, and INPUT_ACTIVE in new */
    if (probe == INPUT_ACTIVE) {
        cm.probe_state = PROBE_SUCCEEDED;
    //  FIXME: this should be its own parameter
    //  cm_set_feed_rate(cm.a[AXIS_Z].latch_velocity);
        cm_straight_feed(pb.start_position, pb.flags);
        return (_set_pb_func(_probing_finish));
    } else {
        cm.probe_state = PROBE_FAILED;
        return (_set_pb_func(_probing_finish));
    }
}
Exemplo n.º 5
0
static stat_t _probing_backoff()
{
    // Test if we've contacted
    int8_t probe = gpio_read_input(pb.probe_input);

    // INPUT_INACTIVE means switch is OPEN (at least for now)
    if ( probe == INPUT_INACTIVE ) {
        cm.probe_state = PROBE_FAILED;

    } else {
        cm.probe_state = PROBE_SUCCEEDED;

        // capture contact position in step space and convert from steps to mm.
        // snapshot was taken by switch interrupt at the time of closure
        float contact_position[AXES];
        kn_forward_kinematics(en_get_encoder_snapshot_vector(), contact_position);

        cm_queue_flush();                               // flush queue & end feedhold
        cm_straight_feed(contact_position, pb.flags);   // NB: feed rate is the same as the probe move
    }
    return (_set_pb_func(_probing_finish));
}
Exemplo n.º 6
0
static stat_t _probing_finish()
{
    int8_t probe = gpio_read_input(pb.probe_input);
	cm.probe_state = (probe==true) ? PROBE_SUCCEEDED : PROBE_FAILED;

    // store the probe results
	for (uint8_t axis=0; axis<AXES; axis++ ) {
		cm.probe_results[axis] = cm_get_absolute_position(ACTIVE_MODEL, axis);
	}

	// If probe was successful the 'e' word == 1, otherwise e == 0 to signal an error
	printf_P(PSTR("{\"prb\":{\"e\":%i"), (int)cm.probe_state);

	if (pb.flags[AXIS_X]) { printf_P(PSTR(",\"x\":%0.3f"), cm.probe_results[AXIS_X]); }
	if (pb.flags[AXIS_Y]) { printf_P(PSTR(",\"y\":%0.3f"), cm.probe_results[AXIS_Y]); }
	if (pb.flags[AXIS_Z]) { printf_P(PSTR(",\"z\":%0.3f"), cm.probe_results[AXIS_Z]); }
	if (pb.flags[AXIS_A]) { printf_P(PSTR(",\"a\":%0.3f"), cm.probe_results[AXIS_A]); }
	if (pb.flags[AXIS_B]) { printf_P(PSTR(",\"b\":%0.3f"), cm.probe_results[AXIS_B]); }
	if (pb.flags[AXIS_C]) { printf_P(PSTR(",\"c\":%0.3f"), cm.probe_results[AXIS_C]); }

	printf_P(PSTR("}}\n"));

	return (_set_pb_func(_probing_finalize_exit));
}