Low USB connection latency on Teensy 4.0 + google chrome's new USB function

Status
Not open for further replies.

romalo

Member
I think only Paul Stoffregen himself can answer this complex question? :)

Paul we bought loads of 3.6 and now 4.0 with good succes.
We recently converted our C++ application to a javascipt webbpaged based program.
We send/receive millions of messages with 1millisecond interval(very accurate).
2 years ago all USB issues were solved with the genius Serial.send_now() function. with USB analysers we see all the USB packages are send with exactly 1ms interval.
But now with Chrome we have a slow USB return time of 21ms.

Our theory:
After some digging we found ut that javascript(read: html) has a refresh/sample rate of 5ms. Settimeout and Setinterval only works with values above 5msec
Our theory is that windows/chrome use default USB time-out of 16.
16+5 = 21.
Coincidence?

Serial.send_now() doesn't seem to work.
With a serial analyser program we can see the messages are send in chuncks, and/or tripple messages in 1. (instead of every 1msec).
Also we see a strong instability. One day we see USB packets including 100 single messages, and the other day we see USB packets including exacly 1message like it should do.

Did you already play around with Chrome's new USB functionality?

Thx!
 
Hmmm, 16ms... let me guess, Microsoft Windows?

As a quick test, try running a game or playing a video in another window while doing your latency test. Does that shave 15ms off?
 
nice idea!

Dropping to 7-10ms
Will upload results later.
Side effect: causing weird problems, like non-working application. Refresh page etc.
 
1= w/o video: 20msec
2= w/ video in separate window: 10msec

3= w/o video: 5-10msec
4= w/ video in separate window: 5-10msec

No consistency, so very hard to take any conclusions.
Problem is now only with sending data from navigator to teensy. Teensy to navigator looks fine (now, not a few weeks ago but chome has updates).
We hope you have a solution! :)
 
1

Capture.PNG
 
I checked the interval milliseconds in USB-monitor and they are exactly the same as in the screenshots above.
 
Did you already play around with Chrome's new USB functionality?

No. This is the first I've heard from Chrome supporting serial without some sort of 3rd party extension.

Does it work on Linux? My main desktop system is Ubuntu 18.04.

How do I use it? Is there a specific html and js file I need? What code should I run on Teensy? In other words... imagine I have only 3 minutes to look at this. What should I do to try it quickly and see the latency issue? If I have to guess how to set things up, or if I can't get it installed easily on Ubuntu 18.04, the result will almost certainly be "I don't have time to go down this rabbit hole".
 
Paul,

We did loads of testing. It is clear there is little influence on the 'return' time from a USB Msg, always between 2msec and 20msec. Because it depends on Windows and the API from Chrome.
So for high speed communication forget Chrome's new API.

The reason we use web based program is because we use a different set of message-filters for each session. Our customers do not want/can repogram the teensy for each new session.
Will start a new topic for that.
 
Status
Not open for further replies.
Back
Top