Want to improve this question? Update the question so it’s on-topic for Electrical Engineering Stack Exchange.
Closed 22 hours ago.Improve this question
After frying a Rpi with this montage 6 months ago:
I followed advice from kind users here and modified the wiring to this back in February:
It has been working fine for 6 months and suddenly yesterday, this montage fried a Rpi again, probably due to a short circuit or maybe PWM failure pushing back current in GPIO.
Now looking for advice on how to protect GPIO on the Rpi. Diode or any other economic solution… PLEASE BE EXPLICIT AND VISUAL IN YOUR ANSWER as I’m a visual learner. If it requires rewiring please draw it or a particular component added, then please name it.
PWM module I’m using:
The Rpi is powered/grounded via a 12V to USB (5V/3A) converter module, which is wired directly to the 12V battery:
Note: I’ve been almost bullied 😛 on raspberrypi.stackexchange.com for asking this question and only received attitude and a downvote. If I knew answers to my own questions, I would not be asking. As ridiculous as my drawings or the “spaghetti” wiring may be to some people, I’m here to learn, just like thousands of future users stumbling upon this post looking for the same answer as I am. Hoping electronics SE will have more class and patience with a novice simply learning.
Now thinking of replacing the above PWM modules with OPTOCOUPLER isolated ones like the LR7843 (max 30V/161A) which seems to address the flash back current problem that I suspect is happening with the current cheap PWM modules (which do not have an optocoupling feature).raspberry-piprotectiongpioflybackshareedit follow flagedited yesterdayasked 2 days agothat-ben16911 silver badge77 bronze badges
- Do you have any documentation on the PWM board? – Peter Bennett 2 days ago
- Thanks for your interest in my Q. Unfortunately, this is a very cheap Chinese PWM so I don’t have much. Here is the product in question: aliexpress.com/item/4000002805230.html – that-ben 2 days ago
- According to the illustration on the website, with the terminal blocks up, power input should be on the left,and output to the motor on the right terminal block. You appear to have that wired backwards. – Peter Bennett 2 days ago
- @PeterBennett Yes but I was about to write that to the contrary of what the AliExpress “diagram” shows, on the ACTUAL circuit board, is it factory printed that + and – terminals are horizontally aligned. Please refresh, I’ve attached an actual photo of the PWM module. – that-ben 2 days ago
- 1How are you grounding your RPi? – Sparky256 2 days ago
- @Sparky256 Thru an USB connector which comes out of a 12V to 5V/3A USB
- module. This one: aliexpress.com/item/32924128603.html – that-ben 2 days ago
- Welcome to EE.SE! Please draw a schematic. – winny yesterday
- Use TVS diodes as freewheel diodes across every motor or relay. They protect both against reverse EMF and misc spikes coming from noisy motors. Bunch of small decoupling caps next to all connectors don’t hurt either. – Lundin yesterday
- @that-ben: Which is cheaper: Replacing a Raspberry Pi, or ordering a PWM module that works properly and has documentation? – JRE yesterday
- You need to try to make a proper schematic diagram. That is part of learning about electronics. As it is, anyone who wants to help you first has to translate your unclear wiring diagrams into schematic diagrams. tlfong01 has tried to do that for you, but has either made a mistake or else you are doing some very strange things indeed. Help us to help you: Trace out your circuits and draw proper schematic diagrams. If you are on a PC, then you can use the CircuitLab editor built into the site editor. Edit your question, then click on the circuit diagram button. – JRE yesterday
- @JRE OK I will try to make one, but it may take several days. I’ll be back and post on here when I have a diagram. – that-ben yesterday
- @Lundin Could you please elaborate by grossly drawing where to connect what in a SE answer? – that-ben yesterday
- The schematic in the posted answer should make it clear. A more detailed answer here: electrical.codidact.com/questions/276116. – Lundin yesterday
- @Lundin Following the link you’ve just posted, their transistor is frying. My transistor modules never fried and I’ve had them for more than 1 year. They’ve fried 2 Rpi tough! Does that change anything in your answer or does the location of the diode remain the same? – that-ben yesterday
- Since you didn’t post a schematic, it’s not really clear how you are connecting this. But it’s the same issue, reverse EMF. It’s always the case when the thing you control is to be regarded as a coil, be it a relay, solenoid or whatever. – Lundin yesterday
- I’m voting to close this question because questions need proper documentation so people can answer them, please properly document your system and reopen the question. – Voltage Spike♦ 22 hours ago
- @VoltageSpike “You cannot delete this question as others have invested time and effort into answering it.” SE has become a mess. It seems it bears no value to amateurs. Well, have fun. My robot works now. Thanks tlfong01 – that-ben 11 hours ago
The OP is learning how to use Rpi to control a 12V DC motor using a 5V relay without any optical isolation. To adjust motor speed and direction, He uses a PWM controller and a DPDT reverse polarity relay to switch the 12V power supply.
So far so looking good, but he has already fried two Rpi’s!
Now the OP has two questions:
(1) That it might be the “back EMF” flash back current that fries his two poor Rpi’s, and what sort of fly back diodes should be used to prevent frying his third Rpi?
(2) Or using an optocoupler might help to isolate any noises or spikes from going back to Rpi and cause trouble?
Note: The schematic v0.3, after a wild guess.
WARNING: I am just a friendly hobbyist. No guarantee no nothing won’t melt down or blow up.
Flyback Diode Notes
/ to continue, …
/ to continue, …
(3) AliExpress High Power 15A 400W MOS FET Trigger PWM Drive Module Control Panel Controller – US$0.50 tlfong01’s remark: Just one “channel” unidirectional high current switch, nothing to do with PWM, though you can use 20kHz (Electromechanical relays can only do 10Hz) PWM signal to do the switching!
/ to continue, …
- 2Are you sure about the PWM driving the coil of the relay? That looks like a very good way to ruin a relay. – JRE yesterday
- 1@tlfong01 FYI, the relay is a 3.3V control one (not 5V). There is absolutely nothing connected to any of the 5V rails on my Rpi. Not sure if it changes anything in the schematic. – that-ben yesterday
- @JRE, Well, but #that-ben has been running it months. His circuit design is not at all that of a friendly newbie, but a ninja grade industrial level innovation, also future proof. His Albert Einstein style ugly drawings show the beauty of the harmony of the Universe. I see him as a prophet without honour in other forums (Mark 6:1-6). – tlfong01 yesterday
- Ah, let me see, There are two relays here. For D4184, VGS(th) is 1.7V min, 2.1V typ, 2.6V max, so is Rpi 3V3 logic friendly. The OP does not tell us if his 5V relay is High or Low trigger. If High Trig, then everything should go well. If Low Trig, then there are a couple of workarounds. See Refs 10, 11. – tlfong01 yesterday
- 1There is no 5V relay anywhere in my project. The Rpi relay (marked BESTEP) is control 3.3V and outputs 12V to the inverse polarity relay which is control 12V output 12V. – that-ben yesterday
- Ah, there seems to be some confusion. I mean 5V relays are usually powered by 5V power, but the control signal at the IN terminal is 3V3. You might like to read Ref 11 to clarify. – tlfong01 yesterday
- 1OK but it’s not the case with my relay. It’s a JQC3F-03VDC-C (3.3V). There is zero 5V rail anywhere in my project. On the FIRST version yes there was a 5V relay and a 5V rail, but those have been replaced in the SECOND version as shown in Q. – that-ben yesterday
- 1Ah, I overlooked that your relay is actually 3V3, not 5V. My apologies. I will correct the error later. Cheers. – tlfong01 yesterday
Not the answer you’re looking for? Browse other questions tagged raspberry-pi protection gpio flyback or ask your own question.
Question The OP is learning how to use Rpi to control a 12V DC motor using a 5V relay without any optical isolation. To adjust motor speed and direction, He uses a PWM controller and a DPDT reverse polarity relay to switch the 12V power supply. So far so looking good, but he has already fried tw…
tlfong013398@JRE, Well, but #that-ben has been running it months.
His circuit design is not at all that of a friendly newbie, but a ninja grade industrial level innovation, also future proof.
His Albert Einstein style ugly drawings show the beauty of the harmony of the Universe.
I see him as a prophet without honour in other forums (Mark 6:1-6).
For D4184, VGS(th) is 1.7V min, 2.1V typ, 2.6V max, so is Rpi 3V3 logic friendly.
The OP does not tell us if his 5V relay is High or Low trigger. If High Trig, then everything should go well. If Low Trig, then there are a couple of workarounds. See Refs 10, 11.
that‑benThere is no 5V relay anywhere in my project. The Rpi relay (marked BESTEP) is control 3.3V and outputs 12V to the inverse polarity relay which is control 12V output 12V.
tlfong01Ah, there seems to be some confusion. I mean 5V relays are usually powered by 5V power, but the control signal at the IN terminal is 3V3. You might like to read Ref 11 to clarify.
that‐benOK but it’s not the case with my relay. It’s a JQC3F-03VDC-C (3.3V). There is zero 5V rail anywhere in my project.
On the FIRST version yes there was a 5V relay and a 5V rail, but those have been replaced in the SECOND version as shown in Q.
tlfong013398Fri 22:33Ah, I overlooked that your relay is actually 3V3, not 5V. My apologies. I will correct the error later. Cheers.
Now the good news. The so called “PWM module” is actually only a high frequency (20kHz) current switch with two power MOSFETs connected in parallel. The good news is that both MOSFETs have built in flyback diodes. So you don’t need to take care of that.
tlfong01As you suggested, you can replaced your cheapy no optocoupler relay by one with optocoupler, or even with JD-Vcc jumper for “Total Optical Isolation”.
tlfong01@that-ben Ah your schematic looks good.
that‐ben513It’s not done yet.The issue I’m facing now is that the components in Circuit-Diagram.org are good, but the DPDT does not have one with 8 pinsIn my setup, my DPDT has 8 pins and I cross linked +/- in a X shape to make it a reverse polarity relay which enables my robot to spin the motor forward and backward.
tlfong01Fri 22:45Ah, please read Ref 2 where I commented that you choice of flyback diode does not seem a good.
You may like to read two more reference below on how to select a flyback diode.
But as I just pointed out, the fake PWM module already has flyback’s so you don’t need to bother.
that‐ben513Oh really?So you think the Rpi did not fry because of the PWM?I don’t see any diode on the PWM module tough!There are 3 resistors, 1 LED and 2 transistors.
tlfong01Yes, don’t reinvent wheels. Double flyback looks stupid.
that‐ben513Also the description (even on different AliExpress store pages) never mention diode protection 😕
tlfong01Ah, the flyback is built into the big black guy. See my schematic v0.3.
that‐ben513You mean this:
tlfong01Fri 22:55Ah, I have inserted the D4148 power MOSTFET datasheet in the reference list as Ref 1. Look at the pictures there! Ah, bed time! So I call it a day. Nice learning new things with you. Good night and cheers.
that‐benThank you so much for your time. I hope I can accept your answer on SE.
tlfong01Ah, yes, I have been playing with power MOSFETs and power NPN BJTs as switches for some time. I noticed that all huge current switches has built in flybacks, otherwise the customers will curse half of the Universe. Bye.
The last message was posted 1 day ago.