|
|
View previous topic :: View next topic |
Author |
Message |
C Turner
Joined: 10 Nov 2003 Posts: 40 Location: Utah
|
Odd resets on 16F876A from A/D inputs... |
Posted: Tue Mar 16, 2004 5:38 pm |
|
|
I ran into an interesting problem with the 16F876A:
I have several analog inputs going to the '876A - to RA0, RA1, RA2 and RA5. RA3 and RA4 are defined as outputs and set to "0" - and are not connected. (Possible future use as A/D inputs, maybe.)
Here's the problem:
These inputs are fed from analog circuits that operate from the 12 volt supply. These inputs are a combination of evelope detectors used to detect the amplitude of an AC signal (a set of diodes and a cap to rectify the AC voltage) and capacitively-coupled analog inputs that are centered at 2.5 volts (midsupply.)
Being that all of these voltage CAN go above +5 volts or (in the case of the capacitively-coupled) below ground, there is a 10k resistor in series with each of these signals. Being that I need only 6-7 bits of accuracy, I don't really care that my input impedance is a bit high.
What I would expect to happen is that any voltage that is > VCC or <GND would be clamped by the input protection diodes. This does, in fact, happen - a fact easily verified by an oscilliscope.
The problem is that occasionally, when the diodes are driven into conduction, the PIC will simply reset - as if !MCLR was pulled down. (It is, in fact, NOT.) This happens even if the A/D inputs are only configured - It'll happen if they are never even read and the converter never started.
The value returned by restart_cause() as well as various debugging variables indicate that it is NOT a WDT timeout of any kind - and it can happen anywhere in the code.
Also, I solved the problem (after a bit of hair-pulling) by adding ADDITIONAL diodes on these inputs to clamp them to VCC. (And yes, the PIC itself is well-bypassed. I didn't need to put GND clamps on...)
Does anyone know what's going on here? I'd think that a few hundred uA through the series 10k resistors and internal clamping diodes would be perfectly OK - but apparently not.
It seemed that RA5 was the most sensitive to this problem - but according to the data sheet, it has its normal complement of protection diodes. In fact, one can find numerous examples in Microchip datasheets where they are relying on the protection diode to clamp the input voltage. (Yes, I know about the potential problem with RA4 - but as mentioned above, that's not even being used.)
'Tis a puzzlement. |
|
|
SteveS
Joined: 27 Oct 2003 Posts: 126
|
Odd resets from ADC input overvoltage |
Posted: Wed Mar 17, 2004 7:26 am |
|
|
Is odd, and you seem to have worked thru the problem well.
However, most engineers are very skeptical about application circuits shown in data sheets. They frequently assume things that aren't always true. In this case I would not ask the internal diodes to be my sole protection if I know my inputs will push them. I just don't think its good practice. I would use external schottky diodes to be sure the internal ones are bypassed. Note also the spec only allows .3V above or below supply. I bet the internal diodes are not that low.
'a few hundred uA' is actually quite a lot for a processor that can run a few milliamps. If your supply isn't very stiff you could easily get out of spec on voltage inside the PIC - even though you have good power supply bypassing. Remember you're using the supply to provide the ultimate clamping action - poor ground or supply tracks etc all play a role.
In the end, the internal diodes are for protection - and the did protect the CPU didn't they?
- SteveS |
|
|
C Turner
Joined: 10 Nov 2003 Posts: 40 Location: Utah
|
Joined: 27 Oct 2003 |
Posted: Wed Mar 17, 2004 1:40 pm |
|
|
True, about not relying on the input protection diodes for any sort of input voltage swing limiting. Having cut my teeth on 4000 series CMOS in my much younger days (I didn't use TTL at all for quite a while - and then they came out with the HC series, so I *still* didn't use TTL) I always avoided allowing conduction of the internal diodes.
I must admit, though, a certain (false) sense of security upon seeing that app note that Microchip put out for a real-time clock (for one of their 12 bit devices) where they feed 120 volts AC directly into the T0 input of their device (via a megohm-range resistor) and explain in the data sheet that it was OK as long as one limited the input current to a safe range for the protection diodes. (It also mentioned something about a "hot chassis and required precautions, etc.)
I first through about the power supply "riding up" with current into Vcc from the protection diode - but I could detect none of that at all with the 'scope.
I *suspect* that the "problem pin" is RA5 - as grounding that out (and putting diodes only on THAT pin, initially) seemed to solve the problem. About the only thing different that it has is "SS" - and maybe that circuit freaks out.
The protection diodes, BTW, test as having a 0.65 volt drop (nominal) and for RA5, I put shottky on it - but I just put '914s on the other pins - which didn't seem to be causing the problem.
It would be interesting to see of the non-A version of the '876 (or different silicon revs) do/does this, or if other members of the family also have this "feature." |
|
|
SteveS
Joined: 27 Oct 2003 Posts: 126
|
|
Posted: Wed Mar 17, 2004 1:53 pm |
|
|
Mostly out of curiosity, have you tested to see if it's the plus or minus voltages that cause the trouble? I date back too, and I remember trouble on some old TTL stuff with clock ringing that went too far negative. Not that these circuits are the same, but I think negative spikes can cause more trouble.
Also noted this in the electrical specs:
Quote: | 2: Voltage spikes below VSS at the MCLR pin, inducing currents greater than 80 mA, may cause latch-up. Thus, a series resistor of 50-100W should be used when applying a �low� level to the MCLR pin, rather than pulling this pin directly to VSS. |
Again not exactly your problem but maybe it points to something?
- SteveS |
|
|
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
|
Posted: Wed Mar 17, 2004 2:04 pm |
|
|
I would make the voltage divider with 100K parts or higher. The high input inpedance may limit the rate you switch channles but it will not effect the accuracy. Switching channles causes a small internal cap to charge to the input voltage. Once than happens there is almost no input current. Less parts is better right? If you have to you could even hang a small cap on the input pins. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|