Help - Arduino Nano & MOSFET retrofit onto manual switch based control

Thread Starter

Jim_cliff11

Joined Sep 5, 2015
36
Hi all,

I have a machine running three 12v solenoid coils. Currently, control is carried out by manual switching of the negative through SPDT toggle switches. The coils all have a positive 12v common.

I am wanting the ability to additionally control the coils through Arduino with serial comms. As such, I have built a basic PCB consisting of a Nano, N channel Mosfets, diodes, voltage reg etc. I have then retrofitted this PCB into the existing machine wiring using a DPDT toggle ON-ON switch (see attached - apologies on the horrendous drawing!! Should do the job though).


When I flick the DPDT switch to power the nano I can successfully control the coils through a basic program. Mission accomplished.... or so I thought.

Initially I was getting a 0v leak through the voltage reg causing the coils to energise slightly (in manual mode), but wiring the voltage reg 0v to switched 0v fixed this.

When controlling the coils manually through the SPDT toggles, there is a back feed into the PCB (via mosfet drain i think) which lights up the LEDs on the Nano as long as the toggle switch is held. This caused the Nano to get hot, smoke and fail.

Is there a way I can provide some sort of back feed protection to the Mosfet drains when operating the coils through the manual switches? I thought of using diodes with anodes to drain and cathodes to coils, but then I stop the 0v return to battery when trying to operate the PCB.

I cant help but feel this would be much easier if switching the positive, but unfortunately in this case this is not an option.

Any help on this would be greatly appreciated.
Thanks in advance. IMG_6728.jpg
 

dl324

Joined Mar 30, 2015
11,913
When controlling the coils manually through the SPDT toggles, there is a back feed into the PCB (via mosfet drain i think) which lights up the LEDs on the Nano as long as the toggle switch is held. This caused the Nano to get hot, smoke and fail.
According to your wiring diagram, the Nano doesn't have a ground connection when you're controlling the coils with the switches. So what you describe couldn't be happening.

It looks like you'll have a problem when controlling the coils with the Nano and they aren't turned on. That will cause 12V to be applied to the Nano supply pin and current will only limited by the resistance of the coils not activated.

If you remove D4-6 that problem will be eliminated. They weren't needed anyway. D1-3 will protect the MOSFETs from back EMF.

Here's an easier to read version of your schematic:
1603508316597.png
 

Thread Starter

Jim_cliff11

Joined Sep 5, 2015
36
Thanks for the reply Denis. Yes I think your right. I've stripped the circuit right back to just two coils. With NO external power or ground back to the Arduino & mosfets for this test. So basically the only two wires going into my PCB are two mosfet drains, each of which has its corresponding gate linking to D12 and D13 on the Nano.

While operating the manual toggles the Nano 'POW' and 'L' led's light up and flash. If I put the multimeter +ve probe on one MOSFET drain and the -ve on the other MOSFET drain (vdc test) I get +12v. One drain seems to be acting as power in, the other gnd.

I will see if I can draw up a better schematic of how my circuit looks tomorrow. Denis out of curiosity, what program did you use to draw that?
 

dl324

Joined Mar 30, 2015
11,913
what program did you use to draw that?
I use an old freeware version of Eagle. I think the newer versions also have a freeware version, but I don't like the interface changes they made.

The inductor is a custom component and I just used wires to make the Nano outline.
 

Irving

Joined Jan 30, 2016
1,070
Your problem is because your suppression diodes D4 - 6 are returned to the 5v rail not the12v. So current is leaking through the relay coil(s) when they're off and passing through the diode(s) and trying to pull the 5v rail to 12v. You don't need D4-6 so remove them, D1-3 are already doing it for you.

Edit: Oops, I missed Dennis' comment in post #2...
 
Last edited:

dl324

Joined Mar 30, 2015
11,913
The reason IC's burned up is that you triggered the parasitic SCR's that exist in all CMOS logic by increasing the anode to cathode voltage high enough to turn them on.

The absolute maximum VCC for 328P is 6V:
clipimage.jpg
 

Thread Starter

Jim_cliff11

Joined Sep 5, 2015
36
Thanks for the help on this one guys. Dennis and Irving you were both spot on. Removed the diodes and that rectified the problem. Really I should have seen this one, as it was staring me right in the face. Either way, your comments made complete sense.

Out of curiosity.... If the coils didn't have their own suppression diodes built in, I would need D4-D6. But where would I run the diode anode to, which didn't risk powering the Nano (when operating manual toggles), but successfully supressed any voltage spike from the coils in the circuit discussed?

In the past when mocking similar circuits up using a breadboard I've always used a 1N4001 diode between FET drain and +ve rail with no problem. But then in these breadboard mock-ups I've never had manual toggle switches connected to the circuit.

Thanks once again.
Jim
 
Last edited:

dl324

Joined Mar 30, 2015
11,913
If the coils didn't have their own suppression diodes built in, I would need D4-D6. But where would I run the diode anode to, which didn't risk powering the Nano (when operating manual toggles), but successfully supressed any voltage spike from the coils in the circuit discussed?
You'd put the diodes across the coils.

Even when you drive the coils high side, you still put the suppression diodes across the coils. When the field in the inductor collapses, it will generate a voltage of the opposite polarity. The diode prevents the voltage from being more than a diode drop. It also slows down field collapse which makes the solenoid/relay turn off slower.
In the past when mocking similar circuits up using a breadboard I've always used a 1N4001 diode between FET drain and +ve rail with no problem. But then in these breadboard mock-ups I've never had manual toggle switches connected to the circuit.
Did you also have multiple voltages for power? If the solenoids and controlling circuits were operating from the same voltage, you wouldn't have had the problem; even with the extraneous diodes.

There are many types of FETs. When I see the generic acronym, I always think of JFETs because they were the first manufactured and the first that I learned about.
 

RPLaJeunesse

Joined Jul 29, 2018
124
One comment about the catch diodes across the solenoids. Yes, they supress the EMF kick at turnoff. But they also clamp that kick at a low voltage, slowing the current decay in the solenoid (per V = L * di/dt). For a faster turnoff add a zener in series with the diode, making sure the supply + zener voltage is well less than what the transistors can tolerate.
 

Thread Starter

Jim_cliff11

Joined Sep 5, 2015
36
Thanks for the feedback on this guys.

When adding a zener in series with the diode, would the faster turnoff of the coil be much more noticeable?

With regards to the breadboard mockups, I've always supplied the Arduino with the same 12v supply through Vin as what I've used as a common for the coils. Negative is switched through the FET's with a suppression diode from drain to same positive rail as the Arduino Vin. I've never had a back feed issue. But then thinking about it I've never had a toggle switch control on the same coil with the arduino powered down. I might mock this up to try when I get 5 minutes.

Separately, I've heard of people using capacitors between Arduino Vin and 0v to smooth power supply to the PLC, but is this really needed?
 

Irving

Joined Jan 30, 2016
1,070
Vin should really be 7 - 9v, 12v is pushing the 5v regulator to its limit, especially if you hang some peripherals off the 5v or 3.3v rails, or drive any signficant loads off more than a couple of GPIO outputs. It never hurts to put a smoothing capacitor on the Vin supply, depending on what else is hanging off there - definitely if you have motors or maybe relays off the 12v and they draw any appreciable current though if you're powered off a decent PSU or reasonable quality battery with low output impedance its less essential. Its hard to give you a definitive yes or no as it depends on circumstance. For example, if you're driving a single quality 12v signal SPCO relay with a 0.2W coil thats taking say <20mA and its on for a couple of seconds in a minute its going to have minimal impact, the Arduino is taking 100mA+ already and the average relay current is tiny by comparison. Replace that with a bank of 5 x 2W automotive 4PCO relays each taking 170mA+ switching on and off each second and you're looking at an RMS current of 0.6A - that could put quite a ripple on the 12v rail if the PSU can't handle that transient very well or its a long way away on thin supply wires. A few 100uF could make all the difference for reliability.

As for the diodes, they should always be placed directly across the relay coil else you could be inducing significant surge voltages in lower power cabling through inductive coupling. You need to suppress that reverse transient as close to the relay as possible (plus doing so prevents the situation you just encountered). The zener will allow a larger back EMF to build and therefore slow the collapse of the magnetic field. I've never had the need, but my gut feeling is its not going to be that noticable. The L/R time constant for small relays is pretty short to start with.
 

RPLaJeunesse

Joined Jul 29, 2018
124
[QUOTE/] The zener will allow a larger back EMF to build and therefore slow the collapse of the magnetic field. [/QUOTE]

Sorry, but no. This is just the opposite of what inductance basics dictates. The equation V(L)= L * di /dt rules. Since L starts out fixed the higher magnitude of V(L) during turnoff means the di/dt will be faster, the current drops to zero quicker. (As the armature/slug moves away the inductance drops, and di/dt collapses even quicker.) The higher inductive kick promotes a quicker collapse of the magnetic field and its stored energy. For some higher power DC coil relays I've seen the use of simple diode clamping frowned upon - warranty voiding even - the slower release it causes can result in contact burning and shortened contact life.
 

eetech00

Joined Jun 8, 2013
2,056
With regards to the breadboard mockups, I've always supplied the Arduino with the same 12v supply through Vin as what I've used as a common for the coils. Negative is switched through the FET's with a suppression diode from drain to same positive rail as the Arduino Vin. I've never had a back feed issue. But then thinking about it I've never had a toggle switch control on the same coil with the arduino powered down. I might mock this up to try when I get 5 minutes.

Separately, I've heard of people using capacitors between Arduino Vin and 0v to smooth power supply to the PLC, but is this really needed?
You can use a 12v power supply for the Arduino only if you power the Arduino with the DC power Jack. The internal 5V regulator can handle that just fine. However, the I/O has to stay at the 5v limit.

In the schematic post#2, the 5v regulator could be eliminated and 12v supply used instead.
 
Last edited:

Irving

Joined Jan 30, 2016
1,070
[QUOTE/] The zener will allow a larger back EMF to build and therefore slow the collapse of the magnetic field.
Sorry, but no. This is just the opposite of what inductance basics dictates. The equation V(L)= L * di /dt rules. Since L starts out fixed the higher magnitude of V(L) during turnoff means the di/dt will be faster, the current drops to zero quicker. (As the armature/slug moves away the inductance drops, and di/dt collapses even quicker.) The higher inductive kick promotes a quicker collapse of the magnetic field and its stored energy. For some higher power DC coil relays I've seen the use of simple diode clamping frowned upon - warranty voiding even - the slower release it causes can result in contact burning and shortened contact life.
[/QUOTE]
You are indeed correct, that was a throwaway line made late at night and I wasn't thinking it through properly.

A clamping diode does slow the release down - for one relay I've tried its from 10mS to 10.5mS for a 12v coil though I didn't see any evidence of problems at the contacts, which admittedly were only switching 1A @ 12v.

On the subject of using zeners my preference would be to put them from collector to ground. I tried simulating that in SystemVision, a multi-physics simulator. A 1W zener heats up <0.5degC due to the current surge as it clamps the back-emf and takes just 3mS to cool down. You might even get away with an 0.5W zener.

1604330417290.png
1604331820225.png
 

Irving

Joined Jan 30, 2016
1,070
You can use a 12v power supply for the Arduino only if you power the Arduino with the DC power Jack. The internal 5V regulator can handle that just fine. However, the I/O has to stay at the 5v limit.

In the schematic post#2, the 5v regulator could be eliminated and 12v supply used instead.
My experience of using the DC Jack and 12v wall warts for student projects on the Arduino Programming & Interfacing course I teach is that its highly marginal if you use only a few GPIO even if you don't put any external load on the 5v or 3.3v rails. Although its a 1A regulator it doesn't have enough heatsinking to handle 12v, but drop it to 7v and its happy to let you use pretty much all you want. Clones seem to be slightly more marginal than pukka Arduinos.

The heatsinking on the R3 is only just above the minimal spec'd for the NCP1117ST50T3G, whch gives it something like 150degC/W junction to ambient. At 25degC ambient and a 175deg thermal shut down thats (175-25)/150 W = 1W, at 12v thats 1/(12-5)= 140mA. Thats no more than 4 or 5 GPIO driving LEDs plus whats on the board. At 7v thats 1/(7-5) = 500mA, a huge difference!

It doesn't matter if you use the DC Jack or Vin, they both end up on the same place, the input to the regulator (DC Jack via a schottky diode) where there is a 47uF capacitor as well.

[edit]: Of course the TS is using a Nano not an R3 so the above conversation is irrelevant!

For a start the Vin to the Nano must be >7v so driving it from a 7805 like the TS shows in post #2 is wrong. Secondly the onboard regulator on the Nano is a Ti 78M05 with a max output of 500mA and a 53degC/W thermal allowance to junction temp of 150degC. so 150-25)/53 = 2.3W = 330mA at 12v or full output at 7 and 9v.
 
Last edited:

eetech00

Joined Jun 8, 2013
2,056
My experience of using the DC Jack and 12v wall warts for student projects on the Arduino Programming & Interfacing course I teach is that its highly marginal if you use only a few GPIO even if you don't put any external load on the 5v or 3.3v rails. Although its a 1A regulator it doesn't have enough heatsinking to handle 12v, but drop it to 7v and its happy to let you use pretty much all you want. Clones seem to be slightly more marginal than pukka Arduinos.

The heatsinking on the R3 is only just above the minimal spec'd for the NCP1117ST50T3G, whch gives it something like 150degC/W junction to ambient. At 25degC ambient and a 175deg thermal shut down thats (175-25)/150 W = 1W, at 12v thats 1/(12-5)= 140mA. Thats no more than 4 or 5 GPIO driving LEDs plus whats on the board. At 7v thats 1/(7-5) = 500mA, a huge difference!

It doesn't matter if you use the DC Jack or Vin, they both end up on the same place, the input to the regulator (DC Jack via a schottky diode) where there is a 47uF capacitor as well.
Well, i've done it and it works fine. But 12v can only be used to power the unit, not for I/O or anything else.

Here is an excerpt from the Arduino Uno data sheet:

1604352816673.png
 
Last edited:

Irving

Joined Jan 30, 2016
1,070
Well, i've done it and it works fine. But 12v can only be used to power the unit, not for I/O or anything else.

Here is an excerpt from the Arduino Uno data sheet:

View attachment 221270
Agreed, it'll work, I'm not saying it won't with a nearly passive Uno (ie only inputs). What I am saying is if you try to use the Uno with 5 or more GPIO outputs at any reasonable load - even without driving external peripherals through the 5v or 3.3v outputs - its likely to be unstable on 12v and above, and the Arduino note above says nothing to that effect - it says ">12v the regulator may overheat & damage the board" which is rubbish because all that will happen is the VR will overheat and go into protective current foldback though its case will get very hot, but not enough to cause any real damage.
 
Top