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

Streaming SAADC values over BLE at 1 ksps

Hi ,

I am working on one application in which i need to stream the ADC values over BLE to the mobile App. This should happen at very high rate i.e. 1000 samples per seconds. I am using SAADC of nrf52 with 12 bit resolution.

Can it be possible and what are the parameters should I consider while doing this? Please help me to solve this issue. Kindly suggest any sample code or any important thread related to this.

Parents
  • Hi Ankush,

    the proper way would be to use a hardware timer (which also may be the second low power RTC) for the sampling interval and use EasyDMA to write the data into a buffer. Have a look at the Product Specification, there you get a very good description about how the hardware works. You can use the END event from SAADC to add the next buffer (double buffering) which is used while you process the new samples (e.g. create a notification packet with 10 samples). This way, you may send notification packets every 10 ms and nothing will be time critical, as the SAADC continues sampling in background with the 1 ms inteval once you set the new buffer and trigger the start task again. In other words, you will get interrupts in 10 ms intervals that provide you with a batch of data to transmit.

  • Hi Ankush,

    First of all, I would like to mention that I am a Nordic customer like you are and I don't have the time to go through all your code (which is in my opinion way too large, by the way) and give you full support. But I'll try to gice you some hints as my linited time allows.

    I have never worked with app_timer (and probably never will), so I cannot give you much help there. Maybe the app_timer does not support small intervals like 1ms? I don't really know at all.

    I suggest you do some debugging and analyze the data that is sent and received. It seems like you use a sequence number in the first byte of the packet. Are packets missing between the sequence numbers? Then you might have a buffer overflow on the sender side (maybe the connection interval is set too slow), or your smartphone is not powerful enough to handle all received notifications. If the sequence number is always the same and does not increase, it seems like your software is causing a reset due to implementation errors. Have you checked for continuous resets? You can also add a printf() statement each time you try to send a packet, so you can track down the error.

    It also seems that you are calling the ble_nus_string_send() with APP_IRQ_PRIORITY_LOW (callback!) and not from the main() loop. Is this allowed? Please check the documentation, if there is a problem with priorities maybe this could cause the SoftDevice to trigger a reset. By the way, when your BLE connection gets disconnected, this usually suggests that something went wrong within the SoftDevice (e.g. SoftDevice timing is out of sync) and there was a system reset.

Reply
  • Hi Ankush,

    First of all, I would like to mention that I am a Nordic customer like you are and I don't have the time to go through all your code (which is in my opinion way too large, by the way) and give you full support. But I'll try to gice you some hints as my linited time allows.

    I have never worked with app_timer (and probably never will), so I cannot give you much help there. Maybe the app_timer does not support small intervals like 1ms? I don't really know at all.

    I suggest you do some debugging and analyze the data that is sent and received. It seems like you use a sequence number in the first byte of the packet. Are packets missing between the sequence numbers? Then you might have a buffer overflow on the sender side (maybe the connection interval is set too slow), or your smartphone is not powerful enough to handle all received notifications. If the sequence number is always the same and does not increase, it seems like your software is causing a reset due to implementation errors. Have you checked for continuous resets? You can also add a printf() statement each time you try to send a packet, so you can track down the error.

    It also seems that you are calling the ble_nus_string_send() with APP_IRQ_PRIORITY_LOW (callback!) and not from the main() loop. Is this allowed? Please check the documentation, if there is a problem with priorities maybe this could cause the SoftDevice to trigger a reset. By the way, when your BLE connection gets disconnected, this usually suggests that something went wrong within the SoftDevice (e.g. SoftDevice timing is out of sync) and there was a system reset.

Children
No Data
Related