Support step motor controllers with active low step pins.

2.0.x
daid 13 years ago
parent b67dacdc8f
commit 12de8fff81

@ -88,6 +88,12 @@
#define MAX_STEP_FREQUENCY 40000 // Max step frequency for Ultimaker (5000 pps / half step) #define MAX_STEP_FREQUENCY 40000 // Max step frequency for Ultimaker (5000 pps / half step)
//By default pololu step drivers require an active high signal. However, some high power drivers require an active low signal as step.
#define INVERT_X_STEP_PIN false
#define INVERT_Y_STEP_PIN false
#define INVERT_Z_STEP_PIN false
#define INVERT_E_STEP_PIN false
//default stepper release if idle //default stepper release if idle
#define DEFAULT_STEPPER_DEACTIVE_TIME 60 #define DEFAULT_STEPPER_DEACTIVE_TIME 60

@ -449,34 +449,34 @@ ISR(TIMER1_COMPA_vect)
counter_x += current_block->steps_x; counter_x += current_block->steps_x;
if (counter_x > 0) { if (counter_x > 0) {
WRITE(X_STEP_PIN, HIGH); WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
counter_x -= current_block->step_event_count; counter_x -= current_block->step_event_count;
WRITE(X_STEP_PIN, LOW); WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
count_position[X_AXIS]+=count_direction[X_AXIS]; count_position[X_AXIS]+=count_direction[X_AXIS];
} }
counter_y += current_block->steps_y; counter_y += current_block->steps_y;
if (counter_y > 0) { if (counter_y > 0) {
WRITE(Y_STEP_PIN, HIGH); WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
counter_y -= current_block->step_event_count; counter_y -= current_block->step_event_count;
WRITE(Y_STEP_PIN, LOW); WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
count_position[Y_AXIS]+=count_direction[Y_AXIS]; count_position[Y_AXIS]+=count_direction[Y_AXIS];
} }
counter_z += current_block->steps_z; counter_z += current_block->steps_z;
if (counter_z > 0) { if (counter_z > 0) {
WRITE(Z_STEP_PIN, HIGH); WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN);
counter_z -= current_block->step_event_count; counter_z -= current_block->step_event_count;
WRITE(Z_STEP_PIN, LOW); WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN);
count_position[Z_AXIS]+=count_direction[Z_AXIS]; count_position[Z_AXIS]+=count_direction[Z_AXIS];
} }
#ifndef ADVANCE #ifndef ADVANCE
counter_e += current_block->steps_e; counter_e += current_block->steps_e;
if (counter_e > 0) { if (counter_e > 0) {
WRITE_E_STEP(HIGH); WRITE_E_STEP(!INVERT_E_STEP_PIN);
counter_e -= current_block->step_event_count; counter_e -= current_block->step_event_count;
WRITE_E_STEP(LOW); WRITE_E_STEP(INVERT_E_STEP_PIN);
count_position[E_AXIS]+=count_direction[E_AXIS]; count_position[E_AXIS]+=count_direction[E_AXIS];
} }
#endif //!ADVANCE #endif //!ADVANCE
@ -704,27 +704,27 @@ void st_init()
//Initialize Step Pins //Initialize Step Pins
#if (X_STEP_PIN > -1) #if (X_STEP_PIN > -1)
SET_OUTPUT(X_STEP_PIN); SET_OUTPUT(X_STEP_PIN);
if(!X_ENABLE_ON) WRITE(X_ENABLE_PIN,HIGH); WRITE(X_STEP_PIN,INVERT_X_STEP_PIN);
#endif #endif
#if (Y_STEP_PIN > -1) #if (Y_STEP_PIN > -1)
SET_OUTPUT(Y_STEP_PIN); SET_OUTPUT(Y_STEP_PIN);
if(!Y_ENABLE_ON) WRITE(Y_ENABLE_PIN,HIGH); WRITE(Y_STEP_PIN,INVERT_Y_STEP_PIN);
#endif #endif
#if (Z_STEP_PIN > -1) #if (Z_STEP_PIN > -1)
SET_OUTPUT(Z_STEP_PIN); SET_OUTPUT(Z_STEP_PIN);
if(!Z_ENABLE_ON) WRITE(Z_ENABLE_PIN,HIGH); WRITE(Z_STEP_PIN,INVERT_Z_STEP_PIN);
#endif #endif
#if (E0_STEP_PIN > -1) #if (E0_STEP_PIN > -1)
SET_OUTPUT(E0_STEP_PIN); SET_OUTPUT(E0_STEP_PIN);
if(!E_ENABLE_ON) WRITE(E0_ENABLE_PIN,HIGH); WRITE(E0_STEP_PIN,INVERT_E_STEP_PIN);
#endif #endif
#if defined(E1_STEP_PIN) && (E1_STEP_PIN > -1) #if defined(E1_STEP_PIN) && (E1_STEP_PIN > -1)
SET_OUTPUT(E1_STEP_PIN); SET_OUTPUT(E1_STEP_PIN);
if(!E_ENABLE_ON) WRITE(E1_ENABLE_PIN,HIGH); WRITE(E1_STEP_PIN,INVERT_E_STEP_PIN);
#endif #endif
#if defined(E2_STEP_PIN) && (E2_STEP_PIN > -1) #if defined(E2_STEP_PIN) && (E2_STEP_PIN > -1)
SET_OUTPUT(E2_STEP_PIN); SET_OUTPUT(E2_STEP_PIN);
if(!E_ENABLE_ON) WRITE(E2_ENABLE_PIN,HIGH); WRITE(E2_STEP_PIN,INVERT_E_STEP_PIN);
#endif #endif
#ifdef CONTROLLERFAN_PIN #ifdef CONTROLLERFAN_PIN

Loading…
Cancel
Save