1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-09-03 03:13:25 +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
if (!approach && (limits_get_state() & cycle_mask)) {
sys_rt_exec_alarm = ExecAlarm::HomingFailPulloff;
}
// Homing failure condition: Limit switch not found during approach. // 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,12 +167,12 @@ 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. // Pull-off motion complete. Disable CYCLE_STOP from executing.
sys_cycleStop = false; sys_cycleStop = false;
break; break;
} }
}
} while (!switch_touched); } while (!switch_touched);
#ifdef USE_I2S_STEPS #ifdef USE_I2S_STEPS

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
if (!approach && (limits_get_state() & cycle_mask)) {
sys_rt_exec_alarm = ExecAlarm::HomingFailPulloff;
}
// Homing failure condition: Limit switch not found during approach. // 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,12 +193,12 @@ 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. // Pull-off motion complete. Disable CYCLE_STOP from executing.
sys_cycleStop = false; sys_cycleStop = false;
break; break;
} }
}
} while (STEP_MASK & axislock); } while (STEP_MASK & axislock);
#ifdef USE_I2S_STEPS #ifdef USE_I2S_STEPS
if (current_stepper == ST_I2S_STREAM) { if (current_stepper == ST_I2S_STREAM) {

View File

@@ -270,22 +270,20 @@ 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.
if (rt_exec_state.value != 0) { // Test if any bits are on
// Execute system abort. // Execute system abort.
if (rt_exec_state.bit.reset) { if (sys_reset) {
sys.abort = true; // Only place this is set true. sys.abort = true; // Only place this is set true.
return; // Nothing else to do but exit. return; // Nothing else to do but exit.
} }
// Execute and serial print status // Execute and serial print status
if (rt_exec_state.bit.statusReport) { if (sys_statusReport) {
report_realtime_status(CLIENT_ALL); report_realtime_status(CLIENT_ALL);
sys_statusReport = false; sys_statusReport = false;
} }
// NOTE: Once hold is initiated, the system immediately enters a suspend state to block all // 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. // main program processes until either reset or resumed. This ensures a hold completes safely.
if (rt_exec_state.bit.motionCancel || rt_exec_state.bit.feedHold || rt_exec_state.bit.safetyDoor || rt_exec_state.bit.sleep) { if (sys_motionCancel || sys_feedHold || sys_safetyDoor || sys_sleep) {
// State check for allowable states for hold methods. // State check for allowable states for hold methods.
if (!(sys.state == State::Alarm || sys.state == State::CheckMode)) { if (!(sys.state == State::Alarm || sys.state == State::CheckMode)) {
// If in CYCLE or JOG states, immediately initiate a motion HOLD. // If in CYCLE or JOG states, immediately initiate a motion HOLD.
@@ -295,7 +293,7 @@ void protocol_exec_rt_system() {
sys.step_control = {}; sys.step_control = {};
sys.step_control.executeHold = true; // Initiate suspend state with active flag. sys.step_control.executeHold = true; // Initiate suspend state with active flag.
if (sys.state == State::Jog) { // Jog cancelled upon any hold event, except for sleeping. if (sys.state == State::Jog) { // Jog cancelled upon any hold event, except for sleeping.
if (!rt_exec_state.bit.sleep) { if (!sys_sleep) {
sys.suspend.bit.jogCancel = true; sys.suspend.bit.jogCancel = true;
} }
} }
@@ -308,7 +306,7 @@ void protocol_exec_rt_system() {
} }
// Execute and flag a motion cancel with deceleration and return to idle. Used primarily by probing cycle // 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. // to halt and cancel the remainder of the motion.
if (rt_exec_state.bit.motionCancel) { if (sys_motionCancel) {
// MOTION_CANCEL only occurs during a CYCLE, but a HOLD and SAFETY_DOOR may been initiated beforehand // 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 // 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. // will handle and clear multiple planner block motions.
@@ -318,7 +316,7 @@ void protocol_exec_rt_system() {
sys_motionCancel = false; sys_motionCancel = false;
} }
// Execute a feed hold with deceleration, if required. Then, suspend system. // Execute a feed hold with deceleration, if required. Then, suspend system.
if (rt_exec_state.bit.feedHold) { if (sys_feedHold) {
// Block SAFETY_DOOR, JOG, and SLEEP states from changing to HOLD state. // Block SAFETY_DOOR, JOG, and SLEEP states from changing to HOLD state.
if (!(sys.state == State::SafetyDoor || sys.state == State::Jog || sys.state == State::Sleep)) { if (!(sys.state == State::SafetyDoor || sys.state == State::Jog || sys.state == State::Sleep)) {
sys.state = State::Hold; sys.state = State::Hold;
@@ -328,7 +326,7 @@ void protocol_exec_rt_system() {
// Execute a safety door stop with a feed hold and disable spindle/coolant. // Execute a safety door stop with a feed hold and disable spindle/coolant.
// NOTE: Safety door differs from feed holds by stopping everything no matter state, disables powered // NOTE: Safety door differs from feed holds by stopping everything no matter state, disables powered
// devices (spindle/coolant), and blocks resuming until switch is re-engaged. // devices (spindle/coolant), and blocks resuming until switch is re-engaged.
if (rt_exec_state.bit.safetyDoor) { if (sys_safetyDoor) {
report_feedback_message(Message::SafetyDoorAjar); report_feedback_message(Message::SafetyDoorAjar);
// If jogging, block safety door methods until jog cancel is complete. Just flag that it happened. // If jogging, block safety door methods until jog cancel is complete. Just flag that it happened.
if (!(sys.suspend.bit.jogCancel)) { if (!(sys.suspend.bit.jogCancel)) {
@@ -362,7 +360,7 @@ void protocol_exec_rt_system() {
sys.suspend.bit.safetyDoorAjar = true; sys.suspend.bit.safetyDoorAjar = true;
} }
} }
if (rt_exec_state.bit.sleep) { if (sys_sleep) {
if (sys.state == State::Alarm) { if (sys.state == State::Alarm) {
sys.suspend.bit.retractComplete = true; sys.suspend.bit.retractComplete = true;
sys.suspend.bit.holdComplete = true; sys.suspend.bit.holdComplete = true;
@@ -370,12 +368,12 @@ void protocol_exec_rt_system() {
sys.state = State::Sleep; sys.state = State::Sleep;
sys_sleep = false; 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

View File

@@ -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

@@ -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();