This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Scaling of ADC value.

Hi,

Can any one say as to why people scale 3.3 volts to 4096 & not 4095 when in reality 4096 is a 13 bit value that can never be represented on a 12 bit ADC?

What if 0 to 3.3 is scaled to 0 to 4095 counts? Why not 3.3/4095.0 ?

#if MATH_TYPE == IQ_MATH

#define AdcFsVoltage _IQ(3.3) // ADC full scale voltage

#else // MATH_TYPE is FLOAT_MATH

#define AdcFsVoltage _IQ(3.3/4096.0) // ADC full scale voltage

#endif_iq Result; // ADC result

void main(void){Result = _IQmpy(AdcFsVoltage, _IQ12toIQ( (_iq)AdcResult.ADCRESULT0));

Regards

Raghu

  • Raghu,

    The scaling with 4096 is correct.  The scaling equation will never actually return 3.3V.  This is because the ADC result never actually equals 4096.  The IQ12 conversion of the ADC result will be a fraction less than 1 (e.g., 0.999).

    If you look in the datasheet, you will find a somewhat more complex conversion formula than just a single equation.  For example, The F2806x datasheet SPRS698c p.82 shows:

     

    This is the same as what the scaling computation you show in your post will produce (Note: for the middle equation, you truncate any fractional portions as the digital value result must be an integer).  Make a graph of the above three conversion cases.  You will convince yourself that they are correct.

    Regards,

    David

  • Hi David,

    Digital Value = 4095,                                          When input = 3.3V

    If your last expression were true then why don't we out / display 3.3v upon getting a ADC count value of 4095 but still use the 2nd expression to display less than 3.3v?

    Regards

    Raghu 

  • Raghu,

    The ADC implements a function from input voltage to digital output value.  That is, given an input voltage, I can tell you the unique digital output value.  The converse is not true however.  Given a digital output value, I cannot tell you a unique input voltage.  There is a range of input voltages that could generate that same digital value (i.e., the converse is NOT a function).  Here is the ADC mapping:

    You will note that at exactly 3.3 V, the output is not actually defined.  We know of course that if we input 3.3 V to the ADC, we get 4095 as the output.  In fact, if we put anything in that is 3.3 V or greater, we get 4095.  I could have added this to the graph, but I didn't.

    So to your question, if the converted value was 4095, how do you know that the input voltage was 3.3 V?  It could have been anything from 3.2992 V or greater.  If you plot the scaling equation

      Digital Value = 4096 x (Input Analog Voltage - VREFLO)/3.3    for 0 V < input < 3.3V

    you will find that it plots exactly as the graph I show above.

     

    Regards,

    David