This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

what is the principle of converting Ticks in to seconds

Hello

I am trying to change the ticks value of Battery measurement interval (ble_app-prox example) but i am not able to understand how the ticks period is measured based on what i understood from the example 1s is equal to 1000ms so totally we are setting it to120s then the ticks period is equal to 120000 if am wrong please correct me and explain me the correct method my aim to see the battery level changing based on the battery -measure_interval any help would be greatly appreciated

thankyou

  • @Karan: I change the proximity app to check the battery level every 10 s

    #define BATTERY_LEVEL_MEAS_INTERVAL         APP_TIMER_TICKS(10000, APP_TIMER_PRESCALER)
    

    When you connect your MCP to the device ->discover services->enable services then you will see that MCP will start to get notifications every 10 s for the battery level change. Note that the notification is only sent of the battery level has changed from the previous notified value.

    @prabhudurai: The voltage always starts with 100% when your app starts irrespective of what the actual voltage on your device. After the first sample is taken BATTERY_LEVEL_MEAS_INTERVAL time after your enable the services, then it will then check the actual voltage and tell you that the real value.

    15% does not mean that your battery is very old or dying.

     *           The discharge curve for CR2032 is non-linear. In this model it is split into
     *           4 linear sections:
     *           - Section 1: 3.0V - 2.9V = 100% - 42% (58% drop on 100 mV)
     *           - Section 2: 2.9V - 2.74V = 42% - 18% (24% drop on 160 mV)
     *           - Section 3: 2.74V - 2.44V = 18% - 6% (12% drop on 300 mV)
     *           - Section 4: 2.44V - 2.1V = 6% - 0% (6% drop on 340 mV)
    
  • Thanks for your kind brief information about this point could you tell me some ideas how to implement the fucntion in order to see the real battery voltage something around 80 to 90percent atleaset because i would like to broadcast the battery votlage to the MASTER control panel in real time ?i have checked via UART putty terminal in the ADC handler fucntion am getting adc_result value as 57 and batt_level_milli_volts as 809 and percentage in battery as 0 hardly i did nto understand how this value are interrelated (all measurements are done via USB power)

  • depends on your chip. From the info center i can read that nrf51422 has suppy range of 1.8V-3-6V. This means that 2.1V must be 0% because this is low of CR2032 battery. and 3.3 must be 100% (because most coin cell comes with 3.0V output).

    in app_util.h change the function battery_level_in_percent like below

    static __INLINE uint8_t battery_level_in_percent(const uint16_t mvolts)
    {
        // We assume 3000 mV is 100% and 2100 mv (dead CR2032) is 0%  = (((mvolts - 2100) * 100)/900);
        return ((mvolts - 2100) /9);
    }
    

    from the above you can tell that your suppy voltage is (percentage * 9) + 2100 Remember that CR2032 will never get to 1.8V i guess, but the above example

    and change BATTERY_LEVEL_MEAS_INTERVAL to appropriate interval you need. Remember that first time the drop will be from 100% to down drastically because we start the program with assumption of 100%

  • thanks for your kind reply after i have modified those function am getting 68perrcentage as batteryv oltage but how can i make sure that value is correct? however the CR2032 maximumvoltage will be 3V as per the datasheet so can we put 1800 instead of 2100 if i put like that am getting 93 percentage battery for 1800 value and 68 percent for 2100 value in the above formula

  • is there is any other ways to check the battery voltage inorder to make sure the measurement is correct how do you calculate the function like that percentage +12 is there is any idea behind in it?

Related