Author Options:

How to reverse polarity digitally (with software) ? Answered

I would like to get a DC motor to spin in one direction for a specific number of rotations and then spin in the opposite direction for the same amount of rotations and continue to do this automatically? I know that changing the direction of the motor is achieved by reversing the polarity from the power supply, but how can this be done without using a switch or potentiometer or any other piece of hardware? I am new to this stuff so any help is much appreciated. Thanks


You could use parallel port outputs- hook up a darlington pair, one in each direction. Just don't bring both pins high at the same time.


9 years ago

Depending on the precision you require

You also (as far as I understand) need to know how many rotations it has turned in one direction in order to reverse it. Assuming that you might have a hard time without switches because if the effort to rotate in one direction is different to the other direction, as it likely is, then simply timing in one direction and switching to another direction is going to result in too many turns one way or another.

Depending on what your doing; a simple mechanism to trigger rotation switching may be all you need. One or more gears, a cam and a couple of switches.

If the amount of rotations you require in either direction may vary over time or needs to be very precise, it might pay to get a micro-controller doing the counting for you. You could probably achieve it with 74 series logic, but for this I think a micro controller would be easier.
Hope this helps,


Answer 9 years ago

thank you!