Author Topic: How to 9-key USB keyboard with NKRO?  (Read 2256 times)

0 Members and 1 Guest are viewing this topic.

Offline Ettasian

  • Thread Starter
  • Posts: 15
  • Location: Poland/Gdynia
How to 9-key USB keyboard with NKRO?
« on: Wed, 11 November 2015, 08:01:14 »
Hi everyone.
I want to make a USB board with 9 switches and NKRO. It doesn't really matter how many many rows and columns are in the matrix, but one row/nine columns is prefered. Which controllers provide the right amount of I/O pins and supports USB? Do you know any legitimate templates of the code that can be used here?
I aim to use Cherry MX switches and 1N4148 diodes for NKRO.
« Last Edit: Wed, 11 November 2015, 08:27:23 by Ettasian »
Cherry G80-0777/1

Offline VinnyCordeiro

  • Posts: 432
Re: How to 9-key USB keyboard with NKRO?
« Reply #1 on: Wed, 11 November 2015, 09:10:41 »
Hi everyone.
I want to make a USB board with 9 switches and NKRO. It doesn't really matter how many many rows and columns are in the matrix, but one row/nine columns is prefered. Which controllers provide the right amount of I/O pins and supports USB? Do you know any legitimate templates of the code that can be used here?
I aim to use Cherry MX switches and 1N4148 diodes for NKRO.
Which kind of microcontroller you plan to use? AVR (from Atmel)? ARM? Another familiy of microcontrollers (like PIC)?

You can do this project with whatever microcontroller you want. Some are easier than others for that, though. As a rule of thumb I use Atmel ATmega32U4 microcontrollers for my projects, it serves me well: it have 26 I/O pins, but typically you can use only 25 (one of the pins have to be pulled down to enable the bootloader).

For such a tiny keyboard you can use ATmega32U2, it have 20 I/O pins, more than enough for your project. And it is cheaper then the 32U4.

As for the firmware, I can recommend 3 options: Soarer's, TMK and Easy AVR, but beware: only TMK supports the ATmega32U2 AFAIK.

I hope I could be of some help. Welcome to Geekhack!

Offline Ettasian

  • Thread Starter
  • Posts: 15
  • Location: Poland/Gdynia
Re: How to 9-key USB keyboard with NKRO?
« Reply #2 on: Wed, 11 November 2015, 14:15:53 »
I'm an equal newbie in all of these, but I was considering using Teensy, since I just happen to have one. There is also Adafruit Trinket, but from what I read it's not even close to be capable of supporting a 9-key pad with NKRO.

Do you use only the microcontrolers with your project, or buy the whole development boards?

Can you show me how to get started? Maybe you know any good tutorial?

You surely are of help  :thumb: and thanks, but I'm not exactly new here  :))
Cherry G80-0777/1

Offline suicidal_orange

  • * Global Moderator
  • Posts: 4771
  • Location: England
Re: How to 9-key USB keyboard with NKRO?
« Reply #3 on: Wed, 11 November 2015, 14:16:27 »
What Vinny said, except to note that EasyAVR also claims to work with the ATMega32u2 and that if you use EasyAVR you'll need to configure a spare pin as a second row with nothing connected to make it work, and you need to use the "beta" version not the "latest"  It does work and is very easy, but the handwire option is new and kinda dodgy...

Also if you have one pin for each switch you won't need any diodes :)

edit: Vinny is an expert and designs his own PCBs (AUNK) but many of us use Teensys, especially for a board this small.

Hopefully you have a Teensy 2.0 not a 3.something?
« Last Edit: Wed, 11 November 2015, 14:23:44 by suicidal_orange »
120/100g linear Zealio R1  
GMK Hyperfuse
'Split everything' perfection  
MX Clear
SA Hack'd by Geeks     
EasyAVR mod

Offline Ettasian

  • Thread Starter
  • Posts: 15
  • Location: Poland/Gdynia
Re: How to 9-key USB keyboard with NKRO?
« Reply #4 on: Wed, 11 November 2015, 15:26:37 »
Yup, it's Teensy 2.0.

So how do I configure a pin as a second row? In what language? In what software?

Also, which are the I/O pins in Teensy 2.0?
Cherry G80-0777/1

Offline VinnyCordeiro

  • Posts: 432
Re: How to 9-key USB keyboard with NKRO?
« Reply #5 on: Wed, 11 November 2015, 15:33:35 »
What Vinny said, except to note that EasyAVR also claims to work with the ATMega32u2 and that if you use EasyAVR you'll need to configure a spare pin as a second row with nothing connected to make it work, and you need to use the "beta" version not the "latest"  It does work and is very easy, but the handwire option is new and kinda dodgy...

Also if you have one pin for each switch you won't need any diodes :)

edit: Vinny is an expert and designs his own PCBs (AUNK) but many of us use Teensys, especially for a board this small.

Hopefully you have a Teensy 2.0 not a 3.something?
You flatters me. :-[ I'm just a guy who studied in an electronics technical school long ago.

Offline suicidal_orange

  • * Global Moderator
  • Posts: 4771
  • Location: England
Re: How to 9-key USB keyboard with NKRO?
« Reply #6 on: Wed, 11 November 2015, 15:42:16 »
Vinny linked three options of full featured firmware above, you can use any of them with your Teensy so have a read of the documentation with each and see which one you like the look of.  There's a good video posted here by sylcat which shows how to connect a premade strip of buttons, yours will be the same except you have more and need to connect one leg on each switch together to use as what he calls the "power" wire.
120/100g linear Zealio R1  
GMK Hyperfuse
'Split everything' perfection  
MX Clear
SA Hack'd by Geeks     
EasyAVR mod

Offline VinnyCordeiro

  • Posts: 432
Re: How to 9-key USB keyboard with NKRO?
« Reply #7 on: Wed, 11 November 2015, 15:56:36 »
Yup, it's Teensy 2.0.

So how do I configure a pin as a second row? In what language? In what software?

Also, which are the I/O pins in Teensy 2.0?
This is your first project, so let's start simple:

You have a Teensy 2.0. That's good, its heart is a microcontroller from Atmel, model ATmega32U4. It is well supported by the firmware options I gave.

Let's stick with Easy AVR. It has a graphical user interface and is very easy to use. You won't have to mess with configuration files or C/C++ code.

Easy AVR have an option for hand-wired keyboards. That's the one we are going to use for your keyboard.

I'll quote the HOWTO from Easy AVR on how to create a hand-wired keyboard:

Quote
HOWTO: Easy AVR USB Keyboard Firmware - Using the hand-wired matrix
metalliqaz@geekhack

==============
Introduction
============

Although Easy AVR USB firmware builds are programmable, the hardware details
must be pre-compiled and incorporated into the tool.  Therefore, in order for
a new hand-wired keyboard design to work with Easy AVR USB firmware, it must
be wired according to this pre-defined description.

For lack of a better standard, I have chosen the venerable Phantom as the model
for this default hardware configuration.

=======================
Hardware Requirements
=====================

A Teensy 2.0, programmable with the Teensy Loader
    (other project boards will typically work, if they use an ATmega32U4)
Up to 108 (6x18) switches
Diodes for each switch
Up to 4 LEDs, with matching resistors

========================
Electrical Connections
======================

Remember that diodes and LEDs are directional and must be installed with the
correct orientation for the system to work.

Diodes must be installed such that current flows from Row to Col.

LEDs must be installed such that current flows from the pin to ground.

=================
Pin Assignments
===============

Note:
Top left (typically Esc) is Row 0, Col 0
Bottom right (typically arrow) is Row 5, Col 16

The following assignments may be reconfigured by adding a new section
to the handwire_hardware.cfg file in the cfg directory.  Remember that
there are not enough pins on a Teensy to fill all possible assignments.
At least three "NA" are required, though you may use more for smaller
designs.  Never reuse pins.

Row 0: B5
Row 1: B4
Row 2: B3
Row 3: B2
Row 4: B1
Row 5: B0

Col  0: D5
Col  1: C7
Col  2: C6
Col  3: D4
Col  4: D0
Col  5: E6
Col  6: F0
Col  7: F1
Col  8: F4
Col  9: F5
Col 10: F6
Col 11: F7
Col 12: D7
Col 13: D6
Col 14: D1
Col 15: D2
Col 16: D3
Col 17: NA

LED0: B6
LED1: B7
LED2: NA
LED3: NA

=================
Making a Layout
===============

Once the board is wired, each switch will have a (row,col) coordinate.  To
assign a key, find that coordinate in the keymapper application and assign
your selected function.  The layout may be located anywhere within the 6x18
matrix, as long as it fits.

The layout view in the keymapper is configurable with .cfg files.  This step
is purely cosmetic and is not required.  If you wish to customize the view,
an example .cfg file is provided.
If you have any doubts, just ask. I'll try to answer to the best of my knowledge.

Offline Ettasian

  • Thread Starter
  • Posts: 15
  • Location: Poland/Gdynia
Re: How to 9-key USB keyboard with NKRO?
« Reply #8 on: Wed, 11 November 2015, 16:16:59 »
Whoa, thanks guys! I think I get everything now  :D
I will surely post the results of this little project in a couple of days.
Thanks again, you are all just awesome  :thumb:
Cherry G80-0777/1