Search FAQs on the left to see if your question has been answered. Click on the dropdown to view all of the documents associated with the product. If you can't find your question, click on Ask a Question

ADUCM360/361: Convert ADC reading to voltage

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 code 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
Comments
Anonymous
Related