So I have a project driving a Bi - Polar stepper motor from 0-8RPM with the A4988 motor driver as below. (EDIT: Just realised I've left out the 12V motor supply, assume that is connected to the capacitor at the driver inputs! )
In my previous project I was using brushed motors and it was simply a matter of changing the polarity so it was easy to wire it up for it to rotate Clockwise or counter clockwise. I used a DPDT switch, with a three position action CCW - OFF - CW
But with a stepper (which I havenโt worked with before) it seems to be a bit more involved.
I'm trying to envision the wiring of this and how it would work. A first example has a DPDT switch that changes the polarity on the motor as before, but I'm unsure if this would work as intended.
I've then got another setup using an SPST switch (like a rocker) on the inputs. With DIR set to HIGH, one side will select that high, the other goes to ground (thus LOW) and reverse direction. The center position is on the STEP pin to stop the step pulses.
The direction of rotation of the stepper is determined by the DIR pin on the driver board - high for one direction, low for the other. You can use the SPST switch to change direction. The common (switched) contact goes to the DIR input, with the other 2 contacts on the switch going to +5V and GND.
But why? As @anon57585045 says, you can control the direction by software.
Looks like you have a pot to control the speed and now you want a switch to control the direction?
Why are you using a stepper motor rather than a DC motor this time? Sounds to me like a stepper motor was probably not an appropriate choice for this project. Also sounds like a waste of an Arduino for both the previous project and this one!
Awesome, so just tried it out. I'm getting reversing behaviour when switched either side (Yay!). But at middle position I'm still getting rotation anti-clockwise (as expected), which I'm pretty sure is the DIR low behavior. How can power off the motor in middle position. Maybe I could throw the yellow wire onto the SLEEP pin, in middle position this will pull high and put the driver to sleep?
Ah, I see. I think I misunderstood some detail of what you were trying to achieve.
When your switch is in the middle position, you don't want the motor to move, regardless of the value coming from the pot?
You could do this with a centre off DPDT switch, but you will probably have more success (and the wiring would be less complicated) if you allowed the UNO to control the STEP and DIR signals directly, and got the UNO to read the state of the switch on a couple of spare digital inputs.
Yep exactly that. Seems weird when the pot can turn it off as well but theres reasons.
Iโm open to the weird wiring of the DPDT way if it means using less pins on the board, as I need all the pins I can get, but I might test the other way as well. Otherwise Iโd grab the mega and be free to use however many I wanted, but again theres reasons.