Can I put 20V on a PIC IO pin if I put it through a 470K resistor? Will the protection diodes on the PIC be able to handle that? Or should I add my own Zener? It's a 3.3V system that I need to detect the presence of a 6-20V keypress, so a simple divider won't work.
Feed it through a 47k or so resistor and add a schottky diode from the IO pin to Vcc (Anode to the pin, cathode to Vcc). Use a schottky to keep the differential voltage below the maximum ratings. They are as cheap as 'standard' types nowadays.
The over voltage specs (and current from outside the supply rails) for the PIC only account for the threshold of damage, not for perfect operation. If it was my design, I would provide a series resistor and voltage clamp (2.5 volt shunt regulator chips work pretty well).
If the key press voltage could be present when the micro is unpowered, I would also add a series resistor downstream of the clamp to limit the current into the unpowered input.
If the lack of key press provides an open circuit, I would also provide a shunt resistor to zero volts at the input that would not divide a 6 volt signal to less than the 3.3 volt supply voltage.
OK. I'll have to put this together in my head. In the mean time I'll add some info to confuse the issue. This is for a power switch for the system. Pressing the switch will turn the regulator on and then the PIC will hold the regultaor on. To power down, I need to detect when that switch is pressed again. So I guess your point may be an issue.
I'm also open to any other bright ideas dealing with an 'on/off' circuit for an MCU.
I was assuming the OP wanted a very simple solution using a series resistor if possible. I've 'overvoltaged' PICs through schottkys in production units (more than 100k shipped) where the overvoltage event (+ ~ 0.2V because of the diode) happens regularly (numerous times per day) and I've never had one fail (shipping started 2 years ago on that product).
In fact, Microchip, have an application note, using a large resistor this way to detect mains!. I'd not want to do this, but the diodes will handle this fine. Remember though that these diodes are clamping to the supply rail, so have the same problem in this regard as a Schottky. There are also some other 'caveats'. For instance, if this is one of the chips that allows you to do I/O on the MCLR/Vpp pin, this pin _does not_ have a normal protection diode, and raising the voltage on this one will trigger a programming cycle!. Also, though most PICs are fairly immune from latchup, some models will occassionally experience this if a pin is pulled well above the supply when the chip wakes up. The lower drop of the Schottky diode prevents this behaviour.
You can generally get away with this (except on /MCLR or the occasional open-drain pin that some PICs have), but you might have small effects like an increase in Idd or current spilling out onto other (perhaps analog) inputs, especially on the same port. You won't damage the part.
Best regards, Spehro Pefhany
--
"it\'s the network..." "The Journey is the reward"
speff@interlog.com Info for manufacturers: http://www.trexon.com
A 32 ua is a typical current that feed the protect diode in the PIC without risk ( see APP. Note in microchip website : a title like "detecting powerline with PIC") so the 470K is an acceptable value.
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.