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.

ADC Ground Reference

Other Parts Discussed in Thread: CC2540

I'm having an issue with using the ADC in the CC2540. I'm trying to read values from an external sensor using a modified version of the simple profile. The sensor outputs a voltage in the range of 0v to 2.5v. However I'm finding that I get no reading from the ADC until the output of the sensor passes ~950mV. I'm assuming that the value should actually be a proportion of the voltage between 0v and AVDD (as configured in my code) but this doesn't seem to be happening. Could anyone suggest why this is the case?

My code is given below. The actual device I'm working on is the the BLE112 breakout board and the sensor has three wires - VSS (connected to pin 3), Sense (connected to pin 26) and GND (connected to pin 30) (http://goo.gl/YaQRq)

 static void performPeriodicTask( void )
 {
  uint16 adc;
  uint8 valueArray[2];

  HalAdcSetReference( HAL_ADC_REF_AVDD );
  //HalAdcSetReference( HAL_ADC_REF_125V );

  adc = HalAdcRead( HAL_ADC_CHN_AIN2, HAL_ADC_RESOLUTION_12 );

  valueArray[0] = HI_UINT16(adc);
  valueArray[1] = LO_UINT16(adc);

    /*
     * Call to set that value of the load characteristic in the profile. Note
     * that if notifications of the load characteristic have been enabled by
     * a GATT client device, then a notification will be sent every time this
     * function is called.
     */
   Loadcell_SetParameter( LOADCELL_LOAD, LOADCELL_LOAD_LEN, &valueArray);
 }

EDIT: Upon further investigation it turns out that this voltage is recognised by the ADC upon exceeding 1.2V or so.

Input Volts    ADC Value
1.158V           00:0A. 
1.337V           02:B5 (increase of 683 decimal)
1.519V           03:32 (increase of 125 decimal)

All other increases after this are approx ~120. Hence from the looks of things the ADC isn't updating correctly until a certain voltage is present (rather than just not seeing this voltage)

  • Hello,

    To convert a voltage to an ADC value in your example, isn't  this the case: (AIN Voltage)/AVDD * 4096 = adc value

    #define HAL_ADC_REF_AVDD  (This is the voltage on the AVDD SOC Pin Reference)

    What is your AVDD value?

    LPRF Rocks the World

  • LPRF Rocks the World said:

    Hello,

    To convert a voltage to an ADC value in your example, isn't  this the case: (AIN Voltage)/AVDD * 4096 = adc value

    #define HAL_ADC_REF_AVDD  (This is the voltage on the AVDD SOC Pin Reference)

    What is your AVDD value?

    LPRF Rocks the World

    Yes that's how I understand it anyway. As far as AVDD goes, it's tied to the input voltage no? I don't have the device to hand however I'm using one of the BLE112 breakout boards and powering it using the CC debugger. Last time I checked, I had a voltage of roughly 3.2V on the pin.

  • What is the impedance of the sensor connection to your ADC, is it from a low impedance source like an opamp? The adc has a significant input impedance of a few hundred K which can cause significant drop in signal if your source impedance is too high. Also confirm the voltage of your AVDD.

  • Eng351 said:

    What is the impedance of the sensor connection to your ADC, is it from a low impedance source like an opamp? The adc has a significant input impedance of a few hundred K which can cause significant drop in signal if your source impedance is too high. Also confirm the voltage of your AVDD.

    Impedence mismatch was exactly the problem. My output was from an in-amp, so I tied it to ground using a 1k resistor and the ADC magically started registering an input from 0v upwards. Lesson learned.

    However, my ADC value is still not correct. I have it configured as given in the initial post - 12 bits, with an AVDD reference voltage (3.045V coincidentally) and input taken on AIN2. However, I'm finding the ADC is maxing out at 0x07FF (2047). I had been expecting this to be 0x0FFF (4095). Based on the code above, would anyone have any idea why this is not the case?

  • Hello,

    Since the ADC can give negative values the 12 bit number is a signed number so the 7FF indicates the most positive value.

    Regards,

    BK

  • What In-amp are you using? An In-amp should have a low output impedance without needing an external 1k load resistor. What voltage is the in-amp reference connected to? Are you always expecting to see a +ve swing on the input?

  • Confirming also from experience when operating the ADC in 14-bit mode, you will get 8191 as the max when VIN = VREF, so in 12 bit mode you should get 2047 as max

  • Eng351 said:

    What In-amp are you using? An In-amp should have a low output impedance without needing an external 1k load resistor. What voltage is the in-amp reference connected to? Are you always expecting to see a +ve swing on the input?

    I'm using Analogs AMP04 (a single supply in amp) with a 500mV reference voltage. The input is from a Wheatstone bridge (a load cell) so it may not be +ve initially (inaccuracies in the strain gauges etc.), but it will be for the majority of the time.

  • (AIN Voltage)/AVDD * 4096 = adc value ...... sorry guyz i am new 2 this type of coding and in this stepwhatdoes 4096 stands fr ?? 

    and what does HAL_ADC_CHN_VREF means ??? how much voltage is taken as vreff ????