TCKB: My journey in the world of STM32 driven keyboards (60%)
Posted: 04 Nov 2016, 01:26
Hello everyone,
As an introduction, I'll talk a bit about me and say I'm an embedded software engineer since about ten years. The firm I work for make a huge use of multiple STM32 arm micro controllers and I play with them every day
1) The genesis
For my personal entertainment I wanted to take a look at the new development tools STMicroelectronics provides for their line of mcus. My main concern was about STM32CubeMX which is a device configuration gui and code generator.
While the possibilities provided by that tool were interesting, I was a bit frustrated by the lack of concrete application I had to give it.
Being a late MK guy, (I'm typing right now on my brown Ducky Shine4), I decided in the first part to explore the software side of moderns MK. By modern I mean USB. The usb hid class that is generated by cubeMX is a mouse device and was my first headache... but I managed to adapt it to a 6kro keyboard.
With a 1ms polling and debouncing, my first prototype looked like that:
The black box is a logic analyzer I used to monitor matrix polling and usb frames.
I created my first two layers/ten keys usb keyboard, driven by an STM32L053R8T6 nucleo eval kit (32MHz, 8kB ram, 64kB flash, 2kB user eeprom)!
2) Code that seriously
You may imagine that playing with ten switches on a breadboard can be quickly boring. It was!
As a consequence for the second iteration of my creature, i came to the conclusion that i needed to structure all that test code I put together to make it easier to upgrade.
To ease my software skills, and focus on the application side, I choose to run my microcontroller through a real time operating system.
Good news, CubeMX can generate a FreeRTOS project skeleton. I rewrote my application from scratch in the form of several tasks and came to the same ten keys USB board... with an embedded OS!
3) Give it some pimp
My previous step with FreeRTOS being quite promising, I felt the urge to throw some glitter on the monster and make it a princess... And as I had another nucleo kit in the drawer, I fired my best soldering iron and quickly soldered a 5*14 led matrix... (you see what I did there )
One of the caveat of driving a led matrix is that the mcu outputs are not strong enough to provide the necessary current. To solve that matter, I used a bunch of N and P channel MOSFETS hooked to that second kit:
This is only a small part of the actual matrix.
Both controllers are connected through an 8MHz SPI link with an homemade protocol.
Right now, each key press is sent to the computer and the led controller:
4) Serious business
Ok, the thing runs quite well but if I want to make it usable, I'll have to design a bit of hardware.
For a first timer in the custom keyboard land, I found a lot of help from the community and specifically through the GH60 project from which I kept the board outline, switch/stabilizer and fixing holes coordinates as I had no reference hardware to reverse.
To ease the process I choose to make a strict ANSI/ISO compatible board. Sorry to all the exotic layouts lovers
After a few days of trial and errors with Kicad, the beast was drawn, the all mighty dual processor TCKB (Tiny Custom Key Board).
The hidden part is a silly movie quote I keep for myself until someone get a hand on one of the few pcbs that will be produced.
5) Holy mailman!
Today, November 03rd, after three weeks, I had the pleasure to find in my mailbox five of those marvelous red gems:
Needless to say that I'm eager to solder all the component I collected through the bay the past weeks and check for routing mistakes. Too bad I'll have some busy days to come and will not be able to solder my new toy until at least a week.
6) Download !
Your hawk eye must have noticed the little Open Hardware logo on the pcb.
The kicad files are saved int the following GitHub repo: https://github.com/Ced67/TCKB_Kicad
While the software sources are in that one : https://github.com/Ced67/TCKB_Software
7) More to come...
I'll add some tutorials on how to flash the STM32s using different tools: USB to Serial, Segger J-Link, ST-Link...
Thanks for reading!
As an introduction, I'll talk a bit about me and say I'm an embedded software engineer since about ten years. The firm I work for make a huge use of multiple STM32 arm micro controllers and I play with them every day
1) The genesis
For my personal entertainment I wanted to take a look at the new development tools STMicroelectronics provides for their line of mcus. My main concern was about STM32CubeMX which is a device configuration gui and code generator.
While the possibilities provided by that tool were interesting, I was a bit frustrated by the lack of concrete application I had to give it.
Being a late MK guy, (I'm typing right now on my brown Ducky Shine4), I decided in the first part to explore the software side of moderns MK. By modern I mean USB. The usb hid class that is generated by cubeMX is a mouse device and was my first headache... but I managed to adapt it to a 6kro keyboard.
With a 1ms polling and debouncing, my first prototype looked like that:
The black box is a logic analyzer I used to monitor matrix polling and usb frames.
I created my first two layers/ten keys usb keyboard, driven by an STM32L053R8T6 nucleo eval kit (32MHz, 8kB ram, 64kB flash, 2kB user eeprom)!
2) Code that seriously
You may imagine that playing with ten switches on a breadboard can be quickly boring. It was!
As a consequence for the second iteration of my creature, i came to the conclusion that i needed to structure all that test code I put together to make it easier to upgrade.
To ease my software skills, and focus on the application side, I choose to run my microcontroller through a real time operating system.
Good news, CubeMX can generate a FreeRTOS project skeleton. I rewrote my application from scratch in the form of several tasks and came to the same ten keys USB board... with an embedded OS!
3) Give it some pimp
My previous step with FreeRTOS being quite promising, I felt the urge to throw some glitter on the monster and make it a princess... And as I had another nucleo kit in the drawer, I fired my best soldering iron and quickly soldered a 5*14 led matrix... (you see what I did there )
One of the caveat of driving a led matrix is that the mcu outputs are not strong enough to provide the necessary current. To solve that matter, I used a bunch of N and P channel MOSFETS hooked to that second kit:
This is only a small part of the actual matrix.
Both controllers are connected through an 8MHz SPI link with an homemade protocol.
Right now, each key press is sent to the computer and the led controller:
4) Serious business
Ok, the thing runs quite well but if I want to make it usable, I'll have to design a bit of hardware.
For a first timer in the custom keyboard land, I found a lot of help from the community and specifically through the GH60 project from which I kept the board outline, switch/stabilizer and fixing holes coordinates as I had no reference hardware to reverse.
To ease the process I choose to make a strict ANSI/ISO compatible board. Sorry to all the exotic layouts lovers
After a few days of trial and errors with Kicad, the beast was drawn, the all mighty dual processor TCKB (Tiny Custom Key Board).
The hidden part is a silly movie quote I keep for myself until someone get a hand on one of the few pcbs that will be produced.
5) Holy mailman!
Today, November 03rd, after three weeks, I had the pleasure to find in my mailbox five of those marvelous red gems:
Needless to say that I'm eager to solder all the component I collected through the bay the past weeks and check for routing mistakes. Too bad I'll have some busy days to come and will not be able to solder my new toy until at least a week.
6) Download !
Your hawk eye must have noticed the little Open Hardware logo on the pcb.
The kicad files are saved int the following GitHub repo: https://github.com/Ced67/TCKB_Kicad
While the software sources are in that one : https://github.com/Ced67/TCKB_Software
7) More to come...
I'll add some tutorials on how to flash the STM32s using different tools: USB to Serial, Segger J-Link, ST-Link...
Thanks for reading!