Voltage measurement by pic microcontroller

Status
Not open for further replies.

smallboy404

New Member
Hello guys !
i would like to know a method that can measure DC voltage (0-20V for example )
pic can measure a voltage 0-5v , voltage divider can be used? plz if its possible schematics
Thanks
 
You can use a simple voltage divider. Just use a 1 kΩ resistor between the PIC input and ground, and a 3 kΩ resistor between the 0-20 V signal and the PIC input.
 
Just make a 4:1 voltage divider using possibly a 15K and 5K resistor, or for that matter use a 10K or 20K pot with the input across the pot and the out the pot wiper and ground. Check the data sheet on your PIC for the max allowable input impedance. The merit to using a pot is adjustment for a pretty accurate divider. Make sense?

<EDIT> Diver was quicker than I was. </EDIT>

Ron
 
Last edited:
most datasheets on 18f pics advise <2K5 on ADC pins i have used 10k a few times and found that as long as i had a fairly long aquire time it was ok also i found a few pics that had ADC errata sheets!!! so now i try and always chk the device erata sheet
 
Hi,


Just to note, the low 'impedance' spec (which is really a low resistance spec) for the PIC chips comes about mostly because of the internal chip leakage current, which is a DC current and can be plus or minus. The leakage current creates an error in the measured signal if the external resistance is too high. The normal requirement is to keep the effect of the leakage current down to an error of plus or minus one half bit. This means that the total impedance must be something like 2.5k (check data sheet for this spec).
This doesnt have to be the actual value of the series resistor however, but the total impedance of the series resistor in parallel with the parallel resistor. So with a 5k to ground and a 5k series resistance (fed by a 0 ohm source) the equivalent impedance feeding the input is 2.5k. If the source impedance is higher however then this isnt quite enough. If the source impedance is 1k for example and the series resistance is 4k and the parallel resistance is 5k, then the total impedance feeding the input is 2.5k (source impedance in series with the series resistance and then that combo in parallel with the parallel resistance to ground on the PIC adc input).

Yes this total impedance also affects the acquisition time too so you'd have to figure that in with your calculation. The data sheets fully explain this requirement.

I've used as high as 25k external impedance for room temperature projects that dont change chip temperature too much (which creates a change in the internal leakage current). A little calibration and apps that are not too demanding still work pretty well.
 
Last edited:
Hi,


Just to note, the low 'impedance' spec (which is really a low resistance spec) for the PIC chips comes about mostly because of the internal chip leakage current, which is a DC current and can be plus or minus.

No it doesn't - it's mostly due to the charge/discharge time of the sample and hold capacitor inside the chip.

As long as you allow it enough time to charge/discharge the capacitor it works perfectly with values higher than the design spec. It's also far more of a problem when you switch between channels.
 


Hello Nigel,

I think you might want to re read some of the data supplied by Microchip for the PIC chips ADC input requirements. They specifically state that the leakage current is the pin leakage current and is a DC current that biases the input sort of similar to an op amp input bias current. They also specifically write out in clear type that to get the specified ADC accuracy we need to keep the error caused by the (possibly varying) leakage current to 1/2 bit, and to do this the resistance must be low enough such that the maximum leakage current can not develop a significant voltage across the input resistance. If i rem right, this leakage current is spec'd as a max of plus or minus 1ua. It acts as an internal current source and should be considered to be always present, but possibly varying (mostly due to temperature changes).

No argument about the acquisition time due to external impedance, but the leakage current is an accuracy issue that applies for all time, not just the charge and/or discharge times. In a 5v system one bit is about 5mv, and 1ua can develop 10mv across 10k ohms which is already 2 bits. To get this down to 1 bit accuracy, we'd have to go down to 5k, and to get down to the required 1/2 bit we'd have to go down to 2.5k ohms. That's the required resistance to meet the spec over the full temperature range of the device.
 
Last edited:

I second this.

I found that no matter how long the acquisition time (used a few seconds) there was an error in the measured value. The parts with 10k input impedance are better (obviously). I have used dividers with output resistance as high as 160k ohm with 10k parts. Parts with 2.5k recommended input impedance, I have used dividers with output resistance of about 6k ohm.
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…