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.

RTOS/CC2640: Configure the correct input pin to the ADC to digitize battery voltage

Part Number: CC2640
Other Parts Discussed in Thread: CC2650,

Tool/software: TI-RTOS

Hello E2E fellows,

i'm currently working on a custom board that has CC2640F128. Our board has a battery monitor pin (DIO_11), as the following schematic,

According to my schematic, if I want my max battery vol = 3.7 and my min battery vol = 3, then my BATT_MON should range from 1.08 to 1.33.

I'm trying to use the ADC in the adcsinglechanel project but I don't understand how I should configure my ADCCC26XX_HWAttrs,

const ADCCC26XX_HWAttrs adcCC26xxHWAttrs[CC2650_LAUNCHXL_ADCCOUNT] = {
    {
        .adcDIO = PIN_UNASSIGNED,
        .adcCompBInput = ADC_COMPB_IN_DCOUPL,
        .refSource = ADCCC26XX_FIXED_REFERENCE,
        .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
        .inputScalingEnabled = true,
        .triggerSource = ADCCC26XX_TRIGGER_MANUAL
    },
    {
        .adcDIO = IOID_19,
        .adcCompBInput = ADC_COMPB_IN_VSS,
        .refSource = ADCCC26XX_FIXED_REFERENCE,
        .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
        .inputScalingEnabled = true,
        .triggerSource = ADCCC26XX_TRIGGER_MANUAL
    },
    {
        .adcDIO = IOID_19,
        .adcCompBInput = ADC_COMPB_IN_VDDS,
        .refSource = ADCCC26XX_FIXED_REFERENCE,
        .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
        .inputScalingEnabled = true,
        .triggerSource = ADCCC26XX_TRIGGER_MANUAL
    }
};

#define     Board_ADC0              CC2650_LAUNCHXL_ADCVSS
#define     Board_ADC1              CC2650_LAUNCHXL_ADCVDDS

If I want to digitize voltage on my BATT_MON pin (pin IOID_19), how should I modify the above code? Board_ADC0 currently gives me a value of  3 and Board_ADC1 give me a value of 2771, which is not a valid number that I want.

Many thanks,

Henry

  • Bump for help!

    Thanks,

    Henry

  • Hi Henry,

    Actually the values you're getting seem to make sense if the voltage you're supposed to be seeing is 2.8V through your voltage divider (check with a multimeter) 4.2 [reference] / 4096 [resolution] = 1 V/bit, with your ADC code, it's roughly 2.8V. (Check my math)

    Either way, why not just use the battery monitor that's built into the cc2650? Instead of using a separate ADC channel?

    If you're worried about power, you can actually run the battery monitor from the sensor controller

    Regards,
    Rebel
  • Hello Rebel,

    I really appreciate your response. Coming from a CS background, everything in embedded software is brand new to me.

    The reason that I'm doing this (I might be wrong) is, our board is supplied by a 3.7V battery and through the voltage divider, the VCC would go down to 3V. I tried the below code to check the voltage from the built in battery monitor.

    AONBatMonEnable();
    
    uint32_t val = 0;
    val =  AONBatMonBatteryVoltageGet();
    val = (val * 125) >> 5;

    and the value that I got from a full charged 3.7V battery is 3V.

    What I want is checking the battery every X minutes and let the system go into sleep/standby mode when the battery goes down to 3.1V. If using the above code, I never could check that scenario. 

    Also, I don't understand your math. I thought that the signal value from my pin DIO_11 that I want to digitize would be calculate as:

    BATT_MON = V_BATT x [ R14 / (R14+R12) ]

    so with my battery voltage ranged from 3.7V (when fully charge) to 3.1V (the minimum voltage that I want to detect) the BATT_MON should range from 1.12V to 1.33V. Is that correct?

    Thanks again,

    Henry

  • Hello Rebel,

    In other words, if your device is powered directly from the batteries you'd use the internal Battery Monitor and do not need to use the ADC.  But I'm running off a regulator, so VDDS is constant while the actual battery voltage is varying (3.7V down to 3.1V <--- I want to make the system standby/sleep at this point). That's why I need to digitize the battery voltage level from the ADC of pin IOID_11 (BATT_MON).

    Btw, does anyone know why my replies in this post have to be approved by forum moderators before they can be posted? My previous reply to you does not show up here!.

    Thanks,

    Henry 

  • Ops, seems like my previous reply to you get deleted? idk, I'm going write it again.

    Hello Rebel,

    I really appreciate your response. Coming from a Computer science background, everything in embedded software is brand new to me.

    The reason that I'm doing this (I might be wrong) is, our board is supplied by a 3.7V battery and through the voltage divider, the VCC would go down to constant 3V. I tried the below code to check the voltage from the built in battery monitor.

    AONBatMonEnable();
    
    uint32_t val = 0;
    val = AONBatMonBatteryVoltageGet();
    val = (val * 125) >> 5;

    and the value that I got from a full charged 3.7V battery is 3V.

    What I want is checking the battery every X minutes and let the system go into sleep/standby mode when the battery goes down to 3.1V. If using the above code, I never could check that scenario.

    Also, I don't understand your math. I thought that the signal value from my pin DIO_11 that I want to digitize would be calculate as:

    • BATT_MON = V_BATT x [ R14 / (R14+R12) ]

    so with my battery voltage ranged from 3.7V (when fully charge) to 3.1V (the minimum voltage that I want to detect) the BATT_MON should range from 1.12V to 1.33V. Is that correct?

    Thanks again,

    Henry

  • Hi Henry,

    Only DIO23 to DIO30 are analog capable (on the 7x7 package). Using other DIOs will not work.

    Cheers,
    Fredrik
  • Thank you for your response Fredirik,

    I got your point. But as a discussion in my previous post here, our custom board has different pin mapped. Therefore, it is not compatible with the projects that run on CC2640/CC2650 until I changed the pin ID that match with my schematic, and I think this might be the same case with my BATT_MON pin.

    Thanks,

    Henry

  • Hi Henry,

    The internal battery monitor measures the VDDS voltage.

    The ADC can only read voltage on certain DIOs. On the 7x7 package these are DIO23 - DIO30. There is no way to reconfigure this.

    BR,
    Fredrik
  • Thank you for your explanation Fredrik, it makes sense. Still, I don't understand what the purpose of putting the BATT_MON - DIO11 on our custom board.

    I don't know what is the minimum voltage needed for our board (and I will double check this), but if it cannot run if the supply voltage is below 3V, the point of measuring VDDS is pointless (that's also the reason why I want to stop the software when the battery voltage drops down to 3.1V), do you have any suggestion for this case?

    Thanks again for your time and your help,

    Henry

  • Since you are running off a regulator, using the battery monitor does not make sense as you say.

    I cannot tell you why DIO11 is used on your board, but it definitely needs to be move to an analog capable pin to be connectable to the ADC.
  • Thank you very much Fredrik. I will suggest our team to move it to the DIO_26 - DIO_30 in the next version board.
    May I ask If it's moved to DIO_30, how would I read the battery voltage on that pin?

    Thanks,
    Henry