Drive Relays

GroupDIY Audio Forum

Help Support GroupDIY Audio Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

Rochey

Well-known member
White Market Member
Joined
Jul 2, 2004
Messages
2,697
Location
Dallas, TX - Formerly UK
Guys...

how can I convert a basic CMOS output (say a GPIO port on a processor) to switch a relay on and off. My analogue design skills are actually crap - so any advice you have would be appreciated.

:)

Cheers

R
 
Have a look here (at the remote control schematics): http://stiftsbogtrykkeriet.dk/~mcs/

Best regards,

Mikkel C. Simonsen
 
Hi I think were both looking at something similar right now?????

I think you need a transistor driver to supply enough current to the relay coils, there is an NPN driver chip with 8 devices on there, the ULN2803 I think.....

I think you may need to calculate a dropper resistor somewhere.

People am I on the right track?

Cheers Tom
 
Logic level MOSFETs. I use them all the time to control relays from IC's. Do you want to turn ON(normally open) the relay or turn it OFF(normally closed)? easy to do with a single pull up/down resistor. Make sure you get the ones with the integral body diode to freewheel the current/voltage spikes.

let me know how you intend to use the relay and I'll show you how to set it up!

:guinness:
 
I just remembered this too, try something like the tc4427. there is a whole family of mosfet driver ICs that can source/sink 1A or more in micro seconds... most work @logic levels and come in quad ICs:

http://www.microchip.com/ParamChartSearch/chart.aspx?branchID=9010&mid=10&lang=en&pageId=79

we actually use these to switch motors directly in our products, driven directly from an atmel MCU.
 
> a basic CMOS output (say a GPIO port on a processor) to switch a relay

This isn't analogue, except in the sense that all "digital" circuits are overdriven analog circuits.

It is more like wiring house lamps.

But there are ways to screw it up.

relays.gif


If you have a very low power relay, you can drive it directly from some digital chip outputs. CMOS may only be good for 1mA at 4V, or may be good for 16mA at 4.5V: read those datatsheets! There are 5V relays that are made to work directly. (If you remember TTL: in TTL it is better to connect the relay to V+. TTL is poor at pull-up, better at pull-down.)

The general case for small relays is 6V to 24V, 20mA to 100mA. More than a general logic output can deliver. The general solution is any transistor rated for the voltage and current, plus a couple resistors so the logic and transistor play nice together. R1 must limit current: enough to saturate the transistor with full relay current, yet not so much that the logic strains. 1mA will generally be a good number. Assuming the logic pulls up to 4.0V, and the transistor Base voltage is about 0.7V, we have 4V-0.7V= 3.3V across the resistor. 3.3V/1mA= 3.3K ohms. R2 is usually not needed with CMOS and silicon transistors in reasonable temperatures.

If you are whacking big relays, line-power control or valve-tube B+ switching (or I was switching a 3-phase air conditioner), you may need a relay more than about 12V 100mA. Then the old standby TIP120 Power Darlington is cheap handy sturdy interface. Use R1 about 2K. R2 is built into TIP120; if you use another Darlington then use 5K from Base to ground to drain off leakage. TIP120 is rated 60V, so "should be OK" past 48V relay voltage. I like lots of margin: TIP122 is rated 100V and that is what I would use at 48V.

In all transistor-drive-relay applications, put a diode across the relay coil. Otherwise a 24V relay will spike up over 200V when you turn the transistor off, and xap the transistor. The diode should be rated for the relay voltage and current: 1N914 for 50mA-100mA chores, 1N1004 for most 1A relays, or something larger if your relay is very fat. (Actually the peak diode current is equal to the relay current, and very transient, so you could use a much smaller diode. But diodes like 1N1004 are so cheap, you may as well over-kill.)
 
I think PRR is a BJT guy. :green:
I like FETs myself.. but only because IGBTs are still too much $. :thumb:

either way, It'll work.

:guinness:
 
Thanks PRR...

I had a feeling I'd se a transistor somewhere... I only wish i'd listenened at uni to the transistor theory lectures...

I always respected people who could just get a peice of paper and juts draw a whole circuit (including all that bloody transistor theory) and include all the values as they go along... always looked like magic to me.

sigh -- maybe someday i'll get to be as wise :roll:

Cheers

R
 
Or use a ULN2003.

They're a bunch of darlington transistors masked as a less anxiety-provoking DIL IC :grin: - they're well protected and interfaces easily. And are easy to get hold on.

Jakob E.
 
Gyraf:

I've downloaded the datasheet at: http://focus.ti.com/lit/ds/symlink/uln2003a.pdf

So.. from what I can tell, I connect the Emitter to ground on the device (0v). The Input (B) to the processor and the output (c) to the relay.

This is going to sound stupid... but what about the Common out? It looks identical to the Output, except there's a Diode on it as well... What does that diode do?

(in my book, a diode serves 2 purposes - (a) make sure current only flows in 1 direction, and (b) drops a certain voltage accross itself)

Have I missed something, or am I just plain stupid...


be nice.

:grin:

R
 
[quote author="Rochey"]Gyraf:

I've downloaded the datasheet at: http://focus.ti.com/lit/ds/symlink/uln2003a.pdf

Have I missed something, or am I just plain stupid...[/quote]
You missed the link I posted. Go to that site. Click "Remote controlled passive preamp", click "circuit description" and download the schematic at the bottom of the page. That schematic shows you how to use the ULN chip.

Best regards,

Mikkel C. Simonsen
 
Diode common connects to V+, these are protection diodes to prevent reverse spikes generated by e.g. relay coils from destroying the transistors.

See .pdf page 8 top for example..

Jakob E.
 
gotta make it so complicated! Just use a logic level N-Mosfet with the body diode as your low side switch to ground. connect the other side of the coil to V+ and you are good to go. when High, the mosfet turns on, so does the relay.
 
[quote author="PRR"]> [
relays.gif

[/quote]
Relays have rather high power consumption if are on.
To lower it, use paralel RC circuit in series to relay.
R some 100 Ohm C 100 mikrofarads, it want experimenting.

xvlk
 
sorry about not being able to link the pic directly,

http://pg.photos.yahoo.com/ph/noireclipse/detail?.dir=e039&.dnm=5b8c.jpg

let me know if you want me to send it to you direct. this is a fet switch I use for relay switching

I have DXF formats too

http://www.irf.com/product-info/datasheets/data/irlml2502.pdf

is what i used

EDIT: make sure your CMOS output will pull the gate of the MOSFET down to GND when low.. if left to float it might turn on by itself. you should double check that or put a pull down resistor from the gate to source.. around 10k should be ok, maybe up to 47k depending on how much current your CMOS output can source..
 
SORRY! i didn't realize until just now that the picture was not shared!!!!

should be shared now!

how is the relay drive going?
 
Back
Top