NRF52832 ADC trigger at Low battery voltage

Hello everyone,

I have a nrf52832 device and want to fire a feedback (led and vibration) in case of low battery voltage. I am measuring the battery voltage over a ADC channel and it is already working. The point is I have to always send a command to read out the sampled value. So I have the possibility to add a while loop and check every second the battery voltage till it is low.

But I am sure there must be a more elegant way to realize it. I think about some kind of ADC trigger/interrupt where the µC detects a threshold and starts a handler. I already implemented something similar for the GPIO. What is the best way to identify a low battery voltage ?

Best regards

Hani

Parents
  • Hello,

    The SAADC does not have a sensing mechanism to automatically detect if the voltage dips below certain thresholds. So you will need to trigger periodic sampling to be able to monitor the battery voltage. I posted an example of this here: https://devzone.nordicsemi.com/f/nordic-q-a/71940/low-power-mode-using-saadc-with-ble_app_beacon

    However, if you only need detect "battery low", then you may also consider using the Power-fail comparator 

            Power-fail comparator

    The power-fail comparator (POF) can provide the CPU with an early warning of impending power failure. It will not reset the system, but give the CPU time to prepare for an orderly power-down.

    The comparator features a hysteresis of VHYST, as illustrated in Figure 4. The threshold VPOF is set in register POFCON. If the POF is enabled and the supply voltage falls below VPOF, the POFWARN event will be generated. This event will also be generated if the supply voltage is already below VPOF at the time the POF is enabled, or if VPOF is re-configured to a level above the supply voltage.

    If power-fail warning is enabled and the supply voltage is below VPOF the power-fail comparator will prevent the NVMC from performing write operations to the NVM. See NVMC — Non-volatile memory controller for more information about the NVMC.

Reply
  • Hello,

    The SAADC does not have a sensing mechanism to automatically detect if the voltage dips below certain thresholds. So you will need to trigger periodic sampling to be able to monitor the battery voltage. I posted an example of this here: https://devzone.nordicsemi.com/f/nordic-q-a/71940/low-power-mode-using-saadc-with-ble_app_beacon

    However, if you only need detect "battery low", then you may also consider using the Power-fail comparator 

            Power-fail comparator

    The power-fail comparator (POF) can provide the CPU with an early warning of impending power failure. It will not reset the system, but give the CPU time to prepare for an orderly power-down.

    The comparator features a hysteresis of VHYST, as illustrated in Figure 4. The threshold VPOF is set in register POFCON. If the POF is enabled and the supply voltage falls below VPOF, the POFWARN event will be generated. This event will also be generated if the supply voltage is already below VPOF at the time the POF is enabled, or if VPOF is re-configured to a level above the supply voltage.

    If power-fail warning is enabled and the supply voltage is below VPOF the power-fail comparator will prevent the NVMC from performing write operations to the NVM. See NVMC — Non-volatile memory controller for more information about the NVMC.

Children
  • Hi Vidar,

    Thank you for the feedback! I think I understood how to implement your example. Meanwhile I want to clearify a question:

    How is the current consumtion if I would use "nrf_drv_saadc_sample()" for example every 5 seconds in my while loop compared to your method with the timer. What is the general advantage there?

  • Hi,

    The timer offers you convenient way of getting the app perform a specific task at a fixed interval. The timer interrupt wakes the CPU from sleep so you can perform the task(s) you want, and then let it return back to sleep afterwards (provided you are calling the idle function from your main loop).

    Hani_Montana said:
    How is the current consumtion if I would use "nrf_drv_saadc_sample()" for example every 5 seconds in my while loop compared to your method with the timer.

    It depends on how you have implemented it. Busy-waits with nrf_delay_ms(),etc are not power efficient as they keep the CPU running. To get low power consumption, you need something that can signal the program when to sample the SAADC without needing to keep the CPU awake.

Related