Why can’t I trigger my relay?
Ask QuestionAsked todayActive todayViewed 53 times21
I guess I should preface this with the fact that I’m definitely a beginner when it comes to electronics and circuit design/debugging. Thanks for the help!
I recently developed a circuit board for use with my Raspberry Pi 3 A+. The purpose of the board is to accept various inputs, but also toggle some relays (two solid state, and two regular). My current issue is that I can’t seem to turn relays C and D on. I’d hoping someone could help me find out where I went wrong.
Here’s a snippet of my schematic for reference:
This is what I know so far:
- All the outputs on the pi are working properly (I can see ~3.3v at R2 – R5 when I toggle the respective pins on).
- All channels of the optocoupler are working properly (I can see ~5v at R6 – R9 when I toggle the respective pins on).
- I’m unsure of exactly how to tell if a transistor is doing it’s job with a multimeter, but if I plug a resistor and led into J8 or J9 I can verify those channels are working as the led lights up when I toggle the respective pin on.
- I can say it’s not the protection diode installed wrong, as removing it had no effect.
- If I run a wire from GND to pin 2 of either of the relays, they click.
My best guess right now is that I chose the values for R6 – R9 incorrectly for the application. When picking the values for R2 – R5, I had a good reason (I chose a value that would ensure that even if all 4 channels of the optocoupler were on at once, I would not exceed the RPi’s 50ma limit on the 3.3v rail). However, when designing the circuit, I couldn’t find any rationale as to why one would choose a resistor value to go in front of the base of a transistor. I also got extremely confused trying to decypher the datasheet for the MMBT3904. In the end, I just recycled a resistor value I was already using in the circuit.
resistorsrelayraspberry-pischematicsopto-isolatorshareedit follow flagedited 3 hours agoasked 9 hours agoToms Jensen2122 bronze badges New contributor
- 1how are the grounds connected? – jsotola 7 hours ago
- 1On my PCB, I filled all the area between the traces with a common ground plane. Everything marked GND is connected directly to that. – Toms Jensen 7 hours ago
- 1Test if the relay portion is actually working (irrespective of your control circuit): take a short wire from ground and touch it to pin 2 of the relay. You should hear it click. – td127 7 hours ago
- 1Clicking confirmed. – Toms Jensen 6 hours ago
- 1the relay power grounds are not separate from the RPi ground? … what’s the point of using opto-couplers then? – jsotola 6 hours ago
- 1That was previously brought to my attention. I decided to keep the optocoupler to distance potentially noisy circuitry (120v AC) as much as I could from the digital portion. To be honest though, I’m unsure if that is grounded in reality or wishful thinking. – Toms Jensen 6 hours ago
- @Toms Jensen, you design looks nice. I am writing up the draft version of my answer. It would be nice if you can make comments or counter suggestions as I go along. Have a nice project. Cheers. – tlfong01 4 hours ago
- 1You get a click, good – your relay is fine. So now, when you turn assert your on condition the transistor should be saturated and its collector voltage something like 0.3V. Do you see that? – td127 4 hours ago
What is the resistance of the coil on the relay? if it’s low, your connecting +5v to ground thru the 3904 transistor. What does the +5v do when the relay is enabled?shareedit follow flag answered 6 hours agouser2625671 New contributor
- 1According to the datasheet it looks like the resistance of the coil is 70 ohms. – Toms Jensen 6 hours ago
- 1I also don’t think I understand the second part of your question… – Toms Jensen 6 hours ago
How come my relays C and D do not turn on?
I read your design and found everything looking good. I will later look at the datasheets you referred and see if there are other complications.
But first thing first, I would suggest a couple troubleshooting tricks as summarized below.
Part A – Troubleshooting suggestions
A.1 Preparation for offline testing.
(a) Remove the 120VAC 1.5A load and put it aside. The reason is that when the relay switch is on, you should hear a click sound, and another click sound when switch is off.
In other words, there is no need to use the high voltage, heavy current load, especially if it is a big motor which generates EMI spikes and noises. If you like, you can use a LED in series with a 1k as the load and status indicator.
(b) Have you multi-meter ready to measure voltage in a range less than 5V.
(c) It would be nice if you have a NE555 timer module and set it to very roughly to 5Hz (Note 1) , 50% duty cycle to be used as input signal at T1. But this is not at all necessary. You can just use a jumper wire and by hand connect T1 to 0V (Ground) and 3V.
Note 1 – relay switch max frequency is roughly 10Hz, ie, it cannot toggle more than 10 times a second.
/ to continue, …
(1) TCMT1600, TCMT4600, TCMT4606 Optocoupler, Phototransistor Output, AC Input, Single/Quad Channel (If abs max 60mA, opr 50mA, CTR (Ic/If) @Vcc 5V, If 5mA = 80% min)) – Vishay Semi 2015jul21
(2) MMBT3904 40V NPN Small Signal Transistor (Ic abs max 200mA) – Diodes
(3) 1N4148WS General Purpost (If 300mA cont)Fast Switching Diode – SMC
(4) SRD 03/05/06/09/12/24/48VDC Relay Datasheet – Songle
(5) How to use a JD-Vcc Relay? – tlfong01, EE SE 2020jun13
(6) Transistor as a Switch – Electronics Tutorials
(7) 2N3904 General Purpose Transistors NPN BJT Silicon (40V, 200mA, Vce(sat) 0.2V max @ 10mA, hFE = 100 min, 300 max @ 10mA) – On Semi
/ to continue, …
Appendix A – Relay, Optocoupler Sample Specifications
Appendix C – The OP’s design with additional status LEDs
Appendix D – Analysis of the OP’s relay switch driver part of design (ie, without the front optoisolated input section)
Appendix E – 2N3904 NPN BJT Datasheet Reading Make Simple Part 1 of 2
Appendix F – 2N3904 NPN BJT Datasheet Reading Make Simple Part 2 of 2
Newbies often found semiconductor devices datasheets difficult to understand. There are many reasons, including the following.
Take the simplest semiconductor device the diode as an example. Let me first explain what is meant by linearity. If the relation of two variables, say independent variable x and dependent variable y, and
y = 3x.
Then we say the relation between y and x is linear.
Now if z = square of x, or z = x**2, or power of 2, or higher, then we say z and z has a non-linear relationship.
The 2N3904 can be over simplified as two diodes glued together, and the current I vs voltage V relationship is also non-liner as shown below:
Ideal diode equation – Libretests
/ to continue, …
shareeditdeleteflagedited 4 mins agoanswered 4 hours agotlfong0169044 silver badges77 bronze badges
- 1Hey, thanks for taking the time to post! A) Indeed, for testing, I have made sure to disconnect any potentially unsafe voltages. B) Yes, I have a multimeter handy. C) I unfortunately don’t have a 555 timer on hand, but I can trigger parts of the circuit with a jumper wire or my Raspberry Pi. – Toms Jensen 3 hours ago
- @Toms Jensen, (1) Thank you for your confirmation. As I said, NE555 timer is just a handy tool for second stage troubleshooting. For initial troubleshooting. using a jumper wire to select 0V or 3V signal to input the relay is already very effective. (2) You mention that: (a) “I couldn’t find any rationale as to why one would choose a resistor value to go in front of the base of a transistor. (b) I also got extremely confused trying to decypher the datasheet for the MMBT3904 Reading transistor 3904 is a bit advanced. Perhaps I can later give an introduction to newbies. / to continue, … – tlfong01 2 hours ago
- You need to have some prerequisite knowledge in suing NPN BJT as a switch, to understand 2N3904 NPN BJT datasheet. I would suggest you to first read Ref 6 of my answer, to know the basic theory of using NPN BJT as a switch (that is hwat your are doing in your relay design) and then skim Ref 7 the 2N3904 datasheet. The most important parameters for using 2B3904 are the following: (a) hFE Ic/Ib current gain), (b) max Ic. / to continue, … – tlfong01 1 hour ago
- The optocoupler datasheet is a bit hard to understand, unless you already know NPN BJT. That is why I suggest you to forget the optocoupler part, and focus on the 2N3904 driving relay switch part. It might take you some time to digest things, but you don’t need to understand everything before you move. So I will perhaps wait for a couple of days before you come back to ask more newbies questions, before we move on. Happy learning. Cheers. – tlfong01 1 hour ago
Leave a Reply