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

0 Members and 1 Guest are viewing this topic.

Offline ChrisGreece52Topic starter

  • Frequent Contributor
  • **
  • Posts: 829
  • Country: gb
  • Electronics Engineer - Hacker - Nerd
Re: Relay with Optocoupler problem
« Reply #25 on: May 10, 2020, 09:54:32 am »
MK14, i have to say i totally agree with your statement about poor designs floating on the web since i have used one here  :P
Also 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 dumb  :P

Edit  : Of course after connecting these two areas to the ground plane the problem was fixed.
« Last Edit: May 10, 2020, 10:46:30 am by ChrisGreece52 »
 
The following users thanked this post: MK14

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12910
Re: Relay with Optocoupler problem
« Reply #26 on: May 10, 2020, 10:40:16 am »
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  dead
  • With 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.
« Last Edit: May 10, 2020, 10:48:20 am by Ian.M »
 

Offline ChrisGreece52Topic starter

  • Frequent Contributor
  • **
  • Posts: 829
  • Country: gb
  • Electronics Engineer - Hacker - Nerd
Re: Relay with Optocoupler problem
« Reply #27 on: May 10, 2020, 10:47:50 am »
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.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12910
Re: Relay with Optocoupler problem
« Reply #28 on: May 10, 2020, 10:49:44 am »
Yes, we were having an editing race.  See my edit above replying to your edit.
 

Offline Manul

  • Super Contributor
  • ***
  • Posts: 1124
  • Country: lt
Re: Relay with Optocoupler problem
« Reply #29 on: May 10, 2020, 11:15:52 am »
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.
 
The following users thanked this post: MK14

Offline ChrisGreece52Topic starter

  • Frequent Contributor
  • **
  • Posts: 829
  • Country: gb
  • Electronics Engineer - Hacker - Nerd
Re: Relay with Optocoupler problem
« Reply #30 on: May 10, 2020, 12:24:11 pm »
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.
I 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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf