Friday, August 28, 2020

The Aardvark

V-USB, ATmega328P, APA106 experiment

The aardvark is a 3x12 keyboard powered by an ATmega328P. The ATmega328P does not have a built in USB controller. Instead it uses the V-USB software USB library for AVR processors. 

V-USB

To interface the controller to a USB bus you have to adjust the data lines to communicate at 3.3v levels. There are several methods of accomplishing this listed here. Another method is to use LEDs instead of zener diodes, I used this method on the tiny USB stick I made. The SparkFun AVR stick also uses this method.

On the aardvark I used the 3.6v zener diode method. I also use the same data pin selection as the Metaboard, since I have one and can use it for testing. D+ is connected to PD2 and D- is connected to PD4. The switch to boot into USBASP is connected to PD7. The parts needed are the same as on the Metaboard. The only omission is the 1Mohm resistor, it works fine without that. 

The Metaboard next to another V-USB project I made several years ago.

The V-USB circuit requires:

1    1.5Kohm resistor
2    3.6v 500mw zener diodes
2    68ohm resistors

The PCB has markings with values for each part.

 
The rest of the board: 

1    500mA or less polyfuse
1    LED for power indication
1    1.5Kohm resistor for LED
1    10Kohm resistor for RESET pullup
2    6mm tactile switches for RESET and USBASP
1    ATmega328P
1    16MHz 3 pin ceramic resonator
1    28pin socket for ATmega328P
36   1n4148 diodes
1    Full size USB or Mini USB socket
1    47mF capacitor
2    100nF bypass capacitors
1    2x3 header for ICSP
3    APA106 5mm RGB LEDs

Full size USB connector. I have lots of these left over from old projects.


Mini USB connector sits inside the footprint the the full size USB connector. That blue thing next to the ATmega328P is the 16MHz ceramic resonator. It has built in capacitors. Ceramic resonators are not as accurate as crystals but are fine for most uses that don't demand extreme precision.

Bootloader

For the bootloader I used the USBaspLoader, same as the Metaboard. This allows flashing firmware while connected through USB. I used the fork available on github

Only two changes need to be made to bootloadercfg.h. Change D- to 4, and jumper to 7.

In the Makefile.inc change the DEVICE to atmega328p.

You will need to update the FUSE bits, working settings can be found in the Makefile.inc. If you use those settings avrdude will probably complain that it is missing bits, that is fine since one of the registers ignores some bits and different programs deal with the missing bits in different ways.

Using a USBTINY programmer the avrdude command to flash the bootloader and set the FUSEs at the same time is:

avrdude -p m328p -c usbtiny -U lfuse:w:0xD7:m -U hfuse:w:0xD0:m -U efuse:w:0xFC:m -U flash:w:bootloader.hex

This firmware will also run on the older ATmega328 (no P). Just remove the 'p'. I have several of these from old Arduino projects. They function identically to 328P but consume more power having been built using a larger die process. They do have a different chip ID so have to be specified when flashing. Otherwise they run code identically.

avrdude -p m328 -c usbtiny -U lfuse:w:0xD7:m -U hfuse:w:0xD0:m -U efuse:w:0xFC:m -U flash:w:bootloader.hex 

With the bootloader installed, if you hold PD7 to ground while you RESET the ATmega328P it will go into USBasp mode for flashing. When PD7 is not held to ground during a RESET it will run the normal firmware instead.

You may need to install a driver for USBasp to be detected. More information can be found on the USBasp site

When in bootloader mode you can flash the keyboard firmware with:

avrdude -p atmega328p -c usbasp -U flash:w:firmware.hex

APA106

I used the same ring diode arrangement as on the Germanium. Instead of using the square WS2812B surface mount RGB LEDs, I used 5mm through hole APA106 LEDs. There are several types of these through hole WS2812B compatible LEDs. 5mm, 8mm, with different pinouts.

The APA106 LEDs I use have the pinout shown above.

The LEDs have thick notches on the leads. These get stuck in the tiny holes in the PCB.

I installed a set with the notches. With the donut hole in the diode top it works fine, but looks odd sticking out so high.

I used Peel-A-Way sockets for the diodes. The diodes are soldered with all the cathodes connected to the top donut PCB. The anodes connect to the board. Sockets are optional.

A second PCB is used as the bottom. There are holes for M2 spacers and screws.

If you trim the leads off just above the notches the LEDs will fit flush against the PCB.

Firmware

TMK supports the ATmega328P via V-USB. It only requires editing the usbconfig.h to set the correct pins and making some changes to the Makefile to define the MCU type and the bootloader size.

You may also need to disable the serial port if it enabled by default.

I also had to modify rgblight.c to use timer 1 instead of timer 3 (the ATmega328P does not have a timer 3). The timer is used to drive the RGB animations.

Plates

I made some 3x4 plates for plate mount switches.

Gerber files on git.

Get PCB pricing on PCB Shopper.

Thursday, August 27, 2020

thinner gherkin express

Lower profile resonator and 4.7uF capacitor

Got new shorter parts for the Gherkin Express.

The tallest part is now the switches. The tiny 16MHz resonator fits on top the footprint for the larger one. Centered it makes good contact with the pads.

The rest of the components are the same. The resonator part is Murata CSTNE16M0VH3L000R0. The low profile 4.7uF capacitor is Samsung CL31A475KOCLNNC. The original parts are listed in the BOM.

Original parts on the left and lower profile parts on the right.

Friday, August 21, 2020

invisible backlight

Gherkin with 3mm 940nm IR LED backlight

Installed 30 IR LEDs into a regular Gherkin with MOSFET driven backlight circuit. 940nm wavelength light is not visible to the human eye.

I am running this as an IR remote control as described here. While the light is diffused and not directional, it is so bright that it works as long as there is line of sight to the TV.

I used a modified Canon Powershot camera with the IR filter removed to take this picture. These were cheap LEDs I got off eBay, and you can see they aren't very consistent in brightness.

The keycaps are translucent white DSA profile.

Regular 3mm LEDs can fit under some switches. The white bottom RGB style Gaterons with the large cut out on the bottom work. It is a tight fit, and it makes it very difficult to remove the switch as the LED is pressing against the clip mechanism. White bottom Kailh box switches without click bars also work. It is easiest to solder the LEDs with the switch holding it in place.

Wednesday, August 19, 2020

blue rubber bands

 #61 blue rubber bands on the Penny

I bought some smaller rubber bands that hold the boards together more tightly. #61 is a 2" by 1/4" band. I had previously used #64 bands which are 3.5" by 1/4".

The bands are much tighter and the board feels more solid. The blue looks better too. I am using plate mount switches with the 4x4 plates from the unquadquad.

I bought some M12 copper crush washers. 18mm outer diameter and 1.5mm thick. About the same diameter as a dime but the thickness of a penny. 17mm diameter washers may be too small to use with a plate as it might touch.


Friday, August 14, 2020

gherkin remote

Using a Gherkin as an IR remote control

The recently released IRremote 2.61 library for Arduino supports the Sparkfun Pro Micro. Only one small change needs to be made for it to work with a Gherkin.

On the original Gherkin the backlight control pin is on PB5 (Arduino pin 9). The default for the IRlibrary is to use PC6 (Arduino pin 5). After installing the library with the Arduino library manager you need to edit the IRremoteBoardDefs.h file and comment out the line for Pin 5 and uncomment the line for Pin 9

The location of this file varies. On Windows it is in \Documents\Arduino\libraries\IRremote\src\private

On the PB Gherkin there is no backlight circuit, but PB5 is unused. You can connect an LED directly to PB5 and ground (with a currently limiting resistor.) 

The same can be done on the original Gherkin if you did not install the MOSFET for backlight. If you did install the MOSFET then you can connect the IR LED to any of the 30 in switch LED pads. The MOSFET is also controlled by PB5. The Pro Micro is installed face down on the original Gherkin. The pins will be on the opposite side.

The LED is the IR LED from Adafruit. Any 940nm should work. The brighter the better. The ATmega32U4 has a max 20mA per pin output, do not exceed this when connecting directly to the data pin. Select an appropriate current limiting resistor.

If you are using the original Gherkin with the MOSFET backlight output then you can pull much higher current through one of 30 LED backlight pads, all the current flows through the MOSFET and not the data pin.

You will also need an IR sensor to record the original codes from your old remote control. You use this in conjunction with the IRrecord.ino sketch to capture the codes using another Arduino compatible board.

Much more information on the IRremote library is available in it's wiki. https://github.com/z3t0/Arduino-IRremote/wiki

I have an example Arduino sketch that will control a Visio TV. You will need the Adafruit Keypad library, which is in the Library Manager. If you have not installed the Sparkfun board definitions you will need to add that to the Arduino IDE as well. https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide/all

Thursday, August 13, 2020

wonky

One key with the Seeeduino XIAO

Tiny M0 controller with USB-C.

I made a small 1 key PCB for the new XIAO microcontroller from Seeedstudio.

The board has 4 WS2812B LEDs and an in switch LED. It uses only 3 of the pins on the XIAO. D1- switch, D2-LED, D3-WS2812B.

Despite Seeedstudio stating that the XIAO has 14 GPIO, 2 of them are only accessible from tiny pads on the bottom, and RESET isn't really usable as an IO pin, so there are really only 11 pins that are readily accessible.

I bought a 3 pack from Amazon. You can also buy them direct from Seeedstudio, but shipping from China is either slow, or very expensive. Digikey has them in stock and Mouser has them on order. $5 for a tiny microcontroller with USB-C.

I added pins to make it socketable. The XIAO comes with the common large square pin headers which I rarely use. You can see the tiny pads that connect to 2 more IO pins. I put a piece of kapton tape over the bottom to keep it from accidentally shorting on something.

I used a second PCB as the bottom. M2 spacers are screws hold the two PCBs together. A PCB mount MX compatible switch needs be used as there is no plate to hold the switch in place.

XIAO socketed and assembled. I used Peel-A-Way sockets. You can see the current limiting resistor for the LED which I installed inside the switch.

Bottom of the PCB. You can see the footprints for the WS2812B LEDs. The dot indicates pin 1 which is opposite the corner with the notch on the WS2812B.

I wrote a small Arduino script to run this. It is a slightly modified version of the Adafruit buttoncycler. You will need to install the boards definiton from Seeedstudio to add the XIAO to the Arduino IDE. Instructions are on Seeedstudios Wiki. https://wiki.seeedstudio.com/Seeeduino-XIAO/#software

The Adafruit NeoPixel library will need to be installed using the library manager. https://learn.adafruit.com/adafruit-neopixel-uberguide/arduino-library-installation

Gerber files on git

Get PCB pricing on PCB Shopper.


Wednesday, August 12, 2020

gherkin express

What's in your wallet?

A tiny credit card sized TMK powered gherkin.

The Gherkin Express is running an ATmega32U2 running at 16MHz. There are 30 5.2mm tactile switches. (31 including the reset switch). A PTC fuse to protect from power shorts and a power LED. All surface mount components are 1206 sized.

There are no diodes. Unless you have really tiny fingers you can only press 2 keys at a time, and ghosting will not be a problem. The MATRIX_HAS_GHOST flag is turned on in the firmware, which should prevent erroneous keystrokes if you do manage it.

There is a footprint for a ICSP header which I left unpopulated. Only needed if the factory USB bootloader on the ATmega32U2 gets corrupted, or maybe install a mass storage bootloader.

The 4 unused pins are brought out to little pads. (TX, RX, PD5, PD6)

There is a BOM in git. The TMK firmware is also on git.

The PCB is slightly smaller than a credit card. The PCB material is 0.6mm thick. Fully populated it is 2.6mm at it's thickest.

JLCPCB will produce a 0.6mm PCB at the same price as the common 1.6mm, but only in green solder mask. Due to lower volume, any other color comes with a setup premium. Since this is under 100mm square it cost only $5 for 10 pieces.

The back has no components. Everything is surface mounted on the front of the PCB. The circles and holes are cosmetic.

The tallest components are the 16MHz ceramic resonator and the 4.7uF capacitor. I have ordered some lower profile parts. Hopefully I can get the total thickness down to 2.1mm. (0.6mm PCB and 1.5mm tall switches.)

This is considerably thinner than the Flanck.

I am using the USB PCB connector library from https://github.com/Pinuct/Eagle_PCB_USB_connectors 

Pinuct also has USB-C connectors.

Another project using this library is the Fluff M0 project.

The 0.6mm thick PCB slides right into the micro USB connector.

This connector is not practical for heavy use. For an emergency input device it should be fine.

Get PCB pricing on PCB Shopper.