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

Using ADC/SAADC to read data in BLE app

I am currently development an app based on the example from the experimental folder using a NRF DK52 as a relay between a central and multiple peripherals.

The app should now react on the press of a button from an external device. The device is built like that - for whatever reason the unpressed button is at voltage 2.7V whereas when pressed falls down to 1.2V. The way the device works is out of my control. Because of the high lower value I was told I cannot use a digital input as the maximum 0 value would be recognized at 0.8V.

Therefore I now think about using ADC/SAADC to read the voltage continously and act when the read values are in the range that indicate the button was pressed. 

I was looking at the peripheral/saadc example and it worked quite well so far. But then I read that it is not recommended to perform SAADC measurements while BLE RF is happening at the same time. Also SAADC measurements seem to be delayed or in general slower when BLE is active?

What is your recommendation to perform that task? Should I use plain ADC or SAADC? I believe in order to recognize the button press accurately my sampling interval should not be much slower than every 100ms? Whats the best practice here? 

Parents
  • Thanks @snoopy20. What do you mean by "you have the AC comparator available"? Any chance you have a small sample code to illustrate your idea? I'm still learning the SDK and focused on the BLE stuff with yet little experience on the peripherals themselves. A diode might actually be helpful... good idea! I'll check it out!

  • The NRF52832 has two comparators, the 810 has one. A comparator continuously 'samples' a voltage and triggers an event when it goes above or below a threshold level (which you can define). It should be your first choice. The ADC with the LIMIT feature is doing the same thing basically, just it's slower and uses more power (if you're bothered).

    No code here but it's easy to follow the direct documentation. I only use the SDK for BLE, all other peripherals I control direct as I find the SDK is bloated and an unnecessary abstraction. If I wanted that I'd use Arduino.

    infocenter.nordicsemi.com/index.jsp

    The comparator (COMP) compares an input voltage (VIN+) against a second input voltage (VIN-). VIN+ can be derived from an analog input pin (AIN0-AIN7). VIN- can be derived from multiple sources depending on the operation mode of the comparator.

    Main features of the comparator are:

    • Input range from 0 V to VDD
    • Single-ended mode
      • Fully flexible hysteresis using a 64-level reference ladder
    • Differential mode
      • Configurable 50 mV hysteresis
    • Reference inputs (VREF):
      • VDD
      • External reference from AIN0 to AIN7 (between 0 V and VDD)
      • Internal references 1.2 V, 1.8 V and 2.4 V
    • Three speed/power consumption modes: low-power, normal and high-speed
    • Single-pin capacitive sensor support
    • Event generation on output changes
      • UP event on VIN- > VIN+
      • DOWN event on VIN- < VIN+
      • CROSS event on VIN+ and VIN- crossing
      • READY event on core and internal reference (if used) ready
Reply
  • The NRF52832 has two comparators, the 810 has one. A comparator continuously 'samples' a voltage and triggers an event when it goes above or below a threshold level (which you can define). It should be your first choice. The ADC with the LIMIT feature is doing the same thing basically, just it's slower and uses more power (if you're bothered).

    No code here but it's easy to follow the direct documentation. I only use the SDK for BLE, all other peripherals I control direct as I find the SDK is bloated and an unnecessary abstraction. If I wanted that I'd use Arduino.

    infocenter.nordicsemi.com/index.jsp

    The comparator (COMP) compares an input voltage (VIN+) against a second input voltage (VIN-). VIN+ can be derived from an analog input pin (AIN0-AIN7). VIN- can be derived from multiple sources depending on the operation mode of the comparator.

    Main features of the comparator are:

    • Input range from 0 V to VDD
    • Single-ended mode
      • Fully flexible hysteresis using a 64-level reference ladder
    • Differential mode
      • Configurable 50 mV hysteresis
    • Reference inputs (VREF):
      • VDD
      • External reference from AIN0 to AIN7 (between 0 V and VDD)
      • Internal references 1.2 V, 1.8 V and 2.4 V
    • Three speed/power consumption modes: low-power, normal and high-speed
    • Single-pin capacitive sensor support
    • Event generation on output changes
      • UP event on VIN- > VIN+
      • DOWN event on VIN- < VIN+
      • CROSS event on VIN+ and VIN- crossing
      • READY event on core and internal reference (if used) ready
Children
No Data
Related