There seems to be some confusion regarding ADC scaling requirement so here are some examples why and how you would do it...
Example No 1: Voltage to be measured is higher than 5V...
Do take note that PIC ADC has a maximum input of VDD (+5V) thus if you want to measure voltage higher than 5V, you need to do some scaling of the actual voltage before it gets into PIC. Easiest way is to use a voltage divider using resistors (for more demanding applications, an opamp-based circuit may be required).
Lets look at an example. Assuming you want to measure the automotive battery voltage. Typically, the battery voltage will be between 11V (standby) and 14V (charging). For safety reason, let's assume we design for 20V maximum input voltage (25% safety factor). To accomplish this, we'll use 4 resistors of 4.7k each... a potentiometer can also be used to set it correctly. Wire the resistors as shown below:
In the above circuit, when a 20V voltage is present at the input, input to the ADC will be 5V... a 10V input will result in 2.5V input at the ADC... thus, the input voltage has been scaled by factor of 1/4. The ratio is obtained from the voltage divider... check some references if you not sure why this is so... :-)
Voltage at PIC ADC Input = Actual Input x (R1 / (R1+R2+R3+R4))
Assuming you use VDD (5V) as the ADC+ reference, the ADC reading will be 1023 when the ADC input is 5V (actual input of 20V). So, to get the actual voltage reading, you need to calculate it as follows:
Actual Voltage = ADC Reading * Designed Maximum Voltage /1024. Putting the actual numbers in, Actual Voltage = 1023 * 20 /1024 = 19.98V. The small difference is because the 10-bit ADC maximum value is 1023 instead of 1024...
Under this scenario, the maximum resolution is 20V/1024 = 19.5mV.
I'll post another example for expanded ADC resolution later...
PIC-Based Battery Monitor
-
My friends, as usual, drove me to craziness again and led me to design,
fabricate and test a smart battery monitor... The usual blinking lights and
so on.....
13 years ago
1 comment:
It is also advisable to place a zeiner diode to ground just before the adc, with a breakdown voltage below the maximum voltage that the adc can take. This offers significant extra protection over just using a safety factor when specifying a voltage divider. :)
Post a Comment