Author Topic: Ergodox latency  (Read 13192 times)

0 Members and 1 Guest are viewing this topic.

Offline musclecups

  • Thread Starter
  • Posts: 7
Ergodox latency
« on: Fri, 19 February 2016, 21:26:10 »
I'm curious if any ergodox users have experienced latency issues as a result of the IO expander used in the lefthand of the classic ergodox. 

That is to say: do lefthand keystrokes register noticeably later than righthand keystrokes?

As a followup to anyone who owns both a standard and an InputClub "infinity" ergodox, is there any difference in this latency?

Thanks!

Offline iaeen

  • Posts: 13
  • Location: Controlling your thoughts
Re: Ergodox latency
« Reply #1 on: Sat, 20 February 2016, 07:01:43 »
I have never used the original ErgoDox, but the infinity has no noticeable latency.

HaaTa addressed the issue on the Massdrop comment board (here: https://www.massdrop.com/buy/infinity-ergodox/talk/352332, also see tyr.goossens' post immediately above). The description is pretty technical, but the takeaway is that the poll rate for the interconnect is several orders of magnitude faster than the USB poll rate. With the infinity, the keypress is virtually guaranteed to travel over the interconnect and reach the USB comm buffer before the next USB cycle.
ErgoDox Infinity

Offline Findecanor

  • Posts: 5036
  • Location: Koriko
Re: Ergodox latency
« Reply #2 on: Sat, 20 February 2016, 07:10:32 »
The Infinity has different electronics. There are microcontrollers on both sides, not an I/O expander on one and a microcontroller only on the other side.

Anyway. I have gone through the source code for the official firmware for the original ErgoDox, and it does not poll the left side less often than the right side.

Offline musclecups

  • Thread Starter
  • Posts: 7
Re: Ergodox latency
« Reply #3 on: Sat, 20 February 2016, 08:42:57 »
Quote
does not poll the left side less often than the right side

Someone intimated to me that using the MCP23018 I/O expander with i2c protocol between the boards would lead to measurable latency differences between the left and right sides of the board.  So it's not the polling I'm asking about, but whether or not the data is there yet to be polled?

I'm unfamiliar with the topic, but the data sheet for the chip says that it operates at either 100kHz or 400kHz.  In the Massdrop discussion referenced above, it is mentioned that USB 2.0 operates at 1000Hz.  So, the i2c transmission and reception should add negligible delay to the computer's receipt of the keypress, especially when compared to the debounce processing?

My question boils down to this:

TLDR - Does using an I/O expander to communicate left-hand keystrokes add measurable (or maybe significant) latency to reception of the keypress, or should I simply route the matrix to the right side wholesale?


Offline vvp

  • Posts: 887
Re: Ergodox latency
« Reply #4 on: Sat, 20 February 2016, 11:44:01 »
There was a post about in on deskthority (or maybe here on geekhack???). IIRC, the I2C handling was taking about 120 µs. If so, then it is not a big deal since poll rate on full speed USB (12 mb/s) is 1 ms or more. It may represent a  considerable part (about 12%) of processing but it should not result in higher latency.

That is if I remember it correctly. Search ergodox thread on deskthority (or maybe even on geekhack) to know for sure.

If you care about latency then optimizing debouncing is more important. Debouncing is typically around 5 ms. You can bias debouncing to the released state or to the pressed state. If you bias it to the pressed state then press will be detected with about 1 ms delay and release with about 6 ms delay. If you bias to the released state then press will be detected with about 6 ms delay and release with about 1 ms delay. Choose your poison!

Offline xephon

  • Posts: 8
  • Location: Oakville, ON, Canada
Re: Ergodox latency
« Reply #5 on: Mon, 22 February 2016, 16:53:48 »
As firmware engineer that uses UART and I2C bus all the time, I can't imagine either bus give any sort of meaningful latency to be honest. Nevertheless, their behavior on NKRO may be vary. In particular, it is quite possible for UART to perform way better providing NKRO than I2C due to the nature of the bus design.

Offline musclecups

  • Thread Starter
  • Posts: 7
Re: Ergodox latency
« Reply #6 on: Tue, 23 February 2016, 21:55:07 »
Thanks, that's exactly the experienced response I was seeking!

I think I read somewhere that Hasu's TMK firmware has NKRO (or 128 at least).  I don't think I'll need more than 6 for what I plan to use it for, anyhow.

Offline obfuscated

  • Posts: 10
Re: Ergodox latency
« Reply #7 on: Mon, 07 March 2016, 14:06:37 »
If you look here: https://github.com/benblazak/ergodox-firmware you'll see that the ergodox is at ~167 Hz scan rate.
And if you look here: https://github.com/benblazak/ergodox-firmware/blob/master/references.md you'll see that the cherry mx switches have 5ms debouce time, which limits them to 200hz. I doubt there is a problem with latency in there.

@xephon: Do you use some async code to talk to the i2c bus, because the code in the ergodox is synchronous and thus there is major slowdown? I'm not testing ergodox directly, but a similar design using arduino micro and mcp23018.

Offline HaaTa

  • Master Kiibohd Hunter
  • Posts: 794
  • Location: San Jose, CA, USA
  • Kiibohds!
    • http://kiibohd.com
Re: Ergodox latency
« Reply #8 on: Thu, 26 May 2016, 13:32:59 »
So, the latency isn't a huge deal, though it can give an edge.

The big reason why the original ergodox has a bit of delay: Poll+debounce.

1) Poll, you need to query, then receive the data. The original ergodox is not asynchronous.
2) Debounce, you must poll multiple times in order to determine if the key was press/released

Just removing (2), would make it significantly better (sadly I don't have an original ergodox around to scope the latency).

For the Infinity Ergodox I was deciding between UART, I2C and CAN. And ended up going with UART:
  • Not difficult to implement
  • Totally asynchronous (without multi-master)
  • Available on pretty much every MCU

By sheer luck I managed to get the UART running stupid fast without errors, so that was just a fun extra.

Advantages the Infinity Ergodox has that makes it faster:
  • Asynchronous
  • Debounce before transmission
  • DMA UART receive buffers
Kiibohd

ALWAYS looking for cool and interesting switches
I take requests for making keyboard converters (i.e. *old keyboard* to USB).

Offline Data

  • Posts: 2608
  • Location: Orlando, FL
Re: Ergodox latency
« Reply #9 on: Thu, 26 May 2016, 14:02:20 »
Purely anecdotal and subjective:

I game on my Dox (Falbatech PCB) and have never experienced latency on keystrokes.  If there's a delay it's insignificant.  I haven't hooked it up to a scope or anything, but then I've never really had a reason to.   ;)

Offline xtrafrood

  • formerly csmertx
  • * Elevated Elder
  • Posts: 2715
  • Location: Gainesville, FL
  • wildling
Re: Ergodox latency
« Reply #10 on: Thu, 26 May 2016, 16:53:06 »
Phew, during my Ergodox research I came across mentions of latency. I won't worry about it anymore :)

Offline obfuscated

  • Posts: 10
Re: Ergodox latency
« Reply #11 on: Tue, 07 June 2016, 20:07:13 »
For the Infinity Ergodox I was deciding between UART, I2C and CAN. And ended up going with UART:
  • Not difficult to implement
  • Totally asynchronous (without multi-master)
  • Available on pretty much every MCU
Do you have a schematic somewhere?

Offline HaaTa

  • Master Kiibohd Hunter
  • Posts: 794
  • Location: San Jose, CA, USA
  • Kiibohds!
    • http://kiibohd.com
Re: Ergodox latency
« Reply #12 on: Tue, 07 June 2016, 20:49:37 »
All our schematics and gerbers are here -> https://github.com/kiibohd/pcb
Kiibohd

ALWAYS looking for cool and interesting switches
I take requests for making keyboard converters (i.e. *old keyboard* to USB).

Offline Questengine

  • Posts: 26
    • Heroglyphix Nonogram Logic Puzzles
Re: Ergodox latency
« Reply #13 on: Mon, 01 August 2016, 07:42:10 »
I've not noticed any, but I'm not a super-fast typer, so I'm probably not an authority on the matter.