Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC analog input protection

Status
Not open for further replies.

Peet19

Member
Hello!
Should the analog input of the PIC be protected with a resistor? In this case, does the current flow into the PIN?
I want to measure the voltage at the center terminal of a potentiometer.
Thanks in advance for your help!
 
If the pot is supplied by the PIC power, it can be directly connected, as nothing can make it exceed the 0V to V+ range.

For anything that could cause the input voltage to exceed the PIC supply, use a series resistor and a diode (preferably a schottky diode) from the input to power - or to both power and ground - to limit the voltage.

If the input is high impedance, eg. 10K or higher, add a 0.1uF cap from input to PIC 0V / ground, and a protection diode from input to power.

You may get better accuracy by adding the can even with lower impedance inputs.
 
Note, there's also a current limit per port (maybe) and a current limit for the whole chip (120mA/85mA). However, unusually for this chip, max current is 50mA per pin.

Each port pin already had protection diodes to Gnd and Vcc so only requirement is not to exceed their max current (20mA). So if reading a 9V signal then use a >200Ω resistor in series (assumed Vcc=5V). However, it's better to use a higher impedance resistive divider.

Adding an input capacitor to ground improves the ADC acquisition time. Think of it as a storage battery (100nF = 100,000pF) that can quickly charge the tiny battery (15pF capacitor) inside.

Mike.
 
One more quick question. The maximum output current is 50 mA?
That's the from the "Absolute maximum" table - the level where you may expect failure, not what's allowed in normal operation.

See the output voltage vs current graphs on page 406; "sink" current is shown up to 25mA, with a loss of about 0.5V, but source current is only around 5 - 7mA to get a similar voltage drop.

Also note the absolute max current through VDD and VSS, and the total power dissipation. Keep everything reasonably well under those, of you want the device to last.



There was a long discussion on here a while back about preventing any current to pins in analog mode, as it can cause problems if not latch-up in the device.

One of the most basic things is that as the ADCs need a low impedance drive (unlike using eg. a 1M in series to a digital pin to limit current), an overvoltage from the ADC divider may provide enough current through the protection diode to VDD, if no outputs are sourcing current & loading the supply more, to increase the device supply voltage and overvoltage it.

That can also happen via external protection diodes if the voltage divider is not calculated correctly. The diodes are last-resort and power fail protection rather than a normal operating part of the device.

Good design means always keep voltages within the correct limits.


Each port pin already had protection diodes to Gnd and Vcc so only requirement is not to exceed their max current (20mA). So if reading a 9V signal then use a >200Ω resistor in series (assumed Vcc=5V). However, it's better to use a higher impedance resistive divider.

"Real Bad Idea" ™

The whole device may be taking 5mA or less when running on the internal oscillator.
That means your 9V via 200 Ohms, dropping 1V across the resistor at 5mA, could massively overvoltage the device.

That's an example of why you should never rely on the input diodes as part of the overall circuit function.
 
As I said, much better to use a high impedance resistive divider.

No, because the ADC needs a low impedance source to charge/discharge the sample and hold capacitor - something like a maximum of 2.2K? (depending on the exact device). High impedance divider followed by a buffer is the better way, with the buffer opamp fed from the same supply as the PIC.
 
Why would we be discussing protection diodes if we were feeding the ADC?
I was talking about IF 9V was present.

Mike.
Perhaps you should read the title and content of the thread :D

PIC analog input protection​


The inputs have protection diodes regardless of analogue or not, and it's MUCH more likely that an analogue input could exceed the supply rails.
 
Thanks for everyone.
I took the resistor off the analog input. It is connected directly to the middle terminal of the potentiometer. I think the supply voltage for this PIC is 3.3 V. I want to put a 130 ohm resistor on the digital outputs. That's good?
Maximum 25mA, if I count correctly.
 
I don't understand the graph on page 406.
If 25mA is the output current then 0.5V voltage drops?
That is, if the supply voltage is 3.3V, will it drop to 2.8V at 25mA?
 
Képernyőkép 2022-06-02 21-35-36.png

One more question.
Don't need a diode between MCLR contact and R1?
If I program the PIC within a circuit, the voltage will be higher than the 3.3 V displayed on the VDD branch. No?
 
View attachment 137331
One more question.
Don't need a diode between MCLR contact and R1?
If I program the PIC within a circuit, the voltage will be higher than the 3.3 V displayed on the VDD branch. No?
No, historically that was always done - but it was changed to just a 10K resistor a VERY long time ago. The 10K limits the current to low enough not to upset any voltage levels.
 
I think the supply voltage for this PIC is 3.3 V. I want to put a 130 ohm resistor on the digital outputs. That's good?
Maximum 25mA, if I count correctly.
25mA is the sink current - with a load connected between power and output.

Also note the maximum total current allowed for the device VDD and VSS pins; 350mA absolute maximum through VSS, and ideally no more than 120mA for long term reliability.

VDD pin absolute max and preferred max are 250mA & 85mA.

In other words you cannot use all pins at high currents without cooking the IC.

If 25mA is the output current then 0.5V voltage drops?
That is, if the supply voltage is 3.3V, will it drop to 2.8V at 25mA?

Yes. The internal MOSFETS that switch the output pins have "on" resistance, so there is a voltage drop across each FET dependant on the output pin load current.

With a 25mA load between an output and VDD, the FET will have about 0.5 - 0.6V across it.

If you put a load between an output and ground / VSS, the output voltage would be around 0.6V less than VDD at just 6mA, as the upper FETs are smaller and have higher on resistance.

On 3V supply, you could think of the FET that outputs high as having around 100 Ohms on resistance, and the output low one as 20 Ohms.

Ideally, use a separate buffer IC or external transistors to drive high current loads. That way any fault is separated from the PIC and has less chance of damaging it.

Darlington driver ICs are cheap and can run vastly higher load power than the PIC pins.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top