Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bouncy probes. #485

Open
wants to merge 1 commit into
base: edge
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions g2core/cycle_probing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ static void _send_probe_report(void);
***********************************************************************************/

/***********************************************************************************
* cm_probing_cycle_start() - G38.x probing cycle using contact (digital input)
* cm_straight_probe() - G38.x probing cycle using contact (digital input)
*
* cm_probe_cycle_start() is the entry point for a probe cycle. It checks for
* cm_straight_probe() is the entry point for a probe cycle. It checks for
* some errors, sets up the cycle, then prevents any new commands from queuing
* to the planner so that the planner can move to a stop and report motion stopped.
*
Expand Down Expand Up @@ -261,6 +261,8 @@ static uint8_t _probing_start()
return(_probing_exception_exit(STAT_PROBE_IS_ALREADY_TRIPPED));
}

en_clear_snapped();

// Everything checks out. Run the probe move
_probe_move(pb.target, pb.flags);
pb.func = _probing_backoff;
Expand All @@ -279,7 +281,7 @@ static stat_t _probing_backoff()
// captured from the encoder in step space to steps to mm. The encoder snapshot
// was taken by input interrupt at the time of closure.

if (pb.trip_sense == gpio_read_input(pb.probe_input)) { // exclusive or for booleans
if (en_get_snapped()) {
cm->probe_state[0] = PROBE_SUCCEEDED;
float contact_position[AXES];
kn_forward_kinematics(en_get_encoder_snapshot_vector(), contact_position);
Expand Down
7 changes: 7 additions & 0 deletions g2core/encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,15 @@ void en_take_encoder_snapshot() {
en.snapshot[MOTOR_5] = en.en[MOTOR_5].encoder_steps + en.en[MOTOR_5].steps_run;
en.snapshot[MOTOR_6] = en.en[MOTOR_6].encoder_steps + en.en[MOTOR_6].steps_run;
*/

en.snapped = true;
}

void en_clear_snapped() { en.snapped = false; }

bool en_get_snapped() { return en.snapped; }


float en_get_encoder_snapshot_steps(uint8_t motor) { return (en.snapshot[motor]); }

float* en_get_encoder_snapshot_vector() { return (en.snapshot); }
Expand Down
4 changes: 4 additions & 0 deletions g2core/encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ typedef struct enEncoder { // one real or virtual encoder per controlle

typedef struct enEncoders {
magic_t magic_start;
bool snapped;
enEncoder_t en[MOTORS]; // runtime encoder structures
float snapshot[MOTORS]; // snapshot vector
magic_t magic_end;
Expand All @@ -134,4 +135,7 @@ void en_take_encoder_snapshot();
float en_get_encoder_snapshot_steps(uint8_t motor);
float* en_get_encoder_snapshot_vector();

void en_clear_snapped();
bool en_get_snapped();

#endif // End of include guard: ENCODER_H_ONCE