ATMEGA32U4 vs AT90USB1286

tedfs3

11 Nov 2018, 19:36

Forgive my ignorance on this and the rambling, I'm still trying to learn and wrap my head around designing a keyboard from the ground up.

Has anyone done a keyboard PCB using the AT90USB1286 ? I have no idea what the AU-ND and MU-ND designations mean and have no idea which one would be better suited for keyboard PCB use. The Teensy 2++ uses the AT90USB1286 MU, for reference, so I'm guessing the MU-ND is the better option.

My confusion stems from going over the open source GH80-3000, which uses the ATMega32u4-AU and has support for 117 keys. Trying to create a standard 101 - 104 key PCB using the ATMega32u4-AU and it just doesn't seem like there are enough pins on that chip to support 6 rows, 21 columns and status LEDs. I'm probably just not understanding how this all works yet, hence this post.

It's my understanding that each row and each column needs it's own unique pin on the chip. The ATMega32u4-AU has 26 pins available for use, which is not enough for 6 rows, 21 columns and status LEDs as I currently understand. The AT90USB1286 MU has 48 available pins, which would be more than enough. Unless I'm just not understanding how the wiring matrix works with the controller, which is quite possible.

Just trying to create a left handed keyboard, as it just makes more sense to me as a die hard Numpad user. Obviously I'm in way over my head and am trying to learn how people know what controller to chose and ohh you need some decoupling capacitors here, sprinkle some resistors for the LEDS over there, wire it like this etc...

Sorry to ramble but that's where I'm at right now. Sitting in KiCad looking at the board matrix, counting rows and columns. Looking at the Firmware builder and the ATMega32u4-AU data sheets, not finding pins on the chip that Firmware builder says to use. Those pins are on the Teensy 2++ but not the ATMega32u4-AU itself. Which makes no sense to me why the firmware builder would say to use pins E0 - E7 when selecting the ATMega32u4 as the controller when the only pins on that controller are E2 and E6 ?

Sure I could just design the board around a Teensy 2++ as a plug in module but that really defeats the purpose of understanding how the controller is used and why. Understanding the how and why is the goal here, hopefully there is some guidance out there or specific links to follow for me to learn.

This whole thing really has me rethinking the project and just manually wiring it...

Findecanor

11 Nov 2018, 20:00

tedfs3 wrote: Has anyone done a keyboard PCB using the AT90USB1286 ? I have no idea what the AU-ND and MU-ND designations mean and have no idea which one would be better suited for keyboard PCB use. The Teensy 2++ uses the AT90USB1286 MU, for reference, so I'm guessing the MU-ND is the better option.
It's the same chip in different packages. One is smaller with the pins closer together.
tedfs3 wrote: My confusion stems from going over the open source GH80-3000, which uses the ATMega32u4-AU and has support for 117 keys. Trying to create a standard 101 - 104 key PCB using the ATMega32u4-AU and it just doesn't seem like there are enough pins on that chip to support 6 rows, 21 columns and status LEDs.
That's because the matrix does not have to be precisely 6 rows with 21 columns but could have any configuration. sqrt(117) ~= 10.8, so the smallest possible matrix for a 117-key keyboard would be 11×11, using 22 pins.
The ATMega32U4 has 26 I/O lines of which 3 special lines are usually used for LEDs because those are PWM-output capable . (Caps Lock, Num Lock and Scroll Lock, most keyboards don't support a LED for a Compose key unfortunately).

But if you are hand-wiring a 117-key keyboard, then by all means use a Teensy2.0++ with a 6×21 matrix because that would be the easiest to wire.

tedfs3

11 Nov 2018, 20:27

I guess understanding how the matrix is created is my issue then. I was under the impression that it should follow the physical layout of the keys in order to be valid ?

An 11 x 11 matrix would be perfect for the ATMEGA32U4 but I'm not understanding how an 11 x 11 would work if following the wiring shown on firmware builder.
Wiring.png
Wiring.png (5.73 MiB) Viewed 4033 times
I'd rather not hand wire but design a pcb. Just need to wrap my head around the details, which will take time and learning.

ETA: Which lines are used for the status LEDs ? I'm not finding info on that yet.

Zoomed in on the PCB a bit and think the LED question answered itself. Looks like Pins 30, 29 and 12 are used for the LEDs ?
ATMEGA32U4.png
ATMEGA32U4.png (3.03 MiB) Viewed 4020 times

tedfs3

16 Nov 2018, 10:21

Can someone post an example of how an 11 x 11 matrix might be wired to the Atmega32U4 ? I'm just not understanding how to fit 101 - 104 keys without splitting them up like the firmware builder shows. Not that far enough along in my understanding yet.

User avatar
DiodeHead

16 Nov 2018, 16:40

you can do it yourself, in the pictures that you posted earlier you can modify and put an 11x11 matrix with the buttons on the bottom part, I think the concept that your not taking into account is that "the matrix" is how you connect your keys electrically, but has nothing to do with how you arrange them, you could even have them all arranged in the same column for example and still be electrically connected by a matrix of 11x11, the PCB would be a nightmare to design but still possible. That electrical matrix will generate two sets of 11 bits in your microcontroller PORTA, PORTB etc...
So if you press the key at (1,1) it would generate:
10000000000 10000000000

And that is how you tell your firmware which key you pressed.

I hope it helps :)

User avatar
vvp

16 Nov 2018, 16:46

You have already drawn a matrix for 6*22.
Consider two adjacent physical columns as one keyboard matrix scanning column. For the sake of scanning, you will get 6+6 = 12 rows. You get an easy to wire matrix with dimensions of 12 * 11.

As for as creation of matrix with dimensions 11 * 11. Just divide the switches to ordered groups of 11 pieces. Then one group is one column in the scanning matrix. First row will connect first switches in each group. Second column will connect second switches in each group ... etc.

User avatar
swampangel

16 Nov 2018, 20:18

tedfs3 wrote: Can someone post an example of how an 11 x 11 matrix might be wired to the Atmega32U4 ? I'm just not understanding how to fit 101 - 104 keys without splitting them up like the firmware builder shows. Not that far enough along in my understanding yet.
Here is how I understand it, conceptually:

The default arrangement of 6 rows and ~22 columns is a good match for the physical layout of the kb and allows your wires to be fairly straight.

To get closer to the 11x11 arrangement that minimizes pins, you have to make your columns longer and rows shorter (making the whole arrangement "squarer" from a circuit perspective -- but not from a physical wiring perspective)

You can imagine one way to do this is to "wrap" the columns around the corners of the board. Here's an example of how you *might* lay this out:
CCI11162018_00000.jpg
CCI11162018_00000.jpg (109.92 KiB) Viewed 3926 times
Please mind -- I have not checked my work or built a keyboard like this, it's just a doodle.

You can see how the columns at the left and right of the board wrap around and keep going. The 11 columns are drawn in red -- most of them have 11 keys in them, but a couple are shorter.

However, you can also see the dotted pencil line which would represent "row 1" in such a configuration -- and you'd have to figure out how to lay out the other 10 rows too.

For a hand wire keyboard, it's easier to use the Teensy++ and not to worry. If you're designing a pcb, I expect there are some tools to make it easier, or you can see if someone else has made a schematic available for a similar fullsize board.
vvp wrote: You have already drawn a matrix for 6*22.
Consider two adjacent physical columns as one keyboard matrix scanning column. For the sake of scanning, you will get 6+6 = 12 rows. You get an easy to wire matrix with dimensions of 12 * 11.

As for as creation of matrix with dimensions 11 * 11. Just divide the switches to ordered groups of 11 pieces. Then one group is one column in the scanning matrix. First row will connect first switches in each group. Second column will connect second switches in each group ... etc.
Visualized version of what vvp said:
2018_11_16_19_12_25_Keyboard_Firmware_Builder.png
2018_11_16_19_12_25_Keyboard_Firmware_Builder.png (35.65 KiB) Viewed 3909 times
then wire column 0 to column 11, 1 to 12, and so on up to 10 to 22.

You'd have to manually specify the details of the matrix in order to generate compatible firmware for it.

tedfs3

17 Nov 2018, 01:56

Thank you everyone, it's much clearer now !

The replies here made me go back and look at the PCB design again and to actually start following traces. Sure enough there are long columns in a few places.
Matrix-Revised.png
Matrix-Revised.png (2.53 MiB) Viewed 3904 times
Now I understand how a " 6x22 " can fit on the ATMEGA32U4 by simply extending some columns to include more keys versus actually trying to physically mimic the key layout on the board. I'm still wondering if anyone has used the AT90USB1286 for a board though and will keep looking. They are twice the cost of the ATMEGA32U4 though.

I really do appreciate the help.

Post Reply

Return to “Workshop”