Commit 8f9f6e0d authored by MagoKimbra's avatar MagoKimbra

Return to Delay for High Low Step

parent ff4ec79f
...@@ -235,8 +235,8 @@ ...@@ -235,8 +235,8 @@
// Default stepper release if idle. Set to 0 to deactivate. // Default stepper release if idle. Set to 0 to deactivate.
#define DEFAULT_STEPPER_DEACTIVE_TIME 60 #define DEFAULT_STEPPER_DEACTIVE_TIME 60
// Uncomment it if you have High speed stepping driver // Decomment it if you have low speed stepper driver
#define ENABLE_HIGH_SPEED_STEPPING //#define STEPPER_HIGH_LOW_DELAY 1u // Delay in microseconds
#define DEFAULT_MINIMUMFEEDRATE 0.0 // minimum feedrate #define DEFAULT_MINIMUMFEEDRATE 0.0 // minimum feedrate
#define DEFAULT_MINTRAVELFEEDRATE 0.0 #define DEFAULT_MINTRAVELFEEDRATE 0.0
......
...@@ -92,7 +92,6 @@ static volatile char endstop_hit_bits = 0; // use X_MIN, Y_MIN, Z_MIN and Z_PROB ...@@ -92,7 +92,6 @@ static volatile char endstop_hit_bits = 0; // use X_MIN, Y_MIN, Z_MIN and Z_PROB
#endif #endif
static bool check_endstops = true; static bool check_endstops = true;
static bool stepper_start_x, stepper_start_y, stepper_start_z, stepper_start_e = false;
volatile long count_position[NUM_AXIS] = { 0 }; volatile long count_position[NUM_AXIS] = { 0 };
volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 }; volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 };
...@@ -317,27 +316,17 @@ FORCE_INLINE unsigned short calc_timer(unsigned short step_rate) { ...@@ -317,27 +316,17 @@ FORCE_INLINE unsigned short calc_timer(unsigned short step_rate) {
unsigned short timer; unsigned short timer;
if (step_rate > MAX_STEP_FREQUENCY) step_rate = MAX_STEP_FREQUENCY; if (step_rate > MAX_STEP_FREQUENCY) step_rate = MAX_STEP_FREQUENCY;
#ifdef ENABLE_HIGH_SPEED_STEPPING if(step_rate > (2 * DOUBLE_STEP_FREQUENCY)) { // If steprate > 2*DOUBLE_STEP_FREQUENCY >> step 4 times
if (step_rate > 20000) { // If steprate > 20kHz >> step 4 times
step_rate = (step_rate >> 2) & 0x3fff; step_rate = (step_rate >> 2) & 0x3fff;
step_loops = 4; step_loops = 4;
} }
else if (step_rate > 10000) { // If steprate > 10kHz >> step 2 times else if(step_rate > DOUBLE_STEP_FREQUENCY) { // If steprate > DOUBLE_STEP_FREQUENCY >> step 2 times
step_rate = (step_rate >> 1) & 0x7fff; step_rate = (step_rate >> 1) & 0x7fff;
step_loops = 2; step_loops = 2;
} }
else { else {
step_loops = 1; step_loops = 1;
} }
#else
if (step_rate > 10000) { // If steprate > 10kHz >> step 2 times
step_rate = (step_rate >> 1) & 0x7fff;
step_loops = 2;
}
else {
step_loops = 1;
}
#endif
if (step_rate < (F_CPU / 500000)) step_rate = (F_CPU / 500000); if (step_rate < (F_CPU / 500000)) step_rate = (F_CPU / 500000);
step_rate -= (F_CPU / 500000); // Correct for minimal speed step_rate -= (F_CPU / 500000); // Correct for minimal speed
...@@ -458,16 +447,13 @@ FORCE_INLINE void trapezoid_generator_reset() { ...@@ -458,16 +447,13 @@ FORCE_INLINE void trapezoid_generator_reset() {
#define STEP_START(axis, AXIS) \ #define STEP_START(axis, AXIS) \
_COUNTER(axis) += current_block->steps[_AXIS(AXIS)]; \ _COUNTER(axis) += current_block->steps[_AXIS(AXIS)]; \
if (_COUNTER(axis) > 0) { \ if (_COUNTER(axis) > 0) { _APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS),0); }
_APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS),0); \
stepper_start_## axis = true; \
_COUNTER(axis) -= current_block->step_event_count; \
count_position[_AXIS(AXIS)] += count_direction[_AXIS(AXIS)]; }
#define STEP_END(axis, AXIS) \ #define STEP_END(axis, AXIS) \
if (stepper_start_## axis) { \ if (_COUNTER(axis) > 0) { \
_COUNTER(axis) -= current_block->step_event_count; \
count_position[_AXIS(AXIS)] += count_direction[_AXIS(AXIS)]; \
_APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS),0); \ _APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS),0); \
stepper_start_## axis = false; \
} }
// "The Stepper Driver Interrupt" - This timer interrupt is the workhorse. // "The Stepper Driver Interrupt" - This timer interrupt is the workhorse.
...@@ -663,9 +649,11 @@ ISR(TIMER1_COMPA_vect) { ...@@ -663,9 +649,11 @@ ISR(TIMER1_COMPA_vect) {
#endif #endif
} }
#ifdef ENABLE_HIGH_SPEED_STEPPING
// Take multiple steps per interrupt (For high speed moves) // Take multiple steps per interrupt (For high speed moves)
for (int8_t i = 0; i < step_loops; i++) { for (int8_t i = 0; i < step_loops; i++) {
#ifndef AT90USB
MSerial.checkRx(); // Check for serial chars.
#endif
#ifdef ADVANCE #ifdef ADVANCE
counter_e += current_block->steps[E_AXIS]; counter_e += current_block->steps[E_AXIS];
...@@ -682,6 +670,10 @@ ISR(TIMER1_COMPA_vect) { ...@@ -682,6 +670,10 @@ ISR(TIMER1_COMPA_vect) {
STEP_START(e,E); STEP_START(e,E);
#endif #endif
#ifdef STEPPER_HIGH_LOW_DELAY
delayMicroseconds(STEPPER_HIGH_LOW_DELAY);
#endif
STEP_END(x, X); STEP_END(x, X);
STEP_END(y, Y); STEP_END(y, Y);
STEP_END(z, Z); STEP_END(z, Z);
...@@ -692,15 +684,6 @@ ISR(TIMER1_COMPA_vect) { ...@@ -692,15 +684,6 @@ ISR(TIMER1_COMPA_vect) {
step_events_completed++; step_events_completed++;
if (step_events_completed >= current_block->step_event_count) break; if (step_events_completed >= current_block->step_event_count) break;
} }
#else
STEP_START(x,X);
STEP_START(y,Y);
STEP_START(z,Z);
#ifndef ADVANCE
STEP_START(e,E);
#endif
step_events_completed++;
#endif
// Calculate new timer value // Calculate new timer value
unsigned short timer; unsigned short timer;
...@@ -763,21 +746,13 @@ ISR(TIMER1_COMPA_vect) { ...@@ -763,21 +746,13 @@ ISR(TIMER1_COMPA_vect) {
// ensure we're running at the correct step rate, even if we just came off an acceleration // ensure we're running at the correct step rate, even if we just came off an acceleration
step_loops = step_loops_nominal; step_loops = step_loops_nominal;
} }
#ifndef ENABLE_HIGH_SPEED_STEPPING
STEP_END(x, X);
STEP_END(y, Y);
STEP_END(z, Z);
#ifndef ADVANCE
STEP_END(e, E);
#endif
#endif
// If current block is finished, reset pointer // If current block is finished, reset pointer
if (step_events_completed >= current_block->step_event_count) { if (step_events_completed >= current_block->step_event_count) {
current_block = NULL; current_block = NULL;
plan_discard_current_block(); plan_discard_current_block();
} }
} // current_block != NULL }
} }
#ifdef ADVANCE #ifdef ADVANCE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment