1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-09-02 10:53:01 +02:00

Fixed typo

This commit is contained in:
Mitch Bradley
2020-12-22 20:52:14 -10:00
parent f6df8cd701
commit c43f479342
5 changed files with 138 additions and 166 deletions

View File

@@ -134,7 +134,7 @@ bool user_defined_homing(uint8_t cycle_mask) {
// convert back to motor steps // convert back to motor steps
inverse_kinematics(target); inverse_kinematics(target);
pl_data->feed_rate = homing_rate; // feed or seek rates pl_data->feed_rate = homing_rate; // Set current homing rate.
plan_buffer_line(target, pl_data); // Bypass mc_line(). Directly plan homing motion. plan_buffer_line(target, pl_data); // Bypass mc_line(). Directly plan homing motion.
sys.step_control = {}; sys.step_control = {};
sys.step_control.executeSysMotion = true; // Set to execute homing motion and clear existing flags. sys.step_control.executeSysMotion = true; // Set to execute homing motion and clear existing flags.
@@ -148,23 +148,18 @@ bool user_defined_homing(uint8_t cycle_mask) {
st_prep_buffer(); // Check and prep segment buffer. NOTE: Should take no longer than 200us. st_prep_buffer(); // Check and prep segment buffer. NOTE: Should take no longer than 200us.
// Exit routines: No time to run protocol_execute_realtime() in this loop. // Exit routines: No time to run protocol_execute_realtime() in this loop.
if (sys_safetyDoor || sys_reset || sys_cycleStop) { if (sys_safetyDoor || sys_reset || sys_cycleStop) {
ExecState rt_exec_state; if (sys_reset) {
rt_exec_state.value = sys_get_rt_exec_state().value; // Homing failure condition: Reset issued during cycle.
// Homing failure condition: Reset issued during cycle.
if (rt_exec_state.bit.reset) {
sys_rt_exec_alarm = ExecAlarm::HomingFailReset; sys_rt_exec_alarm = ExecAlarm::HomingFailReset;
} } else if (sys_safetyDoor) {
// Homing failure condition: Safety door was opened. // Homing failure condition: Safety door was opened.
if (rt_exec_state.bit.safetyDoor) {
sys_rt_exec_alarm = ExecAlarm::HomingFailDoor; sys_rt_exec_alarm = ExecAlarm::HomingFailDoor;
} } else if (approach) { // sys_cycleStop must be true if we get this far
// Homing failure condition: Limit switch still engaged after pull-off motion // Homing failure condition: Limit switch not found during approach.
if (!approach && (limits_get_state() & cycle_mask)) {
sys_rt_exec_alarm = ExecAlarm::HomingFailPulloff;
}
// Homing failure condition: Limit switch not found during approach.
if (approach && rt_exec_state.bit.cycleStop) {
sys_rt_exec_alarm = ExecAlarm::HomingFailApproach; sys_rt_exec_alarm = ExecAlarm::HomingFailApproach;
} else if (limits_get_state() & cycle_mask) {
// Homing failure condition: Limit switch still engaged after pull-off motion
sys_rt_exec_alarm = ExecAlarm::HomingFailPulloff;
} }
if (sys_rt_exec_alarm != ExecAlarm::None) { if (sys_rt_exec_alarm != ExecAlarm::None) {
@@ -172,11 +167,11 @@ bool user_defined_homing(uint8_t cycle_mask) {
mc_reset(); // Stop motors, if they are running. mc_reset(); // Stop motors, if they are running.
protocol_execute_realtime(); protocol_execute_realtime();
return true; return true;
} else {
// Pull-off motion complete. Disable CYCLE_STOP from executing.
sys_cycleStop = false;
break;
} }
// Pull-off motion complete. Disable CYCLE_STOP from executing.
sys_cycleStop = false;
break;
} }
} while (!switch_touched); } while (!switch_touched);

View File

@@ -174,23 +174,18 @@ void limits_go_home(uint8_t cycle_mask) {
st_prep_buffer(); // Check and prep segment buffer. NOTE: Should take no longer than 200us. st_prep_buffer(); // Check and prep segment buffer. NOTE: Should take no longer than 200us.
// Exit routines: No time to run protocol_execute_realtime() in this loop. // Exit routines: No time to run protocol_execute_realtime() in this loop.
if (sys_safetyDoor || sys_reset || sys_cycleStop) { if (sys_safetyDoor || sys_reset || sys_cycleStop) {
ExecState rt_exec_state; if (sys_reset) {
rt_exec_state.value = sys_get_rt_exec_state().value; // Homing failure condition: Reset issued during cycle.
// Homing failure condition: Reset issued during cycle.
if (rt_exec_state.bit.reset) {
sys_rt_exec_alarm = ExecAlarm::HomingFailReset; sys_rt_exec_alarm = ExecAlarm::HomingFailReset;
} } else if (sys_safetyDoor) {
// Homing failure condition: Safety door was opened. // Homing failure condition: Safety door was opened.
if (rt_exec_state.bit.safetyDoor) {
sys_rt_exec_alarm = ExecAlarm::HomingFailDoor; sys_rt_exec_alarm = ExecAlarm::HomingFailDoor;
} } else if (approach) { // sys_cycleStop must be true if we get this far
// Homing failure condition: Limit switch still engaged after pull-off motion // Homing failure condition: Limit switch not found during approach.
if (!approach && (limits_get_state() & cycle_mask)) {
sys_rt_exec_alarm = ExecAlarm::HomingFailPulloff;
}
// Homing failure condition: Limit switch not found during approach.
if (approach && rt_exec_state.bit.cycleStop) {
sys_rt_exec_alarm = ExecAlarm::HomingFailApproach; sys_rt_exec_alarm = ExecAlarm::HomingFailApproach;
} else if (limits_get_state() & cycle_mask) {
// Homing failure condition: Limit switch still engaged after pull-off motion
sys_rt_exec_alarm = ExecAlarm::HomingFailPulloff;
} }
if (sys_rt_exec_alarm != ExecAlarm::None) { if (sys_rt_exec_alarm != ExecAlarm::None) {
@@ -198,11 +193,11 @@ void limits_go_home(uint8_t cycle_mask) {
mc_reset(); // Stop motors, if they are running. mc_reset(); // Stop motors, if they are running.
protocol_execute_realtime(); protocol_execute_realtime();
return; return;
} else {
// Pull-off motion complete. Disable CYCLE_STOP from executing.
sys_cycleStop = false;
break;
} }
// Pull-off motion complete. Disable CYCLE_STOP from executing.
sys_cycleStop = false;
break;
} }
} while (STEP_MASK & axislock); } while (STEP_MASK & axislock);
#ifdef USE_I2S_STEPS #ifdef USE_I2S_STEPS

View File

@@ -222,8 +222,8 @@ void protocol_buffer_synchronize() {
// is finished, single commands), a command that needs to wait for the motions in the buffer to // is finished, single commands), a command that needs to wait for the motions in the buffer to
// execute calls a buffer sync, or the planner buffer is full and ready to go. // execute calls a buffer sync, or the planner buffer is full and ready to go.
void protocol_auto_cycle_start() { void protocol_auto_cycle_start() {
if (plan_get_current_block() != NULL) { // Check if there are any blocks in the buffer. if (plan_get_current_block() != NULL) { // Check if there are any blocks in the buffer.
sys_cycleStart = true; // If so, execute them! sys_cycleStart = true; // If so, execute them!
} }
} }
@@ -270,112 +270,110 @@ void protocol_exec_rt_system() {
} }
sys_rt_exec_alarm = ExecAlarm::None; sys_rt_exec_alarm = ExecAlarm::None;
} }
ExecState rt_exec_state;
rt_exec_state.value = sys_get_rt_exec_state().value; // Copy volatile sys_rt_exec_state. // Execute system abort.
if (rt_exec_state.value != 0) { // Test if any bits are on if (sys_reset) {
// Execute system abort. sys.abort = true; // Only place this is set true.
if (rt_exec_state.bit.reset) { return; // Nothing else to do but exit.
sys.abort = true; // Only place this is set true. }
return; // Nothing else to do but exit. // Execute and serial print status
} if (sys_statusReport) {
// Execute and serial print status report_realtime_status(CLIENT_ALL);
if (rt_exec_state.bit.statusReport) { sys_statusReport = false;
report_realtime_status(CLIENT_ALL); }
sys_statusReport = false; // NOTE: Once hold is initiated, the system immediately enters a suspend state to block all
} // main program processes until either reset or resumed. This ensures a hold completes safely.
// NOTE: Once hold is initiated, the system immediately enters a suspend state to block all if (sys_motionCancel || sys_feedHold || sys_safetyDoor || sys_sleep) {
// main program processes until either reset or resumed. This ensures a hold completes safely. // State check for allowable states for hold methods.
if (rt_exec_state.bit.motionCancel || rt_exec_state.bit.feedHold || rt_exec_state.bit.safetyDoor || rt_exec_state.bit.sleep) { if (!(sys.state == State::Alarm || sys.state == State::CheckMode)) {
// State check for allowable states for hold methods. // If in CYCLE or JOG states, immediately initiate a motion HOLD.
if (!(sys.state == State::Alarm || sys.state == State::CheckMode)) { if (sys.state == State::Cycle || sys.state == State::Jog) {
// If in CYCLE or JOG states, immediately initiate a motion HOLD. if (!(sys.suspend.bit.motionCancel || sys.suspend.bit.jogCancel)) { // Block, if already holding.
if (sys.state == State::Cycle || sys.state == State::Jog) { st_update_plan_block_parameters(); // Notify stepper module to recompute for hold deceleration.
if (!(sys.suspend.bit.motionCancel || sys.suspend.bit.jogCancel)) { // Block, if already holding. sys.step_control = {};
st_update_plan_block_parameters(); // Notify stepper module to recompute for hold deceleration. sys.step_control.executeHold = true; // Initiate suspend state with active flag.
sys.step_control = {}; if (sys.state == State::Jog) { // Jog cancelled upon any hold event, except for sleeping.
sys.step_control.executeHold = true; // Initiate suspend state with active flag. if (!sys_sleep) {
if (sys.state == State::Jog) { // Jog cancelled upon any hold event, except for sleeping. sys.suspend.bit.jogCancel = true;
if (!rt_exec_state.bit.sleep) {
sys.suspend.bit.jogCancel = true;
}
} }
} }
} }
// If IDLE, Grbl is not in motion. Simply indicate suspend state and hold is complete. }
if (sys.state == State::Idle) { // If IDLE, Grbl is not in motion. Simply indicate suspend state and hold is complete.
sys.suspend.value = 0; if (sys.state == State::Idle) {
sys.suspend.bit.holdComplete = true; sys.suspend.value = 0;
sys.suspend.bit.holdComplete = true;
}
// Execute and flag a motion cancel with deceleration and return to idle. Used primarily by probing cycle
// to halt and cancel the remainder of the motion.
if (sys_motionCancel) {
// MOTION_CANCEL only occurs during a CYCLE, but a HOLD and SAFETY_DOOR may been initiated beforehand
// to hold the CYCLE. Motion cancel is valid for a single planner block motion only, while jog cancel
// will handle and clear multiple planner block motions.
if (sys.state != State::Jog) {
sys.suspend.bit.motionCancel = true; // NOTE: State is State::Cycle.
} }
// Execute and flag a motion cancel with deceleration and return to idle. Used primarily by probing cycle sys_motionCancel = false;
// to halt and cancel the remainder of the motion. }
if (rt_exec_state.bit.motionCancel) { // Execute a feed hold with deceleration, if required. Then, suspend system.
// MOTION_CANCEL only occurs during a CYCLE, but a HOLD and SAFETY_DOOR may been initiated beforehand if (sys_feedHold) {
// to hold the CYCLE. Motion cancel is valid for a single planner block motion only, while jog cancel // Block SAFETY_DOOR, JOG, and SLEEP states from changing to HOLD state.
// will handle and clear multiple planner block motions. if (!(sys.state == State::SafetyDoor || sys.state == State::Jog || sys.state == State::Sleep)) {
if (sys.state != State::Jog) { sys.state = State::Hold;
sys.suspend.bit.motionCancel = true; // NOTE: State is State::Cycle.
}
sys_motionCancel = false;
} }
// Execute a feed hold with deceleration, if required. Then, suspend system. sys_feedHold = false;
if (rt_exec_state.bit.feedHold) { }
// Block SAFETY_DOOR, JOG, and SLEEP states from changing to HOLD state. // Execute a safety door stop with a feed hold and disable spindle/coolant.
if (!(sys.state == State::SafetyDoor || sys.state == State::Jog || sys.state == State::Sleep)) { // NOTE: Safety door differs from feed holds by stopping everything no matter state, disables powered
sys.state = State::Hold; // devices (spindle/coolant), and blocks resuming until switch is re-engaged.
} if (sys_safetyDoor) {
sys_feedHold = false; report_feedback_message(Message::SafetyDoorAjar);
} // If jogging, block safety door methods until jog cancel is complete. Just flag that it happened.
// Execute a safety door stop with a feed hold and disable spindle/coolant. if (!(sys.suspend.bit.jogCancel)) {
// NOTE: Safety door differs from feed holds by stopping everything no matter state, disables powered // Check if the safety re-opened during a restore parking motion only. Ignore if
// devices (spindle/coolant), and blocks resuming until switch is re-engaged. // already retracting, parked or in sleep state.
if (rt_exec_state.bit.safetyDoor) { if (sys.state == State::SafetyDoor) {
report_feedback_message(Message::SafetyDoorAjar); if (sys.suspend.bit.initiateRestore) { // Actively restoring
// If jogging, block safety door methods until jog cancel is complete. Just flag that it happened.
if (!(sys.suspend.bit.jogCancel)) {
// Check if the safety re-opened during a restore parking motion only. Ignore if
// already retracting, parked or in sleep state.
if (sys.state == State::SafetyDoor) {
if (sys.suspend.bit.initiateRestore) { // Actively restoring
#ifdef PARKING_ENABLE #ifdef PARKING_ENABLE
// Set hold and reset appropriate control flags to restart parking sequence. // Set hold and reset appropriate control flags to restart parking sequence.
if (sys.step_control.executeSysMotion) { if (sys.step_control.executeSysMotion) {
st_update_plan_block_parameters(); // Notify stepper module to recompute for hold deceleration. st_update_plan_block_parameters(); // Notify stepper module to recompute for hold deceleration.
sys.step_control = {}; sys.step_control = {};
sys.step_control.executeHold = true; sys.step_control.executeHold = true;
sys.step_control.executeSysMotion = true; sys.step_control.executeSysMotion = true;
sys.suspend.bit.holdComplete = false; sys.suspend.bit.holdComplete = false;
} // else NO_MOTION is active. } // else NO_MOTION is active.
#endif #endif
sys.suspend.bit.retractComplete = false; sys.suspend.bit.retractComplete = false;
sys.suspend.bit.initiateRestore = false; sys.suspend.bit.initiateRestore = false;
sys.suspend.bit.restoreComplete = false; sys.suspend.bit.restoreComplete = false;
sys.suspend.bit.restartRetract = true; sys.suspend.bit.restartRetract = true;
}
} }
if (sys.state != State::Sleep) {
sys.state = State::SafetyDoor;
}
sys_safetyDoor = false;
} }
// NOTE: This flag doesn't change when the door closes, unlike sys.state. Ensures any parking motions if (sys.state != State::Sleep) {
// are executed if the door switch closes and the state returns to HOLD. sys.state = State::SafetyDoor;
sys.suspend.bit.safetyDoorAjar = true; }
sys_safetyDoor = false;
} }
} // NOTE: This flag doesn't change when the door closes, unlike sys.state. Ensures any parking motions
if (rt_exec_state.bit.sleep) { // are executed if the door switch closes and the state returns to HOLD.
if (sys.state == State::Alarm) { sys.suspend.bit.safetyDoorAjar = true;
sys.suspend.bit.retractComplete = true;
sys.suspend.bit.holdComplete = true;
}
sys.state = State::Sleep;
sys_sleep = false;
} }
} }
if (sys_sleep) {
if (sys.state == State::Alarm) {
sys.suspend.bit.retractComplete = true;
sys.suspend.bit.holdComplete = true;
}
sys.state = State::Sleep;
sys_sleep = false;
}
// Execute a cycle start by starting the stepper interrupt to begin executing the blocks in queue. // Execute a cycle start by starting the stepper interrupt to begin executing the blocks in queue.
if (rt_exec_state.bit.cycleStart) { if (sys_cycleStart) {
// Block if called at same time as the hold commands: feed hold, motion cancel, and safety door. // Block if called at same time as the hold commands: feed hold, motion cancel, and safety door.
// Ensures auto-cycle-start doesn't resume a hold without an explicit user-input. // Ensures auto-cycle-start doesn't resume a hold without an explicit user-input.
if (!(rt_exec_state.bit.feedHold || rt_exec_state.bit.motionCancel || rt_exec_state.bit.safetyDoor)) { if (!(sys_feedHold || sys_motionCancel || sys_safetyDoor)) {
// Resume door state when parking motion has retracted and door has been closed. // Resume door state when parking motion has retracted and door has been closed.
if (sys.state == State::SafetyDoor && !(sys.suspend.bit.safetyDoorAjar)) { if (sys.state == State::SafetyDoor && !(sys.suspend.bit.safetyDoorAjar)) {
if (sys.suspend.bit.restoreComplete) { if (sys.suspend.bit.restoreComplete) {
@@ -410,7 +408,7 @@ void protocol_exec_rt_system() {
} }
sys_cycleStart = false; sys_cycleStart = false;
} }
if (rt_exec_state.bit.cycleStop) { if (sys_cycleStop) {
// Reinitializes the cycle plan and stepper system after a feed hold for a resume. Called by // Reinitializes the cycle plan and stepper system after a feed hold for a resume. Called by
// realtime command execution in the main program, ensuring that the planner re-plans safely. // realtime command execution in the main program, ensuring that the planner re-plans safely.
// NOTE: Bresenham algorithm variables are still maintained through both the planner and stepper // NOTE: Bresenham algorithm variables are still maintained through both the planner and stepper
@@ -695,8 +693,8 @@ static void protocol_exec_rt_suspend() {
} }
#endif #endif
if (!sys.suspend.bit.restartRetract) { if (!sys.suspend.bit.restartRetract) {
sys.suspend.bit.restoreComplete = true; sys.suspend.bit.restoreComplete = true;
sys_cycleStart = true; // Set to resume program. sys_cycleStart = true; // Set to resume program.
} }
} }
} }

View File

@@ -26,17 +26,17 @@ system_t sys;
int32_t sys_position[MAX_N_AXIS]; // Real-time machine (aka home) position vector in steps. int32_t sys_position[MAX_N_AXIS]; // Real-time machine (aka home) position vector in steps.
int32_t sys_probe_position[MAX_N_AXIS]; // Last probe position in machine coordinates and steps. int32_t sys_probe_position[MAX_N_AXIS]; // Last probe position in machine coordinates and steps.
volatile Probe sys_probe_state; // Probing state value. Used to coordinate the probing cycle with stepper ISR. volatile Probe sys_probe_state; // Probing state value. Used to coordinate the probing cycle with stepper ISR.
volatile ExecAlarm sys_rt_exec_alarm; // Global realtime executor bitflag variable for setting various alarms. volatile ExecAlarm sys_rt_exec_alarm; // Global realtime executor bitflag variable for setting various alarms.
volatile ExecAccessory sys_rt_exec_accessory_override; // Global realtime executor bitflag variable for spindle/coolant overrides. volatile ExecAccessory sys_rt_exec_accessory_override; // Global realtime executor bitflag variable for spindle/coolant overrides.
volatile bool sys_statusReport; // For state transitions, instead of bitflag volatile bool sys_statusReport; // For state transitions, instead of bitflag
volatile bool sys_cycleStart; volatile bool sys_cycleStart;
volatile bool sys_cycleStop; volatile bool sys_cycleStop;
volatile bool sys_feedHold; volatile bool sys_feedHold;
volatile bool sys_reset; volatile bool sys_reset;
volatile bool sys_safetyDoor; volatile bool sys_safetyDoor;
volatile bool sys_motionCancel; volatile bool sys_motionCancel;
volatile bool sys_sleep; volatile bool sys_sleep;
#ifdef DEBUG #ifdef DEBUG
volatile bool sys_rt_exec_debug; volatile bool sys_rt_exec_debug;
@@ -343,20 +343,6 @@ uint8_t sys_calc_pwm_precision(uint32_t freq) {
return precision - 1; return precision - 1;
} }
ExecState sys_get_rt_exec_state() {
ExecState result;
result.value = 0;
result.bit.statusReport = sys_statusReport;
result.bit.cycleStart = sys_cycleStart;
result.bit.cycleStop = sys_cycleStop;
result.bit.feedHold = sys_feedHold;
result.bit.reset = sys_reset;
result.bit.safetyDoor = sys_safetyDoor;
result.bit.motionCancel = sys_motionCancel;
result.bit.sleep = sys_sleep;
return result;
}
void __attribute__((weak)) user_defined_macro(uint8_t index) { void __attribute__((weak)) user_defined_macro(uint8_t index) {
// must be in Idle // must be in Idle
if (sys.state != State::Idle) { if (sys.state != State::Idle) {

View File

@@ -139,14 +139,14 @@ extern volatile Percent sys_rt_s_override; // Spindle overri
// System executor bits. Used internally by realtime protocol as realtime command flags, // System executor bits. Used internally by realtime protocol as realtime command flags,
// which notifies the main program to execute the specified realtime command asynchronously. // which notifies the main program to execute the specified realtime command asynchronously.
extern volatile bool sys_statusReport; extern volatile bool sys_statusReport;
extern volatile bool sys_cycleStart; extern volatile bool sys_cycleStart;
extern volatile bool sys_cycleStop; extern volatile bool sys_cycleStop;
extern volatile bool sys_feedHold; extern volatile bool sys_feedHold;
extern volatile bool sys_reset; extern volatile bool sys_reset;
extern volatile bool sys_safetyDoor; extern volatile bool sys_safetyDoor;
extern volatile bool sys_motionCancel; extern volatile bool sys_motionCancel;
extern volatile bool sys_sleep; extern volatile bool sys_sleep;
#ifdef DEBUG #ifdef DEBUG
extern volatile bool sys_rt_exec_debug; extern volatile bool sys_rt_exec_debug;
@@ -185,5 +185,3 @@ bool sys_pwm_control(uint8_t io_num_mask, float duty, bool synchronized);
int8_t sys_get_next_PWM_chan_num(); int8_t sys_get_next_PWM_chan_num();
uint8_t sys_calc_pwm_precision(uint32_t freq); uint8_t sys_calc_pwm_precision(uint32_t freq);
ExecState sys_get_rt_exec_state();