Hi Nigel,
PIC supply is 5V and voltage to measure is from a 3 cell LiPo battery, so the voltage is in the range 9-12.6V. The PIC just needs to know when the voltage is getting below 9.6V so the battery is not damaged by deep discharge.
I don't use any protection of the battery other than this low voltage measurement.
Every analog pin has a leakage spec associated with it, and that spec is plus or minus 1 microampere.
Sorry Al, but I would disagree - it's mostly down to the time taken to charge the sample and hold - apart from that the source impedance can be considerably higher than the maximum specified.
Like I said previously to the OP, try the different value resistors, and compare the results.
H
Well if you disagree then do a simulation where you have a 1ua current source in parallel with the resistor and external source to be measured.
The datasheet's "1uA max leakage" is a bit pessimistic, based on my experience.
I routinely use 100k, 220k, even 560k in ADC voltage dividers and the ADC measured result is never too far from what the calc says it should be. So, based on that I don't think I've ever seen a PIC input pin set to analogue input that draws 1uA, but I guess you could be right. I always calibrate the ADC by testing, and always use a decent sized cap (0.1uF or more) on ADC inputs used to measure DC voltages.
BTW the application i always talk about uses a 50k resistor and a 50k thermistor in series to sense temperature and biased by a relatively stable power supply voltage of a few volts. So that works out to 25k input resistance for that circuit... and it works pretty nice
Hi again Nigel,
I think i understand what you are doing there, and i think i agree with that. If i wrote my other posts correctly what i was trying to get across was that the equivalent internal current source that represents the leakage current of an analog pin came into question as to changing the accuracy of the reading over the full temperature range, and the only way to make absolutely sure it does not change the basic accuracy of the PIC chip analog to digital converter would be to make sure that any signal current can override the leakage current even when we consider the highest possible leakage current for the chip. So i do agree with the timing issues, but i also interject that the leakage current is also an issue in determining the best value (given the app requirements of course) for the project.
I can provide a drawing if think that would help.
This is a good thread. I would like to see it moved to micro controllers and made sticky.
Not really needed, my concern is only that the possible leakage current is fairly theoretical, so 'may' be a problem - the capacitor issue is a more serious concern.
You could also use the same method I suggested above to check for potential leakage problems, leave the pot set where it is and change the series resistor value.
The source impedance should be no more than 2.5K, your divider is considerably more than that!. This will restrict how fast you can switch between channels, and may have some bearing on accuracy.
If you can't use a lower value potential divider, you should consider an opamp buffer between the PIC and divider - check my analogue tutorial!.
Hello again Nigel,
Nice to see this in the uC section finally. Thanks for moving it.
When you say 'may' that is exactly what i am talking about. They state that 1ua for a reason, and i'd like to hear your take on that spec.
Apparently at one time you agreed with me fully:
Also, if you check the 18F series (i'd have to look up some of those after years of not reading) they do in fact state 2.5k in the calculation, yet they show the exact same circuit and same leakage current! It's interesting that Microchip came up with two different 'maximum' values for the same resistance in the same circuit. And also interesting is that the hold capacitance is smaller for the 18F and that would theoretically allow a HIGHER than 10k if in fact we were mainly concerned with the acq time over the leakage current spec. It's also interesting that is many data sheets they actually come right out and state that the value of Rs is chosen to meet the leakage pin requirements.
...
What else would be interesting to test is if this leakage current changes with input voltage. For example, what is it at 4.9v input and what is it at 0.1v input.
...
That's a very good point. Just guessing, but I would think there would be variance in the leakage depending on the pin voltage. Probably leaking IN to the pin at low voltages, and OUT of the pin at higher voltages?
IF that is the case, and you set the ADC to generally read somewhere around the middle 2.5v (which I usually do) then the pin leakage may be close to zero.
It would not be hard to test with a 1uA ammeter and a PIC and a pot.
But generally regarding the "max" conditions in the datasheet, Microchip are very conservative. It's not unusual for the real operating value to be many times less than the datasheet "max" value.
Test it and see.
The quote said nothing of the kind.
Again - check it and see - but 2.5K is to do with fast charge/discharge of the sample and hold capacitor. far more than anything else.
Well i said 2.5k and you said 2.5k, so i figured you were agreeing. But it appears that you were
only agreeing to the 'timing' part of the requirement. So which do you prefer then, 10k or 2.5k ?
I'd like to know what you believe this resistor value does for the timing. For example,
if we use 2.5k, 10k, or say 25k, what is the difference if the application required sample
time is 10 milliseconds?
Also:
1. What value resistor would i use if the application sample time was 1 full second?
2. What value resistor would i use if the application sample time had to be as fast as possible for the PIC chip?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?