5 years, 9 months ago.

Can I detect a peak in an analog signal of around 1ms duration while using the nRF51822 with BLE?

I am building a demonstrator which is a target for a hacky-sack throwing game for a BLE UI development tool. I find that the pulses when the sack hits the target are short - around 10ms and to identify the ring that the sack hits requires me to find the peak of three signals with the peak appearing to be identifiable only within around a 2ms window. Without external electronics - which I'd like to avoid - I think I need regular ADC sampling of around 1000 samples per second (on 3 channels) - or maybe it's better to say a maximum of 2ms between samples.

I'm doing this with an nRF51822-MKIT and want the BLE to remain functional as this is the purpose of the demonstrator.

To get started I've experimented by modifing the BLE_HeartRate example. By default it has a 1s "ticker" which sets a flag to allow sampling in the main loop (rather than in the ticker ISR). Adding in a timer to measure the "latency" of this approach gave me the impression that sampling in the main loop wouldn't permit me to get anywhere close to the 1ms between samples that I seek.

One approach I tried was to increase the "ticker" rate to 1000 ticks per second but this makes the example unstable (reading around the issue I believe the BLE softdevice requires around 1.8ms to do its stuff in some cases).

I've tried a 2ms "ticker" in the following code ...


This seems stable (I've left it running overnight :) ) [EDIT - actually it seems to have just hung too] but I don't know how to be certain that it won't fail in some edge conditions.

I looked at burst mode ADC options but the nRF51822 seems to only have one ADC result register so I don't think that would help even if I could work out how to program the chip to do it.

Are there any other solutions to taking 3 analog samples at a max of 2ms between samples while still maintaining BLE operation?

Be the first to answer this question.