I'm working on a project involving driving some 12V motors via a H bridge chip. While the H bridge chip is almost certainly designed to isolate the 5v vcc (this is not coming from the same place as the arduino's 5V power) and the input direction and PWM lines from the 12V motor power, i don't want to rely on this alone, and there's always ofcourse the risk of a short occuring somewhere in the project which might result in a 12V (or briefly a little higher if the motor causes any spikes) voltage contacting either the arduino's (an uno, atmega328p based) digital pins (some as inputs, others as outputs). I have quite a few digital and analogue inputs of the arduino connected to wires which run close to moving things which could perhaps snag them and close to 12V wires than could also get snagged. And I have some digital output wires from the arduino in a similar location.
Are there any simple circuits, not something as big, fancy (and slow in terms of passing signals) as a relay or optoisolator, just something (using resistors, caps and diodes) which will let logic and analogue signals pass if they are between 0V and 5V above the arduino's ground, but will otherwise block anything higher voltage.
A potential divider won't really work, where inputs are concerned normal HIGH values would all become LOW if one divides down enough to protect a 5V capable arduino against 12V (and higher) spikes.
The idea of this protection is as a last line of defence, not something expected to happen often, and also a way to protect the 5V USB ports of any computer connected to the arduino at the time, should 12V from the motor power supply somehow short itself to digital input or output pins of the atmega328p. One thing I can guarantee is that the arduino's 5V rail isn't in one of the wires that could short, the wires which could short are only those from digital input/output and analogue output pins of the 328p, and ofcourse also the arduino's ground.
So on each arduino pin which runs towards the areas where shorts t 12V could occur, put a zener of about 5.5V from GND to the pin (I've seen 5.5V on USB stuff often, and know I'd be getting constant false positive shutoffs if I used 5.1V), then a resistor (any size large enough to limit currents to entirely survivable ones) from the pin before the wire towards the risky regions. And this will work on both digital outputs and inputs? And won't distort analogue input reading much, so long as the resistor chosen isn't too big, or if it does should be easy enough to compensate in software for.
Protecting digital inputs is easy. Protecting analog inputs without compromising the accuracy is more tricky - a "zener" diode does not have a sharp cut-off as you can see here
to protect an analog input from a short to a 12V supply a suitable value series resistor will limit the current and if the input exceeds the arduino supply the protection diodes will clamp the analog input to a safe value. Choosing that resistor will depend on the speed at which your analog input can change, and how often you are measuring it.
Zener diodes are generally speaking useless for pin protection.
Schottky clamping diodes is the only way to protect a pin at any MCU supply voltage (zeners don't).
You still need a series resistor to limit current.
To protect a power supply (you mentioned USB), use TVS diodes (zeners on steroids).
Leo..
Posts #6 and #7. Can you explain why a 5.4 Zener won't do any good if set out in the configuration used by that "ruggeduino" device? I've bought a pack full of zeners and could really use being certain I'd need schottky's or TVS's instead before I order those too. Also I've already ordered a PCB this is going on to, and it only has space to solder a single diode on to each digital line which needs protection, if I can only solder one type of the diodes in to that space (either way round given I think schottky's and TVS's would go the opposite way to zeners) which one is best for protecting the 5V atmega from voltages of 12V and maybe up to 24V (really bad luck and implasuibly large for a spike from a pretty low current 12V motor) which may last in the several ms to sizable fraction of 1s time period.
Max (positive) pin voltage is not 5volt, it's VCC+0.3volt.
Now imagine the Arduino is off (VCC = 0volt), and a sensor outputs 3.3volt.
The zener only sees 3.3volt, so does nothing.
The pin however is in trouble, receiving 3volt more than it should.
The 220ohm resistor is the only part that protects (limits fault current).
IMHO that Ruggeduino diagram isn't doing much better than a common Arduino.
They should have used clamping diodes (try Google, images),
and maybe a 5volt TVS diode across VCC of the MCU if total fault current can exceed MCU current.
Leo..
Perhaps you wont make that mistake again - get the circuit right before you order pcbs.
So we can provide more accurately directed advice, can you show us what is already "fixed" - ie a schematic for the system, including how it will be powered (5V AND 12V supplies) , and links to specs for the motor, h bridge, etc.
Right now each of my lines from the arduino towards the other stuff looks like, image as derived from the ruggeduino design:
except I'm able to use a larger resistor 1K to 10K (Ican easily adjust) as I know that I won't, either when the arduino pin is an input output, have all that much current needing to flow. The "connector terminal" as marked on that image is where my lines travel off towards either the H-bridge inputs or to 5V sensor systems located physically close to the area where 12V motor wires run.
I do NOT actually need to protect my 5V line as the arduino's 5V line does not power anything but the arduino, all the 5V stuff on the board which gets closer to the 12V motor stuff is powered from a fully separate 5V supply rail (common ground rail) which is of a type which can cope with occasional spikes. So my protection is just about looking after some minimal current digital and analogue inputs and outputs. Also, the powered off condition probably isn't so important, the arduino has decoupling caps and such so when power is shut off there would always be power to the atmega chip long after the 12V stuff had all discharged itself.
OK you have 3 different issues: protecting digital inputs
is dead easy. This is the equivalent cct for a digital input: Cpin is typically "a few pF" so provided you dont need a mega fast response you can use a large value resistor adjacent to the input pin (to minimise pick-up)
The clamp diodes will take care of any excess voltage.
Analog inputs
can be treated the same way. The input is optimised for an input impedance of 10k or less; so you can use a 10k resistor which will provide all the protection you need.
Digital outputs
can tolerate currents of up to 40mA - you need to ensure a digital output set low and connected to your +12V will be protected - so you need a resistor larger than 300 ohm. (12V/ 0.04A)
After that it depends on the external circuits to which it is connected. If their inputs are cmos then you can use much larger resistors.
Of course that wont protect it if its re-configured as an input.
The op amp trick is clever, I'm thinking that would need a 12V tolerant op amp, although could run it from gnd to 5V or gnd to 12V, no need for split rails hopefully.
As regards the input IO pin equivalent schematic, that would I guess protect for any circumstances where the wire marked "logic circuit" gets higher than Vcc+V_diode_drop or lower than Gnd-V_diode_drop, I guess placing a series resistor between "logic circuit" and the area actually beside the diode ends would help reduce the risk of overcurrenting either diode, so long as chosen so as not disrupt any pullups or pulldowns in use.
For output then, so long as there's a series resistor between the output and the part of the circuit which could have spikes, then the output pin will stay at its own voltage and sink or source as much current as needed to do so, hence a need for a resistor big enough to keep current to safe levels. The things being connected t are indeed CMOS, and these pins don't get reconfigured to inputs at any point during use.
In the long term ten, protect inputs with a series resistor and diodes (lowest drop possible) from GND to the pin and from the pin to Vcc, and outputs just with a series resistor. Or try input protection with an op amp as a voltage follower. For now though, should a 5.4V zener from Gnd to the pin (so it reverse conducts when V-in_to_pin goes >5.4V) and a series resistor between here and the wider circuit be ok, so long as I don't need to worry about negative spiking below ground or about situations where spikes occur while the atmega328p is powered down?
If not, is there any other 2 element circuit I could put in to the post#11 configuration (the PCB has space for something between gnd and the pin and something between the in and the wider circuit) which would do? Alternative diode types perhaps? I cannot for input pins resort to a dual resistor potential divider ofcourse though, as that would send 5V digital input signals to levels lower than the logic threshold.
I think you're over-thinking things.
Very few here would worry about protecting the I/O of an Atmega328 from the I/O of a motor driver. You would only do that when it was highly mission-critical, like a trip to the moon.
Leo..