PIC + Relay

Discussion in 'Embedded Systems and Microcontrollers' started by TCOP, Jan 31, 2013.

  1. TCOP

    Thread Starter Member

    Apr 27, 2011
    89
    0
    Hi all,
    I'm stuck with an engineering mistake and now I don't know how to handle it properly. My circuit is supposed to send singal to a din rail relay (12V / 220V). To make the long story short, only 3 cables leave from the rail and go to the mcu, which is about 10meters away. 2 for dc power and one from the one end of the relay's coil. The other end of the coil is getting +12 from the rail power unit.
    On my mcu circuit, i connect the relay wire to the collector of a 2n4401 transistor and the emmiter is connected to gnd. So I am actually sinking. The base is taking signal from my mcu. Everything worked perfectly until I realised I was
    getting some back EMF when i switched off the relay.
    The problem is that i can't connect anywere a protection diode. I mean that i have no access to the 2 ends of the coil which stand on the rail but only on the one end that is connected on my transistor. So , how am i going to protect my circuit?
    Adding a 4th cable must be my last option.
     
    Last edited: Jan 31, 2013
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,394
    1,606
    Can you add the diode at (or inside?) the relay itself? That has the 2 points you need to address.
     
  3. TCOP

    Thread Starter Member

    Apr 27, 2011
    89
    0
    Unfortunately I can't.
     
  4. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    Can you make the transistor switch off more slowly? Maybe a capacitor from base to ground.
     
  5. TCOP

    Thread Starter Member

    Apr 27, 2011
    89
    0
    schem.png

    this is a draft shem...
    advice where to place anything
     
  6. takao21203

    Distinguished Member

    Apr 28, 2012
    3,577
    463
    10m wire give you enough resistance the spike will run away on it's own.

    They are not so much powerful. You get a small cable capacitor as well from 10m cable.
     
  7. TCOP

    Thread Starter Member

    Apr 27, 2011
    89
    0
    I haven't tried it with a full length cable yet, but on my desk with 10 cm distance, i can get a LED flash for half a second when the transistor switches off, due to back emf, when i connect it reversed, on the power supply and the transistor's collector
     
  8. takao21203

    Distinguished Member

    Apr 28, 2012
    3,577
    463
    For a 10m cable you need ESD protection.

    One lightening strike, and your PCB will be gone.

    There are plugable overvoltage arrestors. But they need 500 or 600V minimum.
     
  9. TCOP

    Thread Starter Member

    Apr 27, 2011
    89
    0
    the pcb receives only 12v dc. Are you sure there is a possibility of an ESD?
    Shouldnt the high voltage stop on the dc supply unit that is on the rail?
     
  10. TCOP

    Thread Starter Member

    Apr 27, 2011
    89
    0
    @Markd77
    I just tried a 10μF capacitor as suggested. On the simulator seems ok. I have a delay both in switching on and off but I think it is acceptable.
    Anyway, if you were to redesign it. What would you do?
     
  11. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,394
    1,606
    <slaps head> Must be on stupid pills today.

    Just put a zener diode across your transistor, somewhere between the 12V and the Vce of the switch. When the relay spikes the diode will avalanche and protect the transistor.
     
  12. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    Never accept that as "solving the problem". As an example, in the future, when the original design constraints are forgotten, the relay is moved to the board, or the board is moved closer to the relay? No protection diode across the transistor would kill it.
     
  13. TCOP

    Thread Starter Member

    Apr 27, 2011
    89
    0
    Today, I contacted a local electronic shop. They offer an octal type rail socket for the 8 pin relays I use, that has a varistor in parallel with the coil, to suppress the EMF. The extra cost of switching to this socket is 2,5 euros, so I think that this is my best solution.
    Thanks everyone for your help.
    By the way, do you know if there is an optocoupler that can withstand about 150ma of current? I can't find one and I think that it would be a nice solution to completly isolate my pcb's inputs by using optocouplers, instead of using transistors.
     
    Last edited: Feb 1, 2013
  14. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    Have you looked at Solid State Relays?
     
  15. TCOP

    Thread Starter Member

    Apr 27, 2011
    89
    0
    solid state was not an option since i am forced to use a din rail relay, that is already installed.
    in addition, the cost of switching to a din rail solid state relay is about 25-35euros per relay.
     
  16. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    Here's one

    I'd suggest one capable of 180mA or 200mA if it is to be switching 150mA.

    There are others available in DIN rail mount as well, but none are in stock at Digi-Key, and the price is about 50 times higher.
     
    TCOP likes this.
Loading...