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.

Status
Not open for further replies.

#### Yobortsa

##### Member
Hi all,

How do you calculate the current required for the analog ports on a PIC? Do they accept anything up to 25mA like the output ports?

I'm using a voltage divider to reduce 25.575V to 5V. I am intending to use R1=6K8 plus 1K pot and R2=1K8. What size current limiting resister should be used or don't you need one?

I'm using a 12F675 for this application.

Regards,

David

Hi all,

How do you calculate the current required for the analog ports on a PIC? Do they accept anything up to 25mA like the output ports?

I'm using a voltage divider to reduce 25.575V to 5V. I am intending to use R1=6K8 plus 1K pot and R2=1K8. What size current limiting resister should be used or don't you need one?

I'm using a 12F675 for this application.

Regards,

David

hi,
If you stay within +v and 0V for the analog signal, the adc input impedance is very high.
Outside +v and 0V [ allowing an internal diode drop] the diodes will carry about 20mA.
Keep the adc source impedance <= 10K

Last edited:
Those values are fine, the 6K8 will act as a current limiting resistor just in case the input does go too high.

What would you say is the maximum resistance you should use in this scenario to make sure the sample caps charge fast enough?

What would you say is the maximum resistance you should use in this scenario to make sure the sample caps charge fast enough?

hi,
Some app notes say 5K and others 10K as the max source resistance.

hi,
Some app notes say 5K and others 10K as the max source resistance.

I've not checked on this particular PIC, but normally it's stated as 2.5K in the datasheet - but it depends how fast you switch channels, if you only use one channel it's not so important.

Right, the recommended input impedance has been 2.5Kohms for most of the 18F series. The newer J models and 33Fs and all, check the datasheet.

IIRC, I think you've got it backwards. The impedance limitation due to channel-switching can always be countered simply by waiting longer to take a reading. However, the DC leakage current at the pin itself presents a problem, that will physically change the voltage on the pin and no amount of waiting will change that accuracy problem. Adding a capacitor to the pin will not change it. Remember, at 5v and 1024 codes, that's only 4.9mV to read a different code. At reduced Vref to increase accuracy, the codes are smaller but the pin leakage is NOT reduced. The leakage is unpredictable, drifts with temp, and changes with pin voltage.

Note that the impedance on the pin is as seen by the pin. 8v going through a divider made of two 5k resistors will make an impedance of 10K as far as the 8v source is concerned, BUT only 2.5k as far as the pin is concerned.

Oznog,
Your post is very close to the info I need for my project, but I'm still confused about what exactly source impedance refers to, and how to measure it.

With your example of 2 x 5kohm resistors to divide the 8v voltage, i don't understand why the impedance at the pin is only 2.5kohm. I would have thought it would be 5kohm, because there is only one 5kohm resistor between positive rail and the pin. So, to provide current required for AD, this is only ever drawn from the positive rail, through a 5kohm resistor, to the pin. So, why is this not considered 5kohm input impedance?

Also, would you be able to expand on ways to circumvent this limiation: I am trying to measure a signal from a force load cell (varies impedence with applied force, where increasing force leads to decreasing resistance) and its minimum impedance is still a lot above 10kohm. So, should I be op-amping my signal? Do different op-amps have different output impedances? Is there a standard op-amp design for interfacing with PICs?

Thanks,
Brian

Yes, you should be op-amping your signal - check my tutorials for how I did it, there are many different ways though.

Oznog,
Your post is very close to the info I need for my project, but I'm still confused about what exactly source impedance refers to, and how to measure it.

With your example of 2 x 5kohm resistors to divide the 8v voltage, i don't understand why the impedance at the pin is only 2.5kohm. I would have thought it would be 5kohm, because there is only one 5kohm resistor between positive rail and the pin. So, to provide current required for AD, this is only ever drawn from the positive rail, through a 5kohm resistor, to the pin. So, why is this not considered 5kohm input impedance?

Also, would you be able to expand on ways to circumvent this limiation: I am trying to measure a signal from a force load cell (varies impedence with applied force, where increasing force leads to decreasing resistance) and its minimum impedance is still a lot above 10kohm. So, should I be op-amping my signal? Do different op-amps have different output impedances? Is there a standard op-amp design for interfacing with PICs?

Thanks,
Brian
Don't recall the name of the electrical law, but the impedance for a node is all the impedances leading to DC voltages, in parallel. So if you want to measure a 12v battery voltage and divide it with a 10k resistor and a 4.7k resistor, the impedance seen at the ADC pin is 10k in parallel with 4.7k ~3.2k. Whereas the battery sees a 14.7k load impedance for the divider.

Honestly? I doubt the PIC's ADC will give you acceptance load cell resolution. How much % does the load cell resistance change from your max and min load conditions, and how many codes do you need to realize in that range?

A load cell is just a resistance bridge, and works fine at voltages below its max rating. So DON'T give it 8v. Just give it 5v!

An op amp will not only remove the impedance issue as seen by the PIC, but can also greatly amplify the range. So what was +- 20mV may become +/- 2.5v. However, lemme warn you. It is difficult to get a differential amp balanced. If it's not balanced, the PIC won't get 2.5v=no load. If you try to software-adjust the center for say 4v=no load, then the usable dynamic range is screwed. Normal resistor tolerances can easily throw off this balance, and all amps of this type using external resistors must manually be adjusted with a trim pot. Trim pot adjustment is a minor pain and temperature drift in the resistors and pot itself can affect the center voltage.

Generally you want the ADC, op-amp, and PIC running on the same supply voltage. If you don't do that, the op-amp or ADC pin could get >Vdd on the input pin which is a "bad thing".

I prefer an actual differential load cell ADC, if at all possible, like the LTC2410. That'll give incredible accuracy and drift is essentially nonexistent. It's fairly cheap, and the more accurate multi-turn pots are actually not cheap. You'll need some sort of breakout board though.

Last edited:
Ah, forgot something important, that not a lot of PIC users understand:
IF you provide >Vdd on an input or output pin and forward-bias the protection diode to shunt to Vdd rail, and IF that shunt current into Vdd exceeds that consumed by the PIC at any time plus any other devices tied to the Vdd trace on the board, the Vdd node's voltage will rise on both the internal rail and on the Vdd pin. This can most definitely cause PIC latch-up which can only be recovered by cycling the power. WDT cannot recover it from latch-up, nor will cycling the MCLR pin AFAIK.

Note that when in Sleep mode, the PIC draws just about nothing, so even a fraction of a mA coming into a pin from a voltage>Vdd may be a problem if there's nothing else on the Vdd trace to use it. 5v regulators often have very little ability to SINK current if Vout (Vdd) is raised >5v by an external current in, this varies per regulator and is rarely specified. So there's no guarantee how much current it may take to exceed what the reg can sink and result in overvolting Vdd.

Status
Not open for further replies.

Replies
0
Views
205
Replies
28
Views
7K
Replies
7
Views
4K
Replies
2
Views
3K
Replies
18
Views
3K