# Comments on my simple relay-PWM motor controller circuit

Discussion in 'General Electronics Chat' started by hspalm, Sep 28, 2010.

1. ### hspalm Thread Starter Active Member

Feb 17, 2010
201
8
Hello
I am trying to think of a way to make an H-bridge motor controller using two SPDT relays. I want the power to the motor to be PWM controlled. The forward and backward relay coil inputs are controlled by microcontroller, so let's say its safe to say they will never be powered at the same time.

edit: scaled down the image a bit

File size:
54.6 KB
Views:
33
2. ### SgtWookie Expert

Jul 17, 2007
22,182
1,728
You're using the NPN transistor as an emitter follower. Since it will never saturate when used that way, it will dissipate much more power than if you were using it as a saturated switch.

You haven't said anything about the rest of your application; is it battery powered? Relays are not very good to use on battery power, as the coil takes quite a bit of power to keep energized.

3. ### hspalm Thread Starter Active Member

Feb 17, 2010
201
8
That's a good point. Yes, it will be battery powered. I guess I just wanted an h-bridge circuit that was not as complex as all the mosfet circuits I've found. Is there anything else to say about this circuit? Thank you for your reply.

4. ### SgtWookie Expert

Jul 17, 2007
22,182
1,728
You're using an NPN transistor to source current to the high side, and there is no current limiting resistor on the base of the transistor. This is guaranteed to burn out your uC's I/O port in short order, as most uC's have an I/O current limit of +/-20mA per pin.

Instead, use the transistor to switch the low-side current, and use a base current limiting resistor.

Calculating the base current limiting resistor (Rbase):
Rbase = (Vin - Vbe) / (Ic / 10), where:
Vin = the maximum voltage the I/O pin can place on the end of Rbase opposite the transistor base, relative to the transistors' emitter terminal.
Vbe = typically 0.7v; but see the datasheet for the transistor to be certain.
Ic = desired collector current.

For example, if your uC's Vcc/Vdd =5v, and you're using a 2N/PN2222 transistor, and your maximum I/O current is 20mA, you can start out like this:

Rbase = (5v-0.7v)/20mA = 4.3/0.02 = 215 Ohms. The closest standard value is 220 Ohms. This will give 4.3v/220 Ohms = 19.545...mA base current, which will guarantee good saturation for Ic up to 195.454...mA collector current.

If your desired collector current is less, then use the 1st formula to determine the best base resistance value to use.

You will need to have a reverse-EMF protection diode across the collector and emitter terminals of the transistor. Without it, when the transistor turns off, the reverse EMF from the motor will blast the transistor's collector with high voltage, frying it.

5. ### hspalm Thread Starter Active Member

Feb 17, 2010
201
8
Thank you so much for your answer. If there is one thing I am unsure of, it's transistors in different applications, especially bjt's. What I do know is relays, so I usually draw my schematics as if the transistors were relays... Thank you for the clarification!

So besides the fact that relays are not very battery friendly, is this h-bridge design okay? Of course, correcting the transistor part.

6. ### sbombs Member

Feb 26, 2010
33
0
Why not use an LN298? Or some other H-bridge, if the LN298 is unsuitable.

7. ### fanie Active Member

Jan 20, 2007
63
0
I think this is what you're looking for.

The circuit is virtually foolproof. Either relay can be on or off without a short on the supply when the speed fet is on.

The relays and motor can work off different voltages (or the same).

I used an IRLZ44 for driving the motor since a pic can drive it directly (logic level fet).
The relays are switched with 2N7002 logic level fets.
You don't need gate resistors.

You'd want to switch the speed fet off, change relays for direction then PWM for the speed you want.
No arcing or the relays will make them last forever and the contacts can carry much larger currents if they don't do switching.

• ###### HBridge Relay.jpg
File size:
73.9 KB
Views:
63
Last edited: Sep 29, 2010
8. ### hspalm Thread Starter Active Member

Feb 17, 2010
201
8
sbombs, I actually have several l293d, but my motor just exceeds its current limit. I also have several pcb relays laying around, so I thought I'd give it a try. So I wanted to use relays both because it's a more familiar setup for me, and because I'm not too comfortable with transistors yet. The ready made h-bridge chips are easy and good, and I have already finished my circuit with l293d too see if my uC job was okay, but with load my RC car will draw too much current...

Fanie, that's a cool circuit. I have several logic level transistors, and I am planning on using them in this project. So handy when dealing with microcontrollers.

9. ### fanie Active Member

Jan 20, 2007
63
0
You're welcome.

Transistors are really easy, a transistor is a current controlled switch with 0.8V drop over it when full on and that generates some heat. They make nice finger toasters.

Fet's have the advantage they switch on with voltage and have a low on resistance, so when full on they can conduct a lot more current before heating up.

Both transistors and fets have a problem when half switched on, it's then in linear mode and the impedance is high. Applying ohm's law directly you can see how radical heat gets generated very quickly. So it's important how long you take to swich a device from on to off and vice versa.

Easiest way to measure power consumption is to measure voltage over a device and the current through it... (since you cannot measure the ohms in a live circuit)

You have to stay well below the secified package power when no heatsink and below the max power when heatsinked. Heatsink size is expressed in deg C /W of power dissipated by the device attached to it. This means keep the device current in check.

Neither transistor / fet likes overvoltage or spikes exceeding their max voltage.

That's almost it ! Now you know the basic transistor / fet and shouldn't have any more problems

10. ### sbombs Member

Feb 26, 2010
33
0
Ah, I understand. I kind of like the idea of using the relays, especially if you're careful applying power (so as not to weld the contacts). Good Luck.

11. ### hspalm Thread Starter Active Member

Feb 17, 2010
201
8
Fanie, I like your brief introduction to transistors. I guess it is like everything I have managed to learn over this year I have been interested in such things (electronics, robotics, microcontrollers). I you fear it, you will never master it. At my university one of the half year courses was actually electronics, were we learned about most basic passive components + op-amps. The transistor part I guess was not too difficult to master, it's just that when you want to learn how to use the darn thing, it's a bit de-motivating to go straight on to the low-level theory about transistors, then struggle with one laboratory exercise before heading further on to op-amps or what ever. The part of the course about heatsinks was easy though, but thanks for the reminder!

sbombs, I am not sure yet what solution to go for, but if I finish with relays, I will certainly post the results here.

sbombs likes this.