Relay with Optocoupler problem - Page 1
Forum section: electronics / beginners

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: May 09, 2020, 12:08:21 pm
content: 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 usedSFH690BT : 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.pdfProblem : 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.

author: MK14
author_rank: Super Contributor
timestamp: May 09, 2020, 01:20:24 pm
content: 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.

author: Manul
author_rank: Super Contributor
timestamp: May 09, 2020, 01:24:51 pm
content: Welll, there is not enough current for relay. Mostly because relay current in your circuit goes through 510 resistor and LED.

author: wraper
author_rank: Unknown
timestamp: May 09, 2020, 01:27:32 pm
content: 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.

author: Manul
author_rank: Super Contributor
timestamp: May 09, 2020, 01:32:42 pm
content: 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.

author: MK14
author_rank: Super Contributor
timestamp: May 09, 2020, 01:36:01 pm
content: 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

author: MK14
author_rank: Super Contributor
timestamp: May 09, 2020, 02:01:23 pm
content: Quote from: wraper on May 09, 2020, 01:27:32 pmQuote from: Manul on May 09, 2020, 01:32:42 pmAlthough 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.

author: Manul
author_rank: Super Contributor
timestamp: May 09, 2020, 02:22:58 pm
content: 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).

author: MK14
author_rank: Super Contributor
timestamp: May 09, 2020, 02:44:41 pm
content: Quote from: Manul on May 09, 2020, 02:22:58 pmI 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.

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: May 09, 2020, 02:50:28 pm
content: 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)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)

author: Manul
author_rank: Super Contributor
timestamp: May 09, 2020, 03:03:34 pm
content: Quote from: MK14 on May 09, 2020, 02:44:41 pmI'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.

author: MK14
author_rank: Super Contributor
timestamp: May 09, 2020, 03:47:32 pm
content: Quote from: Manul on May 09, 2020, 03:03:34 pmI 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.

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: May 09, 2020, 04:05:03 pm
content: I found a similar schematic to what i have here :http://wiki.sunfounder.cc/index.php?title=2_Channel_5V_Relay_ModuleHaving 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.

author: MK14
author_rank: Super Contributor
timestamp: May 09, 2020, 04:38:56 pm
content: Quote from: ChrisGreece52 on May 09, 2020, 04:05:03 pmThat 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.

author: Manul
author_rank: Super Contributor
timestamp: May 09, 2020, 04:50:10 pm
content: MK14, I totally agree with your justification and I really understand the things you say. Yet, I still think, that back-emf protection isnot 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.

author: MK14
author_rank: Super Contributor
timestamp: May 09, 2020, 05:27:05 pm
content: Quote from: Manul on May 09, 2020, 04:50:10 pmI 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 goAs 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;drThere seem to be plenty of "bad" (but they still might work), circuits floating about the web. Which sometimes gets modified, rather than properly designed.

author: Ian.M
author_rank: Super Contributor
timestamp: May 09, 2020, 05:59:24 pm
content: @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. hFEof 75 @IC=10mA rising to 100 @IC=150mA, so I estimate its probably min. 85 @IC=60mA. It would therefore need a min. IBof 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 hFEof 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 IFthrough 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.

author: MK14
author_rank: Super Contributor
timestamp: May 09, 2020, 10:15:12 pm
content: 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.zipFrom page:http://wiki.sunfounder.cc/index.php?title=8_Channel_5V_Relay_Moduletl;drIn 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.

author: Ian.M
author_rank: Super Contributor
timestamp: May 09, 2020, 11:21:17 pm
content: 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 belowAll 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 byChinese whispersand 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!

author: MK14
author_rank: Super Contributor
timestamp: May 09, 2020, 11:50:30 pm
content: 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.pdfWhich 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.Quote from: Ian.M on May 09, 2020, 11:21:17 pmQuote from: Ian.M on May 09, 2020, 11:21:17 pm

author: Ian.M
author_rank: Super Contributor
timestamp: May 10, 2020, 12:23:19 am
content: *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 Ifto 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.

author: eblc1388
author_rank: Frequent Contributor
timestamp: May 10, 2020, 12:40:02 am
content: 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.

author: Ian.M
author_rank: Super Contributor
timestamp: May 10, 2020, 12:54:25 am
content: 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!

author: Manul
author_rank: Super Contributor
timestamp: May 10, 2020, 01:40:40 am
content: Quote from: Ian.M on May 09, 2020, 11:21:17 pmMy 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).

author: Ian.M
author_rank: Super Contributor
timestamp: May 10, 2020, 02:39:33 am
content: 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.

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: May 10, 2020, 09:54:32 am
content: MK14, i have to say i totally agree with your statement about poor designs floating on the web since i have used one hereAlso seeing your second post about the 8 channel relay board i see where the optocoupler would be useful. That is not in my case where i have a single regulated power supply.Ian.M, you are right i should have have attached the corresponding datasheets so that there would be no room for error.Fortunately i was clear about the different diode and optocoupler used. Also i cannot thank you enough for the analysis you have done here. It really gave me an insight of the circuit. I had just copied and did not think about how it would function. Changing the logic should not be a problem since the code is finished already i will have to change a few bits of it. I will drive the transistor directly.Furthermore the bullet points will be copied and kept as notes with the additions from MK14. The points you made WILL be very useful for me. Thank you so much.Also Manul and eblc1388 thank you for your feedback and additions so much.TBH i have little to no experience in designs that implement optocouplers, thus i just found a basic "proven" schematic to base my design on.In addition from reading what you all had to say i made the changes to the board but something is not yet right. I am driving the MMBT2222A directly but the relay does not get activated. I will post the new schematic below for you to take a look. Its straight forward the MCU pin in series with an LED and a resistor connected to the 2222. I will take a look at the joints , diode orientation and bridges then start taking some measurements. Its odd that the relay is not active when a logic "1" is applied. I would like to troubleshoot on my own for a bit then ill post what the culprit was (if I solve the issue).UPDATE: It was too naive of me to rely that my PCB design skills would not fail me. This whole time while troubleshooting (since before i posted the question on the forum) the second pin of the transistor was floating.See when you have made a polygon pour that is used as a ground plane and is cut in pieces by traces on the bottom of the PCB, its good practice to connect these pieces together.I will attach a picture below of my bottom layer. It is evident that the area marked as ground on the pin of Q2 and Q1 respectively is not connected to the ground plane.In the photo i marked the "ground" areas with red. As seen they are not connected to the ground plane at all. Call it a rookie mistake but i would call it just dumbEdit : Of course after connecting these two areas to the ground plane the problem was fixed.

author: Ian.M
author_rank: Super Contributor
timestamp: May 10, 2020, 10:40:16 am
content: I assume nothing is shorted or open circuit, all components are as specified on the schematic, and you will test by directly applying +5V to the board input. If possible, use a 5V supply current limited to 100mA. All voltages to be measured with respect to ground (Q2 emitter). Here's a troubleshooting checklist :First check the voltage at the collector of Q2 with no input to its base. It should be 5V. If not something is pulling it down e.g. bad or miswired Q2. If it reads approx 0.7V, you've mixed up the collector and the base.Apply 5V to the input. Does D5 illuminate? If not, ground the base of Q2. If D5 still doesn't illuminate its backwards (or deadWith 5V still applied to the input, check the collector voltage of Q2. It should be about 0.3V, and the relay should be activated. If not, check the supply voltage. If its collapsed below 4.5V, D6 is probably reversed. If the supply's OK but Q2 collector voltage is high, either Q2 collector and emitter are swapped or Q2 is bad, or R8 is the wrong value, significantly higher than it should be.Edit: Well at least that's easy to fix with a couple of bodge wires. What PCB package are you using? It should have flagged two errors that polygons were not connected to their associated net. Never ignore errors even if they are apparently trivial. It can help to check ground (or power) is actually routable before you flood fill a plane.

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: May 10, 2020, 10:47:50 am
content: Thank you for your reply Ian.M i added an update to my previous post. Pin 2 of both transistors (that was supposed to be connected to ground) was floating.

author: Ian.M
author_rank: Super Contributor
timestamp: May 10, 2020, 10:49:44 am
content: Yes, we were having an editing race. See my edit above replying to your edit.

author: Manul
author_rank: Super Contributor
timestamp: May 10, 2020, 11:15:52 am
content: It has been talked before, and if someone wants to have active low and active high option, XOR gate may be useful. May also be made with a jumper, to select which input of gate is used.

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: May 10, 2020, 12:24:11 pm
content: Quote from: Ian.M on May 10, 2020, 10:40:16 amI am using Altium Designer 20. There were no ERC or DRC errors. In addition there are two similar issues with the top 5V plane.Besides i knew that connections needed to be made between the GND polygon areas since Altium marked unrouted connections. After pouring the polygons I run the traces needed to connect the areas that were cut by signal traces. That was done on both planes on all nets marked by Altium thus i did not consider that there might be floating pins.As for the XOR gate Manul I have to say that since i have already the PCB's at hand i would like to do as little modding as possible. But that will be useful for future reference. In my case i have used to the relay signals being active low so if i were to design the board again considering the current setup i would just use an inverter. Still if it able to be solved by a bit of code its no use to try adapting the pcb.