# Dc motor directions

Hi, I am really new to all of this.

I am try to figure out how to control the direction of a small dc motor (15mm) using the arduino mini and h-bridge. I was wondering if it was possible to program the mini to automatically control the speed as well as direction of the motor? For example have the motor rotate 180 degrees clockwise then reverse counter-clockwise 180 degrees and repeat that sequence under a slow rate of speed until shut off? And if so what things would I need to go the the programming process as well as how would I go about connecting an external power source?

You're going to need some sort of feedback mechanism to tell the controller when the motor has reached 180 degrees. Is the motor geared at all? A simple free-running DC motor without gearing will be very difficult to stop and reverse at precisely 180 degree intervals.

Using PWM to control the motor speed only works for a loaded motor doing many turns. You can't control a DC motor to half a turn without lots of gearing.

With a decent DC motor that exhibits zero magnetic cogging and a hi resolution encoder you can use PWM routines to move the motor spindle through an arbitrary angle and stop - down to 1 or 2 degrees anyway.

With a more typical motor you will still need an encoder on the motor spindle, but the motor must be attached to a gearbox. A gearbox will of course give more torque

A stepper motor may be more suitable for this application?

You sounds a little like you are starting your question in the middle of the problem... what is it that you are actually trying to do?

tomhow: With a decent DC motor that exhibits zero magnetic cogging and a hi resolution encoder you can use PWM routines to move the motor spindle through an arbitrary angle and stop - down to 1 or 2 degrees anyway.

Interesting ? and how does that work, considering the limitations that must be presented by the commutator assembly

jackrae: Interesting ? and how does that work, considering the limitations that must be presented by the commutator assembly

I'm not a motor designer - I don't know exactly how they work. :)

I just use them. 8)

Zero cogging motors can operate smoothly across a wide speed rate, e.g. 5rpm to 5000rpm with good torque - (assuming you can write a half decent PID controller) - Very useful in some applications but I think the chap here doesn't need that flexibility and may be better served by a stepper motor - unless he's got an extreme space constraint.

Thank you for all your suggestions. I looked into stepper motors and it looks as though they might do a better job. What I am trying to do is have a small electric motor mounted on the front outer edge of a computer screen with a gear on the shaft of motor with a ring gasket around that gear and another gear which would be mounted on the other side of the screen. On this gasket will be a thin wiper starting at the motor and basically all I need is for the wiper to move from left to right, stop and then move back from right to left at a relatively slow speed and simply continue this process until power is shut off. And I would like to do all of this using the smallest arduino board as well as a relatively small stepper motor. The hard part for me is finding out which hardware to use and how to program it to do as I expalined.

Grumpy_Mike: You can't control a DC motor to half a turn without lots of gearing.

Not quite true - it depends on the "DC motor" - technically, a laser positioning galvanometer is a DC servo-motor that (with the correct driver circuitry) can be controlled in such a manner, at a very high speed with accuracy and repeatability.

Granted, high quality/high speed galvs and drivers aren't anything close to "inexpensive" (and even the homebrew ones take more time and expertise to construct than most people are willing to expend).

...but in general, your standard DC motor can't be controlled in this fashion (too much rotor mass for one thing; galvs are really low mass devices).

;)

Hey I thought I was a nit picker but that is just another level!