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

Devt #618

Merged
merged 13 commits into from
Sep 28, 2020
Prev Previous commit
Next Next commit
Basic testing Complete
  • Loading branch information
bdring committed Sep 22, 2020
commit 286ed2a1046b4471af27fa05c4f38dd0df0af8f3
1 change: 1 addition & 0 deletions Grbl_Esp32/src/Grbl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ static void reset_variables() {
memset(sys_probe_position, 0, sizeof(sys_probe_position)); // Clear probe position.
sys_probe_state = 0;
sys_rt_exec_state = 0;
cycle_stop = false;
sys_rt_exec_motion_override = 0;
sys_rt_exec_accessory_override = 0;
system_clear_exec_alarm();
Expand Down
8 changes: 4 additions & 4 deletions Grbl_Esp32/src/Limits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void limits_go_home(uint8_t cycle_mask) {
}
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.
if (sys_rt_exec_state & (EXEC_SAFETY_DOOR | EXEC_RESET | EXEC_CYCLE_STOP)) {
if ((sys_rt_exec_state & (EXEC_SAFETY_DOOR | EXEC_RESET)) || cycle_stop) {
uint8_t rt_exec = sys_rt_exec_state;
// Homing failure condition: Reset issued during cycle.
if (rt_exec & EXEC_RESET) {
Expand All @@ -217,7 +217,7 @@ void limits_go_home(uint8_t cycle_mask) {
system_set_exec_alarm(ExecAlarm::HomingFailPulloff);
}
// Homing failure condition: Limit switch not found during approach.
if (approach && (rt_exec & EXEC_CYCLE_STOP)) {
if (approach && cycle_stop) {
system_set_exec_alarm(ExecAlarm::HomingFailApproach);
}

Expand All @@ -228,7 +228,7 @@ void limits_go_home(uint8_t cycle_mask) {
return;
} else {
// Pull-off motion complete. Disable CYCLE_STOP from executing.
system_clear_exec_state_flag(EXEC_CYCLE_STOP);
cycle_stop = false;
break;
}
}
Expand Down Expand Up @@ -371,7 +371,7 @@ void limits_disable() {
// number in bit position, i.e. Z_AXIS is bit(2), and Y_AXIS is bit(1).
uint8_t limits_get_state() {
uint8_t pinMask = 0;
auto n_axis = number_axis->get();
auto n_axis = number_axis->get();
for (int axis = 0; axis < n_axis; axis++) {
for (int gang_index = 0; gang_index < 2; gang_index++) {
uint8_t pin = limit_pins[axis][gang_index];
Expand Down
18 changes: 17 additions & 1 deletion Grbl_Esp32/src/Machines/6_pack_stepstick_XYZ_v1.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,27 @@ Socket #5

*/

// 4x Input Module in Socket #1
/*
// 4x Input Module in Socket #1
// https://github.com/bdring/6-Pack_CNC_Controller/wiki/4x-Switch-Input-module
#define X_LIMIT_PIN GPIO_NUM_33
#define Y_LIMIT_PIN GPIO_NUM_32
#define Z_LIMIT_PIN GPIO_NUM_35
*/

// 4x Input Module in Socket #2
// https://github.com/bdring/6-Pack_CNC_Controller/wiki/4x-Switch-Input-module
#define X_LIMIT_PIN GPIO_NUM_2
#define Y_LIMIT_PIN GPIO_NUM_25
#define Z_LIMIT_PIN GPIO_NUM_39

// 4x Input Module in Socket #3
// https://github.com/bdring/6-Pack_CNC_Controller/wiki/4x-Switch-Input-module
#define CONTROL_CYCLE_START_PIN GPIO_NUM_26
#define CONTROL_FEED_HOLD_PIN GPIO_NUM_4
#define CONTROL_RESET_PIN GPIO_NUM_16
#define CONTROL_SAFETY_DOOR_PIN GPIO_NUM_27
//#define INVERT_CONTROL_PIN_MASK B0000


// ================= Setting Defaults ==========================
Expand Down
8 changes: 4 additions & 4 deletions Grbl_Esp32/src/Protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ void protocol_exec_rt_system() {
system_clear_exec_alarm(); // Clear alarm
}
uint8_t rt_exec = sys_rt_exec_state; // Copy volatile sys_rt_exec_state.
if (rt_exec) {
if (rt_exec || cycle_stop) {
// Execute system abort.
if (rt_exec & EXEC_RESET) {
sys.abort = true; // Only place this is set true.
Expand Down Expand Up @@ -399,12 +399,12 @@ void protocol_exec_rt_system() {
}
system_clear_exec_state_flag(EXEC_CYCLE_START);
}
if (rt_exec & EXEC_CYCLE_STOP) {
if (cycle_stop) {
// 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.
// NOTE: Bresenham algorithm variables are still maintained through both the planner and stepper
// cycle reinitializations. The stepper path should continue exactly as if nothing has happened.
// NOTE: EXEC_CYCLE_STOP is set by the stepper subsystem when a cycle or feed hold completes.
// NOTE: cycle_stop is set by the stepper subsystem when a cycle or feed hold completes.
if ((sys.state == State::Hold || sys.state == State::SafetyDoor || sys.state == State::Sleep) && !(sys.soft_limit) &&
!(sys.suspend & SUSPEND_JOG_CANCEL)) {
// Hold complete. Set to indicate ready to resume. Remain in HOLD or DOOR states until user
Expand Down Expand Up @@ -433,7 +433,7 @@ void protocol_exec_rt_system() {
sys.state = State::Idle;
}
}
system_clear_exec_state_flag(EXEC_CYCLE_STOP);
cycle_stop = false;
}
}
// Execute overrides.
Expand Down
20 changes: 9 additions & 11 deletions Grbl_Esp32/src/Stepper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,8 @@ static void stepper_pulse_func() {
spindle->set_rpm(0);
}
}

system_set_exec_state_flag(EXEC_CYCLE_STOP); // Flag main program for cycle end
return; // Nothing to do but exit.
cycle_stop = true;
return; // Nothing to do but exit.
}
}
// Check probing state.
Expand Down Expand Up @@ -362,8 +361,7 @@ static void stepper_pulse_func() {
st.counter_a -= st.exec_block->step_event_count;
if (st.exec_block->direction_bits & bit(A_AXIS)) {
sys_position[A_AXIS]--;
}
else {
} else {
sys_position[A_AXIS]++;
}
}
Expand All @@ -379,8 +377,7 @@ static void stepper_pulse_func() {
st.counter_b -= st.exec_block->step_event_count;
if (st.exec_block->direction_bits & bit(B_AXIS)) {
sys_position[B_AXIS]--;
}
else {
} else {
sys_position[B_AXIS]++;
}
}
Expand All @@ -396,8 +393,7 @@ static void stepper_pulse_func() {
st.counter_c -= st.exec_block->step_event_count;
if (st.exec_block->direction_bits & bit(C_AXIS)) {
sys_position[C_AXIS]--;
}
else {
} else {
sys_position[C_AXIS]++;
}
}
Expand Down Expand Up @@ -1229,8 +1225,10 @@ float st_get_realtime_rate() {
case State::Homing:
case State::Hold:
case State::Jog:
case State::SafetyDoor: return prep.current_speed;
default: return 0.0f;
case State::SafetyDoor:
return prep.current_speed;
default:
return 0.0f;
}
}

Expand Down
1 change: 1 addition & 0 deletions Grbl_Esp32/src/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ volatile uint8_t sys_rt_exec_state; // Global realtime executor
volatile ExecAlarm sys_rt_exec_alarm; // Global realtime executor bitflag variable for setting various alarms.
volatile uint8_t sys_rt_exec_motion_override; // Global realtime executor bitflag variable for motion-based overrides.
volatile uint8_t sys_rt_exec_accessory_override; // Global realtime executor bitflag variable for spindle/coolant overrides.
volatile bool cycle_stop; // For state transitions, instead of bitflag
#ifdef DEBUG
volatile uint8_t sys_rt_exec_debug;
#endif
Expand Down
5 changes: 3 additions & 2 deletions Grbl_Esp32/src/System.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ extern system_t sys;
// know when there is a realtime command to execute.
#define EXEC_STATUS_REPORT bit(0) // bitmask 00000001
#define EXEC_CYCLE_START bit(1) // bitmask 00000010
#define EXEC_CYCLE_STOP bit(2) // bitmask 00000100
// #define EXEC_CYCLE_STOP bit(2) // bitmask 00000100 moved to cycle_stop
#define EXEC_FEED_HOLD bit(3) // bitmask 00001000
#define EXEC_RESET bit(4) // bitmask 00010000
#define EXEC_SAFETY_DOOR bit(5) // bitmask 00100000
Expand Down Expand Up @@ -163,6 +163,7 @@ extern volatile uint8_t sys_rt_exec_state; // Global realtime executor bitfla
extern volatile ExecAlarm sys_rt_exec_alarm; // Global realtime executor bitflag variable for setting various alarms.
extern volatile uint8_t sys_rt_exec_motion_override; // Global realtime executor bitflag variable for motion-based overrides.
extern volatile uint8_t sys_rt_exec_accessory_override; // Global realtime executor bitflag variable for spindle/coolant overrides.
extern volatile bool cycle_stop;

#ifdef DEBUG
# define EXEC_DEBUG_REPORT bit(0)
Expand Down Expand Up @@ -228,5 +229,5 @@ bool sys_pwm_control(uint8_t io_num_mask, float duty, bool synchronized);

int8_t sys_get_next_RMT_chan_num();

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