Author Topic: Designing a PCB, how do I do a key matrix with different row switch counts?  (Read 7884 times)

0 Members and 1 Guest are viewing this topic.

Offline kelvinhall05

  • Thread Starter
  • Posts: 69
  • Location: London, Ontario
    • LinusTechTips
All the guides I've found show how to do it when all the rows are the exact same amount of key switches. How am I supposed to wire the columns of switches when the rows are differing lengths? Thanks!

Offline gipetto

  • Posts: 91
assuming there's enough pins, generally the matrix is scaled in size until the rows are as many as the number of switches in the longest row. then the empty positions are set to KC_NO in the keymap.

Offline nevin

  • Posts: 1646
  • Location: US
all standard/staggered boards (with some larger keys than 1u) are like this. you end up with some columns that have less keys than others. just have to specify correctly in the firmware.
Keeb.io Viterbi, Apple m0110, Apple m0120, Apple m0110a, Apple 658-4081, Apple M1242, Apple AEK II, MK96, GH60/Pure, Cherry g84-4100, Adesso AKP-220B, Magicforce 68

Offline Findecanor

  • Posts: 5036
  • Location: Koriko
Your electric matrix does not have to correspond to the layout of the keys, but it makes it easier to route the board and write the firmware when it does.

Offline kelvinhall05

  • Thread Starter
  • Posts: 69
  • Location: London, Ontario
    • LinusTechTips
all standard/staggered boards (with some larger keys than 1u) are like this. you end up with some columns that have less keys than others. just have to specify correctly in the firmware.

assuming there's enough pins, generally the matrix is scaled in size until the rows are as many as the number of switches in the longest row. then the empty positions are set to KC_NO in the keymap.

Your electric matrix does not have to correspond to the layout of the keys, but it makes it easier to route the board and write the firmware when it does.

Thanks. One more question. Does each column need its own dedicated pin on the microcontroller? There's only 6 available afaik. I'm using this guide: https://github.com/ruiqimao/keyboard-pcb-guide

Offline nevin

  • Posts: 1646
  • Location: US
what size board are you building and what micro controller are you using?

.... but typically, yes
Keeb.io Viterbi, Apple m0110, Apple m0120, Apple m0110a, Apple 658-4081, Apple M1242, Apple AEK II, MK96, GH60/Pure, Cherry g84-4100, Adesso AKP-220B, Magicforce 68

Offline kelvinhall05

  • Thread Starter
  • Posts: 69
  • Location: London, Ontario
    • LinusTechTips
what size board are you building and what micro controller are you using?

.... but typically, yes

Probably at least 80-100 keys and probably a Pro Micro or clone. Those are good to use, right?

Offline nevin

  • Posts: 1646
  • Location: US
you'll have to get creative with the matrix. if using teensy/promicro

also look at the teensy ++2.0 as well as others that have more inputs (to make things easier)

examples....
5 rows, 15 columns = 75 keys, 20 i/o pins
9 rows, 9 columns = 81 keys, 18 i/o pins

the more "square" you make the matrix, the more switches you'll be able to get with fewer i/o pins used.
« Last Edit: Wed, 08 January 2020, 19:57:43 by nevin »
Keeb.io Viterbi, Apple m0110, Apple m0120, Apple m0110a, Apple 658-4081, Apple M1242, Apple AEK II, MK96, GH60/Pure, Cherry g84-4100, Adesso AKP-220B, Magicforce 68

Offline kelvinhall05

  • Thread Starter
  • Posts: 69
  • Location: London, Ontario
    • LinusTechTips
you'll have to get creative with the matrix. if using teensy/promicro

also look at the teensy ++2.0 as well as others that have more inputs (to make things easier)

examples....
5 rows, 15 columns = 75 keys, 20 i/o pins
9 rows, 9 columns = 81 keys, 18 i/o pins

the more "square" you make the matrix, the more switches you'll be able to get with fewer i/o pins used.

Ok. I'm "using" a pro micro because that's what the guide I linked basically told me to design the PCB around. Can I have a Teensy as a drop-in replacement? I also don't want to be spending a lot on this, which is another reason I would rather use the pro micro.


Is it possible to have 80+ keys on a pro micro? If so, how?

Offline nevin

  • Posts: 1646
  • Location: US
Yeah. Like I said, pro micro is fine but you'll have to get creative with the matrix, wiring keys that are not physically in that row or column to be in another row or column. Making the matrix more square, so you can get it all on the promicro.

- Promicro is a clone of the teensy 2.0
- The teensy ++2.0 is different, uses a different processor, has more i/0 pins, but is fully supported in qmk, and usually your first choice for larger 75+ boards
Keeb.io Viterbi, Apple m0110, Apple m0120, Apple m0110a, Apple 658-4081, Apple M1242, Apple AEK II, MK96, GH60/Pure, Cherry g84-4100, Adesso AKP-220B, Magicforce 68

Offline Findecanor

  • Posts: 5036
  • Location: Koriko
Re: Designing a PCB, how do I do a key matrix with different row switch counts?
« Reply #10 on: Wed, 08 January 2020, 22:23:59 »
The Teensy 2.0 and the Pro Micro have the same microcontroller chip on board: the ATmega32U4, but different pinouts. The Pro Micro makes fewer of its the pins available.
The Pro Micro got popular because Chinese copies are inexpensive (it is Open Hardware). There are other boards with the ATmega32U4 that are also quite affordable, and all firmware that supports the ATmega32U4 should work with any of those too.

But when we are speaking of "clones of Pro Micro", we usually refer to other small boards with also the same pinout as the Pro Micro. Those are (usually) drop-in replacements for using the Pro Micro on circuit boards.
I think the Teensy 2.0 came before the first Pro Micro, also.

One popular Pro Micro clone is the Elite-C, but it makes six more pins available (24 total, five on the short edge and one instead of the RAW pin) and has a USB C socket instead of Micro USB.
« Last Edit: Wed, 08 January 2020, 22:29:48 by Findecanor »

Offline nevin

  • Posts: 1646
  • Location: US
Re: Designing a PCB, how do I do a key matrix with different row switch counts?
« Reply #11 on: Thu, 09 January 2020, 04:28:48 »
... off topic...
@Findecanor - is there a sticky on the forum with these common micro controllers, listing the available pins, pins to avoid for certain applications and tips or tricks (like getting a teensy 2.0 to work in a split keyboard for example). if not, i think it would be a good idea because i find myself searching for the same details every now & then. i might start one, even if only for my own reference....

... just did a quick search, deskthority has pages on them in their wiki but ours is still missing/empty. (still not getting much help rebuilding the wiki?)
Keeb.io Viterbi, Apple m0110, Apple m0120, Apple m0110a, Apple 658-4081, Apple M1242, Apple AEK II, MK96, GH60/Pure, Cherry g84-4100, Adesso AKP-220B, Magicforce 68

Offline kelvinhall05

  • Thread Starter
  • Posts: 69
  • Location: London, Ontario
    • LinusTechTips
Re: Designing a PCB, how do I do a key matrix with different row switch counts?
« Reply #12 on: Thu, 09 January 2020, 15:22:02 »
The Teensy 2.0 and the Pro Micro have the same microcontroller chip on board: the ATmega32U4, but different pinouts. The Pro Micro makes fewer of its the pins available.
The Pro Micro got popular because Chinese copies are inexpensive (it is Open Hardware). There are other boards with the ATmega32U4 that are also quite affordable, and all firmware that supports the ATmega32U4 should work with any of those too.

But when we are speaking of "clones of Pro Micro", we usually refer to other small boards with also the same pinout as the Pro Micro. Those are (usually) drop-in replacements for using the Pro Micro on circuit boards.
I think the Teensy 2.0 came before the first Pro Micro, also.

One popular Pro Micro clone is the Elite-C, but it makes six more pins available (24 total, five on the short edge and one instead of the RAW pin) and has a USB C socket instead of Micro USB.

Can I do 58 switches with a Pro Micro?

Here's my current schematic. I believe I can only use the PF0-PF7 lines, but I might be wrong.

Offline Findecanor

  • Posts: 5036
  • Location: Koriko
Re: Designing a PCB, how do I do a key matrix with different row switch counts?
« Reply #13 on: Thu, 09 January 2020, 16:10:32 »
That's a schema with a ATMega32U4. You'd want to use a footprint for the Pro Micro's pins only.

You can use any of the microcontroller's GPIO pins for a columns or row. Each is configurable to be either an input or an output.

Offline kelvinhall05

  • Thread Starter
  • Posts: 69
  • Location: London, Ontario
    • LinusTechTips
Re: Designing a PCB, how do I do a key matrix with different row switch counts?
« Reply #14 on: Thu, 09 January 2020, 16:54:49 »
That's a schema with a ATMega32U4. You'd want to use a footprint for the Pro Micro's pins only.

You can use any of the microcontroller's GPIO pins for a columns or row. Each is configurable to be either an input or an output.

Cool, thanks

Offline nevin

  • Posts: 1646
  • Location: US
Re: Designing a PCB, how do I do a key matrix with different row switch counts?
« Reply #15 on: Thu, 09 January 2020, 17:00:20 »
@kelvinhall05

58... absolutely.
it's more than 8 inputs, all of the ones that begin with"p"

on a teensy 2.0 - pins D6, GND and VCC should be avoided
on a promicro - we've run into issues with a row or column connected to one of the "init" pins, don't remember exactly which and i can't seem to find the old post at the moment but it was either PD1 (D2) or PD0 (D3)

here's some good articles on handwiring a board (i know you're designing a pcb, but this will give you the general concept)
https://geekhack.org/index.php?topic=87689.0
https://deskthority.net/viewtopic.php?f=7&t=6050

do you have your layout in KLE? http://www.keyboard-layout-editor.com/
...so we can see what rows/columns you're trying to get

... and we'll talk about the firmware part later
Keeb.io Viterbi, Apple m0110, Apple m0120, Apple m0110a, Apple 658-4081, Apple M1242, Apple AEK II, MK96, GH60/Pure, Cherry g84-4100, Adesso AKP-220B, Magicforce 68

Offline kelvinhall05

  • Thread Starter
  • Posts: 69
  • Location: London, Ontario
    • LinusTechTips
Re: Designing a PCB, how do I do a key matrix with different row switch counts?
« Reply #16 on: Thu, 09 January 2020, 18:38:23 »
@kelvinhall05

58... absolutely.
it's more than 8 inputs, all of the ones that begin with"p"

on a teensy 2.0 - pins D6, GND and VCC should be avoided
on a promicro - we've run into issues with a row or column connected to one of the "init" pins, don't remember exactly which and i can't seem to find the old post at the moment but it was either PD1 (D2) or PD0 (D3)

here's some good articles on handwiring a board (i know you're designing a pcb, but this will give you the general concept)
https://geekhack.org/index.php?topic=87689.0
https://deskthority.net/viewtopic.php?f=7&t=6050

do you have your layout in KLE? http://www.keyboard-layout-editor.com/
...so we can see what rows/columns you're trying to get

... and we'll talk about the firmware part later

Here's a screenshot of the layout I'm (probably) going to use. Hopefully this suffices. I took this screenshot long before this reply so I don't have it open anymore.

Offline nevin

  • Posts: 1646
  • Location: US
Re: Designing a PCB, how do I do a key matrix with different row switch counts?
« Reply #17 on: Thu, 09 January 2020, 21:17:02 »
ok. cool.

here's a link to your layout again

so here's an example on the wiring, you can do it however you like though
233330-0

obviously, you do not solder all the switches together like a waffle, this just shows how your rows & columns could flow.

also attached is the json config from https://kbfirmware.com/ (it's an older build of QMK but does work in most cases)
and is a fantastic starting point for handwired/custom layout keyboards
* kelvinhall05.json (34.78 kB - downloaded 87 times.)
« Last Edit: Thu, 09 January 2020, 21:19:18 by nevin »
Keeb.io Viterbi, Apple m0110, Apple m0120, Apple m0110a, Apple 658-4081, Apple M1242, Apple AEK II, MK96, GH60/Pure, Cherry g84-4100, Adesso AKP-220B, Magicforce 68

Offline kelvinhall05

  • Thread Starter
  • Posts: 69
  • Location: London, Ontario
    • LinusTechTips
Re: Designing a PCB, how do I do a key matrix with different row switch counts?
« Reply #18 on: Fri, 10 January 2020, 09:35:11 »
ok. cool.

here's a link to your layout again

so here's an example on the wiring, you can do it however you like though
(Attachment Link)

obviously, you do not solder all the switches together like a waffle, this just shows how your rows & columns could flow.

also attached is the json config from https://kbfirmware.com/ (it's an older build of QMK but does work in most cases)
and is a fantastic starting point for handwired/custom layout keyboards
(Attachment Link)

Awesome, thanks. So my 6x10 matrix with two switch sockets that'll be empty is irrelevant then? Or will my current matrix just make the firmware part more confusing? Here's what I currently have, how should I connect the Pro Micro? Sorry for all the dumb questions lol. Never done this before.

Offline nevin

  • Posts: 1646
  • Location: US
Re: Designing a PCB, how do I do a key matrix with different row switch counts?
« Reply #19 on: Fri, 10 January 2020, 11:51:57 »
1. are you having a pcb made? or are you hand wiring it?
2. are you having them solder smd components? or are you just using the bare pcb as the wiring/traces and soldering an off the shelf promicro to it?

i would do the matrix as 5x15 instead of 6x10. (5x15 is support for 75 switches) even though you only have 58 in your layout. but will make life easier with firmware if your matrix matches your layout. the only time you need to do a condensed matrix is when you don't have enough i/o pins to support the matrix unaltered (like a full size 104 keyboard)
rows & columns get connected to i/o pins on the pro micro and you specify all of this in the firmware... what pins were used, what the matrix is, what your keymap is, etc....
Keeb.io Viterbi, Apple m0110, Apple m0120, Apple m0110a, Apple 658-4081, Apple M1242, Apple AEK II, MK96, GH60/Pure, Cherry g84-4100, Adesso AKP-220B, Magicforce 68

Offline kelvinhall05

  • Thread Starter
  • Posts: 69
  • Location: London, Ontario
    • LinusTechTips
Re: Designing a PCB, how do I do a key matrix with different row switch counts?
« Reply #20 on: Fri, 10 January 2020, 12:02:10 »
1. are you having a pcb made? or are you hand wiring it?
2. are you having them solder smd components? or are you just using the bare pcb as the wiring/traces and soldering an off the shelf promicro to it?

i would do the matrix as 5x15 instead of 6x10. (5x15 is support for 75 switches) even though you only have 58 in your layout. but will make life easier with firmware if your matrix matches your layout. the only time you need to do a condensed matrix is when you don't have enough i/o pins to support the matrix unaltered (like a full size 104 keyboard)
rows & columns get connected to i/o pins on the pro micro and you specify all of this in the firmware... what pins were used, what the matrix is, what your keymap is, etc....

I think I might end up hand wiring it. I'll probably spend the same amount of time making the PCB as hand wiring but I won't have to wait for shipping lol. If I do make a PCB I will solder a pro micro to it.

How will a bunch of empty spots in my matrix worth? I'm not gonna have 75 keys.

Offline nevin

  • Posts: 1646
  • Location: US
Re: Designing a PCB, how do I do a key matrix with different row switch counts?
« Reply #21 on: Fri, 10 January 2020, 12:13:20 »
Quote
How will a bunch of empty spots in my matrix worth? I'm not gonna have 75 keys.

unless you're doing a ortholinear (full grid of 1u switches) board (which you're not), you will have spaces in your matrix.

you don't want to convolute the key matrix if you don't have to. like i said, that's usually only done when you don't have enough pins to support your layout unaltered.

do you know what type of case you want to go with? 3d printed or sandwitch style metal, acrylic, FR4, etc...

if you are going to handwire, i'd start with the KLE layout, get it over to the swill plate builder and read some of the handwiring guides. you can use https://kbfirmware.com/ as a starting point, or ask here for more help.

http://www.keyboard-layout-editor.com/#/gists/dee7835caf4a4905e1b874aa7c2d61c3
http://builder.swillkb.com/
https://geekhack.org/index.php?topic=87689.0
https://geekhack.org/index.php?topic=103108.0
https://deskthority.net/viewtopic.php?f=7&t=6050
Keeb.io Viterbi, Apple m0110, Apple m0120, Apple m0110a, Apple 658-4081, Apple M1242, Apple AEK II, MK96, GH60/Pure, Cherry g84-4100, Adesso AKP-220B, Magicforce 68

Offline kelvinhall05

  • Thread Starter
  • Posts: 69
  • Location: London, Ontario
    • LinusTechTips
Re: Designing a PCB, how do I do a key matrix with different row switch counts?
« Reply #22 on: Fri, 10 January 2020, 12:17:07 »
Quote
How will a bunch of empty spots in my matrix worth? I'm not gonna have 75 keys.

unless you're doing a ortholinear (full grid of 1u switches) board (which you're not), you will have spaces in your matrix.

you don't want to convolute the key matrix if you don't have to. like i said, that's usually only done when you don't have enough pins to support your layout unaltered.

do you know what type of case you want to go with? 3d printed or sandwitch style metal, acrylic, FR4, etc...

if you are going to handwire, i'd start with the KLE layout, get it over to the swill plate builder and read some of the handwiring guides. you can use https://kbfirmware.com/ as a starting point, or ask here for more help.

http://www.keyboard-layout-editor.com/#/gists/dee7835caf4a4905e1b874aa7c2d61c3
http://builder.swillkb.com/
https://geekhack.org/index.php?topic=87689.0
https://geekhack.org/index.php?topic=103108.0
https://deskthority.net/viewtopic.php?f=7&t=6050

I have a metal plate and I'm going to attempt and make my own wood case. Probably going to be as few pieces as I need, hopefully just two.

Offline nevin

  • Posts: 1646
  • Location: US
Re: Designing a PCB, how do I do a key matrix with different row switch counts?
« Reply #23 on: Fri, 10 January 2020, 12:44:48 »
rows & columns get soldered to promicro, doesn't have to be a specific order, just make sure you take notes while you're doing it so you know how the matrix is wired to the controller because you specify the pins in the firmware.

does that answer your questions for now?
Keeb.io Viterbi, Apple m0110, Apple m0120, Apple m0110a, Apple 658-4081, Apple M1242, Apple AEK II, MK96, GH60/Pure, Cherry g84-4100, Adesso AKP-220B, Magicforce 68

Offline kelvinhall05

  • Thread Starter
  • Posts: 69
  • Location: London, Ontario
    • LinusTechTips
Re: Designing a PCB, how do I do a key matrix with different row switch counts?
« Reply #24 on: Fri, 10 January 2020, 13:14:42 »
rows & columns get soldered to promicro, doesn't have to be a specific order, just make sure you take notes while you're doing it so you know how the matrix is wired to the controller because you specify the pins in the firmware.

does that answer your questions for now?

Yup, think so. Thank you so so much. You've been super helpful.

Offline nevin

  • Posts: 1646
  • Location: US
Re: Designing a PCB, how do I do a key matrix with different row switch counts?
« Reply #25 on: Fri, 10 January 2020, 13:15:46 »
no problem.

keep us updated with your progress. :thumb:
Keeb.io Viterbi, Apple m0110, Apple m0120, Apple m0110a, Apple 658-4081, Apple M1242, Apple AEK II, MK96, GH60/Pure, Cherry g84-4100, Adesso AKP-220B, Magicforce 68

Offline kelvinhall05

  • Thread Starter
  • Posts: 69
  • Location: London, Ontario
    • LinusTechTips
Re: Designing a PCB, how do I do a key matrix with different row switch counts?
« Reply #26 on: Thu, 23 January 2020, 06:20:05 »
no problem.

keep us updated with your progress. :thumb:

Small update. I've started work on the case and have almost everything cut, just need to finish the bottom half and then sand/stain everything or whatever. May end up restarting the case, but that's irrelevant.


I've started soldering the matrix and have my diodes and almost all my columns done. I should have 13 columns and 5 rows when I'm done. Will that work with my Pro Micro?

Offline nevin

  • Posts: 1646
  • Location: US
Re: Designing a PCB, how do I do a key matrix with different row switch counts?
« Reply #27 on: Thu, 23 January 2020, 11:03:52 »
Quote
I've started soldering the matrix and have my diodes and almost all my columns done. I should have 13 columns and 5 rows when I'm done. Will that work with my Pro Micro?

yes
Keeb.io Viterbi, Apple m0110, Apple m0120, Apple m0110a, Apple 658-4081, Apple M1242, Apple AEK II, MK96, GH60/Pure, Cherry g84-4100, Adesso AKP-220B, Magicforce 68

Offline kelvinhall05

  • Thread Starter
  • Posts: 69
  • Location: London, Ontario
    • LinusTechTips
Re: Designing a PCB, how do I do a key matrix with different row switch counts?
« Reply #28 on: Thu, 23 January 2020, 11:36:37 »
Quote
I've started soldering the matrix and have my diodes and almost all my columns done. I should have 13 columns and 5 rows when I'm done. Will that work with my Pro Micro?

yes

How would I wire that up? Would you mind making a quick schematic or just simple drawing?

Offline nevin

  • Posts: 1646
  • Location: US
Re: Designing a PCB, how do I do a key matrix with different row switch counts?
« Reply #29 on: Thu, 23 January 2020, 12:13:53 »
actually, i'm counting 5x14 from the wiring example i posted. (not sure how your doing it)
234165-0

really read & soak in the info in these posts
Quote
here's some good articles on handwiring a board (i know you're designing a pcb, but this will give you the general concept)
https://geekhack.org/index.php?topic=87689.0
https://deskthority.net/viewtopic.php?f=7&t=6050

there's no one way to "wire it correctly", you just have to know what row/column is connected to which pin on the promicro because it is specified in the firmware.

you can refer back to the post about  https://kbfirmware.com/ earlier in this thread and use it as a reference. connecting to the controller is specified on the "pins" tab (but your actual wiring has to match the matrix on the "wiring" tab, you can adjust the lines if it's not identical)
Keeb.io Viterbi, Apple m0110, Apple m0120, Apple m0110a, Apple 658-4081, Apple M1242, Apple AEK II, MK96, GH60/Pure, Cherry g84-4100, Adesso AKP-220B, Magicforce 68

Offline kelvinhall05

  • Thread Starter
  • Posts: 69
  • Location: London, Ontario
    • LinusTechTips
Re: Designing a PCB, how do I do a key matrix with different row switch counts?
« Reply #30 on: Thu, 23 January 2020, 16:28:35 »
actually, i'm counting 5x14 from the wiring example i posted. (not sure how your doing it)
(Attachment Link)

really read & soak in the info in these posts
Quote
here's some good articles on handwiring a board (i know you're designing a pcb, but this will give you the general concept)
https://geekhack.org/index.php?topic=87689.0
https://deskthority.net/viewtopic.php?f=7&t=6050

there's no one way to "wire it correctly", you just have to know what row/column is connected to which pin on the promicro because it is specified in the firmware.

you can refer back to the post about  https://kbfirmware.com/ earlier in this thread and use it as a reference. connecting to the controller is specified on the "pins" tab (but your actual wiring has to match the matrix on the "wiring" tab, you can adjust the lines if it's not identical)

I was gonna do the columns a bit differently but just ended up finishing them like you suggested in your picture. I still have columns to do, but I guess the question I've been trying to ask this whole time is which pins I can and can't use on the Pro Micro. There's 24 total, I need 19. Obviously I can't use any of the VCC or GND pins, but I dunno.

Offline nevin

  • Posts: 1646
  • Location: US
Re: Designing a PCB, how do I do a key matrix with different row switch counts?
« Reply #31 on: Thu, 23 January 2020, 17:42:37 »
on a teensy 2.0 - pins D6, GND and VCC should be avoided
on a promicro - we've run into issues with a row or column connected to one of the "init" pins, don't remember exactly which and i can't seem to find the old post at the moment but it was either PD1 (D2) or PD0 (D3)

Keeb.io Viterbi, Apple m0110, Apple m0120, Apple m0110a, Apple 658-4081, Apple M1242, Apple AEK II, MK96, GH60/Pure, Cherry g84-4100, Adesso AKP-220B, Magicforce 68

Offline kelvinhall05

  • Thread Starter
  • Posts: 69
  • Location: London, Ontario
    • LinusTechTips
Re: Designing a PCB, how do I do a key matrix with different row switch counts?
« Reply #32 on: Thu, 23 January 2020, 20:05:55 »
on a teensy 2.0 - pins D6, GND and VCC should be avoided
on a promicro - we've run into issues with a row or column connected to one of the "init" pins, don't remember exactly which and i can't seem to find the old post at the moment but it was either PD1 (D2) or PD0 (D3)

Well, ****. Seems I can't finish this project with a Pro Micro after all. Even if I assume that both PD1 and PD0 work, I only have eighteen pins to work with. I need nineteen for my matrix.


Oh well. Thanks anyway.

Offline kelvinhall05

  • Thread Starter
  • Posts: 69
  • Location: London, Ontario
    • LinusTechTips
Re: Designing a PCB, how do I do a key matrix with different row switch counts?
« Reply #33 on: Thu, 23 January 2020, 20:11:57 »
Wait! Seems I can use two pins that would ordinarily be used for LEDs...bringing my total to 20 pins! Awesome. Now I just gotta figure out which one doesn't work, PD1 or PD0...

Offline nevin

  • Posts: 1646
  • Location: US
Re: Designing a PCB, how do I do a key matrix with different row switch counts?
« Reply #34 on: Fri, 24 January 2020, 01:01:44 »
Wait! Seems I can use two pins that would ordinarily be used for LEDs...bringing my total to 20 pins! Awesome. Now I just gotta figure out which one doesn't work, PD1 or PD0...

yes, you are correct.
here's an article & more info on using those two pins
https://golem.hu/guide/pro-micro-upgrade/

PD1 or PD0...... you may not run into the same issue, i was just trying to keep notes about issues we've run across, so it was easier to reference. i know i've gone digging for this information at least a dozen times.
Keeb.io Viterbi, Apple m0110, Apple m0120, Apple m0110a, Apple 658-4081, Apple M1242, Apple AEK II, MK96, GH60/Pure, Cherry g84-4100, Adesso AKP-220B, Magicforce 68

Offline theNestruo

  • Posts: 14
Re: Designing a PCB, how do I do a key matrix with different row switch counts?
« Reply #35 on: Fri, 24 January 2020, 09:10:18 »
If you are short on pins, you can "interleave" a second set of rows thus reducing your column count to a half.
Your 5x14 (19 pins) matrix can become 10x7 (17 pins), or even 9x7 (16 pins) because your bottom row doesn't require interleaving.

Wiring/tracing will get a little bit counter-intuitive but there are tricks to avoid a wiring/routing hell, such as alternating the diode direction (pictured as schema for readability):
234206-0

Or even displacing the interleaved diodes just half-a-diode up or down, so both row traces will run parallel, one of them crossing below the diodes of the other one:
234208-1

Offline kelvinhall05

  • Thread Starter
  • Posts: 69
  • Location: London, Ontario
    • LinusTechTips
Re: Designing a PCB, how do I do a key matrix with different row switch counts?
« Reply #36 on: Fri, 24 January 2020, 09:44:54 »
If you are short on pins, you can "interleave" a second set of rows thus reducing your column count to a half.
Your 5x14 (19 pins) matrix can become 10x7 (17 pins), or even 9x7 (16 pins) because your bottom row doesn't require interleaving.

Wiring/tracing will get a little bit counter-intuitive but there are tricks to avoid a wiring/routing hell, such as alternating the diode direction (pictured as schema for readability):
(Attachment Link)

Or even displacing the interleaved diodes just half-a-diode up or down, so both row traces will run parallel, one of them crossing below the diodes of the other one:
(Attachment Link)

Since I'm done handwiring I'll just stick with 19 pins. I've already desoldered the resistors where I can have two more pins, so I'm fine now. I do have one question, though. When using the keyboard firmware builder linked above, when I get to the "pins" section, I'm not sure which "label" there goes with which pin on the Pro Micro. All the pictures I can find online label the pins with numbers or A0-10, neither of which are in the list of pins on the firmware builder. All the builder has is B0-B7, C0-C7, D0-D7, E0-E7, and F0-F7. Also, which key acts by default as the "switch layer" key?

Offline nevin

  • Posts: 1646
  • Location: US
Re: Designing a PCB, how do I do a key matrix with different row switch counts?
« Reply #37 on: Fri, 24 January 2020, 11:03:39 »
234224-0
designations is light grey

Fn, raise, lower, whatever you want to call it is typically a momentary layer switch. it can be placed where ever you like, it's action is specified in the keymap

in kbfirmware.com.... click on key you want as Fn, click on KC_"letter", go to FN tab, select "MO()" and select layer to switch to... say 1. so it would read MO(1)

on really small boards, you can do a dual function key for Fn. where a tap will give you the normal character, and holding the same key will give you the Fn function.

there are other ways to navigate to other layers, here's what they all mean
https://docs.qmk.fm/#/feature_advanced_keycodes?id=switching-and-toggling-layers

also, the key codes may be helpful
https://docs.qmk.fm/#/keycodes

and of course, the whole guide is extremely helpful
https://docs.qmk.fm/#/newbs
Keeb.io Viterbi, Apple m0110, Apple m0120, Apple m0110a, Apple 658-4081, Apple M1242, Apple AEK II, MK96, GH60/Pure, Cherry g84-4100, Adesso AKP-220B, Magicforce 68