Author Topic: Duplex matrix - design principles  (Read 2638 times)

0 Members and 1 Guest are viewing this topic.

Offline roooot

  • Thread Starter
  • Posts: 3
Duplex matrix - design principles
« on: Sun, 12 September 2021, 04:55:11 »
Using a duplex matrix for switches (i.e. connecting two physical rows of keys as one "logial row") reduces the number of required MCU pins.

This is described here:
https://wiki.ai03.com/books/pcb-design/page/matrices-and-duplex-matrix
https://www.keebtalk.com/t/wiring-to-a-procontroller-rows-columns-questions/8405/3
https://hackaday.com/tag/duplex-matrix/

However, there are many different possibilities regarding which rows to "merge" and where to place the connections. Here are five rough example sketches for where the traces on the PCB can go:


Which ways are better and why? Thanks!

Offline ice9js

  • Posts: 26
Re: Duplex matrix - design principles
« Reply #1 on: Mon, 13 September 2021, 02:41:05 »
Not an electrical engineer, but having successfully designed a boards with a duplex key matrix, I'd say it's largely irrelevant because an average scan rate of 1kHz is still considered pretty low frequency in the EE world and shouldn't cause too much trouble no matter what you do.

That said, other good design principles still apply so you generally want to minimize the trace length, amount of vias, avoid crossing over traces where not necessary, keep adequate amount of space between traces. Ideally you'd run both rows and columns on one layer in some sort of maze-like pattern with a solid ground plane underneath - but that will take time to figure out and might not even be possible depending on your design and matrix size.
But you definitely need to look at it in context of how your board is laid out, where the holes and components are placed. There's no one best solution that fits all, and unless there's nothing else on your board it'll usually need to be some sort of compromise anyway.
But like I said, given the low frequency nature of the signal it'd be very hard to really mess it up.

Less optimal layouts might cause more electromagnetic interference but this is pretty much impossible to discuss without a complete board in hand and running tests on it - which is probably also not necessary unless you're planning on mass production.

Hope this helps.

Offline Findecanor

  • Posts: 5036
  • Location: Koriko
Re: Duplex matrix - design principles
« Reply #2 on: Mon, 13 September 2021, 05:28:40 »
This is mostly for when hand-wiring a keyboard to a MCU board with limited number of pins such as a Pro Micro, but sure it ccould be applied to PCB design as well.

The most economical use of MCU pins would have the logical matrix resembling a square as much as possible, i.e. that the number of rows and columns are close to each-other.
For example, an ortho 60% with 15×5 keys laid out as 15×5 would need 15+5 = 20 pins, but if you did this "duplex" trick and doubled the rows, you'd get a 8×10 matrix, which would need only 8+10 = 18 pins.

I think the fourth and fifth layout are probably the best, especially for hand-wiring. Then you'd need only half of the rows on the left side and the other half on the right.
The other layouts would need the wires for both odd and even rows spanning almost the entire width, which would get more crowded.
« Last Edit: Mon, 13 September 2021, 05:31:18 by Findecanor »

Offline Keyboard Cartel

  • Posts: 2
Re: Duplex matrix - design principles
« Reply #3 on: Tue, 28 September 2021, 16:48:35 »
Thanks for the examples, i have been messing around with matrices, and was having a confusing time visualising out the duplex matrix