Let's Make Robots!

Simple Motor controller and R/C signal interpreter

Takes PWM signals then feeds to an H-Bridge

Okey Dokey,

 What I Have here is a relatively simple way to control 2 low to mid current motors with no fancy integrated circuits. This is just a nothing special H-bridge design, but I haven't seen much on the subject here, hence the post!


Excuse the "Paint" schematic 


   This H-bridge I have coupled with a Parallax BS2 to interpret a PWM (Pulse Width Modulated) signal coming from a Radio Control Receiver ( Will post code tomorrow, on a floppy at my school :D )   and spit out a combination of four outputs to engage the relays in a certain combination, reversing the polarity on one side of the motor at a time. The output states are as follows:


0000 - Stop

1001- Forward

1010 - Left

0101 - Right

   For every One you  see, the corresponding relay in engaged, providing contact to the Normally Open ( NO) contact point, therefore allowing current flow to the motor, putting it in one direction. Each motor is tied to two of the outputs (the Common pins on the relays) Motor One in tied to outA and outB, motor two is tied to outC and outD. 

For simle operation of one motor you have 4 logic states:





11 (not used, no need!)

When inA in low, outA is connected to ground, When inB is high, outB is connected to the positive, therefore the motor will turn in one direction. The same is true with motor 2.

Here is a picture of the finished board



^^Reverse emf protection diodes across the coil

Here is the Stamp I am using to interpret the PWM signal


 I will post the exact code after the Holiday recess, but I can explain the operation! 

   Basically (hehe, its in pbasic, basically, get it? .......Crickets) The stamp is sampling the signal using the PULSIN command, it then stores the width valued in as a decimal value in a word variable. Then there are some conditional inequalites that say "if word var 1 is >700 then FWDsub". When the reciever is recieving a signal for a dead stick, it is receiving a pulse that has a value of ~750 microsec, it stays there as long as you don touch the stick, if you push one channel forward, the value decreases, and visa versa. So Four conditional statements control the program path, 2 per channel, one for fwd and reverse. GOT IT??? I know its not plug and play, but the satisfaction of doing it yourself is so much better than buying a motor controller... for me any way.



Code coming soon!

**Schematic fixed, thanks for catching!



Happy Holidays!




input 10
input 12

output 0
output 1
output 2
output 3

x var word
Channel2 VAR word
Channel1 VAR word

pause 125
high 0
high 1
high 2
high 3
PULSIN 12,1, Channel1
PULSIN 10,1, Channel2
If Channel2 < 700 then Forward_direction
If Channel2 > 850 then Reverse_direction
If Channel1 < 700 then Left_turn
If Channel1 > 850 then Right_turn
GOTO Status

low 0
low 3
goto Status

low 1
low 2
goto Status

low 0
low 2
goto Status

low 1
low 3
goto Status

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
code posted


You shouldn't need the 100 ohm resistors between the relays and VCC. You'll end up dropping more voltage accross the resistor than accross the lower resistance relay coil and could cause the relay to not pull in completely.

 I'm not trying to be picky, just want instructional information to be correct.....otherwise, "newbies" end up getting frustrated when something they build doesn't work even though they "followed the directions".

Theyre actually there ;P, this is the same board I used in a previous project, Ill pull the picture from that to show the back of the board, Theyre there
Take another look at your schematic....it wouldn't work as drawn. The transistor would conduct when turned on and basically shunt your VCC to ground. VCC needs to connect to the top of the relay, (no connection to transistor there), and the collector needs to connect to the bottom of the relay in order to take the relay to ground through the transistor. You'll also find out your transistors will last longer if you put "snubber diodes" accross the relay coils.
If the transistors can take the short circuit current of the supply then technically the circuit would work - the relays are 'on' when the transistor is off, and when the transistor is turned on the relays are deprived of current, so they turn off again...
So, like I said, the circuit would technically work, but it's going to be hell on those batteries and transistors, if they can even withstand the current loading.
Salvage's recommendations will ensure the driver lasts much longer and wastes far, far less power.
Its actually wired like the revised schematic I just posted, I dont know why I drew the schematic the way I did. Ich bin ein dumbkopf!
Ah, much better =)
Although, if you have enough space, the snubber diodes Salvage mentioned are still a good addition.