Author Topic: Matrix PCB questions  (Read 1187 times)

0 Members and 1 Guest are viewing this topic.

Offline joey

  • Thread Starter
  • Posts: 2296
  • Location: UK
Matrix PCB questions
« on: Mon, 12 January 2015, 15:10:50 »
I'm a software guy, still learning about the hardware side of things.


I just learnt about I/O expanders. For a 40% it seems like you could use a Teensy with two 16-bit I/O expanders over I2C and have enough pins to drive all the pins without having to use a matrix. What are the pros and cons of that? Would it be easier to route the switches alone than via a matrix? On the firmware side. would there be any extra issues to account for? I know the ErgoDox uses an I/O expander, but as part of the matrix.

Offline HaaTa

  • Master Kiibohd Hunter
  • Posts: 794
  • Location: San Jose, CA, USA
  • Kiibohds!
    • http://kiibohd.com
Re: Matrix PCB questions
« Reply #1 on: Mon, 12 January 2015, 16:53:48 »
So, using i2c io expanders to scan switches is sorta slow'ish, similar to one half of the ergodox.
You won't get the scanning latency you would from scanning directly with a uc.

It can be made to work, but I wouldn't advertise it as a gaming keyboard.

Let's use some numbers. Normal i2c is around 400 kbit/s, but you can do around 3.4 Mbit/s on some chips if the wire length is short (http://en.wikipedia.org/wiki/I%C2%B2C).

So, you have to scan each switch, this will require at least 3 8 bit words per scan. 1 chip address, 1 register address, 1 reply. Now you mention two io expanders, so divide by two.

3.4 Mbit/s  / (8 * 3 * 2) = 70.833 k scans per io expander.

Now you have 16 bits, so lets say you can do an 8 x 8 matrix which is 64 keys.

70.833 k / 64 = 1106.8 scans per switch per second.

I'm being a bit loose with my math, but even though 1000 scans per second doesn't seem that bad, this also assumes that the uc is optimized for dealing with the i2c.

1000 scans per second per switch doesn't seem to bad (1000 Hz for usb :P). But that assumes no i2c overhead and programming overhead on the uc (i2c gets processing priority).
There's also the increased complexity of having more chips on the board, increasing the possibility of failure.


Now your question talks about scanning each key individually rather than using a matrix. On the firmware side, this actually gets easier. You can have up to 16 * 2 keys (32 keys), which isn't that many keys. And, you now have to deal with routing all those wires... But yeah, firmware is easy. And you'd get a 4x speed increase from the calcs above (only 32 keys instead of 132).

Unless it's a 1 off thing, I really wouldn't recommend it personally due to the routing issues.

Hope this helps.
Kiibohd

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

Offline bpiphany

  • Posts: 1033
  • Location: Stockholm, Sweden
  • bpiph is a special type of crazy. //mkawa
Re: Matrix PCB questions
« Reply #2 on: Thu, 15 January 2015, 01:33:17 »
If you want to get away from the matrix you will probably want to use something like this (a shift register). You won't need diodes anymore, since you don't have a matrix. On the other hand you will need to add pull-up (or -down) resistors since the shift registers doesn't have them built in. The serial communication should be possible to do very fast.

I made an 80% board a while back using shift registers, mostly as a proof of concept. I have one friend using it, and I haven't heard anything indicating it doesn't work as expected. It looks like this There is actually a lot more traces running all over the place than there would be with a matrix.


Offline vvp

  • Posts: 887
Re: Matrix PCB questions
« Reply #3 on: Thu, 15 January 2015, 06:06:46 »
I use shift registers in Katy and they work fine.
The dedicated SPI hardware can be used to load data to shift registers (or read it from them). So the communication with shift registers can be done efficiently.