Shop OBEX P1 Docs P2 Docs Learn Events
Stepper Motor Wiring "Best Practice" — Parallax Forums

Stepper Motor Wiring "Best Practice"

mindrobotsmindrobots Posts: 6,506
edited 2013-03-18 21:33 in Robotics
I've been playing with the "Cheap Chinese Steppers" on my Cheap Robot and have a question about the best way to wire the motors to make directional control and software the easiest.

For example, if you wire your RIGHT motor, with connections IN1 to PIN1, IN2 to PIN2, IN3 to PIN3 an IN4 to PIN4 and then sequence the 8 patterns through them as PIN1, PIN2, PIN3, PIN4, your motor runs clockwise, which for the RIGHT side is seen as FORWARD. If you wire your LEFT motor with connections IN1 to PIN1, IN2 to PIN2, IN3 to PIN3 and IN4 to PIN4 and then sequence the 8 patterns through them as PIN1, PIN2, PIN3 and PIN4, this motor also runs clockwise BUT on the LEFT side, that is seen as REVERSE.

To change the direction on the left side, you can either:

1) wire the motor differently (IN1 to PIN4, IN2 to PIN3, IN3 to PIN2 and IN4 to PIN1) and keep all the software the same and not have to keep track of which motor you are working with or whether forward is backward or if you need to invert directions or pin orders or any of that.

2) wire both motors the same and invert the pin assignments someplace in the software definitions for the left motor pins or the initialization

3) wire both motors the same, keep the pin assignments in the same order and then when you send out the pulses either send out the pulses, invert them for the left motor (you need to keep track of left and right somehow).

The lazy person in me screams #1 for ease of writing software and just make a BIG NOTE that the left and right motors get wired in opposite ways. This keeps all your software the same, forward is forward in relation to the robot. With other stepper applications, you are more than likely talking clockwise and counterclockwise so it's not a big deal keeping track of direction.

Yes? No? Maybe? Don't really care?

Any of the Robot Masters have any words of wisdom to steer me away from #1?

Servos are another matter and direction control has to be done in software with LEFT/RIGHT motor flags and adjusting accordingly but the steppers give you the very easy rewire option.

Comments

  • prof_brainoprof_braino Posts: 4,313
    edited 2013-03-17 12:46
    mindrobots wrote: »
    To change the direction on the left side, you can either:
    1) wire the motor differently
    2) wire both motors the same and invert the pin assignments someplace in the software definitions for the left motor pins or the initialization
    3) wire both motors the same, keep the pin assignments in the same order and then when you send out the pulses either send out the pulses, invert them for the left motor (you need to keep track of left and right somehow).

    Any of the Robot Masters have any words of wisdom to steer me away from #1?

    I don't know what the Robot Masters might say, but I would advise WIRE EVERYTHING THE SAME and KEEP THE SOFTWARE THE SAME until the absolute last minute at the highest level.

    That is, define for example FOWARD = Left CCW and RIGHT CW, at the level just below the final application. It makes debug and test easier.
  • kwinnkwinn Posts: 8,697
    edited 2013-03-18 09:49
    I agree with prof_braino, keep the wiring the same. You can use the same motor step table for both motors by XORing the data for one of the motors before it is output.
  • lardomlardom Posts: 1,659
    edited 2013-03-18 21:33
    Just my 2¢. You need at least two bit patterns anyway for forward and reverse. I sometimes include two extra methods for acceleration and deceleration. If I switch from transistors to a ULN2803 the motor direction might reverse. I just invert the bit patterns. It's much easier to change bit patterns than rewire the circuit.
Sign In or Register to comment.