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.

Hercules RM48 ADC Data Interpretation

Other Parts Discussed in Thread: HALCOGEN

Hi,

  We are using the Hercules RM48 Board.

  For hex adc value returned from TI sample code

1. for ambient light sensor /** - Start Group1 ADC Conversion * Select Channel 9 - Ambient Light Sensor for Conversion */ adcStartConversion_selChn(adcREG1, Ambient_Light_Sensor, 1, adcGROUP1); /** - Wait for ADC Group1 conversion to complete */ while(!adcIsConversionComplete(adcREG1, adcGROUP1)); /** - Read the conversion result * The data contains the Ambient Light sensor data */ adcGetSingleData(adcREG1, adcGROUP1, adc_data_ptr); is there an equation to convert the returned hex value?

2. Same for TI's Temp_Sensor_Demo.

/** - Start Group1 ADC Conversion

* Select Channel 8 - Tempurature Sensor for Conversion

*/

adcStartConversion_SelChn(adcREG1, Temperature_Sensor, 1, adcGROUP1);

/** - Wait for ADC Group1 conversion to complete */

while(!adcIsConversionComplete(adcREG1, adcGROUP1));

/** - Read the conversion result

* The data contains the Temperature sensor data

*/

adcGetSingleData(adcREG1, adcGROUP1, adc_data_ptr);  

Also with the how should convert returned hex data from i.e., ambient light and temperature data to interpret this data? Is there someplace in manual which outlines how to process returned hex values from adc?  Thank you
 

  • Hi Tammy,

    1. for ambient light sensor /** - Start Group1 ADC Conversion * Select Channel 9 - Ambient Light Sensor for Conversion */ adcStartConversion_selChn(adcREG1, Ambient_Light_Sensor, 1, adcGROUP1); /** - Wait for ADC Group1 conversion to complete */ while(!adcIsConversionComplete(adcREG1, adcGROUP1)); /** - Read the conversion result * The data contains the Ambient Light sensor data */ adcGetSingleData(adcREG1, adcGROUP1, adc_data_ptr); is there an equation to convert the returned hex value?

    >> I will look up the light sensor datasheet to see if there is a specified conversion between the analog voltage and the light intensity sensed. We know that the analog voltage output increases with increasing light intensity.

    2. Same for TI's Temp_Sensor_Demo.

    The temperature sensing is achieved using a thermal resistor (R148). This resistor's part number is NCP18WF104J03RB and you can find its datasheet at http://www.murata.com/~/media/webrenewal/support/library/catalog/products/thermistor/ntc/r44e.ashx.

    R148 is used as part of a voltage divider, whose output is fed to AD1IN8 channel. Below circuit is pasted from the HDK design schematic:

    The datasheet of this thermal resistor gives the relationship between temperature and the change in resistance value. You can use this information to determine the actual temperature. The HDK ships with a temperature sensing demo. You can also refer to this demo source code to identify the actual conversion from ADC result to temperature.

    Regards, Sunil

  • Thank you. I have gone to the thermal resistor datasheet.  So given tables below from this datasheet, and ADC data returned (via ADCGet Halcogen function) = 0x0600, how do we convert that to the temperature value? I did look at demo CD from TI, I found the Hercules board source, but not the PC source for the demo which actually does the conversion before displaying temperature on PC for user running demo. Is that code available which demonstrates how infro from this datasheet is used to calculate temperature?  Thank You.

  • Tammy,

    The datasheet gives the formula for the resistance at a given temperature:

    Also, this table provides the required numbers for R0 at 25C (T0).

    So the resistance at a given temperature x (in Kelvin) would be:

    Rx = 100k * exp [4334 * (1/x - 1/298.15)]

    Using this formula, for x= 80C you get Rx = 10.435k.

    This will cause the ADC input voltage to increase from 3.3V/2 at 25C to about 3V at 80C.

    You can do similar calculations for the rest of the temperatures.

    -Sunil

  • Thank you. Let me rephrase. TI Demo Code from CD for Hercules Demo below. The data returned by ADC driver is in adc_data_ptr->value in TI code.  What is the math formula for us to know what that value returned by TI driver (HalCogen generated)  represents in terms of temperature (I assumed it was celcius). Thank you.

    void Temp_Sensor_Demo(void)

    {

    adcData_t adc_data;

    adcData_t *adc_data_ptr = &adc_data;

    /** - Start Group1 ADC Conversion

    * Select Channel 8 - Tempurature Sensor for Conversion

    */

    adcStartConversion_SelChn(adcREG1, Temperature_Sensor, 1, adcGROUP1);

    /** - Wait for ADC Group1 conversion to complete */

    while(!adcIsConversionComplete(adcREG1, adcGROUP1));

    /** - Read the conversion result

    * The data contains the Temperature sensor data

    */

    adcGetSingleData(adcREG1, adcGROUP1, adc_data_ptr);

    /** - Transmit the Conversion data to PC using SCI

    */

     sciSend_32BitData(scilinREG, ((unsigned int) (adc_data_ptr->value)));

     }

  • Tammy,

    There are several linked steps once you get an ADC conversion.

    1. Each ADC conversion reflects the analog output of the voltage divider that I had shown earlier. This is a divider formed by the thermal resistor and a fixed 100k-ohm resistor. For 25C, the thermal resistor is also 100k, so that the voltage seen by the ADC input is 3.3V/2, or 1.65V.
    2. Voltage Vin, seen by the ADC, is simply: (3.3V * 100k) / (Rx + 100k)
    3. Vin can also be calculated from the ADC chapter of the TRM as: 3.3V - (conv result * 3.3 / 4096)

    So you first go from the conversion result to the output of the voltage divider. Then you calculate the value of the thermal resistor based on this voltage. Then you calculate the temperature based on the value of the thermal resistor.

    You can perform these calculations on a PC and then create a look-up table between the ADC conversion result and the temperature that is stored in the flash memory. Or, like is done on the demo, you can only work with the ADC conversion results on the MCU and only do the calculation steps on the PC which takes in the ADC conversion results.

    Regards, Sunil

  • Thank you. So let us take a practical example to be sure we can understand process.

    i.e., assume adc_data_ptr->value = 1536 ( you wrote Each ADC conversion reflects the analog output of the voltage divider using TI example code, is this correct?)

    1. You wrote above first go from the conversion result to the output of the voltage divider. adc_data_ptr->value = 1536, so "1536" is the output of the voltage divider is what you mean

    2.Then you calculate the value of the thermal resistor based on this voltage.  Above you wrote that Vin can also be calculated from the ADC chapter of the TRM as: 3.3V - (conv result * 3.3 / 4096) so

    Vin = 3.3V - (1536 *3.3 /4096) = 2.0625

    3.  Then you wrote calculate the value of the thermal resistor based on this voltage. Is that equation #2 above? Or which math formula do we use to calculate value of thermal resister from value calculated after step 1?

    4. Then you wrote calculate the temperature based on the value of the thermal resistor (which is the direct table lookup in datasheet) Is this correct?  If you can calculate each step so we can have a visual of this process using a real number that would be helpful.. 

    Thank you again.

  • Tammy,

    See calculations below.

    1. ADC conversion result = 1536
      1. This indicates an ADC input of 3.3V - (1536 * 3.3 / 4096) = 2.0625V
    2. Vin = 2.0625V means that Rx = 60k-ohm
      1. Vin = 100k * 3.3V / (Rx + 100k)
      2. Rx = 100k * 3.3 / (Vin) - 100k = (100k * 3.3 / 2.0625) - 100k = 60k-ohm
    3. Now from the datasheet of the thermal resistor: Rx = 100k * exp [4334 * (1/x - 1/298.15)]
      1. 60k = 100k * exp[4334 * (1/x - 1/298.15)]
      2. After calculations, x = 309 degrees Kelvin, which is 35.85 degrees Celsius

    Regards, Sunil

  • Tammy,

    I made an error in the formula for the ADC input voltage based on the conv result in an earlier email.

    Conv result = 4096 * (Vin / 3.3) for a high-ref of 3.3V and a low-ref of 0V.

    So for a result of 1536, the input voltage is 1.2375V

    This gives Rx = 166.67 k-ohm, which then gives a temp of 14.87 degrees C.

    Sorry about the error.

    Regards, Sunil

  • Thank you. Great.  We will wait until you have more info then on the 2nd part of question on the ambient light calculation as you wrote initially above at start of thread. Thank you again.

  • Tammy,

    The PC program does not convert the light sensor data to actual light intensity. Instead, the demo just uses the ADC conversions to identify whether the light intensity is increasing or decreasing depending on whether the conversion values are increasing or decreasing, respectively.

    You can contact Vishay for more information if you really need to identify the actual light intensity from the the analog voltage output of this sensor.

    Regards, Sunil

  • Ok, then never mind, we stick to % then as test demo intended. Thank you.