stepper: Default to a high direction pin meaning positive direction
Invert the default meaning of the stepper direction pin. Instead of treating a low value as position motion, treat a high value as positive motion. This matches what other firmwares do, and it matches what common stepper motor drivers document. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
5e6127869a
commit
afecf7ce36
|
@ -19,8 +19,8 @@
|
|||
[stepper_x]
|
||||
step_pin: ar29
|
||||
# Step GPIO pin (triggered high)
|
||||
dir_pin: ar28
|
||||
# Direction GPIO pin (low indicates positive direction)
|
||||
dir_pin: !ar28
|
||||
# Direction GPIO pin (high indicates positive direction)
|
||||
enable_pin: !ar25
|
||||
# Enable pin (default is enable high; use ! to indicate enable low)
|
||||
step_distance: .0225
|
||||
|
@ -86,7 +86,7 @@ position_max: 200
|
|||
# stepper_x section
|
||||
[stepper_z]
|
||||
step_pin: ar23
|
||||
dir_pin: ar22
|
||||
dir_pin: !ar22
|
||||
enable_pin: !ar25
|
||||
step_distance: .005
|
||||
max_velocity: 250
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
[stepper_x]
|
||||
step_pin: PC0
|
||||
dir_pin: PL1
|
||||
dir_pin: !PL1
|
||||
enable_pin: !PA7
|
||||
step_distance: .0225
|
||||
max_velocity: 500
|
||||
|
@ -20,7 +20,7 @@ position_max: 200
|
|||
|
||||
[stepper_y]
|
||||
step_pin: PC1
|
||||
dir_pin: !PL0
|
||||
dir_pin: PL0
|
||||
enable_pin: !PA6
|
||||
step_distance: .0225
|
||||
max_velocity: 500
|
||||
|
@ -35,7 +35,7 @@ position_max: 250
|
|||
|
||||
[stepper_z]
|
||||
step_pin: PC2
|
||||
dir_pin: PL2
|
||||
dir_pin: !PL2
|
||||
enable_pin: !PA5
|
||||
step_distance: .005
|
||||
max_velocity: 250
|
||||
|
@ -51,7 +51,7 @@ position_max: 200
|
|||
|
||||
[extruder]
|
||||
step_pin: PC3
|
||||
dir_pin: !PL6
|
||||
dir_pin: PL6
|
||||
enable_pin: !PA4
|
||||
step_distance: .004242
|
||||
max_velocity: 200000
|
||||
|
|
|
@ -105,9 +105,9 @@ class CartKinematics:
|
|||
self.stepper_pos[i] = new_step_pos
|
||||
steps = move.axes_d[i] * inv_step_dist
|
||||
step_offset = step_pos - move.start_pos[i] * inv_step_dist + 0.5
|
||||
sdir = 0
|
||||
if steps < 0:
|
||||
sdir = 1
|
||||
if steps < 0:
|
||||
sdir = 0
|
||||
steps = -steps
|
||||
step_offset = 1. - step_offset
|
||||
mcu_time, so = self.steppers[i].prep_move(move_time, sdir)
|
||||
|
|
|
@ -97,9 +97,9 @@ class PrinterExtruder:
|
|||
steps = forward_d * inv_step_dist
|
||||
step_offset = self.stepper_pos - start_pos * inv_step_dist + 0.5
|
||||
self.stepper_pos = new_step_pos
|
||||
sdir = 0
|
||||
if steps < 0:
|
||||
sdir = 1
|
||||
if steps < 0:
|
||||
sdir = 0
|
||||
steps = -steps
|
||||
step_offset = 1. - step_offset
|
||||
mcu_time, so = self.stepper.prep_move(move_time, sdir)
|
||||
|
@ -142,7 +142,7 @@ class PrinterExtruder:
|
|||
step_offset = start_pos * inv_step_dist - self.stepper_pos + 0.5
|
||||
self.stepper_pos = new_step_pos
|
||||
mcu_time, so = self.stepper.prep_move(
|
||||
move_time+accel_t+cruise_t+decel_t, 1)
|
||||
move_time+accel_t+cruise_t+decel_t, 0)
|
||||
|
||||
move_step_d = retract_d / steps
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@ command_config_stepper(uint32_t *args)
|
|||
s->step_pin = gpio_out_setup(args[1], s->flags & SF_INVERT_STEP ? 1 : 0);
|
||||
s->dir_pin = gpio_out_setup(args[2], 0);
|
||||
s->min_stop_interval = args[3];
|
||||
s->position = STEPPER_POSITION_BIAS;
|
||||
s->position = -STEPPER_POSITION_BIAS;
|
||||
}
|
||||
DECL_COMMAND(command_config_stepper,
|
||||
"config_stepper oid=%c step_pin=%c dir_pin=%c"
|
||||
|
@ -238,7 +238,7 @@ void
|
|||
stepper_stop(struct stepper *s)
|
||||
{
|
||||
sched_del_timer(&s->time);
|
||||
s->position = stepper_get_position(s);
|
||||
s->position = -stepper_get_position(s);
|
||||
s->count = 0;
|
||||
s->flags &= SF_INVERT_STEP;
|
||||
gpio_out_write(s->dir_pin, 0);
|
||||
|
|
Loading…
Reference in New Issue