Relying on microcontroller pin protection diodes?

Thread Starter

AlbertHall

Joined Jun 4, 2014
12,345
I want to drive a 270Ω coil with a bipolar 1.5V square wave from a microcontroller (PIC16F1847) running on 5V. First thought was an h-bridge but that seems over the top. Second thought was simply the coil in series with a 620Ω resistor between two of the uC pins but this would rely on the pin protection diodes to catch inductive spikes. The spec from the datasheet (I think) sets a maximum current at 20mA and this would be only 5.5mA.

Is this a good idea, or dangerous?

1598893494846.png
 

Analog Ground

Joined Apr 24, 2019
460
I think one issue is long term reliability. The spec is probably for occasional currents under fault conditions. Funny things can happen when currents like this go through a device on a routine basis. Electromigration comes to mind. Also, currents going through these pin structures and into the chip can cause operational problems in some devices. Weird resets or other faults. I would stay away from them. Why can't you put in external diodes like Schottky diodes which are in parallel with the device structures? Use Schottky for the lower voltage drop.
 

John P

Joined Oct 14, 2008
2,025
No, you can't just put a diode across the coil, because current flows both ways. But you could put in 4 Schottky diodes forming a bridge, 2 with cathodes to Vcc and 2 with anodes to Gnd, either side of the coil. I know, 4 extra components, but they can be small diodes.
 

Picbuster

Joined Dec 2, 2013
1,047
I want to drive a 270Ω coil with a bipolar 1.5V square wave from a microcontroller (PIC16F1847) running on 5V. First thought was an h-bridge but that seems over the top. Second thought was simply the coil in series with a 620Ω resistor between two of the uC pins but this would rely on the pin protection diodes to catch inductive spikes. The spec from the datasheet (I think) sets a maximum current at 20mA and this would be only 5.5mA.

Is this a good idea, or dangerous?

View attachment 216085
It could do the job however: I would not trust it. A mosfet + coil diode for relay control provides a save method.
A filter between vdd and the 'relay' mosfet is advisable. (small coil, resistor and 2 caps (100nF + xxuf)) xx to be calculated from current and switching frequency.
The main reason: Spikes run into the chip and could be blocked but where in the chip.

Picbuster
 

Deleted member 115935

Joined Dec 31, 1969
0
@trebla, to clarify , the Bat 54s , has two diodes in the package,
thus two BAT54S can be wired as a H bridge,
 

Irving

Joined Jan 30, 2016
3,843
Now I understand what @AlbertHall is trying to do, see diagram below... here are my thoughts:

He didn't spec the actual relay but the KEMET one shown is a 5v, 250ohm coil with a set/reset voltage of 3.75v minimum. If the resistor is set to 0 ohm the current flow while setting/resetting will be 18mA. However the 16F1847 is only spec'd at 8mA sink, 3.5mA source so there's a problem there, as at those currents the actual Voh - Vol will be 5 - 0.7 - 0.6 = 3.7v, too low... so immediately there's an issue.

1598950716691.png
1598951384422.png

As AH said originally, an H-bridge is the obvious solution, and a convenient & cheap chip is Diodes Inc ZXBM5210 (Mouser, $1.10 SOP-8 package, datasheet attached). No diodes/resistors needed, just 1 capacitor.

1598954149018.png

RC6/REVRC7/FWDOUT1OUT2
LLXXOutputs off, ZXBM5210 powered down/standby
HLLHReset
LHHLSet
HHLLOutputs low, ZXBM5210 powered up.
 

Attachments

Last edited:

Thread Starter

AlbertHall

Joined Jun 4, 2014
12,345
I think one issue is long term reliability. The spec is probably for occasional currents under fault conditions. Funny things can happen when currents like this go through a device on a routine basis. Electromigration comes to mind. Also, currents going through these pin structures and into the chip can cause operational problems in some devices. Weird resets or other faults. I would stay away from them. Why can't you put in external diodes like Schottky diodes which are in parallel with the device structures? Use Schottky for the lower voltage drop.
I had an ache in the back of my head that this might be the case.
Thanks.
 

Irving

Joined Jan 30, 2016
3,843
Ah... my bad, I'd assumed a relay... (never Ass-U-ME doh!) - a PIC driven/controlled clock? That's novel...

Your coil will be a little short-changed on volts with a 600ohm series resistor because of the voltage drop of the PIC outputs at 5.5mA, you've actually got 3.7v (worst case) so need a 390ohm instead.

Though the H-bridge chip is still a good option, it keeps the PIC clean...
 

trebla

Joined Jun 29, 2019
542
I have sometimes used this protection circuit for MCU inputs only and with two bigger value resistors, one from diodes to MCU input and second from diodes to outside world. Maybe it can reduce current through MCU protection diodes in your design too, i have'nt tested this on outputs.
 

Thread Starter

AlbertHall

Joined Jun 4, 2014
12,345
However the 16F1847 is only spec'd at 8mA sink, 3.5mA source so there's a problem there, as at those currents the actual Voh - Vol will be 5 - 0.7 - 0.6 = 3.7v, too low... so immediately there's an issue.
I have plenty of pins spare so would it be kinder to the PIC to parallel two port pins for each end of the coil?
 

Irving

Joined Jan 30, 2016
3,843
I have plenty of pins spare so would it be kinder to the PIC to parallel two port pins for each end of the coil?
As long as you can be sure you don't have one high and one low at the same time. Split the 390ohm into 4 series parallel resistors to enable current sharing, so a 390 on each pin. This will also limit the current between pins on the same side.
 
Top