Monday, January 11, 2021

PCA10059 running KMK firmware

Cheap way to try out KMK firmware

The PCA10059 is a USB stick with the NRF52840 chip on it. Digikey and Mouser have them in stock for $10. It is very bare bones and is designed to be powered directly from the USB port and uses the built in voltage regulator to provide the 3.3v running voltage. To run KMK you must first install CircuitPython.

There is currently a bug in CircuitPython on the PCA10059 that causes file corruption. It is being worked on.

The process is fairly involved. If you have a Raspberry Pi you can do it without buying a dedicated programmer. I followed the very complete instructions on Rototron.info. The only difference is that I used an old Raspberry Pi 1 (first generation) instead of a Raspberry Pi 3 as in their example.

The only changes to the process are to the config file. I commented out the lines for Raspberry Pi 3 and uncommented the ones for Raspberry Pi 1. I also dropped the adapter_khz to 100. I don't know if this was necessary but it worked fine for me.

The connections were identical to the example. I soldered header pins to the PCA10059 and inserted it into a breadboard. I used a USB extension cable to connect it to the Pi.

I ran all the commands remotely through a SSH connection.

The Raspberry Pi 1 has a problem with resetting when a USB device is hot plugged. You should power it down before making connections.

Heed the warning about resetting the PCA10059 before attempting to flash the bootloader. If you don't flash the bootloader immediately after erasing it you may lose the connection to the Pi and will need to use a level shifter to regain access to program it.

The flash process takes about 30 seconds. It will sit seeming to do nothing for most of this time. Just wait.

After you have flashed the bootloader you will need to install the latest CircuitPython for the PCA10059. https://circuitpython.org/board/pca10059/

Then install the latest KMK release. https://cdn.kmkfw.io/kmk-latest.zip

Instructions here

KMK Setup

I wanted to use the built in SW1 (the white button on the top of the board) for a simple 1 key keyboard. The problem is that KMK is setup in the reverse of how most keyboard matrices are setup and it pulls the input high when pressed, instead of pulling low. The SW1 being connected to ground did not register.

I modified matrix.py to invert the logic. My modified matrix.py is here.

Line 83 pull up instead of down.

Line 104 set output False instead of True.

Line 118 add 'not' to invert reading of pin.

Line 144 set output True instead of False.

I made a very simple code.py keymap that has a single key output of the letter 'A'.

The col pins don't do anything, since SW1 is connected to ground. But they do make the RGB LED light up to show the matrix scanning. There is also a limitation that you can not define a single row or column, you need at least two. So I added a P1_10 as a second non existent row.

It also wants the Adafruit BLE library, even though it does not use BLE. You can find this in the latest library archive from here. Copy the entire 'adafruit_ble' folder to the lib folder on the PCA10059.

The PCA10059 has 15 GPIO pins along the edges and a few more on tiny pads on the bottom. 15 are enough for a small macropad or even a Gherkin. It lacks any battery circuitry so a wireless BLE keypad is not likely without additional circuitry.

Thursday, January 7, 2021

Adafruit QT PY

Tiny MCU with the same footprint as the XIAO

The Adafruit QT PY is built off an ARM M0 core just like the XIAO. The pinout is compatible with the XIAO and most Arduino code will run without modification.

The main difference is that the QT PY has a built in RGB LED, a reset button, and a spot for a 2MB SPI flash chip. On the XIAO you have to short two tiny pads to reset it.

The optional SPI chip makes this a much more capable CircuitPython device. The 8 pin SOIC chip is available at Digikey GD25Q16CTIGR.

The QT PY is currently $6 from Adafruit or Digikey. It is listed as a "Limited Time" price.

The XIAO (left) has a metal can covering the components. The QT PY (right) has an additional connector for I2C devices.

The bottom of the QT PY is where the optional 2MB SPI flash chip is soldered. I soldered diodes legs to make them socketable.


Friday, December 18, 2020

Nice oxidation

Applied liver of sulfur to exposed copper

As an experiment I used liver of sulfur to apply a forced patina to the exposed copper layer to highlight the legends on the Feegle XS.

The shiny copper turned almost black. It looks very good against the white soldermask.

The all white PCB is what it looked like originally. I carefully sanded off the raised areas of the solder mask to expose the copper. Laying a piece of 1000+ grit sandpaper on a flat piece of glass is the quickest way to only sand off the raised areas.

The forced patina compared the the naturally occurring oxidation on another Feegle XS.

I will probably spray a layer of clear lacquer over the top to protect the thin oxidized layer.
 

ROT XIAO

Rotary encoder soldered directly to a XIAO

Small, with the encoder sitting directly on top the metal shield on the XIAO and soldered directly to the pins.

The encoder is connected to pins 8, 9, 10. The switch is connected to pins 3 and 5.

Pins 9 and 5 are set as output low to behave as ground pins.

The solder lugs were bent and trimmed. I soldered this side to the metal case of the XIAO.

The other lug I soldered to the top of the USB-C connector.

I taped the bottom of the XIAO when soldering the pins so that solder would not flow out the bottom. This left the bottom perfectly flat.

I added heavy duty 3M VHB tape to the bottom. I can now add an encoder anywhere.

It runs a simple Arduino script. It uses the HID-Project and CommonBusEncoders libraries. 

You can get 3 packs of XIAO on Amazon and Digikey sometimes has them in stock.

Pro Micro version

I had to trim off the mounting lugs since they would short out on the components on the Pro Micro. I also used a small square of VHB tape between the encoder and the ATmega32u4.

Same as the XIAO version, but the encoder is connected to pins 15, 18, 19. The switch is connected to 4 and 6. It runs the same Arduino script as the XIAO, with only the pin definitions changed.


Wednesday, December 9, 2020

ORTHOPI rotary encoder

Rotary encoder connected and setup as volume control

I connected the encoder to the GPIO header with the same 30awg wire I used for the other connections.

There are 4 connections, Ground (black), Encoder A (yellow), Encoder B (orange), Switch (blue).The ground connection is shared for the encoder and the switch.

I soldered directly to the GPIO header. I chose GPIO 17, 27, and 22 since they are easy to access.

I followed the instructions and modified the script I found here: https://gist.github.com/savetheclocktower/9b5f67c20f6c04e65ed88f2e594d43c1

Change the GPIO pin definitions in the script https://gist.github.com/savetheclocktower/9b5f67c20f6c04e65ed88f2e594d43c1#file-monitor-volume-L33-L38

Also change all references to the "PCM" device to "HDMI". https://gist.github.com/savetheclocktower/9b5f67c20f6c04e65ed88f2e594d43c1#file-monitor-volume-L188-L223

I had Encoder A and Encoder B swapped so had to swap GPIO 17 and 27 to get the volume to go up when turned clockwise.

Friday, December 4, 2020

ORTHOPI

Raspberry Pi 400 mechanical keyboard mod

I integrated the ORTHOPI mechanical keyboard PCB with the Raspberry Pi 400 keyboard matrix into the top half of the Raspberry Pi 400 case. The top was gutted, completely removing the old keyboard. The connection between the Raspberry Pi 400 and the keyboard is detailed here.

Works like the original. The power on/off (FN+F10), and the LEDs.

The keyboard is a grid layout. All keys on the original Pi 400 keyboard are represented. The space bar is duplicated as two 2U keys. 4U space bars are uncommon. The Return and Right Shift keys are also 2U.

I also added a rotary encoder. It is a EC12 type. EC11 should also fit.

Since there is no plate, the switches are PCB mount Gateron clears. These are light linear switches. Gateron PCB mount switches fit very snug in these PCB mount holes, other brands are much looser. The 2U PCB mount stabilizers are standard Cherry ones.

Most of the plastic from the center of the top part of the case was removed. Holes were drilled and notches ground to accommodate the switch pins on the top row and the clips on the stabilizers on the bottom row.

Heavy duty, double sided 3M VHB tape was applied to the PCB.

PCB stuck to top plastic case. I ended up removing all the remaining plastic, leaving only the edges.

Assembled. The VHB tape is very strong. It is still easy to separate the top half of the case from the bottom.

The PCB is a little smaller than the case top.


The PCB ended up very slightly crooked on the case. Removing the VHB tape is a major effort and not worth it to do over.

DSA style keycaps from a cheap ortholinear set from Amazon. It had most of the keys needed. There were only one CTRL and ALT keycaps so I used the symbol ones for the right CTRL and right ALT. Also there was only two 2U key caps, one convex (rounded) and one concave top, I used these for the space bars. The 2U Return and right Shift are from the Lepton set I bought a long time ago.

The switches/keycaps double the height of the Pi 400.

You can see the PCB is stuck to the case slightly crooked.

I removed the status LEDs and soldered 30awg wires to the pads. Cathode on the left, anode to the right.

The Capslock, Numlock and Esc key switches have pads for LEDs. I soldered the 30awg wires directly to the LED pins.

The PCB footprint for those LED switches is very slightly off center from the rest of the switches. It does not make a difference with PCB mount switches, but a plate might have slight alignment problems.

Routing the wires is the most tedious part. There is quite a lot of space between the heatsink and PCB, but there are some pinch points that you want to avoid.

LEDs functioning. The Power LED is much brighter than the Capslock and Numlock. It may just be the cheap 3mm LEDs I am using.

The only thing left to do is to connect the rotary encoder to the GPIO pins. These will have to be manually wired like the LEDs.

The PCB should also be grounded like the original one was (conductive foam pad near Ethernet port). The two mounting lugs on the rotary encoder are connected to the ground plane on the PCB. A drain wire from there to a suitable ground point should work.

Gerber on git.

Wednesday, December 2, 2020

Raspberry Pi 400 matrix verified

Tested with prototype PCB

Made a simple PCB layout with all of the same key positions as the original Pi 400 keyboard. The matrix keymap is correct.

As long as you use the available keys in the matrix you can make a replacement keyboard connected to the Holtek controller.

Connections to the Pi 400 PCB were made with 30awg wires. I got these on Amazon, it is a roll of 8 different colors bundled together.

The keyboard end with labeled pads.

The Pi 400 matrix pads. I labeled the pads on some masking tape.

The 8 different wire colors in 3 sets, total of 24 connections.

The completed ORTHOPI is here.


Monday, November 30, 2020

PCB copper lead test

Lead test of exposed PCB copper layer

I have several of the 3M Lead Check tests and used one on the exposed copper layer of a PCB. 

As expected there was no reaction. Which is good since I've been carrying this Feegle XS around with me for a while now.

A patina has formed on the copper surface. I replaced the steel screws with some brass ones, the outline of the old screws is still visible.

Thursday, November 12, 2020

Raspberry Pi 400 keyboard matrix keymap

The diodeless matrix

Like most rubber dome keyboards, there are no anti-ghosting diodes. Instead, the matrix is arranged in a way that it is unlikely to be able to press any combination of keys that would cause ghosting, or blocking.

The matrix on the Raspberry Pi 400 keyboard is 8x16. 24 total io pins used. The connector is 26 wide, 2 are not used (H and J in my numbering).

This is for the ANSI layout keyboard. Someone with the ISO version will need to compare.

The order of the pins on the bottom of the PCB are not in the same order as the ribbon connector.

My original labeling using A through Z on the ribbon connector.

This matrix/keymapping has not yet been verified. I have tested the matrix here.

ORTHOPI PCB that uses this matrix here.

Tuesday, November 10, 2020

Raspberry Pi 400 keyboard controller

HOLTEK HT45R0072

The keyboard of the Raspberry Pi 400 is connected to a dedicated MCU that uses one of the 4 ports of the built in USB hub.

D+ and D- USB data lines are circled. They go through the vias to the other side of the board and run across to the VLI USB chip. The large test pad is VBUS.

On the other side of the board the D+ and D- lines connect to the VLI chip.

On the bottom of the PCB under keyboard ribbon connector the matrix pins are broken out. If you could reprogram the Holtek controller you could connect a custom keyboard matrix. Unfortunately this is a OTP (one time programmable) device, so unless you can work with the existing matrix the Holtek is not very useful.

The easiest way to replace the keyboard would be to cut the traces between the USB hub and the Holtek chip. Then connect the D+ and D- to a separate controller.

The keyboard has a power key (Fn+F10). This functions similarly to the modification I did on the Flirc case. A custom replacement keyboard could use an io pin to trigger the power on/off the same way.

ORTHOPI PCB that connects to the Holtek controller here.