Author Topic: Relay with Optocoupler problem  (Read 2540 times)

0 Members and 2 Guests are viewing this topic.

Offline ChrisGreece52Topic starter

  • Frequent Contributor
  • **
  • Posts: 829
  • Country: gb
  • Electronics Engineer - Hacker - Nerd
Relay with Optocoupler problem
« on: May 09, 2020, 12:08:21 pm »
Hello everyone, i have designed a PCB that uses the schematic posted bellow to control a relay using an MCU. Problem is when the PCBs and the parts arrived while testing the circuit i could not get it working.
I am a bit confused on whats may be wrong with the schematic. To be honest i just copied the schematic for the arduino relay module since its proven. I had put zero thought on the schematic till now.

The Relay 2 Pin goes to an MCP23017 which in turn is controlled using an ESP8266.
Notes :
R6 : On the schematic R6 is a 510 Ohm resistor where i used a 220 one on the PCB.
FDLL4148 : The FDLL4148 diode was replaced by 1n4007 is used
SFH690BT : Instead of the SFH690BT a CT817 optocoupler is used.

I will link the schematic and the datasheet for the optocoupler.
Optocoupler datasheet : https://datasheet.lcsc.com/szlcsc/1810281220_CT-Micro-International-CT817C-SL-T1-H_C191932.pdf

Problem : When powered both leds are off (as they should) when a 0V signal is applied on the Relay 2 Pin , D5 led comes on. Still D4 is off and the relay is not responding.

I have taken some measurements of the circuit. While D5 is on, pin 2 of the MMBT2222A is at 3V or there about.

« Last Edit: May 09, 2020, 12:12:03 pm by ChrisGreece52 »
 

Offline MK14

  • Super Contributor
  • ***
  • Posts: 4540
  • Country: gb
Re: Relay with Optocoupler problem
« Reply #1 on: May 09, 2020, 01:20:24 pm »
There seem to be a number of problems. I noticed at least three. My somewhat/relatively quick analysis, could be mistaken.

(1)..The current to the opto-isolator, is only around 1.5 milliamps or so. This is very marginal at best, and probably not enough to reliably work. Because of R7/1K and 2 sets of Led voltage drops. The datasheet seems to prefer at least 5ma, if not 10ma or even 20ma for proper saturation of the output transistor.

(2)..R6/510 ohms, will greatly limit the relay coil (which seems to need around 70 milliamps), to a much lower current.

(3)..The voltage drop of Led D4, will limit/stop the relay, from getting most of the 5 volts it needs. Because the led will drop around 2V.
« Last Edit: May 09, 2020, 01:22:16 pm by MK14 »
 

Offline Manul

  • Super Contributor
  • ***
  • Posts: 1109
  • Country: lt
Re: Relay with Optocoupler problem
« Reply #2 on: May 09, 2020, 01:24:51 pm »
Welll, there is not enough current for relay. Mostly because relay current in your circuit goes through 510 resistor and LED.
 
The following users thanked this post: MK14

Offline wraper

  • Supporter
  • ****
  • Posts: 16867
  • Country: lv
Re: Relay with Optocoupler problem
« Reply #3 on: May 09, 2020, 01:27:32 pm »
This circuit is completely pointless. Besides it being full of mistakes, optocoupler functions as good as fifth leg for a dog. It does not isolate input from anything, therefore there is no point using it to begin with.
 
The following users thanked this post: Ian.M, Manul

Offline Manul

  • Super Contributor
  • ***
  • Posts: 1109
  • Country: lt
Re: Relay with Optocoupler problem
« Reply #4 on: May 09, 2020, 01:32:42 pm »
Also there is no isolation in your circuit, so optocoupler has no porpose is such a circuit. I guess you want isolation. If yes, then your input side and output side of optocoupler needs to have separate isolated supplies and separate grounds. Otherwise you can remove optocoupler and drive 2N2222 directly.
 
The following users thanked this post: wraper, Ian.M

Offline MK14

  • Super Contributor
  • ***
  • Posts: 4540
  • Country: gb
Re: Relay with Optocoupler problem
« Reply #5 on: May 09, 2020, 01:36:01 pm »
ChrisGreece52, you have made a very good quality thread/post. It supplies all the information we need, nicely laid out, to quickly discover what is wrong. Many posters, do not accomplish this  :-+
 

Offline MK14

  • Super Contributor
  • ***
  • Posts: 4540
  • Country: gb
Re: Relay with Optocoupler problem
« Reply #6 on: May 09, 2020, 02:01:23 pm »
This circuit is completely pointless. Besides it being full of mistakes, optocoupler functions as good as fifth leg for a dog. It does not isolate input from anything, therefore there is no point using it to begin with.

Also there is no isolation in your circuit, so optocoupler has no porpose is such a circuit. I guess you want isolation. If yes, then your input side and output side of optocoupler needs to have separate isolated supplies and separate grounds. Otherwise you can remove optocoupler and drive 2N2222 directly.

Although I agree, it doesn't give proper isolation (voltage). E.g. Because the ground and 5V rails, are still connected.

It does at least, give the important microcontroller port pin, some degree of extra isolation (even though it is not very well implemented).
E.g. Because of issues (such as slow response times) with the diode, the back emf can build up a bit, before the diode properly kicks in. Well designed circuits, should be able to avoid this anyway, but the OP mentions a slowish 1N4007.
So, the optoisolator is stopping any back emf voltage (before the slow diode has time to react), from interfering with or even breaking the relatively sensitive, port pin. (Although the supply rails are another way it could cause problems, because of lack of proper isolation, between the two sides of the opto-isolator).
Although these days, port pins, seem to be quite well protected, because of the built in esd protection diodes, usually present.
« Last Edit: May 09, 2020, 02:05:30 pm by MK14 »
 
The following users thanked this post: ChrisGreece52

Offline Manul

  • Super Contributor
  • ***
  • Posts: 1109
  • Country: lt
Re: Relay with Optocoupler problem
« Reply #7 on: May 09, 2020, 02:22:58 pm »
To get isolated supply for output side I recommend these easy to use isolated DC/DC converters like IE2405S, TMR 1211, CRE1S0305S3C, etc.

For crude solution it would be even possible to just switch DC/DC isolated supply input with a mosfet and 5V output side would drive a relay. It would give isolation and very simple circuit, which should work. You just need a logic level mosfet and some capacitor on your 5V supply to supply inrush current on switch on.

But more complex circuit with isolated supply and optocoupler would be recommended, because it is not very elegant to keep switching these converters (mostly because of inrush current).
 

Offline MK14

  • Super Contributor
  • ***
  • Posts: 4540
  • Country: gb
Re: Relay with Optocoupler problem
« Reply #8 on: May 09, 2020, 02:44:41 pm »
To get isolated supply for output side I recommend these easy to use isolated DC/DC converters like IE2405S, TMR 1211, CRE1S0305S3C, etc.

For crude solution it would be even possible to just switch DC/DC isolated supply input with a mosfet and 5V output side would drive a relay. It would give isolation and very simple circuit, which should work. You just need a logic level mosfet and some capacitor on your 5V supply to supply inrush current on switch on.

But more complex circuit with isolated supply and optocoupler would be recommended, because it is not very elegant to keep switching these converters (mostly because of inrush current).

I don't really understand why you are trying to push for a fully isolated opto-isolator ?
What is the point ?

The relay, if properly implemented, should provide electrical isolation.
 
The following users thanked this post: Ian.M

Offline ChrisGreece52Topic starter

  • Frequent Contributor
  • **
  • Posts: 829
  • Country: gb
  • Electronics Engineer - Hacker - Nerd
Re: Relay with Optocoupler problem
« Reply #9 on: May 09, 2020, 02:50:28 pm »
Thank you everyone so much for your replies! I tried making the post as clear as i could (years of posting dumb questions here helped evolve this trait  :P )
Taking into account your suggestions while having already the PCBs at hand with no desire to order new ones i will try these :
1) Remove the 220 Ohm (510 Ohm in the schematic )resistor and D4  and connect directly the 5 V rail to the relay,
2) If this solution is not elegant enough or works reliably i will bypass the optocoupler altogether.

Although i would like for the relay switch to close when a low signal is applied on the Relay 2 Pin of the schematic.

Edit : As for isolation i think that ship has sailed when i integrated the relay into the circuit with direct connections to the low voltage elements.

Edit 2 : I attached an image of the board.
The pink traces are isolation cutouts for the relays that handle 220V AC. I posted again when designing the board and deciding about the layout and cutout widths.
The Red traces from the connector at the base of the board are Live and the Blue trace that is barely showing going to the MOV is Neutral. Then they go to a HLK-20M05 AC-DC converter to get down to 5V.
There are also 2 fuses on the Live line one 200mA and one thermal 70C fuse to ensure that the AC-DC converter does not blow.

Edit 3 : Tried the first solution with no results.
Measurements so far suggest :
- Pins 1,2,3 of the MBT2222A are at 5 V (when low signal is applied)
- D5 comes on
- The voltage differential across the 2 Relay pins (or D6) is 0 volts.

I am thinking in might be a current issue since the relay seems to be powered. (suggested by the 0V across its pins)
« Last Edit: May 09, 2020, 03:16:36 pm by ChrisGreece52 »
 
The following users thanked this post: MK14

Offline Manul

  • Super Contributor
  • ***
  • Posts: 1109
  • Country: lt
Re: Relay with Optocoupler problem
« Reply #10 on: May 09, 2020, 03:03:34 pm »
I don't really understand why you are trying to push for a fully isolated opto-isolator ?
What is the point ?

The relay, if properly implemented, should provide electrical isolation.

I'm not pushing, I'm just giving ideas so people may choose depending on their needs. In the original circuit, there is no need for optocoupler if additional isolation is not wanted. Driving relay transistor directly through a current limitting resistor will protect logic input even if transistor base would short to collector or emitter. So maybe for some reason isolation is wanted.
 
The following users thanked this post: MK14

Offline MK14

  • Super Contributor
  • ***
  • Posts: 4540
  • Country: gb
Re: Relay with Optocoupler problem
« Reply #11 on: May 09, 2020, 03:47:32 pm »
I'm not pushing, I'm just giving ideas so people may choose depending on their needs. In the original circuit, there is no need for optocoupler if additional isolation is not wanted. Driving relay transistor directly through a current limitting resistor will protect logic input even if transistor base would short to collector or emitter. So maybe for some reason isolation is wanted.

I think the real problem/issue seems to come about from some of the (although cheap), Chinese circuits. Especially for the arduino. Which don't seem to be especially well/sensibly designed.
I think I've seen on other threads here, complaining about the opto-isolator, being poorly implemented and probably not needed, because the relay usually naturally gives electrical isolation/protection, if properly implemented with slots in the PCB, and other measures to keep good clearances between both sides of the relay.

Although I can see why you think the resistor will limit the current, it won't necessarily work.
(As I assume you know), A port pin can go tri-state. So if while the relay coil is energised, the 5V rail gets briefly interrupted (e.g. contact bounce of a 5V power on/off switch), the rail can flip rapidly between 5V and 0V (depending on capacitance and loads).
This can put the mcu into reset, which immediately tri-states all ports (even if the relay coill was/is still energised), the tri-stating will now turn the relay coil off, but will also make the port pin a very high impedance.
So, if the current limiting resistor, attempts to put the back-emf voltage (before a slow diode has kicked in), into the port, it can.
This is theoretically a datasheet violation, but in practice, will often/usually be survived, because of the inbuilt esd protection diodes.

There are other failure mechanisms, such as software, suddenly making the port tri-state, while the relay is energised.

If you disagree-with me here (following is a joke, but true, really). I will take you to a certain University expert(s), on how students manage to blow up his carefully designed lab experiment equipment things.
I can't remember exactly, but he will point to all the opto-isolators and things, and explain how they keep students from breaking things all the time.
I can't remember if there were opto-isolators, it is too long ago. But, I do remember them being greatly concerned, about stuff.
N.B. I've forgotten too many details, so take what I'm saying about the University, as ultra approximate.
« Last Edit: May 09, 2020, 03:51:58 pm by MK14 »
 
The following users thanked this post: Manul

Offline ChrisGreece52Topic starter

  • Frequent Contributor
  • **
  • Posts: 829
  • Country: gb
  • Electronics Engineer - Hacker - Nerd
Re: Relay with Optocoupler problem
« Reply #12 on: May 09, 2020, 04:05:03 pm »
I found a similar schematic to what i have here :
http://wiki.sunfounder.cc/index.php?title=2_Channel_5V_Relay_Module

Having a bridge from R6 to D4 results in the same exact schematic with a different optocoupler (817C) and unknown transistor and diode.

Also considering the PCB layout and the implemented cutouts i am not worried about isolation. So I just need to get it working.

I would also like to add that my testing is done using an Arduino Nano. The final setup consists of an ESP8266 talking to an MCP23017 via I2C which controls the relays.

The relay pins utilize the internal 100k pullups of the MCP23017. I shall go test the thing on the final setup as well to just be sure while taking some measurements.
 
The following users thanked this post: MK14

Offline MK14

  • Super Contributor
  • ***
  • Posts: 4540
  • Country: gb
Re: Relay with Optocoupler problem
« Reply #13 on: May 09, 2020, 04:38:56 pm »
I found a similar schematic to what i have here :
http://wiki.sunfounder.cc/index.php?title=2_Channel_5V_Relay_Module

That circuit's looking better!
(Ignoring arguments about the opto-isolator connections/need).

The relay should get the full 5V, without any significant current limit or voltage drop.
But, the 1K resistor R1/R4, may not be low enough. To ensure enough drive current to the opto-isolator.
I'd prefer a lower value, such as 330 ohms (if you keep 2 Leds worth of voltage drop). (Ironically too low a value, can actual wear out the opto-isolator in the longer term).
That should then work well.

EDIT:
You might find 1K works. But, in the longer term, it may be too marginal a drive current. So, as the led (in the opto-isolator) fades in brightness, over time. It might get to a point, where it stops working, reliably.
Similarly, too low a resistor value, will "burn out" the opto-isolators led, even quicker. A sort of double edged-sword.
330 Ohms, is probably around 5ma, which is probably a reasonable minimum value. But, more current may be better, as it gets the opto-isolator transistor, closer to saturation.
« Last Edit: May 09, 2020, 04:47:16 pm by MK14 »
 

Offline Manul

  • Super Contributor
  • ***
  • Posts: 1109
  • Country: lt
Re: Relay with Optocoupler problem
« Reply #14 on: May 09, 2020, 04:50:10 pm »
MK14, I totally agree with your justification and I really understand the things you say. Yet, I still think, that back-emf protection is not the job of optocoupler. Optocoupler is for galvanic isolation. Back-emf supression and protection against it is another topic. I mean, if someone puts wrong (slow) diode, it is wrong to say, that now circuit needs optocoupler. No, it needs a fast diode. If there is need for higher protection, why not put a classic BAT54S dual schottky, which together with current limiting resistor will protect really good, does not matter if port is tri-state or not. It is just my philosophy to always use the correct tool for a problem.

Of course if we want to safely switch high voltages, not 5V, then optocoupler may be a good choice, because basically we get into realm of providing galvanic insulation in case of transistor failure.
« Last Edit: May 09, 2020, 04:58:01 pm by Manul »
 
The following users thanked this post: MK14

Offline MK14

  • Super Contributor
  • ***
  • Posts: 4540
  • Country: gb
Re: Relay with Optocoupler problem
« Reply #15 on: May 09, 2020, 05:27:05 pm »
MK14, I totally agree with your justification and I really understand the things you say. Yet, I still think, that back-emf protection is not the job of optocoupler. Optocoupler is for galvanic isolation. Back-emf supression and protection against it is another topic. I mean, if someone puts wrong (slow) diode, it is wrong to say, that now circuit needs optocoupler. No, it needs a fast diode. If there is need for higher protection, why not put a classic BAT54S dual schottky, which together with current limiting resistor will protect really good, does not matter if port is tri-state or not. It is just my philosophy to always use the correct tool for a problem.

Of course if we want to safely switch high voltages, not 5V, then optocoupler may be a good choice, because basically we get into realm of providing galvanic insulation in case of transistor failure.

I completely agree with you!  :-+
An opto-coupler, is really intended to provide significant electrical isolation.

There are a number of power supply circuits, floating about on the web, which make me go  :palm: :palm: :palm:
As soon as I see them. Because the designs are so poor, e.g. A single 2N3055, trying to cope in a linear, 35V, 8 Amp, adjustable power supply.

tl;dr
There seem to be plenty of "bad" (but they still might work), circuits floating about the web. Which sometimes gets modified, rather than properly designed.
 
The following users thanked this post: Manul

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12865
Re: Relay with Optocoupler problem
« Reply #16 on: May 09, 2020, 05:59:24 pm »
@ChrisGreece,

The only significant improvement to your initial post that would have made it easier for your readers, would have been to include a component list with direct links to PDF datasheets of the semiconductors and relay.

Your relay coil resistance is 70R  +/-10% and it  needs 75% min. of its nominal 5V rating to  pull in.   That  gives a minimum current to guarantee pull-in of 60mA.  Pull-in would be impossible with R6 and D4  in circuit - both must be shorted  out.

Your MMBT2222A has a min. hFE of 75 @IC=10mA rising to 100 @IC=150mA, so I estimate its probably min. 85  @IC=60mA.   It would therefore need a min. IB of 0.7mA just to pass the required collector current, and at least double that to guarantee its saturated, so not dropping too much voltage and preventing pull-in.   You therefore need to target min. 1.5mA IB, and preferably for saturated switching applications a forced hFE of  10, i.e. IB=IC/10, which for the max. possible coil current of 75mA would be 7.5mA IB.

Unfortunately the min. CTRR of a CT817 is 50% so you need min. 3mA IF through its LED, and preferably double that to ensure it saturates and to have margin for ageing.   As the grounds and 5V supply either side of it aren't isolated, it therefore does more harm than good and should be removed and bypassed by jumpering pins 2 to 3.  You'll also need to reverse LED D5.    Assuming a 5V logic level driving it with maybe 0.5V droop  at the I/O, you should then get an adequate 3.5mA IB.  If you need to drive it from 3.3V logic you'll have to either short out D5 or reduce R8 to 82R.      N.B. The mod as described will invert the logic:  logic '1' = relay on.

« Last Edit: May 09, 2020, 10:22:20 pm by Ian.M »
 
The following users thanked this post: MK14

Offline MK14

  • Super Contributor
  • ***
  • Posts: 4540
  • Country: gb
Re: Relay with Optocoupler problem
« Reply #17 on: May 09, 2020, 10:15:12 pm »
As others have said. You don't seem to need the opto-isolator. So, feel free to remove it.
But I was currious, as to how it got there in the first place, hence this post.

I've been trying to clarify the confusion surrounding the opto-isolator.

Firstly, there seems to be errors, in the copying of the schematics from place to place. Maybe, by multiple people.
The (what I assume) original source (picture and links, at bottom of post), has the resistor to the opto-coupler, as a 200 Ohm resistor, NOT 1K.
Which ties in with what I, and other(s), have been saying in this thread. 1K is too big.
I suggested 330 Ohms, and said lower would be better. So, 200 Ohms, sounds good.

The reason for the opto-isolators, seems to be because the mcu could be 5V, or 3.3V (since they claim Raspberry PI compatibility), or some other voltage. Also, the two different power supplies (potentially very weak 3.3V) and the relay 5V supplies. Shouldn't be connected together at all, even as regards the grounds.
Because they could be at completely different (relative) potentials.
E.g. One is earthed, the other is floating, with a weak mains voltage biasing it (think cheap, not best of quality, USB 5V chargers, which can give you a slight tingle, if you touch the output, because you are earthed, and it is not, so potential differences, can occur).

The 8 relay board, needs, something like 600ma+, (8x 70ma relays, plus a bit of safety margin), which could easily be too much, for the (potentially) small, mcu power source. There seems to be a jumper option, to choose between combined and isolated supplies (details vague, so I'm partially guessing).

Schematic source:
http://wiki.sunfounder.cc/images/c/cb/8_Relay_Module_schematic.zip

From page:
http://wiki.sunfounder.cc/index.php?title=8_Channel_5V_Relay_Module

tl;dr
In the (multiple ?) copying process. Details, such as 200 Ohms opto drive resistor, rather than 1K, and proper isolated supply rail techniques, seems to have been miscopied, or removed on purpose.

« Last Edit: May 09, 2020, 10:30:55 pm by MK14 »
 
The following users thanked this post: Per Hansson

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12865
Re: Relay with Optocoupler problem
« Reply #18 on: May 09, 2020, 11:21:17 pm »
If you are designing a general purpose relay board and don't want us to heap hot coals of criticism upon your head, consider this checklist:
  • Optoisolated inputs should have TWO terminals for each opto's input side, so the user can choose to drive any of  them active high or active low.
  • Adequate clearance between the inputs of adjacent optos should be provided, so they can safely be driven by logic at significantly different ground potentials.  The clearance under each opto between its output and input sides shall not be compromised, and if its possible without excessively weakening the board it should be slotted under the optos for maximum creepage distance.  No supply or ground track shall cross the isolation barrier.  There must also be enough clearance between adjacent mains rated relays for them to be safe if one is used for mains and the other for low voltage switching.
  • Either the opto CTRR should be 200% or greater or there should be a decent amount of current gain after the optos so they can be driven by relatively weak logic outputs, not capable of more than a couple of mA. e.g. use MOSFETs  to drive the relays if you are using  5V relays with a 5V supply.  Higher supply voltages can use a ULN2803, but its on state VCE(sat) drop must be allowed for. N.B. the drivers should be rated for at least 2.5x the coil voltage.
  • The back-EMF from the relay coils should be adequately suppressed.  Anti-parallel diodes, while commonly used, slow the flux decay, and thus contact opening, increasing the risk of contact burn unless you add a resistor in series with each diode, equal to the coil resistance, to limit the back-EMF across the coil to -Vcc, (i.e. the driver sees 2*Vcc) so the flux decays approx. as fast as it built up at switch-on.  In the case of ULN2803 or similar that has an array of diodes with a common return pin, add an adequately rated zener or TVS diode with a breakdown voltage equal to the coil voltage between the diode common and Vcc.
  • Provide a footprint for a regulator (TO-220, with required caps, divider resistors etc. pre-fitted), or install an on-board regulator for the relay Vcc supply, that can tolerate up to 35V input, either LDO or with a bypass jumper so it can be run at the nominal relay voltage.  Mount it so a heatsink can be fitted for operation at high supply voltages.
  • To reduce input voltage and current requirements, indicator LEDs (+ their series resistors) should EITHER be in parallel with the relay coils OR driven by independent buffers. The LEDs should not be directly connected to either side of the optos.  If across coils that don't have anti-parallel diodes directly across them, the LEDs themselves will require an anti-parallel diode directly  across each LED to protect them from the clamped back-EMF.  Edit: changed in line with MK14's comments below
  • All off-board connections should be on pluggable screw terminal blocks and the manufacturer's part no. supplied so spares of the plug in part with the screws can be purchased.   
  • Additionally there should be unpopulated footprints for optional pin or female headers, (on the output at a pin pitch suitable for mains use if the relays are rated for AC), and for a barrel jack for DC input.
  • Uncommitted bus strips either side of the input header footprints should be  provided so the opto LEDs can be strapped with a common supply or ground.
  • If the relays have their common contact pin  between their coil pins, the board should be slotted either side of it or even on three sides round it to preserve the maximum possible creepage distance.
  • Provide footprints to allow snubbers, TVS diodes or varistors to be added across the relay contacts.
  • Provide min. 4mm mounting holes in each  board corner with a generous clearance to any track on *BOTH* sides of the board, even if a metal hex standoff is used.  Additional mounting holes  should  be provided if the relays are large/heavy or there are more than eight of them.

Please *THINK* before deleting any item from this checklist and only do so if its incompatible with your application requirements.

@MK14: unfortunately most cheap relay boards and many more expensive ones seem to have been specified by Chinese whispers and designed by unqualified draftsmen with absolutely no exposure to western safety standards.  I suspect that if they F**K up too badly designing death-trap USB chargers, they get transferred to relay boards!
« Last Edit: May 10, 2020, 12:42:20 am by Ian.M »
 
The following users thanked this post: MK14, Per Hansson, I wanted a rude username

Offline MK14

  • Super Contributor
  • ***
  • Posts: 4540
  • Country: gb
Re: Relay with Optocoupler problem
« Reply #19 on: May 09, 2020, 11:50:30 pm »
I like your bullet points. With one query. Allowing a higher back emf voltage, for faster decay, AND having an led (plus series resistor), in parallel. Could be problematic.
Older generation leds (even if the datasheet didn't allow it), could usually be fairly tolerant of reverse biasing.
But, modern leds, usually have (and really can break if it is not respected), something like only 5V (-) of reverse bias voltage, allowed in the datasheet.
A quick google search comes up with:
https://www.vishay.com/docs/83171/tlur640.pdf
Which seems to allow an absolute maximum of (-) 6V.

It can be easily resolved, e.g. by putting a small signal diode across the led (before the series resistor), or wiring it up in a different way, which doesn't expose it to the high voltage version of the back-emf.
I'd still be worried, that the relay coil could be too harsh for an led, but it should work, in theory.

  • The back-EMF from the relay coils should be adequately suppressed.  Anti-parallel diodes, while commonly used, slow the flux decay, and thus contact opening, increasing the risk of contact burn unless you add a resistor in series with each diode, equal to the coil resistance.  In the case of ULN2803 or similar that has an array of diodes with a common return pin, add an adequately rated zener or TVS diode with a breakdown voltage equal to the coil voltage between the diode common and Vcc.

  • Indicator LEDs (+ their series resistors) should be in parallel with the relay coils, not directly connected to either side of the optos.
 
The following users thanked this post: Ian.M

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12865
Re: Relay with Optocoupler problem
« Reply #20 on: May 10, 2020, 12:23:19 am »
*EXCELLENT* point.   Yes, an anti-parallel diode directly across the LED would be required.    I'll note that in my list.  With a series resistor that limits If to no more than 50% of its max rating (and a diffuse high efficiency LED shouldn't even need that much current to be clearly visible in anything short of direct sunlight) , the anti-parallel diode + the LED's own junction capacitance will effectively protect it against transients from the relay.
 
The following users thanked this post: MK14

Offline eblc1388

  • Frequent Contributor
  • **
  • Posts: 394
  • Country: gb
Re: Relay with Optocoupler problem
« Reply #21 on: May 10, 2020, 12:40:02 am »
I would add that:

Optoisolated input should be current rated, with range of operating current clearly stated. User must include current limiting resistor to comply with the requirement.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12865
Re: Relay with Optocoupler problem
« Reply #22 on: May 10, 2020, 12:54:25 am »
Hmm. *most* people will want to drive such a board from logic so will want on-board input resistors.   Assuming 1.2V Opto-LED Vf and a design input current of close to 1mA from 3.3V logic (only possible because of a  high gain driver on the opto output), the input resistor would be 470R.  Assuming the input resistors are 1/4W, they'd be OK up to 12V.  Above that, they'd need to be swapped out or additional resistors used. 

If you think there is a significant probability of under-qualified industrial electrician idiocy (e.g miswiring inputs to 230V AC) fit socketed optos and socketed input resistor arrays retained by zip ties through holes either end of  each socket, and if its going to  be a commercial product, get your zip ties custom printed with your company name for warranty validation, or apply some other sort of warranty seal!

« Last Edit: May 10, 2020, 01:03:13 am by Ian.M »
 

Offline Manul

  • Super Contributor
  • ***
  • Posts: 1109
  • Country: lt
Re: Relay with Optocoupler problem
« Reply #23 on: May 10, 2020, 01:40:40 am »
The back-EMF from the relay coils should be adequately suppressed.  Anti-parallel diodes, while commonly used, slow the flux decay, and thus contact opening, increasing the risk of contact burn unless you add a resistor in series with each diode, equal to the coil resistance, to limit the back-EMF across the coil to -Vcc, (i.e. the driver sees 2*Vcc) so the flux decays approx. as fast as it built up at switch-on.

My addition for high tech relay module.

Even faster decay and more elegant would be to use a diode + zenner diode with a parallel resistor, because:

1. Back-emf voltage can be clearly defined and selected to be more close to actual transistor maximum voltage.
2. After clamping phase is finished, only damping resistor will be active giving more speed.
3. Damping resistor can be selected for actual critical damping, will give optimum final decay time and will prevent even the smallest oscillations at the end of decay (oscillations do exist in the classical diode clamp when voltage goes below Vf).
 
The following users thanked this post: MK14

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12865
Re: Relay with Optocoupler problem
« Reply #24 on: May 10, 2020, 02:39:33 am »
That's usually over-kill for a single relay with a 12V or lower voltage coil,  although not too far from what I suggested for the ULN2803, as drivers that can handle a 30V back-EMF transient are dirt common and dirt cheap.  A diode + matched resistor is a good cheap compromise for a faster flux decay than a plain anti-parallel diode. 

However, as you increase the relay coil voltage or need faster contact opening, Zener or TVS clamping becomes more attractive.  Also note that if there's a LED indicator circuit across the coil it will serve to damp the residual oscillation fairly effectively so the damping resistor probably isn't required.   If you use a bidirectional TVS diode with a working voltage  greater than Vcc, you then don't need any other parts, which is useful for retro-fitting simple anti-parallel diode designs that have proved to be unsatisfactory. 

Another option that may be cheaper than a beefy Zener or TVS diode for large relays and contactors, *if* you have a good idea of the stored energy (i.e coil inductance and current), is a diode + capacitor with bleed resistor snubber.  The capacitor is sized to ring with the coil inductance to the desired peak back-EMF, and the resistor is chosen for a time constant of no more than 50ms with the capacitor which will ensure its practically fully discharged in no more than 0.2 seconds.   However to design a D+RC or D+matched R snubber you must know the relay coil characteristics so they are unsuitable for off-board customer supplied relays.
 
The following users thanked this post: MK14, Per Hansson


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf