Alright, I tested with the "which one registers first" method, tweaking a millisecond delay in the arduino to figure out where the threshold is:
Kensington K64370A (rubber dome switches)
USB polling interval: 10ms
Key sample interval: 3.6ms
max latency compared to arduino: 27ms
min latency compared to arduino: 12ms
median latency compared to arduino: 19ms
WASD V1 with Cherry MX brown switches:
USB Polling interval: 1ms
Key sample interval: 1.5ms
max latency compared to arduino: 14ms
min latency compared to arduino: 9ms
median latency compared to arduino: 10ms
Arduino Micro:
USB Polling interval: 1ms
Key sample method: interrupt contingent on the keyboard's key sample interval.
Debounce method: Latch on switch closed, reset 5ms after switch opens.
I'm 95% confident these results are accurate to within 2ms. Possible error sources are the arduino delay() function, USB polling quirks, and large delays that happen <1% of the time.
Measuring keyboard input lag
Re: Measuring keyboard input lag
random question
when you have multiple usb hid devices, are the polls synchronized?
when you have multiple usb hid devices, are the polls synchronized?
Re: Measuring keyboard input lag
The computer needs to be able to handle asynchronous polling, because different devices are allowed to have different polling rates. If you have two USB controllers that happen to run on the same clock, I could see synchronized polling happening by accident. Of course, there are a lot of reasons you might need to give one input priority over the other, like two keyboards simultaneously typing into a text editor, you have to decide somehow which letter to print first. Ultimately it depends on every part of the hardware and software stack allowing it, so probably not.flood wrote:random question
when you have multiple usb hid devices, are the polls synchronized?
Re: Measuring keyboard input lag
Looking into the MCU of my WASD, it's program memory is OTP ROM, so I won't be modifying it. But I did get to thinking about the 6 key rollover limitation of USB, why not just add another interrupt endpoint to get 12 key rollover? Sure, the system might see 2 keyboards, but is that actually a problem?
Re: Measuring keyboard input lag
Nice results!
What you can say about PS/2 and USB gaming keyboards?
What you can say about PS/2 and USB gaming keyboards?
Re: Measuring keyboard input lag
Luckily both these keyboards can do PS/2 as well as USB. The WASD was about 1 ms faster over PS/2(some improvement, but within the error bars), the kensington was significantly faster over PS/2, which makes sense given the 10ms poll interval(more room to improve). The maximum latency dropped by just about exactly 10ms, with the minimum latency staying about the same. Significant improvment, though still slower than the WASD.Q83Ia7ta wrote:Nice results!
What you can say about PS/2 and USB gaming keyboards?
So, if your keyboard and computer can do PS/2, it's probably worth using it. If you don't have a PS/2 port, make sure your keyboard uses a 1ms poll interval.
Re: Measuring keyboard input lag
Thanks for the results. I have been using PS/2 over USB despite my keyboard having 1kHz support because I don't like the processor having to maintain strict intervals for both the mouse and keyboard. Although I'm convinced 1kHz USB is faster than PS/2 (over the latter my keyboard maxes out at ~2.7ms between key event reports).
Are you referring to matrix scan rate with key sample rate? Also, any chance to test for debounce times/technique used?
Are you referring to matrix scan rate with key sample rate? Also, any chance to test for debounce times/technique used?
Re: Measuring keyboard input lag
I am referring to matrix scan rate. All I can tell you about debounce method is that neither keyboard uses hardware debouncing, and neither keyboard uses interrupts. Definitely room for improvement.stirner wrote:Thanks for the results. I have been using PS/2 over USB despite my keyboard having 1kHz support because I don't like the processor having to maintain strict intervals for both the mouse and keyboard. Although I'm convinced 1kHz USB is faster than PS/2 (over the latter my keyboard maxes out at ~2.7ms between key event reports).
Are you referring to matrix scan rate with key sample rate? Also, any chance to test for debounce times/technique used?
Is the 2.7ms interval for the same key, or for any two keys? That might just be your matrix scan interval.
Re: Measuring keyboard input lag
Two keys. I know that it isn't where the matrix scan caps out because with USB I can hit 1ms.
Either PS/2 operation changes something there or it's simply PS/2 having a maximum sample rate of 360Hz.
Either PS/2 operation changes something there or it's simply PS/2 having a maximum sample rate of 360Hz.
Re: Measuring keyboard input lag
Well, it is an interrupt based interface, so it's entirely possible there's some delay after receiving a packet, before you can get the next one. I don't know a whole lot about the PS/2 protocol, but I expect it has some wide tolerances.stirner wrote:Two keys. I know that it isn't where the matrix scan caps out because with USB I can hit 1ms.
Either PS/2 operation changes something there or it's simply PS/2 having a maximum sample rate of 360Hz.