Driving a relay using a 3.3v 2mA digital output from an MCU

Thread Starter

lesneypark

Joined Dec 31, 2015
47
Hi,

I am seeking recommendations, or a tutorial, on how to drive a relay using a 3.3Vdc 2mA digital output from an MCU.

The relay requires a 12Vdc supply and the coil resistance is 270 ohm drawing approximately 45 mA.

I had thought I could use a optocoupler to switch the ground connection of the relay coil but I'm unsure how to correctly size the current limiting resistor between the digital output and the anode of the optocoupler.
  • If I assume Vin = 3.3V, Vf = 1.25V (from data sheet) and If = 20 mA (from data sheet) and using the equation R =(Vin-Vf)/If then the current limiting resistor would be 10.25 Ohm. At 3.3V a 10 ohm resistor would draw 330 mA but the MCU output can only deliver 2mA @ 3.3V.
  • I am also confused about the CTR (%) for the optocoupler. If I assume Ic = 45 mA and If = 20mA and using the equation CTR (%) = (Ic/If) * 100, the CTR for this configuration is 225%. I can't see on the data sheet if this will be ok.
I have based the above on the Toshiba TLP 185 (click for link to data sheet)

Help with my calculations would be appreciated or alternatively if there is a simpler/better way to achieve the same result please let me know.

Thanks,

Neil
 

GopherT

Joined Nov 23, 2012
8,009
Hi,

I am seeking recommendations, or a tutorial, on how to drive a relay using a 3.3Vdc 2mA digital output from an MCU.

The relay requires a 12Vdc supply and the coil resistance is 270 ohm drawing approximately 45 mA.

I had thought I could use a optocoupler to switch the ground connection of the relay coil but I'm unsure how to correctly size the current limiting resistor between the digital output and the anode of the optocoupler.
  • If I assume Vin = 3.3V, Vf = 1.25V (from data sheet) and If = 20 mA (from data sheet) and using the equation R =(Vin-Vf)/If then the current limiting resistor would be 10.25 Ohm. At 3.3V a 10 ohm resistor would draw 330 mA but the MCU output can only deliver 2mA @ 3.3V.
  • I am also confused about the CTR (%) for the optocoupler. If I assume Ic = 45 mA and If = 20mA and using the equation CTR (%) = (Ic/If) * 100, the CTR for this configuration is 225%. I can't see on the data sheet if this will be ok.
I have based the above on the Toshiba TLP 185 (click for link to data sheet)

Help with my calculations would be appreciated or alternatively if there is a simpler/better way to achieve the same result please let me know.

Thanks,

Neil

Get a "comparitor" - the old standards were LM339, LM393, LM311 etc. They can easily work down to 3.3 volt input (from the Microcontroller output. Also, connect the coil of the relay between 12v+ and the "open collector" output of the comparitor. Assumes your coil is not huge current. Check the DATASHEET of the comparitor.
 

crutschow

Joined Mar 14, 2008
38,571
You generally don't need an isolator to drive a relay.
Use a transistor (bc547, 2N3904, 2N2222, etc.) as FM suggested, connection shown below:
The diode is necessary to suppress the inductive spike from the relay coil to avoid zapping the transistor.
upload_2017-6-4_11-34-2.png
 
Top