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

Latency measurement/log

Hi, all. I would like some serious help. I have three nRF52840 boards and have been running all the examples from the blinky to light switch/dimming. I am, however, stuck as to how i can send (arbitrary/advert) packets between these and get a log of the latency. I want the one board to send a packet to the another board. The receiver must acknowledge that it has received by sending its own packet back. I need to know the time it takes for this exchange to occur. I will be connecting the boards as a mesh. Thanks.

  • The radio events are clearly spelled out in the nRF specification.  events_address occurs immediately after reception an address. Although the event clock would be p_clock (16MHz), since the radio phy is either 1 or 2 MHz you should consider the resolution of this event to be about +/-0.5usec since the phy symbols are up to 1usec long and with the Gaussian filtering they don't have a hard edge like digital signals.

    However, that event won't do you a lot of good since you can't interrupt into your code while the softdevice is working.  At best you could route the event to gpiote and do something with it there.

    Likely a better way to handle your question is with a mix of BLE and custom protocol.  By timeslotting some custom protocol comms in with the BLE work you can use the radio to synchronize itself in a system and thereby discover your latency.  The same rules apply that basic error will be about +/-0.5usec but at least it is feasible.

    Nordic published a really nice time sync solution.  You can read about it here: devzone.nordicsemi.com/.../wireless-timer-synchronization-among-nrf5-devices

  • Hi Rorisang, 

    You would need to use acknowledged messages for your purpose. 

    In our light switch example we use that message when sending "reliable publish" message, please check generic_onoff_client_set() function. 

    When there is a status message response to the reliable publish message, the function status_handle() in generic_onoff_client.c will be called. 

    You can calculate the latency by starting a timer when you send the reliable message and stop it when you receive the status call back. 

Related