Google

Jan 10, 2010

How to measure + and - 5 Volts using PIC microcontroller PIC1F4550

This post will explain you how to measure postitive and Negative 5 voltage using PIC microcontroller PIC1F4550

First config the ADC channel in your controller and in the ADCON Registers you have an option to select +Vref & -Vref values. say ADC is 10bit resolution i.e. 2^10 you will get max count from 0 to 1024. so the count "0" indicates your -Vref (-5v) value, count "512" indicates the 0V and the Max count 1024 indicates your +Vref (+5v).
so that is how you can calculate the Voltage

But there is the porblem with the Above approch as we cannot use -ve voltage greater that -0.3 with pic microcontroller which will permanently damage the PIC so first convert this range to 0 to 5 by some analog circuitry and then use it.

Here is the Circut for converting -5 - +5 to 0 - +5 voltage level.