Please explain how I convert an ADC reading to a voltage value?
Please give an example for G=1 and also for G=8.
Calculating the voltage from the ADC reading is very simple and requires very few CPU instructions.
Also, there is no adjustment required for different gain settings - the ADC hardware handles the gain adjustment automatically for the User.
The following example is valid for all gain settings when the internal 1.2V reference is selected as the ADC reference source and when the ADC output code is set for 2's complement mode (ADC1CON.18=1)
float fVolts, fVoltage = 0.0;
volatile long lADC1Result = 0; // Signed 32-bit integer
fVolts = (1.2 / 268435456); // Calculate LSB size= VREF/2^28
fVoltage = (lADC1Result * fVolts); // Convert ADC result to volts
Retrieving data ...