Introduction: QuickStart Bi-directional Motor Control
This is a full H-Bridge bi-directional control circuit for DC motors for the
Parallax QuickStart board.
There are six transistors, four for motor control, the other two connect the
micro-controller output pins to the motor controller.
See the schematic below for the gory details.
It is not a difficult circuit to build on a breadboard.
And it can use larger transistors for larger motors.
Depends on what you need for your project...
Parts:
4 each 2N3904 NPN transistors
2 each 2N3906 PNP transistors
Motor (this one is a geared motor)
Breadboard, wires, etc.
Video:
http://www.youtube.com/watch?v=T7lbAXa1-Bs&feature=youtu.be
Demo:
The demo program is written in SPIN for the Parallax Propeller micro-controller.
It is very straight forward. No drivers or other objects are required as all this
demo does is run the motor back and forth. It does this by setting ONE of the
motor control output pins to 1 to turn on the transistors for that direction.
Note the warning in the code - only turn on ONE output bit at a time.
Turning on both at the same time makes the transistors very angry.
(THEN you'll be sorry!)
For a fancier driver see my one-transistor trick. It shows how to do a soft-start /
speed controller via software generated PWM (Pulse Width Modulation).
(Hey, it was only one transistor. I had to do something to make it interesting!)
Code:
{ BiDirectionalMmotorDemo.spin Richard Lamb - June 16, 2013 }
CON
_CLKMODE=XTAL1
_XINFREQ =5_000_000
' define times
MSec = _XINFREQ / 1_000
' define IO pins
' note only one motor pin may be turned on at any one time!
MOT_LFT = 0
MOT_RIT = 1
LED_LFT = 23
LED_RIT = 16
VAR
PUB Throb
dira [LED_LFT] := 1 ' leds
dira [LED_RIT] := 1
dira [0..1] := 1 ' motors set outputs
outa [MOT_RIT] := 0 ' start with both pins low
outa [MOT_LFT] := 0
Repeat ' repeat forever
'Left
Outa[LED_LFT] := 1 ' LED on
OUTA[MOT_LFT] := 1 ' motor on
Wait(3000)
Outa[LED_LFT] := 0 ' LED off
OUTA[MOT_LFT] := 0 ' motor off
wait(500) ' intermissioin
'Right
Outa[LED_RIT] := 1 ' LED on
OUTA[MOT_RIT] := 1 ' motor on
Wait(3000)
Outa[LED_RIT] := 0 ' LED off
OUTA[MOT_RIT] := 0 ' motor off
PUB wait(MS)
waitcnt((MS*Msec)+cnt)