Go Down

Topic: Stepper motor control with potentiometer (Read 7048 times) previous topic - next topic


Apologies if this topic has been covered, but I couldn't find quite what I was looking for.
Basically what I'm trying to do is control a stepper motor's speed and direction with a potentiometer. When the pot is in the middle, the stepper should be stationary, and either extreme will dive the stepper at speed in that direction. I know a little about electronics, but programming an Arduino is not something I've done before. Looking through various websites, I've found a curious thing called stepper shields. Are these required to drive a stepper, or just useful?
I know I need to buy an Arduino, stepper, and potentiometer, but do I need anything else?


Actually, a potentiometer is not the right device to control the stepper motor. A rotary encoder would be a better choice. You can count the number of steps the encoder has been turned one way, and increase speed (step frequency) as the number of turns increases, and decrease the speed (step frequency) as the number of turns decreases. When the number of turns goes negative, run the stepper the other way.

Whether you need a shield, or not, depends on the current and voltage that the stepper motor needs. The Arduino can directly control only the smallest of stepper motors. Doing so takes 4 pins, too.

Using the shield, it only takes two - one to control direction and one to say when to step.
The art of getting good answers lies in asking good questions.


Actually, a potentiometer is not the right device to control the stepper motor

On the contrary, a pot has a convenient one wire interface, and if it has a centre detent, even better.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.


I don't think I need a rotary encoder, because position is not important for my application. The only thing I care about is being able to control speed and direction. The reason I'm using a stepper is because I was under the impression that they maintain torque independent of speed (as opposed to DC motors.) Also, they can be held at a position without freewheeling if one coil is left energized.


a pot (speed/direction) and a button (press it to make the stepper move, could use a 2nd button for direction to give more resolution on speed for the pot) will be fine for your application.  using a rotary encoder will just give you absolute values (accurate) to work with instead of relying on analog conversion.  The stepper will hold with one coil energised but will be drawing power constantly while its doing it.  as long as you don't disable the enable pins on the motor driver chip then the last coil energised will stay that way until the circuit is reset or the stepper steps again.


I don't want a button to control direction, I need to be able to use the pot in both directions. The application will be a joystick controlled pan and tilt camera head. The camera movement will be controlled with one hand, and the camera itself (zoom, focus, record) with the other. So a button that controls direction isn't practical. I figured that holding the stepper at one position will draw power. This will probably be wall or generator powered, so I don't have to worry about it. My plan is to first try it with one motor and regular rotary pot. If it works, then I will get 2 large steppers and a joystick. This is where the shield comes in, correct?

Ran Talbott

Your idea is sound,  but there are a couple of things you need to watch for.

One is that joysticks (especially the cheapest mass-produced ones) don't always give you a reading of half their value when centered:  you may have to try a couple of different ones,  or set up a calibration routine to find and save the "center" value.

You also need to establish a "dead zone" of several degrees around the center point where the joystick is considered "centered" for purposes of making the pan-tilt head move.  Even if you're using a pot with a center detent,  or a "self-centering" joystick,  you'll find that it never settles in exactly the same spot.  You need to allow for that,  or you'll find the head constantly creeping off in one direction or another when you want it to stay still.

If,  say,  you get an ADC reading of 2.5V when the pot is nominally centered,  you might want to say that anything between 2.4 and 2.6 is "close enough".  You'll need to experiment a little to find values that work for you.



You might try looking at servo motors as an alternative, take a look at this:- http://www.youtube.com/watch?v=FKj9jJgj8Pc.


I have seen that video before. This isn't what I want to do though. I don't need absolute positioning. I also need continuous rotation. I know that servos can be modified for continuous rotation, but then what is the point of using a servo and not a stepper or even a regular DC gear motor? Are servos also as powerful as steppers (especially at the same price point?)


I don't know to be honest, I only received my first servo to play with the other day and haven't got round to doing anything with it yet, it is heavily geared though so should be quite strong.It was also very cheap (under £5).
Why do you need cotinuous rotation on a camera?.

Any BTW i'm sure what you suggested in your OP is feasable.


I want it to be more of a turret, with a one-handed joystick controlling the movement. The continuous rotation will allow the camera to pan as many times as it needs to, unlike a servo which as limits. The control will not be a movement of the camera to match the joystick (like in the video, the rotation of the servo matched that of the pot) but movement of the camera down as long as the joystick is pushed forward etc. The speed of the movement will also be proportional to the distance from the center that the joystick is pushed. Check out this video http://www.youtube.com/watch?v=Wddm9SEYqmc


Gotcha, looks good, as you suggested a pot could be interpreted by a program to give zero steps at mid point and clockwise /anti clock for either side, hopefully someone more clued up than I can help you with this.
Good luck.

Go Up