1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-09-03 03:13:25 +02:00

Fixed a few IRAM_ATTR bugs in stepping. Changed config.yaml to stress testing setup.

This commit is contained in:
Stefan de Bruijn
2021-07-15 21:21:34 +02:00
parent 69b14f3ee3
commit b27b788a5d
7 changed files with 41 additions and 41 deletions

View File

@@ -16,12 +16,12 @@ axes:
shared_stepper_disable: gpio.13:high shared_stepper_disable: gpio.13:high
x: x:
steps_per_mm: 800 steps_per_mm: 1500
max_rate: 2000 max_rate: 50000
acceleration: 25 acceleration: 5000
max_travel: 1000 max_travel: 100000
homing: homing:
cycle: -1 cycle: 0
mpos: 10 mpos: 10
positive_direction: false positive_direction: false
feed_rate: 50.000 feed_rate: 50.000

View File

@@ -160,6 +160,7 @@ namespace Machine {
a->unstep(); a->unstep();
} }
} }
config->_stepping->finishPulse(); config->_stepping->finishPulse();
} }

View File

@@ -244,6 +244,7 @@ void IRAM_ATTR Stepper::pulse_func() {
return; // Nothing to do but exit. return; // Nothing to do but exit.
} }
} }
// Check probing state. // Check probing state.
if (sys_probe_state == ProbeState::Active && config->_probe->tripped()) { if (sys_probe_state == ProbeState::Active && config->_probe->tripped()) {
sys_probe_state = ProbeState::Off; sys_probe_state = ProbeState::Off;

View File

@@ -15,8 +15,6 @@ namespace Machine {
{ Stepping::I2S_STREAM, "I2S_stream" }, { Stepping::I2S_STREAM, "I2S_stream" },
EnumItem(Stepping::RMT) }; EnumItem(Stepping::RMT) };
static std::atomic<bool> busy;
void Stepping::init() { void Stepping::init() {
info_serial("Step type:%s Pulse:%dus Dsbl Delay:%dus Dir Delay:%dus Idle Delay:%dms", info_serial("Step type:%s Pulse:%dus Dsbl Delay:%dus Dir Delay:%dus Idle Delay:%dms",
// stepping->name(), // stepping->name(),
@@ -39,8 +37,6 @@ namespace Machine {
// Register pulse_func with the I2S subsystem // Register pulse_func with the I2S subsystem
// This could be done via the linker. // This could be done via the linker.
// i2s_out_set_pulse_callback(Stepper::pulse_func); // i2s_out_set_pulse_callback(Stepper::pulse_func);
busy.store(false);
} }
// Wait for motion to complete; the axes can still be moving // Wait for motion to complete; the axes can still be moving
@@ -83,7 +79,8 @@ namespace Machine {
NOP(); NOP();
} }
} }
void Stepping::waitPulse() {
void IRAM_ATTR Stepping::waitPulse() {
uint64_t pulseEndTime; uint64_t pulseEndTime;
switch (_engine) { switch (_engine) {
case I2S_STREAM: case I2S_STREAM:
@@ -100,7 +97,8 @@ namespace Machine {
return; return;
} }
} }
void Stepping::waitDirection() {
void IRAM_ATTR Stepping::waitDirection() {
if (_directionDelayUsecs) { if (_directionDelayUsecs) {
// Stepper drivers need some time between changing direction and doing a pulse. // Stepper drivers need some time between changing direction and doing a pulse.
switch (_engine) { switch (_engine) {
@@ -108,7 +106,7 @@ namespace Machine {
i2s_out_push_sample(_directionDelayUsecs); i2s_out_push_sample(_directionDelayUsecs);
break; break;
case stepper_id_t::I2S_STATIC: case stepper_id_t::I2S_STATIC:
case stepper_id_t::TIMED: { case stepper_id_t::TIMED:
// wait for step pulse time to complete...some time expired during code above // wait for step pulse time to complete...some time expired during code above
// //
// If we are using GPIO stepping as opposed to RMT, record the // If we are using GPIO stepping as opposed to RMT, record the
@@ -121,9 +119,8 @@ namespace Machine {
} }
} }
} }
}
void Stepping::startPulseTimer() { void IRAM_ATTR Stepping::startPulseTimer() {
switch (_engine) { switch (_engine) {
case stepper_id_t::I2S_STREAM: case stepper_id_t::I2S_STREAM:
break; break;
@@ -136,7 +133,7 @@ namespace Machine {
} }
} }
void Stepping::finishPulse() { void IRAM_ATTR Stepping::finishPulse() {
switch (_engine) { switch (_engine) {
case stepper_id_t::I2S_STREAM: case stepper_id_t::I2S_STREAM:
break; break;
@@ -191,11 +188,8 @@ namespace Machine {
// with probing and homing cycles that require true real-time positions. // with probing and homing cycles that require true real-time positions.
void IRAM_ATTR Stepping::onStepperDriverTimer() { void IRAM_ATTR Stepping::onStepperDriverTimer() {
// Timer ISR, normally takes a step. // Timer ISR, normally takes a step.
//
// The intermediate handler clears the timer interrupt so we need not do it here // The intermediate handler clears the timer interrupt so we need not do it here
bool expected = false;
if (busy.compare_exchange_strong(expected, true)) {
++isr_count; ++isr_count;
// Using autoReload results is less timing jitter so it is // Using autoReload results is less timing jitter so it is
@@ -213,9 +207,6 @@ namespace Machine {
timerAlarmEnable(stepTimer); timerAlarmEnable(stepTimer);
Stepper::pulse_func(); Stepper::pulse_func();
busy.store(false);
}
} }
void Stepping::group(Configuration::HandlerBase& handler) { void Stepping::group(Configuration::HandlerBase& handler) {

View File

@@ -19,7 +19,6 @@
*/ */
#include "Configuration/Configurable.h" #include "Configuration/Configurable.h"
// #include <atomic>
namespace Machine { namespace Machine {
class Stepping : public Configuration::Configurable { class Stepping : public Configuration::Configurable {
@@ -29,7 +28,7 @@ namespace Machine {
private: private:
static const int stepTimerNumber = 0; static const int stepTimerNumber = 0;
static const bool autoReload = true; static const bool autoReload = false;
static hw_timer_t* stepTimer; static hw_timer_t* stepTimer;
static void onStepperDriverTimer(); static void onStepperDriverTimer();

View File

@@ -143,6 +143,7 @@
<ClInclude Include="Grbl_Esp32\src\StackTrace\debug_helpers.h" /> <ClInclude Include="Grbl_Esp32\src\StackTrace\debug_helpers.h" />
<ClInclude Include="Grbl_Esp32\src\Stepper.h" /> <ClInclude Include="Grbl_Esp32\src\Stepper.h" />
<ClInclude Include="Grbl_Esp32\src\StepperPrivate.h" /> <ClInclude Include="Grbl_Esp32\src\StepperPrivate.h" />
<ClInclude Include="Grbl_Esp32\src\Stepping.h" />
<ClInclude Include="Grbl_Esp32\src\StringRange.h" /> <ClInclude Include="Grbl_Esp32\src\StringRange.h" />
<ClInclude Include="Grbl_Esp32\src\StringStream.h" /> <ClInclude Include="Grbl_Esp32\src\StringStream.h" />
<ClInclude Include="Grbl_Esp32\src\System.h" /> <ClInclude Include="Grbl_Esp32\src\System.h" />
@@ -276,6 +277,7 @@
<ClCompile Include="Grbl_Esp32\src\StackTrace\AssertionFailed.cpp" /> <ClCompile Include="Grbl_Esp32\src\StackTrace\AssertionFailed.cpp" />
<ClCompile Include="Grbl_Esp32\src\StackTrace\debug_helpers.cpp" /> <ClCompile Include="Grbl_Esp32\src\StackTrace\debug_helpers.cpp" />
<ClCompile Include="Grbl_Esp32\src\Stepper.cpp" /> <ClCompile Include="Grbl_Esp32\src\Stepper.cpp" />
<ClCompile Include="Grbl_Esp32\src\Stepping.cpp" />
<ClCompile Include="Grbl_Esp32\src\System.cpp" /> <ClCompile Include="Grbl_Esp32\src\System.cpp" />
<ClCompile Include="Grbl_Esp32\src\Uart.cpp" /> <ClCompile Include="Grbl_Esp32\src\Uart.cpp" />
<ClCompile Include="Grbl_Esp32\src\UserOutput.cpp" /> <ClCompile Include="Grbl_Esp32\src\UserOutput.cpp" />

View File

@@ -507,6 +507,9 @@
<ClInclude Include="X86TestSupport\soc\ledc_struct.h"> <ClInclude Include="X86TestSupport\soc\ledc_struct.h">
<Filter>X86TestSupport\soc</Filter> <Filter>X86TestSupport\soc</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Grbl_Esp32\src\Stepping.h">
<Filter>src</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="Grbl_Esp32\src\WebUI\JSONEncoder.cpp"> <ClCompile Include="Grbl_Esp32\src\WebUI\JSONEncoder.cpp">
@@ -854,6 +857,9 @@
<ClCompile Include="X86TestSupport\driver\uartdriver.cpp"> <ClCompile Include="X86TestSupport\driver\uartdriver.cpp">
<Filter>X86TestSupport\driver</Filter> <Filter>X86TestSupport\driver</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Grbl_Esp32\src\Stepping.cpp">
<Filter>src</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="Grbl_Esp32\src\SimpleOutputStream.md"> <None Include="Grbl_Esp32\src\SimpleOutputStream.md">