How to drive relays?

Discussion in 'The Projects Forum' started by s57aw, Dec 18, 2013.

  1. s57aw

    Thread Starter New Member

    Dec 18, 2013
    12
    0
    Hello guys,

    I am quite newbie in electronic and more or less self-taught in this area.

    I would be happy if you take a look into these schematics with Arduino:
    http://remoteqth.com/hw/band_decoder_sch.png

    I have project completed and digital outputs from Arduino send signal through resistor and led diode, optocoupler and NPN transistor.

    There are 12 open collector outputs and I want to drive 12v relays (about 30ma, 360 ohm coil resistance) on the SV2 outputs.

    I have applied +12v to the relay, put diode over coil and connected specific output to other side of the coil but relay doesn't switch, I got only appropriate led diode on but it looks no output for the relay.

    What I am missing - appreciate your suggestions. What about pin 13 on the SV2 output, should it be connected somewhere?

    Regards,

    Robert
     
  2. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    There is no source of base current to the final NPN relay switching transistors.
     
  3. s57aw

    Thread Starter New Member

    Dec 18, 2013
    12
    0
    Thanks Mike,

    What do you recommend?

    Robert

     
  4. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    This configuration would be the way I would wire it up. Note that the base current of each NPN is supplied via a pull-up resistor and the opto-isolator. Also note that the 0V terminal of the 12V power supply does not connect to the MCU's 0V (GND). One side of each relay connects to +12V.
     
  5. s57aw

    Thread Starter New Member

    Dec 18, 2013
    12
    0
    Thanks,

    I am looking at my project as it is now (like on the schematics). I have one opto-isolator and NPN after LED. All Emiters of final NPNs are connected in parallel in they are floating - pin13. My idea is to energize one relay on each output (1 - 12 on SV2). I see two relays in series in each output in you schematics.

     
  6. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    I only showed two channels in the schematic I posted; you have 12.

    Follow the current path. Assume the left Port signal is high. Its LED and photo-diode are passing current. The left photo-transistor is turned-on, passing current through the 1K resistor into the base-emitter junction of the NPN, which is turned-on. Current flows from the +12V rail, through the relay coil, into the collector of the NPN and returns to the 0v rail via the emitter. The snubber diode is reversed biased while the relay coil has +12V across it. Only one relay is on because the other eleven photo-transistors are all off (assuming you wrote the code so the only one port is high at a time).
     
  7. s57aw

    Thread Starter New Member

    Dec 18, 2013
    12
    0
    Thanks Mike!


     
  8. s57aw

    Thread Starter New Member

    Dec 18, 2013
    12
    0
    As I understand the optocoupler is only there for isolation.

    I assume I need to connect pin 13 to - of the 12V source and outputs will then pull pins 1-12 to ground, so one side of relay connects to +12V, the other to the pin of ther output .

    Robert

     
  9. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    One other thing; The 2.5KΩ resistors between the port pin and the LED are way too high. The current transfer ratio of the PC847 is 50%, so if you are switching >30mA with the NPN, its base current should be >3mA. To get 3mA, the input to the PC847 should be > 6mA.

    When sourcing 6mA, the MCU port pin will be putting out <4.5V. The forward drop across the photo-diode is 1.4V; across the LED, I cant tell, but say it is 2V. Then the voltage drop across the resistor would be 4.5-1.4-2 = 1.1V. To limit the current to 6mA, the resistor value would be E/I = 1.1/6m = 180Ω
     
  10. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    Yes, and isolation means that the power supply driving the relays is totally independent from the one powering the MCU. There is no connection between the 0V terminal on the MCU power supply, and the 0V on the 12V power supply. Two separate supplies.

    Yes. But note that the connector at the bottom needs a pin to connect to +12V and another to connect to 0V. Also notice that all of your snubber diodes are in the wrong place; they need to be across the relay, not across the NPN.
     
  11. sheldons

    Well-Known Member

    Oct 26, 2011
    616
    101
    Depends how complicated you want to go,heres a simple relay driver with an opto....
     
  12. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    Which is the same as what I posted, except that the resistor is above the opto instead of below it, which makes no difference. The posted circuit also undoes the benefit of opto-isolation by tieing the emitter of the NPN to the same ground as the input.
     
  13. s57aw

    Thread Starter New Member

    Dec 18, 2013
    12
    0
    Thanks a lot guys,

    Well, I have just purchased and built the kit base on publish schematics:
    http://remoteqth.com/hw/band_decoder_sch.png

    This is "Band decoder" for radio transmitter (TRX). TRX is connected to Arduino with serial cable (only TX, RX and GND is needed). Arduino reads frequency information from the TRX and based on it puts signal to one of the 12 outputs. I need a relay at the output to drive an antenna switch (switching different antennas for different frequencies).

    Arduino needs +5v and I would like to use 12v relays at the output. This is not an issue itself, I supply 12v to the board and output relays and using a simple DC voltage regulator from 12 to 5V for Arduino. I don't have two separate PSU, ground is the same and sources are not isolated in current configuration.

    Anyway, I didn't change anything, all soldered on PCB as per schematics and I have connected PIN 13 to the same ground for test and relays are working now, but... I would do it again I would use Mike's approach.

    I still don't understand kit schematics / author completely - why the combination of optocoupler, switching transistor, and relay, it looks redundant. I know I need a transistor to effectively and safely drive the relay, but the relay (plus the diode across the coil) would be enough for isolation I think, why optocupler? And why there is a diode across NPN transistor (I am using another diode over relay coil).

    Robert
     
  14. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    If the 12V supply is common with the 5V supply, then there is no reason to use the opto-isolators. You could just as well drive the NPN bases directly from the MCU ports with just a series resistor.

    There are a lot of poorly-conceived circuits created by inexperienced folks on hobbyist web sites, and this is an example. The designer obviously doesn't have a clue, eg the need for isolation, the starved current to the relay drivers, the misplaced snubber diodes. Is the schematic just plain wrong about where the output side of the opto-isolator is connected (base to 0V instead of base to 12V)?

    btw- I'm glad that you didn't design that board...
     
    Last edited: Dec 18, 2013
  15. s57aw

    Thread Starter New Member

    Dec 18, 2013
    12
    0
    Is the schematic just plain wrong about where the output side of the opto-isolator is connected (base to 0V instead of base to 12V)?

    Opto-isulator output connection (on the board):
    Emitter ---- > BC547 Base
    Collector --- > BC547 Collector --- > output
    BC547 Emitter is grounded now

    like on the schematics

    btw- I'm glad that you didn't design that board...


    Thanks :)
     
Loading...