Author Topic: Minimizing round-trip latency  (Read 10158 times)

andersl

  • Member
  • ***
  • Posts: 1
Minimizing round-trip latency
« on: November 20, 2011, 05:48:34 am »
Hi,
I have an application where the host requests a status update from a microcontroller application and then immediately send back a response with new commands to the microcontroller. I want to run this in a very fast loop. We've done some experiments with a microchip dsPIC33 dev kit (full speed) where we sent time stamped packets to the host which just sent them back, then we measured the time on to PIC. It seems that we get ~2.2 ms round trip with the standard HID driver running Windows. We're using small packet sizes (could be less than 64 bytes).

My questions are:
* is it better to use a high-speed capable microcontroller such as the atmel sam3u ?
    - Will it improve latency?

* what about USB 3.0 with regards to latency?

* is HID the right choice for this application?

* would it be possible to get a lower latency by writing a custom driver?

Thanks for any help,
 Anders Larsson


Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Minimizing round-trip latency
« Reply #1 on: November 20, 2011, 10:17:27 am »
Since the smallest bInterval for full speed is 1 ms, 2 ms round trip is about as fast as you can expect. bInterval defines only the reserved bandwidth at the host controller. If the host system is busy, the delay for a host application to read the data and respond might be longer. So you shouldn't assume a response in 2 ms.

With high speed and SuperSpeed, interrrupt endpoints can request a shorter bInterval. However, to comply with the specs, interrupt endpoints in the default interface must have wMaxPacketsize <= 64 bytes, and HID drivers in major OSes don't support selecting alternate interfaces. A custom driver could do so, but if the bandwidth isn't available, the driver can't select a greater bandwidth. And you'll still have the somewhat unpredictable system delay in reading the data and sending the response.

Jan

« Last Edit: November 20, 2011, 03:51:26 pm by Jan Axelson »