Russell, We've had this discussion before and for two current projects (cheap serial interface, mains frequency clock) it's back on plate. My question is there any correct way to do this with junkbox parts? After digging around a bit I had settled on Olin's suggestion in this thread for a +/- 12V input: http://www.microchip.com/forums/m154654-print.aspx that consist of a 10k series resistor, two 1N4148 external clamping diodes, followed by a 1K series resistor to the input. The 10K serves as a current limiter to the two external diodes, while the 1K is added protection to current limit the difference voltage between the external 1N4148's and the internal protection diodes. In effect even if the internal diodes conduct first with something like a 100 mV difference, that the maximum current they would be exposed to is 100 uA through the 1K. Short of using Schottky diodes for the external diode, in order to guarantee they conduct first, what else can be done? BAJ On Fri, Jan 27, 2012 at 02:40:42AM +1300, RussellMc wrote: > Evil AVR app note that uses microcontroller body diodes to zero cross > detect mains. > Insanity writ large. >=20 > http://www.atmel.com/dyn/resources/prod_documents/doc2508.pdf >=20 > The AVR IC designers must tear their hair out when their app note > writers commit such lunacy. > They effectively use 2 megohm input resistance (although they are not > obviously aware of this from in-text comments). > Diode currents of around +/- 240 x 1.414 / 2 m =3D~ 150 uA+ can be expect= ed. > Well above the "microamp range" that Microchip recommend in their not > quite as bad but still stupid foray in figs 10-1 and 10-2 here. >=20 > http://ww1.microchip.com/downloads/en/DeviceDoc/chapter%208.pdf >=20 >=20 > Russell McMahon >=20 > _____________________ >=20 > Copy and paste from my stack exchange rant here >=20 > http://electronics.stackexchange.com/questions/25691/measuring-frequenc= y-of-a-signal-above-5v-with-a-microcontroller >=20 > PROTECTION DIODES: >=20 > Many people are unaware of or just ignore the datasheet distinction > between "Absolute maximum" ratings and recommended operating > conditions. >=20 > Absolute maximum ratings are those which the device is guaranteed to > survive without damage. Correct operation is not guaranteed. >=20 > The PIC concerned allows Vdd + 0.3V on its pins as an absolute maximum > rating. Operation is not guaranteed during this condition. >=20 > Most data sheets clearly specify that during normal operation input > voltages should not exceed the ground to Vdd range. This datasheet may > or may not ro so in its several hundred pages. It is still wrong to do > so. >=20 > Many people have thought that concerns about protection diode currents > are baseless. Only some of them have rued the day they thought so and > most have probably lived to rue it or not :-). >=20 > Note that the (evil) Atmel application note here uses a 1 megohm > resistor (connected to AC mains ! ) and the Microchip app note here - > figs 10-1 10-2 at least has the grace to say " ... The current through > the clamp diodes should be kept small (in the micro amp range). If the > current through the clamping diodes gets too large, then you risk the > part latching up." Atmels hundreds of uA is NOT "inh the microamp > range". >=20 > BUT latch up is the least of your problems. IF you latchup the part > (SCR action triggered by currents into IC substrate) the IC often > turns into a smoking ruin and you realise that something may possibly > be wrong. >=20 > The problem with body diode currents is when you do NOT get an > immediate smoking ruin. What happens is that the IC was never designed > to accept current between input pin and substrate - the layer hat the > IC is laid down on. When you raise Vin > Vdd the current effectively > flows out of the ICV proper into a phantom fairyland that the iC is > unaware of and that the designer did not and usually cannot design > for. Once there you have small potential;s set up that are never > normally there and current can flow back into adjacent circuit modes, > of not quite adjacent nodes or even into locations some distance away > depending on how big the currents are and what voltages are set up. > The reason this is hard to describe and pin down is because it is > totally undesigned and essentially undesignable. One effect is to > iject currents into floating nodes that have no formal output path. > Thse may act as gates for FETs - formal or accidental ones, that tuirn > on or off semirandom parts of your circuit. Which parts ? When? How > often? How long? How hard? Answer - who can tell / nobody can tell - > its undesigned an undesignable. >=20 > Q: Does this actually happen? A: Oh yes! Q: Have I seen it happen? A: Yes= .. >=20 > I started what has now proved to be a 1+ decade crusade to make people > aware of this (even though I should have been well aware of it) after > being very badly bitten by it. > I had a relatively simple async serial circuit that caused me no end > of strife. Processor operation was intermittent or semi random. Code > faulted sometimes and not other times. Nothing was stable. The > problem? Body diode conduction, of course. I had copied a simple > circuit from an application note supplied with a product and away we > went. >=20 > If you do this without due care it WILL bite you. > If you do it with care and intelligence and design it may well not > bite you. But may. > This is akin to pulling over the centre line into ongoing traffic to > overtake - done with care and not too often and leaving what may be > good enough margins you will usually not die. If you do you will > probably not be surprised :-). So it is with body diode conduction. > Microchips 'microamp range" may be OK. Atmel's 1 megohm off mains is > an accident waiting to happen. Suit yourself. > --=20 > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist --=20 Byron A. Jeff Department Chair: IT/CS/CNET College of Information and Mathematical Sciences Clayton State University http://cims.clayton.edu/bjeff --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .