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

Parents
  • Assuming you are using nRF51 and using APP_TIMER (RTC1).

    You initialize the APP_TIMER using the prescaler. lets say that the prescaler is 0 then your timer generates 32768 ticks per second.

    The macro given in app_timer.h converts the milliseconds to number of ticks.

    #define APP_TIMER_TICKS(MS, PRESCALER)\
                ((uint32_t)ROUNDED_DIV((MS) * (uint64_t)APP_TIMER_CLOCK_FREQ, ((PRESCALER) + 1) * 1000))
    

    Above you see that if MS = 120000 and prescaler 0, which is 120 seconds then you will get Ticks = ((120000*32768)/(0+1)*1000) rounded up to integer = 3932160 ticks. This is telling you that the timer will put 3932160 (0X3c0000) in RTC compare register and when RTC is started and is running for this many ticks, then it will be 120 seconds.

    Does this answer your question?

  • @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)
    
Reply
  • @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)
    
Children
No Data
Related