mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-09-01 18:32:37 +02:00
Basic testing Complete
This commit is contained in:
@@ -86,6 +86,7 @@ static void reset_variables() {
|
|||||||
memset(sys_probe_position, 0, sizeof(sys_probe_position)); // Clear probe position.
|
memset(sys_probe_position, 0, sizeof(sys_probe_position)); // Clear probe position.
|
||||||
sys_probe_state = 0;
|
sys_probe_state = 0;
|
||||||
sys_rt_exec_state = 0;
|
sys_rt_exec_state = 0;
|
||||||
|
cycle_stop = false;
|
||||||
sys_rt_exec_motion_override = 0;
|
sys_rt_exec_motion_override = 0;
|
||||||
sys_rt_exec_accessory_override = 0;
|
sys_rt_exec_accessory_override = 0;
|
||||||
system_clear_exec_alarm();
|
system_clear_exec_alarm();
|
||||||
|
@@ -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.
|
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_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;
|
uint8_t rt_exec = sys_rt_exec_state;
|
||||||
// Homing failure condition: Reset issued during cycle.
|
// Homing failure condition: Reset issued during cycle.
|
||||||
if (rt_exec & EXEC_RESET) {
|
if (rt_exec & EXEC_RESET) {
|
||||||
@@ -217,7 +217,7 @@ void limits_go_home(uint8_t cycle_mask) {
|
|||||||
system_set_exec_alarm(ExecAlarm::HomingFailPulloff);
|
system_set_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 & EXEC_CYCLE_STOP)) {
|
if (approach && cycle_stop) {
|
||||||
system_set_exec_alarm(ExecAlarm::HomingFailApproach);
|
system_set_exec_alarm(ExecAlarm::HomingFailApproach);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,7 +228,7 @@ void limits_go_home(uint8_t cycle_mask) {
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
// Pull-off motion complete. Disable CYCLE_STOP from executing.
|
// Pull-off motion complete. Disable CYCLE_STOP from executing.
|
||||||
system_clear_exec_state_flag(EXEC_CYCLE_STOP);
|
cycle_stop = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -371,7 +371,7 @@ void limits_disable() {
|
|||||||
// number in bit position, i.e. Z_AXIS is bit(2), and Y_AXIS is bit(1).
|
// number in bit position, i.e. Z_AXIS is bit(2), and Y_AXIS is bit(1).
|
||||||
uint8_t limits_get_state() {
|
uint8_t limits_get_state() {
|
||||||
uint8_t pinMask = 0;
|
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 axis = 0; axis < n_axis; axis++) {
|
||||||
for (int gang_index = 0; gang_index < 2; gang_index++) {
|
for (int gang_index = 0; gang_index < 2; gang_index++) {
|
||||||
uint8_t pin = limit_pins[axis][gang_index];
|
uint8_t pin = limit_pins[axis][gang_index];
|
||||||
|
@@ -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
|
// https://github.com/bdring/6-Pack_CNC_Controller/wiki/4x-Switch-Input-module
|
||||||
#define X_LIMIT_PIN GPIO_NUM_33
|
#define X_LIMIT_PIN GPIO_NUM_33
|
||||||
#define Y_LIMIT_PIN GPIO_NUM_32
|
#define Y_LIMIT_PIN GPIO_NUM_32
|
||||||
#define Z_LIMIT_PIN GPIO_NUM_35
|
#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 ==========================
|
// ================= Setting Defaults ==========================
|
||||||
|
@@ -271,7 +271,7 @@ void protocol_exec_rt_system() {
|
|||||||
system_clear_exec_alarm(); // Clear alarm
|
system_clear_exec_alarm(); // Clear alarm
|
||||||
}
|
}
|
||||||
uint8_t rt_exec = sys_rt_exec_state; // Copy volatile sys_rt_exec_state.
|
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.
|
// Execute system abort.
|
||||||
if (rt_exec & EXEC_RESET) {
|
if (rt_exec & EXEC_RESET) {
|
||||||
sys.abort = true; // Only place this is set true.
|
sys.abort = true; // Only place this is set true.
|
||||||
@@ -399,12 +399,12 @@ void protocol_exec_rt_system() {
|
|||||||
}
|
}
|
||||||
system_clear_exec_state_flag(EXEC_CYCLE_START);
|
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
|
// 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
|
||||||
// cycle reinitializations. The stepper path should continue exactly as if nothing has happened.
|
// 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) &&
|
if ((sys.state == State::Hold || sys.state == State::SafetyDoor || sys.state == State::Sleep) && !(sys.soft_limit) &&
|
||||||
!(sys.suspend & SUSPEND_JOG_CANCEL)) {
|
!(sys.suspend & SUSPEND_JOG_CANCEL)) {
|
||||||
// Hold complete. Set to indicate ready to resume. Remain in HOLD or DOOR states until user
|
// Hold complete. Set to indicate ready to resume. Remain in HOLD or DOOR states until user
|
||||||
@@ -433,7 +433,7 @@ void protocol_exec_rt_system() {
|
|||||||
sys.state = State::Idle;
|
sys.state = State::Idle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
system_clear_exec_state_flag(EXEC_CYCLE_STOP);
|
cycle_stop = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Execute overrides.
|
// Execute overrides.
|
||||||
|
@@ -296,9 +296,8 @@ static void stepper_pulse_func() {
|
|||||||
spindle->set_rpm(0);
|
spindle->set_rpm(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
cycle_stop = true;
|
||||||
system_set_exec_state_flag(EXEC_CYCLE_STOP); // Flag main program for cycle end
|
return; // Nothing to do but exit.
|
||||||
return; // Nothing to do but exit.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check probing state.
|
// Check probing state.
|
||||||
@@ -362,8 +361,7 @@ static void stepper_pulse_func() {
|
|||||||
st.counter_a -= st.exec_block->step_event_count;
|
st.counter_a -= st.exec_block->step_event_count;
|
||||||
if (st.exec_block->direction_bits & bit(A_AXIS)) {
|
if (st.exec_block->direction_bits & bit(A_AXIS)) {
|
||||||
sys_position[A_AXIS]--;
|
sys_position[A_AXIS]--;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
sys_position[A_AXIS]++;
|
sys_position[A_AXIS]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -379,8 +377,7 @@ static void stepper_pulse_func() {
|
|||||||
st.counter_b -= st.exec_block->step_event_count;
|
st.counter_b -= st.exec_block->step_event_count;
|
||||||
if (st.exec_block->direction_bits & bit(B_AXIS)) {
|
if (st.exec_block->direction_bits & bit(B_AXIS)) {
|
||||||
sys_position[B_AXIS]--;
|
sys_position[B_AXIS]--;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
sys_position[B_AXIS]++;
|
sys_position[B_AXIS]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -396,8 +393,7 @@ static void stepper_pulse_func() {
|
|||||||
st.counter_c -= st.exec_block->step_event_count;
|
st.counter_c -= st.exec_block->step_event_count;
|
||||||
if (st.exec_block->direction_bits & bit(C_AXIS)) {
|
if (st.exec_block->direction_bits & bit(C_AXIS)) {
|
||||||
sys_position[C_AXIS]--;
|
sys_position[C_AXIS]--;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
sys_position[C_AXIS]++;
|
sys_position[C_AXIS]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1229,8 +1225,10 @@ float st_get_realtime_rate() {
|
|||||||
case State::Homing:
|
case State::Homing:
|
||||||
case State::Hold:
|
case State::Hold:
|
||||||
case State::Jog:
|
case State::Jog:
|
||||||
case State::SafetyDoor: return prep.current_speed;
|
case State::SafetyDoor:
|
||||||
default: return 0.0f;
|
return prep.current_speed;
|
||||||
|
default:
|
||||||
|
return 0.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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 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_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 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
|
#ifdef DEBUG
|
||||||
volatile uint8_t sys_rt_exec_debug;
|
volatile uint8_t sys_rt_exec_debug;
|
||||||
#endif
|
#endif
|
||||||
|
@@ -68,7 +68,7 @@ extern system_t sys;
|
|||||||
// know when there is a realtime command to execute.
|
// know when there is a realtime command to execute.
|
||||||
#define EXEC_STATUS_REPORT bit(0) // bitmask 00000001
|
#define EXEC_STATUS_REPORT bit(0) // bitmask 00000001
|
||||||
#define EXEC_CYCLE_START bit(1) // bitmask 00000010
|
#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_FEED_HOLD bit(3) // bitmask 00001000
|
||||||
#define EXEC_RESET bit(4) // bitmask 00010000
|
#define EXEC_RESET bit(4) // bitmask 00010000
|
||||||
#define EXEC_SAFETY_DOOR bit(5) // bitmask 00100000
|
#define EXEC_SAFETY_DOOR bit(5) // bitmask 00100000
|
||||||
@@ -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 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_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 uint8_t sys_rt_exec_accessory_override; // Global realtime executor bitflag variable for spindle/coolant overrides.
|
||||||
|
extern volatile bool cycle_stop;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
# define EXEC_DEBUG_REPORT bit(0)
|
# define EXEC_DEBUG_REPORT bit(0)
|
||||||
@@ -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_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);
|
uint8_t sys_calc_pwm_precision(uint32_t freq);
|
||||||
|
Reference in New Issue
Block a user