Reverse motor

tobyw_1969

New Member
I have a small 2v geared motor which I want to move one way or another depending on user input.

Is there a reason why I can't connect the + and - connections to pins 0 and 1 of a picaxe and swap motor direction by setting the pins alternately high and low like this?

Code:
main:
high 1 ' go one way for 2 secs
low 0
pause 2000
high 0 ' go the other way for 2 secs
low 1
pause 2000
goto main
I tried it, and it sort of works, but sometimes it stops for a bit before continuing - so I am guessing this is not a good way to do this. But I don't know enough about the internal circuitry of the chip to know if I am going to fry it by wiring it up like this. My book suggests I need a specific servo driver to do this...isn't there an easier way to control motor direction from the PICaxe without using (and buying..) another IC?
 

BeanieBots

Moderator
You're probably going to fry your PICAXE doing that:eek:

The PICAXE outputs can only supply 20mA maximum and I expect your motor requires more than that to work.
Have a look in the interfacing manual for methods of driving motors.
For bi-directional use you will need what is called an H-Bridge.
The L293D is a suitable chip (covered in the manual) for driving small motors.
 

tobyw_1969

New Member
Thought so... :( looks like I need to raid the piggy bank yet again. I am averaging about 2 purchases per page at the moment...

Thanks for the help beaniebots
 

BeanieBots

Moderator
It might be OK.
Depends on your motor and how much current it needs.
Try again with a 220R resistor in series with the motor.
If the motor still works, then it's fine and your PICAXE will also be safe.
If it doesn't move at all, then your PICAXE was in mortal danger!
 

premelec

Senior Member
Build an H bridge :)

If you want to understand more about H bridge driver design rather than using an IC - go to bobblick.com click on technical and projects and he has a schematic for building your own H bridge [other interesting projects as well...]
 

tobyw_1969

New Member
Good advice BeanieBots - it didn't move, so I guess my picaxe was indeed in mortal peril... I'm not doing so well, just fried a servo as well..:p

Thanks for the link premelec - some interesting prjects there.
 

DTB Radio

Member
Another option you can use is a DPDT relay to reverse the motor poles. Have one 08 line switching a transistor to control the relay coil, and one line switching the ground side of the motor through a transistor. Remember to use diodes to protect your transistors from reverse EMF. You can use the PWM output to drive the motor control transistor to get variable motor speed if you wish. This is the method I've chosen to use for my current dual motor project
 
Last edited:

Wrenow

Senior Member
Still another simple solution is to use an ESC (Electronic Speed Controller). The right ESC will give you variable speed on both forwards and reverse. You can find it on the Vex Robotics site under Logic devices. The Vex Robotics Motor Controller is only USD$10, and works well for motors with a draw of 1A or less. It is controlled with one pin and the Servo command.

Cheers,

Wreno
 
Top