install G38.{3,4,5}
This commit is contained in:
parent
f78eebcebf
commit
0f7806938d
22
gcode.c
22
gcode.c
@ -210,11 +210,23 @@ uint8_t gc_execute_line(char *line)
|
||||
case 3: gc_block.modal.motion = MOTION_MODE_CCW_ARC; break; // G3
|
||||
case 38:
|
||||
switch(mantissa) {
|
||||
case 20: gc_block.modal.motion = MOTION_MODE_PROBE; break; // G38.2
|
||||
// NOTE: If G38.3+ are enabled, change mantissa variable type to uint16_t.
|
||||
// case 30: gc_block.modal.motion = MOTION_MODE_PROBE_NO_ERROR; break; // G38.3 Not supported.
|
||||
// case 40: // Not supported.
|
||||
// case 50: // Not supported.
|
||||
case 20:
|
||||
sys.probe_away = false;
|
||||
gc_block.modal.motion = MOTION_MODE_PROBE;
|
||||
break; // G38.2
|
||||
case 30:
|
||||
sys.probe_away = false;
|
||||
gc_block.modal.motion = MOTION_MODE_PROBE_NO_ERROR;
|
||||
break; // G38.3
|
||||
case 40:
|
||||
sys.probe_away = true;
|
||||
gc_block.modal.motion = MOTION_MODE_PROBE;
|
||||
break; // G38.4
|
||||
case 50:
|
||||
sys.probe_away = true;
|
||||
gc_block.modal.motion = MOTION_MODE_PROBE_NO_ERROR;
|
||||
break; // G38.5
|
||||
|
||||
default: FAIL(STATUS_GCODE_UNSUPPORTED_COMMAND); // [Unsupported G38.x command]
|
||||
}
|
||||
mantissa = 0; // Set to zero to indicate valid non-integer G command.
|
||||
|
@ -289,7 +289,7 @@ void mc_homing_cycle()
|
||||
uint8_t auto_start_state = sys.auto_start; // Store run state
|
||||
|
||||
// After syncing, check if probe is already triggered. If so, halt and issue alarm.
|
||||
if (probe_get_state()) {
|
||||
if ((sys.probe_away << PROBE_BIT) ^ probe_get_state()) {
|
||||
bit_true_atomic(sys.execute, EXEC_CRIT_EVENT);
|
||||
protocol_execute_runtime();
|
||||
}
|
||||
|
6
probe.c
6
probe.c
@ -37,6 +37,8 @@ void probe_init()
|
||||
PROBE_PORT |= PROBE_MASK; // Enable internal pull-up resistors. Normal high operation.
|
||||
probe_invert_mask = PROBE_MASK;
|
||||
}
|
||||
|
||||
sys.probe_away = false;
|
||||
}
|
||||
|
||||
|
||||
@ -49,8 +51,8 @@ uint8_t probe_get_state() { return((PROBE_PIN & PROBE_MASK) ^ probe_invert_mask)
|
||||
// NOTE: This function must be extremely efficient as to not bog down the stepper ISR.
|
||||
void probe_state_monitor()
|
||||
{
|
||||
if (sys.probe_state == PROBE_ACTIVE) {
|
||||
if (probe_get_state()) {
|
||||
if (sys.probe_state == PROBE_ACTIVE) {
|
||||
if ((sys.probe_away << PROBE_BIT) ^ probe_get_state()) {
|
||||
sys.probe_state = PROBE_OFF;
|
||||
memcpy(sys.probe_position, sys.position, sizeof(float)*N_AXIS);
|
||||
bit_true(sys.execute, EXEC_FEED_HOLD);
|
||||
|
1
system.h
1
system.h
@ -79,6 +79,7 @@ typedef struct {
|
||||
uint8_t auto_start; // Planner auto-start flag. Toggled off during feed hold. Defaulted by settings.
|
||||
volatile uint8_t probe_state; // Probing state value. Used to coordinate the probing cycle with stepper ISR.
|
||||
int32_t probe_position[N_AXIS]; // Last probe position in machine coordinates and steps.
|
||||
uint8_t probe_away; // probe away from work by reversing the switch direction (G38.4, G38.5)
|
||||
} system_t;
|
||||
extern system_t sys;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user