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

Absolute Beginner In need for Step-by-Step Help configuring SAADC for LOW POWER sampling of single input

I've been chasing my tail trying to figure this out, and thought I'd have better luck making a post instead. I could REALLY use your help! If you can merely point me in the right direction, or give me a heads up on possible roadblocks I can expect, anything really, I'd appreciate it! I don't want the majority of my project time going into setting up and configuration, but it has.

I've attempted following these links/tutorials with no success: 

https://github.com/NordicPlayground/nRF52-ADC-examples/blob/master/saadc_low_power/main.c

https://devzone.nordicsemi.com/f/nordic-q-a/8676/simulataneous-adc-sampling

https://devzone.nordicsemi.com/f/nordic-q-a/44758/trouble-with-simple-saadc-sampling

https://devzone.nordicsemi.com/tutorials/b/getting-started/posts/nrf52840-dongle-programming-tutorial

Hardware in hand: nRF52840 Dongle + nRF52840 Development Kit (DK)

Software being used at the moment: SEGGER (on MacOS), nRF Connect

Goal:

A. Configure proper software so for *modular* sampling of 2*max_freq of single analogue input (0-3V) on the Development kit (solely for debugging, end goal will be to only have to use the Dongle)

B. Utilize the internal micro controller so the ADC transfers the data in the local memory acting as a buffer before the wireless transmission.

C. Send via wireless transmission to Nordic mobile app (and implement any bluetooth modules needed)

Questions:
1. How do I configure the UART on SEGGER, or in general display and check my outputs are correct? I attempted following a tutorial from Nordic, mentioning things like baut rate which doesn't seem to be on SEGGER.

2. Do I use nRF Connect, nRF Toolbox, or both for setting up? If both, how do I get these to communicate with each other and SEGGER? 

3. Should I use SoftDevices? Which ones should I look into?

Parents
  • 1) If you want to use SEGGER RTT, just change the sdk_config.h from uart to rtt, which means:

    #define NRF_LOG_BACKEND_RTT_ENABLED 1
    #define NRF_LOG_BACKEND_UART_ENABLED 0
    

    Also make sure that NRF_LOG_ENABLED is set to 1. You can then use the debug terminal (press F5) to debug directly via Segger & receive logging information to Segger. This video may also be helpful.
     
    2) If you are referring to a Bluetooth communication from the 52840 DK (or 52840 dongle) to the mobile phone, you could either use nRF Connect or nRF Toolbox. I would probably go with nRF Connect. If you are referring to the wired RTT communication between the 52840 DK & the Segger IDE (Segger Embedded Studio), then see answer 1.
     
    3) If you want Bluetooth communication, you will need to use the softdevice, as this is the Nordic BLE stack implementation. The S140 softdevice is the one needed for the 52840 device (both DK & dongle). 
    I would take a look at the SAADC example from nRF5 SDK v15.3 (see documentation here). The S140 softdevice will automatically get programmed to the DK when you use any BLE example for the 52840 (i.e. pca10056) (e.g. nRF5_SDK_15.3.0_59ac345\examples\ble_peripheral\ble_app_uart\pca10056\s140). Since the SAADC example does not use a softdevice (because it is only a peripheral example), I would recommend using the ble_peripheral uart example as a starting point & then adding the SAADC functionality to the UART example. Before you start adding code to the uart example, I would test both out separately & make sure you understand the code. 
     
    You can find the softdevice hex file here: nRF5_SDK_15.3.0_59ac345\components\softdevice\s140\hex
  • (URGENT)

    General:

    1. Are either of these good reference /a better starting point? ble_app_uart__saadc_timer_driven__scan_mode example: https://github.com/NordicPlayground/nRF52-ADC-examples/tree/master/saadc_low_power

    saadc_low_power example:

    https://github.com/NordicPlayground/nRF52-ADC-examples/tree/master/saadc_low_power#documentation

    Seems to do exactly what I need: Activate sampling when needed, turn off when not needed. 

          1a. From your previous response in (3) you mentioned I would need to integrate the ADC into the ble_uart example and     the above saadc_lower_power examples “contains a code example that shows nrf52 SAADC scan mode and how to integrate SAADC with softdevice.” Is this what you meant? If so, should I instead reference this ex?



    1. Testing with the SAADC example you recommended, I noticed I can have =< 5 samples in the buffer (print 5 ADC readings at a time for every event). My end goal is to have 12, and changing the one variable #define SAMPLES_IN_BUFFER from 5 to 12 doesn't give me any output. I assume this is because there are other variables with restrictions that communicate with this one - what other things should I change to get my expected 12? 

    App side:

    1. I’ve only been able to test communication between my dongle and the ble_uart_ex running on my DK. So far I can feed in a hex number and obtain the expected output in the SEGGER terminal emulator. Great! But when it comes to using nrF Connect over bluetooth, I’ve had no progress (tested both with an iPhone and iPad). The wireless connection with my DK times out within less than 10 seconds. I get the error message: “Disconnected from device 67:3C:CB:DF:69:C2, reason: BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION.” my goal is to send data from the dongle or DK to be displayed on my iPad, so this means I’d be using the ‘Advertising’ feature on the iPad, correct?



  • Sorry for the delayed response. I have been on a business trip last week & am now on vacation. Due to lower staffing over Easter, there may be some delays in answering questions. DevZone will be fully staffed on the 23rd of April. You can expect a response latest on the 24th of April. Sorry for any inconvenience caused.

  • You could use the github example as a reference. I would rather use the latest nRF5 SDK SAADC example to get started. See the documentation at the bottom of the github example for clarification:

    "This application is one of several applications that has been built by the support team at Nordic Semiconductor, as a demo of some particular feature or use case. It has not necessarily been thoroughly tested, so there might be unknown issues. It is hence provided as-is, without any warranty."

    But at the end of the day, it is up to you! If you can live with the demo nature of the example, you could start with the github example.

    The example should work out of the box on the 52840 DK.

    2) Have you tried with values less than 12? Does a buffer size of 10 samples work for example? Could you also maybe consider decreasing the buffer size to 1 & then doing averaging in the saadc handler, like explained in this great answer here?

    3) No, you won't need to use the "Advertising" feature on nRF Connect. Just scan for the Nordic UART device (i.e. your 52840 DK), connect to it & follow the testing documentation here.

Reply
  • You could use the github example as a reference. I would rather use the latest nRF5 SDK SAADC example to get started. See the documentation at the bottom of the github example for clarification:

    "This application is one of several applications that has been built by the support team at Nordic Semiconductor, as a demo of some particular feature or use case. It has not necessarily been thoroughly tested, so there might be unknown issues. It is hence provided as-is, without any warranty."

    But at the end of the day, it is up to you! If you can live with the demo nature of the example, you could start with the github example.

    The example should work out of the box on the 52840 DK.

    2) Have you tried with values less than 12? Does a buffer size of 10 samples work for example? Could you also maybe consider decreasing the buffer size to 1 & then doing averaging in the saadc handler, like explained in this great answer here?

    3) No, you won't need to use the "Advertising" feature on nRF Connect. Just scan for the Nordic UART device (i.e. your 52840 DK), connect to it & follow the testing documentation here.

Children
No Data
Related