Author Topic: Selecting a MCU for Keyboard  (Read 7424 times)

0 Members and 1 Guest are viewing this topic.

Offline ajo518Topic starter

  • Contributor
  • Posts: 11
Selecting a MCU for Keyboard
« on: June 04, 2019, 12:54:50 am »
Hi guys!

I'm trying to decide on what brand / architecture of chips I should be using. I plan on making a custom pcb for both of these projects, but it is always nice if there is a dev kit that I can use to start out with, but it is not necessary.

I'm working on two related keyboard projects.
1) A keyboard based off of a Lenovo T420 keyboard with usb and or Bluetooth interface
2) full custom mechanical keyboard with bluetooth or usb

 plan on making a custom pcb for both of these projects, but it is always nice if there is a dev kit that I can use to start out with, but it is not necessary.

I have worked with pic for school and have a pic kit 3. I liked it ok, but it seemed a little bit of a pain to get all the registers configured correctly, but that may just have been part of the learning curve.
At work the mostly use arm MCU's which I am not directly involved with, but would like to learn about and possibly use GCC.

I am confident in being able to select the correct chip from a given family (peripherals etc.), but I'm not sure of what the "best" family is. I'm thinking of pic, atmel, or arm. (there may be others that I have missed).

I know pic has the pic kit and mplab which is free, but do the other families have free dev software? Are the In circuit programmers expensive?

I know there are firmware's in existence to do exactly what I want, but I want to write my own mainly just for the experience. (and of course I can always look at the others for inspiration if needed)

I know there is no silver bullet, but I would like to hear some opinions. I also would like something that is expandable to other things as well.

Any advice would be greatly appreciated :D
Thanks!
« Last Edit: June 04, 2019, 01:00:16 am by ajo518 »
 

Offline lucazader

  • Regular Contributor
  • *
  • Posts: 221
  • Country: au
Re: Selecting a MCU for Keyboard
« Reply #1 on: June 04, 2019, 01:47:54 am »
Plenty of options out there.

I would advocate for an arm based system if you are wanting to get into learning gcc based tooling.
Quite a few of the arm manufacturers have free IDE's which use gcc under the hood which might allow an easier transition for you.

I would suggest the stm32 series. Their nucleo dev boards are super cheap (between $10-20 USD for most) and come with a build in st-link.
You can generate projects using their stm32cubeMX. Which you can even setup with USB device with the HID class already up and running.
But this is just what i am used to.
Im sure other people will present other just as valid options momentarily.
It might be good to get a dev board or two and see which one you like playing around with the most.
« Last Edit: June 04, 2019, 01:53:50 am by lucazader »
 

Offline wraper

  • Supporter
  • ****
  • Posts: 16867
  • Country: lv
Re: Selecting a MCU for Keyboard
« Reply #2 on: June 04, 2019, 01:55:48 am »
EFM8UB series would do USB very cheap + you can get free VID/PID from silabs and examples available. And you need is only a few decoupling caps to get the thing going, internal 100mA 3.3V vreg included. Free IDE, easy to debug. Dev board IIRC costs about EUR 30, includes built in J-link which can program/debug external devices as well. Standalone debugger costs about the same.
« Last Edit: June 04, 2019, 02:03:43 am by wraper »
 

Offline NorthGuy

  • Super Contributor
  • ***
  • Posts: 3147
  • Country: ca
Re: Selecting a MCU for Keyboard
« Reply #3 on: June 04, 2019, 02:07:27 am »
Of you've already worked with PICs - PIC16F1454: about $1, requires only couple capacitors to connect to USB. If you need more pins and analog there's 20-pin PIC16F1459.
 

Offline wraper

  • Supporter
  • ****
  • Posts: 16867
  • Country: lv
Re: Selecting a MCU for Keyboard
« Reply #4 on: June 04, 2019, 02:11:36 am »
Of you've already worked with PICs - PIC16F1454: about $1, requires only couple capacitors to connect to USB. If you need more pins and analog there's 20-pin PIC16F1459.
20 pins minus power, GND and USB is too little for keyboard without using additional IC to scan keys.
 

Offline NorthGuy

  • Super Contributor
  • ***
  • Posts: 3147
  • Country: ca
Re: Selecting a MCU for Keyboard
« Reply #5 on: June 04, 2019, 02:58:55 am »
Of you've already worked with PICs - PIC16F1454: about $1, requires only couple capacitors to connect to USB. If you need more pins and analog there's 20-pin PIC16F1459.
20 pins minus power, GND and USB is too little for keyboard without using additional IC to scan keys.

If lots of pins are needed, then it's not going to be as cheap. Something like PIC24FJ64GB410 (100-pin TQFP), or PIC24FJ64GB412 (121-pin BGA) may work. These are about $4. Although PIC24s are quite different from 8-bit PICs.
 

Online rstofer

  • Super Contributor
  • ***
  • Posts: 9890
  • Country: us
Re: Selecting a MCU for Keyboard
« Reply #6 on: June 04, 2019, 08:13:42 pm »
I would expect the keyboard to be multiplexed and scanned

https://www.embedded.com/electronics-blogs/without-a-paddle/4439874/Keyboard-and-display-multiplexing----the-traditional-approach

There are a lot of electrical approaches to this.  If I had 256 keys to scan, I would send out a 4 bit value to the row select and use a 4-16 demux chip to do the actual selection.  Then I would need 16 column inputs.  Total: 20 pins for 256 switches.

The problem with this is that it doesn't necessarily sort out near simultaneous keypresses.  There used to be chips that scanned a keyboard and it looks like some are still around.  I imagine it can all be worked out in firmware because something like Ctrl-Alt-Del just has to work.

Then there is 'n key rollover'

https://en.wikipedia.org/wiki/Rollover_(key)
« Last Edit: June 04, 2019, 08:15:32 pm by rstofer »
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3367
  • Country: nl
Re: Selecting a MCU for Keyboard
« Reply #7 on: June 05, 2019, 12:07:10 am »
GH60
 

Offline ajo518Topic starter

  • Contributor
  • Posts: 11
Re: Selecting a MCU for Keyboard
« Reply #8 on: June 05, 2019, 01:40:11 am »
The keyboard is indeed multiplex. There are 28 pins that make up the keyboard matrix. So that is deferentially a consideration as far as the specific chip, but I'm guessing almost every family has options that will work.
As others have said it is a 10X17 grid. You activate one row say and then read back the columns. This is already laid out so no concern there.

Say I went with an ARM option is there a large difference between the vendors? Are the in circuit debuggers manufacturer specific or just ARM specific? Is there a good in circuit programmer I should be looking at?

Thanks for all the good input! ;D
 

Offline lucazader

  • Regular Contributor
  • *
  • Posts: 221
  • Country: au
Re: Selecting a MCU for Keyboard
« Reply #9 on: June 05, 2019, 01:56:38 am »
Arm is in general pretty similar. At least when it comes to the compiler and the actual core it's self.
However the peripherals and USB stacks and classes will be different and more manufacturer specific.

Usually the debuggers are manufacturer specific, however they are all pretty cheap.
Eg an stlink v2 clone of ebay is about $3. and if you get a nucleo dev board it comes built in.
All the other manufacturers are similar in offering low cost (eg less than $50) options.

 

Offline Dabbot

  • Regular Contributor
  • *
  • Posts: 192
  • Country: au
Re: Selecting a MCU for Keyboard
« Reply #10 on: June 05, 2019, 10:11:25 am »
Also, if you select a chip with plenty of ADC pins, you can implement each group of keys as a resistor ladder and keep the pin count requirement down.
 

Offline mariush

  • Super Contributor
  • ***
  • Posts: 5029
  • Country: ro
  • .
Re: Selecting a MCU for Keyboard
« Reply #11 on: June 05, 2019, 11:22:17 am »
Or you could just add i/o expanders... a 16 i/o i2c/spi expander is under 1$ and can have interrupt on change to simplify your life.
 

Offline NorthGuy

  • Super Contributor
  • ***
  • Posts: 3147
  • Country: ca
Re: Selecting a MCU for Keyboard
« Reply #12 on: June 05, 2019, 01:07:23 pm »
Or a long shift register (probably can be had at close to 1 cent/flop). You just rotate a single '1' bit through it to activate each key sequentially. Then sample with a single MCU pin. This eliminates the need for diodes at every key. With the shift register, you only need 3 MCU pins. The money you save by using a low pin count MCU instead of a big one will pay for the flops.

<edit>Sorry, I wasn't thinking. Diodes, of course, are necessary.
« Last Edit: June 05, 2019, 02:02:42 pm by NorthGuy »
 

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 2550
  • Country: us
Re: Selecting a MCU for Keyboard
« Reply #13 on: June 05, 2019, 04:13:30 pm »
Another PIC choice might be the PIC18F4550.
It has 35 IO pins plus USB.  You would have to really take a look at mapping out the IO pins since you need 27 pins.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf