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

read high speed analog sensor data and send data to pc

Hi,

I'm working on a project where I need to collect and process analog data coming from high speed sensor measurements. The data needs to be read at a speed of 25k samples/sec. In which way do I need to adapt the saadc example file to increase the sampling speed? I tried changing

uint32_t ticks = nrf_drv_timer_ms_to_ticks(&m_timer, 400);

into

uint32_t ticks = nrf_drv_timer_us_to_ticks(&m_timer, 40);

but when I then look at the result in the Termite-terminal, it says 'overflow'. Is the limiting factor here the sampling frequency of the ADC-pins or the rate with which the data is send to the terminal? And is there a way to avoid just getting 'overflow'?

Also, to be able to process the data, I would like to save the samples in an array and then send the entire array all together to my computer once every second for example. I wanted to do this just via the USB-connection that is already established but I don't know if something like this is possible. Do you have some example code where something similar is done?

-Thank you

  • Hi Tim,

    The SAADC peripheral support sampling rate up to 200 ksps, with aquisition time set to 3 us. With default settings from SAADC example from SDK (10 us aquisition time), you should be able to achieve 83.33 ksps sample rate.

    The overflow message you are seeing is from the UART printing. You could try increasing the baudrate, for instance to 1 Megabaud.

    If you are using the nRF52840, there is an USB CDC ACM example in the SDK, which emulates a virtual COM port over the USB interface. You should be able to modify this to transfer the ADC data to the computer. If you are using the nRF52832, there is no USB interface on this chip, but the Segger J-Link IF MCU on the nRF52 DK also provide Virtual COM port interface.

    Best regards,

    Jørgen

  • Thank you for your reply,

    Increasing the baudrate partly fixed the problem with the overflow message. I can now reach up to 2.5k samples/sec. Is it possible to increase the baudrate beyond 1 Megabaud?

    I'm indeed using nRF52840. I implemented the USB CDC ACM example but I would like to receive the data in a .txt file (also .xlsx file or .mat file would work). At this moment I can only view the data in the putty or termite terminal. There seems to be a problem with the Windows driver for the nRF52840 USB CDC ACM. Is there a fix for this?

    Best regards

  • Unfortunately, only up to 1 Mega baud is supported by the UART peripheral. Unfortunately, we do not have any file transfer examples. The closest we provide is the USB MSC Example. It is possible to use the FatFS driver in this example to store files on external QSPI flash, and then copy the files from the MSC device on your computer, but it will not work in an automated way. If you want to transfer files directly, you need to implement your own USB class. What is the issue with the driver? I tested it on Windows 7 yesterday and it worked fine. Also tested example on Windows 10, but there no driver is needed.

  • The driver is not automatically installed when I connect the device to my computer. I added the nordic_cdc_acm_example.inf file manually in the driver settings but still the device doesn't show up as a removable disk so I can't retrieve any of the .txt files that should be created in this example.

  • The nordic_cdc_acm_example.inf driver should not be used with the MSC example, this is only for CDC ACM example. The device should enumerate as MSC device automatically. Which Windows version are you using? Have you tried removing the driver and reconnected the board?

Related