1
\$\begingroup\$

This is a theoretical question. I would like to know what the lowest latency is which can be achieved when interfacing a microcontroller with USB interface. Consider a USB host (computer) sending one byte to a USB device (microcontroller) and waiting for it to respond the same byte. How much time would this at least take? Are there any experiments about that? Any information would help me.

When using serial communication (RS232) the minimum latency you can achieve is 1 ms (by using USB to serial converter). I am looking for a faster way to communicate with my microcontroller (in terms of latency).

\$\endgroup\$

3 Answers 3

3
\$\begingroup\$

USB has a strict master/slave architecture, in which all communication is controlled by the host PC.

When the host wants to send data to the device, and assuming that there are no other devices on the bus, the data can always be sent immediately.

When the host wants to receive data from the device, it must ask for it.
If the host controller has just finished receiving a previous packet, it typically asks for the next packet immediately. But if the bus has been idle, continuously polling for new data would waste lots of power, so this polling happens once every millisecond (for full-speed devices).


To get a latency lower than 1 ms, you would have to use a protocol with a peer-to-peer architecture, in which devices can send data without being asked by the host. Even plain RS-232 can achieve this, but you would need to replace the USB converter with a PCI(e) card.

\$\endgroup\$
1
\$\begingroup\$

With USB it really depends on the endpoint used. USB has 3 different kinds. An interrupt transfer would have the least latency but it is only capable of small transfers. USB to serial converter usually use bulk transfers which grantee transmission but not latency. The best results would be if the USB stack was running directly in the chip.

\$\endgroup\$
1
\$\begingroup\$

I've just measured the USB latency of our USB full speed device, and got around 1 ms when connected directly to the PC, no surprise here.

It gets interesting when you connect a USB 2.0 HS Hub between the PC and the device: The latency goes down to about 0.33 ms on average! My current line of thought is that the device looks more like USB high speed to the PC (with the HUB translating), and the scheduling of high speed transfers is different. So adding a USB 2.0 high speed hub (or USB 3.0 if available) might help you a bit.

\$\endgroup\$
1
  • \$\begingroup\$ USB 2.0 HS Hub performs transaction translation for USB 1.1/2.0 LS/FS devices. BUT (unfortunately) the same translation does not take place from USB 3.0 SS to USB 2.0 HS. USB 3 and USB 2 essentially work independently as two different systems, no translation occurs. A USB 3 SS Hub can only work as a USB 2 HS Hub for USB 2.0 devices. \$\endgroup\$ Oct 26, 2022 at 7:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.