Settings

Theme

Benchmarking latency across common wireless links for microcontrollers

electricui.com

135 points by killcoder 2 years ago · 35 comments

Reader

killcoderOP 2 years ago

We nerd sniped ourselves into testing the latencies of a whole bunch of wireless communication links and protocols for microcontrollers.

We’ll probably do a series of power consumption / range tests later on, let me know if there are any setups in particular that you’d be interested in seeing test cases for.

Raw data, firmware and post processing scripts are here on GitHub:

https://github.com/Scottapotamas/embedded-wireless-latency-e...

  • pockybum522 2 years ago

    Once there's decent embedded HaLow options, I would love to see analysis of this level on it.

    • scottapotamas 2 years ago

      I nearly did, but the write-up was getting pretty long.

      I'll try to find something for the planned range/interference tests. Morse Micro is also an Australian company so I'll probably look into their parts first unless there's any recommendation?

      • pockybum522 2 years ago

        That sounds good if you're an Aussie. I'm honestly confused why there's still so few options, but I guess most radically new standards got a comparatively slow start.

pockybum522 2 years ago

This is one of the most thorough and well laid out analysis of useful hobbyist and low level research options out there. I'll be referencing this for years, thank you very much. Clearly a lot of effort has been put into this.

davidw 2 years ago

Years ago I was working on a system where an Android device communicated with a web server written in Erlang, and our Android guy was going off about how Erlang was "really slow" and that made no sense to me. So we looked at the interaction times, and it was certainly true that something was slow. Instead of the Erlang server, we swapped out Apache serving a static page. That was slow too. It turned out he'd been benchmarking the crappy wifi connection.

skywal_l 2 years ago

Something of a tangent but I couldn't find anywhere a way to wirelessly extend usb ports. Allowing you to plug a mouse/keyboard/Yubikey to a computer in another room with minimum latency and without the need of any software or particular drivers.

If one wanted to do something like that one would probably start by reading that article I guess.

Thanks for this very thorough work.

  • byb 2 years ago

    I've had the same desire to extend USB HID devices, but I want to take it a step further. Once a USB device <- Wi-Fi ->USB host technology is available, then a wireless USB switch should be possible. The research in this article is critical to understanding the impact of latency on the experience.

    Several months ago, I built a project using USB host mode on a Raspberry Pi Pico, which uses a USB numpad to pass messages to an MQTT server. This uses the Rp2040's USB host mode https://gitlab.com/baiyibai/pico-w-usb-host-mqtt-numpad

    https://github.com/adafruit/Adafruit_TinyUSB_Arduino

    My implementation plugs in much higher into the stack and doesn't read the full USB bit mask output, which indicates how many keys are pressed/released.

    From my limited understand ing, it should be possible to pass these USB messages from HID client to HID host and vice-versa. Then it's only a matter of sending this information over a TCP/UDP interface. However, from my research, it seems the TinyUSB library doesn't provide the full bitmask resolution necessary for all devices. The YouTuber Wendell from LevelOneTechs has also talked about the troubles of getting some devices working with his KVM products, so it may not be as simple as I'm suggesting here.

    Overall though, a $15/endpoint is very attractive.

    • skywal_l 2 years ago

      > Several months ago, I built a project using USB host mode on a Raspberry Pi Pico, which uses a USB numpad to pass messages to an MQTT server. This uses the Rp2040's USB host mode https://gitlab.com/baiyibai/pico-w-usb-host-mqtt-numpad

      Maybe I read the README a little to quickly, but you seem to be using standard WiFi for communication. As stated in other comments in this thread, this solution already exists. USB through Ethernet extension are well established and you can already connect this to a WiFi extender.

      What I was thinking was to achieve this with a simple radio connection that do not need configuration or even a WiFi network to function. Just plug it in and it works. Here's a sketch of the high level concept I had in mind: https://ibb.co/VD2d9XM

      Is your point that once you can do that with Wi-Fi it is trivial to do it with any type of radio connection?

      > From my limited understanding, it should be possible to pass these USB messages from HID client to HID host and vice-versa.

      Someone did this here using Etherkey and an ATmega32u4: https://www.sjoerdlangkemper.nl/2022/11/16/running-etherkey-...

      > it seems the TinyUSB library doesn't provide the full bitmask resolution necessary

      If my understanding is correct, Arduino already provides low level USB controls: https://shorturl.at/joSWZ.

      All in all, it seems to me that there is an opportunity here but unfortunately this requires skills in electronic, radio and USB protocol that I do not possesses and seems fairly rare.

  • justsomehnguy 2 years ago

    USBAnywhere + any WiFi AP

    You would need drivers on the computer and I don't know about latency.

  • zamadatix 2 years ago

    WiGig docks were promoted for a short while but the problem they ran into was having an e.g. keyboard in another room wasn't very practical unless the display was as well and that bumped the RF requirements. So it ended up in the 60 GHz range which wouldn't make it to the other room and people basically said "eh, what's the point I'll just plug the dock in and it works".

zh3 2 years ago

That is great stuff, many thanks for it. While not in such depth, for a precision timing network covering multiple sensors our analysis also showed that the delays and variation inherent in most higher-level radio protocols are far too high for microsecond-level synchronisation.

For this reason, we use the nRF52 radio peripheral directly (i.e. barebones C) which means we know exactly when the packet was sent and - at the other end - when it was received. Details are in the Production Specification document, which also shows how long it takes for the transmit to spin up (turn on, transmit pre-amble and so on).

utopcell 2 years ago

Great article!

Here's a perspective from a guitarist's viewpoint. Most wireless guitar systems boast latencies below 3ms, with the better ones being closer to 1ms.

Latency is important here because even small delays can be felt by the player. Since sound travels at ~1 ft per 1ms, a delay on the order of BLE is equivalent to playing with the amplifier ~25ft away from you, which is pretty bad.

It is surprising that the best system is actually nrf24, given how old it is (or maybe because of that ?). It also seems to have enough bandwidth to transfer a 24-bit/48kHz signal.

  • polishdude20 2 years ago

    With guitar, how would the latency stack up when you add a/d conversion?

    • zh3 2 years ago

      A/D conversion itself wouldn't add much at the sample level (say 48KHz sample, it's about 50us per sample). However, packetisation will - a 256 byte packet of 128 samples is 128*50us = 6.4ms right there at the transmitter, and the receiver won't notify until the full packet is received. So a naive digital approach would be 12.8ms (2x6.4ms) even before anything else.

      A pure analogue approach (modulated RF) on the other hand shouldn't have any human-detectable delay - it's effectively distance/speed of light with a bit of a phase shift (addtional delay) introduced by the electronics - should be only a handful of microseconds in total.

      • utopcell 2 years ago

        128-sample buffers are already too large. To compare, the nRF24 has a max buffer of 32 bytes. However, even in your 128 samples, 16bit/48kHz example, latency is a bit better. It will take 1000/48000 * 128 ms to collect the 128 samples, or ~2.66ms. This amounts to 16*128 bits or 2k bits of information that the transmitter will have to send over. At the nRF24 2mbps rate, another ~1ms will be needed to send the buffer over. I'm not sure why you'd think that this time needs to be doubled at the receiver. Even if the nRF24 receiver started moving the buffer after it was fully received, it does so over a 10MHz serial connection, so that would be at most another 0.2ms, for a total of <4ms. For 16-sample buffers and 24bit/48kHz, the end-to-end latency is ~0.6ms.

      • polishdude20 2 years ago

        Analogue would be nice in that regard but wouldn't it be pretty bad with interference, signal quality over distances etc?

        • zh3 2 years ago

          It worked that like for many, many years (radio mics) before digital came along. Think of FM radio - if you have a good signal, it's pretty resilient to interference and in a controlled short range environment it is extremely reliable.

nsasch 2 years ago

Thanks for sharing your research!

I’ve done some similar, but not as thorough, tests with 2.4ghz WiFi and 915MHz LoRa before. My goal is to sync time across multiple devices that go in and out of range of each other to play 60fps light animations and sound within half a frame of each other (8ms), with spare time for some computation.

I’ve been surprised at how bad some oscillators (or voltage regulators) can be and their effect on consistent latency.

I was having fun experimenting, but this will be really useful to get me back to actually implementing my project.

comboy 2 years ago

Outstanding blog post. NRF24 had been my fav for a long time, I planned switching to LoRa but I didn't know the latency is that high.

  • steve_gh 2 years ago

    You go for LoRa or NBIoT when you need the low power consumption, and especially for deep penetration. Generally, if you have a better option, you use it. LoRa and similar high latency networks can't easily run TCP due to the standard TCP timers (especially Ack timeouts).

    What I would like to see is better support from the cloud providers for UDP based protocols such as MQTT-SN.

nanomonkey 2 years ago

This is a great breakdown, although it doesn't go into any detail on the distance trade offs of each transmission type, which is an important part of the comparison. I look forward to when they go into this part of the analysis.

jauntywundrkind 2 years ago

If we had more great reviews like this we'd see hardware improve faster! Thank you! Shine that light!

noman-land 2 years ago

Amazing article and research. Most definitely bookmarked.

snovv_crash 2 years ago

Super cool. I'd love to see 2.4GHz LoRA as well.

  • andai 2 years ago

    Not a radio guy but, isn't the whole point of LoRa to use lower frequencies for greater range?

    • snovv_crash 2 years ago

      It also uses a different modulation so isn't as affected by interference from the more common 2.4GHz sources, while 2.4 gives you a lot more bandwidth and makes licensing easier.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection