mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-09-03 03:13:25 +02:00
Fix step leakage with inverted steps (#570)
* Fix step leakage with inverted steps * Update build date for merge Co-authored-by: Bart Dring <bdring@buildlog.net>
This commit is contained in:
@@ -23,7 +23,7 @@
|
|||||||
// Grbl versioning system
|
// Grbl versioning system
|
||||||
|
|
||||||
#define GRBL_VERSION "1.3a"
|
#define GRBL_VERSION "1.3a"
|
||||||
#define GRBL_VERSION_BUILD "20200827"
|
#define GRBL_VERSION_BUILD "20200828"
|
||||||
|
|
||||||
//#include <sdkconfig.h>
|
//#include <sdkconfig.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
@@ -98,10 +98,6 @@ static volatile uint8_t segment_buffer_tail;
|
|||||||
static uint8_t segment_buffer_head;
|
static uint8_t segment_buffer_head;
|
||||||
static uint8_t segment_next_head;
|
static uint8_t segment_next_head;
|
||||||
|
|
||||||
// Step and direction port invert masks.
|
|
||||||
static uint8_t step_port_invert_mask;
|
|
||||||
static uint8_t dir_port_invert_mask;
|
|
||||||
|
|
||||||
// Used to avoid ISR nesting of the "Stepper Driver Interrupt". Should never occur though.
|
// Used to avoid ISR nesting of the "Stepper Driver Interrupt". Should never occur though.
|
||||||
static volatile uint8_t busy;
|
static volatile uint8_t busy;
|
||||||
|
|
||||||
@@ -420,7 +416,6 @@ static void stepper_pulse_func() {
|
|||||||
// Generate pulse (at least one pulse)
|
// Generate pulse (at least one pulse)
|
||||||
// The pulse resolution is limited by I2S_OUT_USEC_PER_PULSE
|
// The pulse resolution is limited by I2S_OUT_USEC_PER_PULSE
|
||||||
//
|
//
|
||||||
st.step_outbits ^= step_port_invert_mask; // Apply step port invert mask
|
|
||||||
i2s_out_push_sample(pulse_microseconds->get() / I2S_OUT_USEC_PER_PULSE);
|
i2s_out_push_sample(pulse_microseconds->get() / I2S_OUT_USEC_PER_PULSE);
|
||||||
set_stepper_pins_on(0); // turn all off
|
set_stepper_pins_on(0); // turn all off
|
||||||
return;
|
return;
|
||||||
@@ -429,7 +424,6 @@ static void stepper_pulse_func() {
|
|||||||
#ifdef USE_RMT_STEPS
|
#ifdef USE_RMT_STEPS
|
||||||
return;
|
return;
|
||||||
#else
|
#else
|
||||||
st.step_outbits ^= step_port_invert_mask; // Apply step port invert mask
|
|
||||||
// wait for step pulse time to complete...some of it should have expired during code above
|
// wait for step pulse time to complete...some of it should have expired during code above
|
||||||
while (esp_timer_get_time() - step_pulse_start_time < pulse_microseconds->get()) {
|
while (esp_timer_get_time() - step_pulse_start_time < pulse_microseconds->get()) {
|
||||||
NOP(); // spin here until time to turn off step
|
NOP(); // spin here until time to turn off step
|
||||||
@@ -476,8 +470,6 @@ void st_wake_up() {
|
|||||||
// Enable stepper drivers.
|
// Enable stepper drivers.
|
||||||
motors_set_disable(false);
|
motors_set_disable(false);
|
||||||
stepper_idle = false;
|
stepper_idle = false;
|
||||||
// Initialize stepper output bits to ensure first ISR call does not step.
|
|
||||||
st.step_outbits = step_port_invert_mask;
|
|
||||||
// Initialize step pulse timing from settings. Here to ensure updating after re-writing.
|
// Initialize step pulse timing from settings. Here to ensure updating after re-writing.
|
||||||
#ifdef STEP_PULSE_DELAY
|
#ifdef STEP_PULSE_DELAY
|
||||||
// Step pulse delay handling is not require with ESP32...the RMT function does it.
|
// Step pulse delay handling is not require with ESP32...the RMT function does it.
|
||||||
@@ -510,8 +502,8 @@ void st_reset() {
|
|||||||
segment_buffer_head = 0; // empty = tail
|
segment_buffer_head = 0; // empty = tail
|
||||||
segment_next_head = 1;
|
segment_next_head = 1;
|
||||||
busy = false;
|
busy = false;
|
||||||
st_generate_step_dir_invert_masks();
|
st.step_outbits = 0;
|
||||||
st.dir_outbits = dir_port_invert_mask; // Initialize direction bits to default.
|
st.dir_outbits = dir_invert_mask->get(); // Initialize direction bits to default.
|
||||||
// TODO do we need to turn step pins off?
|
// TODO do we need to turn step pins off?
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -716,6 +708,7 @@ void st_go_idle() {
|
|||||||
motors_set_disable(false);
|
motors_set_disable(false);
|
||||||
|
|
||||||
set_stepper_pins_on(0);
|
set_stepper_pins_on(0);
|
||||||
|
st.step_outbits = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called by planner_recalculate() when the executing block is updated by the new plan.
|
// Called by planner_recalculate() when the executing block is updated by the new plan.
|
||||||
@@ -760,22 +753,6 @@ void st_parking_restore_buffer() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Generates the step and direction port invert masks used in the Stepper Interrupt Driver.
|
|
||||||
void st_generate_step_dir_invert_masks() {
|
|
||||||
/*
|
|
||||||
uint8_t idx;
|
|
||||||
step_port_invert_mask = 0;
|
|
||||||
dir_port_invert_mask = 0;
|
|
||||||
for (idx=0; idx<N_AXIS; idx++) {
|
|
||||||
if (bit_istrue(step_invert_mask->get(),bit(idx))) { step_port_invert_mask |= get_step_pin_mask(idx); }
|
|
||||||
if (bit_istrue(dir_invert_mask->get(),bit(idx))) { dir_port_invert_mask |= get_direction_pin_mask(idx); }
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
// simpler with ESP32, but let's do it here for easier change management
|
|
||||||
step_port_invert_mask = step_invert_mask->get();
|
|
||||||
dir_port_invert_mask = dir_invert_mask->get();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Increments the step segment buffer block data ring buffer.
|
// Increments the step segment buffer block data ring buffer.
|
||||||
static uint8_t st_next_block_index(uint8_t block_index) {
|
static uint8_t st_next_block_index(uint8_t block_index) {
|
||||||
block_index++;
|
block_index++;
|
||||||
|
@@ -97,9 +97,6 @@ void st_wake_up();
|
|||||||
// Immediately disables steppers
|
// Immediately disables steppers
|
||||||
void st_go_idle();
|
void st_go_idle();
|
||||||
|
|
||||||
// Generate the step and direction port invert masks.
|
|
||||||
void st_generate_step_dir_invert_masks();
|
|
||||||
|
|
||||||
// Reset the stepper subsystem variables
|
// Reset the stepper subsystem variables
|
||||||
void st_reset();
|
void st_reset();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user