Wednesday, September 23, 2020

nobbs

16 rotary encoders on a Teensy LC

Using the Arduino CommonBusEncoders library it is possible to connect multiple encoders in a keyboard like matrix.

There is a single common data pin for the Encoder A and Encoder B signals. If there is a switch built in then one pin of the switch is also connect to a single bus data pin. The ground pin of each encoder is connected to it's own data pin. The tutorial PDF explains the topology.

16 encoders and 10 APA106 LEDs connected to a Teensy LC. 

There is a second pin 17 on the Teensy LC that has a level converter for the 5v output that the APA106 requires. The rest of the pins run at 3.3v logic. I have a tiny solder bridge jumper that connects either the regular 3.3v pin 17 or the level converted pin 17 to the APA106. When connected to the 3.3v output pin the LEDs flickered randomly. On the Seeeduino Xiao the 3.3v output works fine driving the APA106 without level conversion.

16 encoders with 3 diodes each to prevent ghosting.

I made a simple plate to hold everything in place. Much sturdier than without.

The encoders are spaced the same as MX switches. Small tapered knobs work best.

Side view. M2 spacers and screws holding a second PCB as the base.

A second built with different encoders. These have the split spline shaft instead of the D shaped shaft. The purple Teensy LC is from OSH Park.


Monday, September 21, 2020

Gherkin Express 2 with blue LEDs

Swapped the zener diodes for blue LEDs

0805 LEDs fit the SOD123 footprint. Installed blue LEDs in reverse polarity and it works.

D+ is always on, D- only when there is data being transmitted.

The 4 Gherkin Express 2 that have been completed so far. I have one PCB left.

Friday, September 18, 2020

108 key

Second SMT order from JLCPCB

$8 discount on 100mm x 100mm PCB assembly. This time with 110 4.5mm tactile switches. The only parts not assembled by JLCPCB were the Mini USB connector, ICSP header, PTC fuse and the socket for the ATmega32a.

I ordered 5 PCB's and had 2 assembled. I received the 3 unassembled boards with the 2 completed ones. I used the blank PCB as the bottom.

I used blue LEDs for the V-USB voltage regulator. These were basic items so did not have a setup fee. There is only one extended part, the tactile switches. $3 total additional setup fee. I also placed a footprint for standard zener diode in case the blue LEDs did not work.

The switches are rotated 15 degrees and overlapped to position them as close as possible and still have a square grid. On this particular board they had to manually solder the bottom right switch. I could tell because of the flux residue and there is much more solder on those joints than any of the others. The second board I received was perfect.

Every data pin on the ATmega32a is in use. 12 columns and 9 rows. 5 status LEDs. The USBASP switch on PD7 and the ICSP pins on the header. PD2 and PD4 for the V-USB connection. Same as I use on the ATmega328 on the Aardvark.

TMK supports the ATmega32 with this fork https://github.com/nuess0r/tmk_keyboard


Thursday, September 17, 2020

Gherkin Express TH

Credit Card sized through hole component Gherkin

This shares the same V-USB parts and configuration as the Aardvark and the same matrix and firmware as the Gherkin Express 2.

The main PCB is the standard 1.6mm thickness. The top and bottom plates are 0.8mm thick. JLCPCB will do 0.8mm in other colors for cheap, 0.6mm is only cheap in green soldermask.

The ICSP header is the tallest part. I built one with it to test, but have omitted it from the others so I could fit the top.

The holes in the top are 4mm for the switches and 3mm for the LEDs. The RESET and USBASP switches are shorter than the others.

With a full size socket and the 6.5mm tall resonator 8mm spacers were needed to fit the top piece. 9.5mm tall switches were used.

The lowest profile possible with 4mm spacers. 7mm tall switches are used. No socket for the ATmega328 and the resonator and power capacitor are replaced with the SMT parts from the Gherkin Express.

I use a 1.6mm thick brass nut as a spacer for the bottom piece. The bottom of the switch pins were trimmed. On the full height it has two 1mm thick nylon washers.

I will try replacing the resonator with a miniature through hole crystal and a smaller power capacitor.

Same outer dimensions as the Gherkin Express and Gherkin Express 2.


Wednesday, September 16, 2020

Shine of the Rainbow

Volume Control

I made a rotary encoder with 12 RGB LEDs. I programmed it as a volume control. Pressing down on the knob toggles mute.

The LEDs are the same APA106 5mm WS2812B compatible LEDs I used in the Aardvark. The controller is the Seeedstudio Xiao.

The top plate has 5mm holes in the exact position of the LEDs on the main PCB. When soldering the LEDs I used the top plate to keep the LEDs positioned so they line up perfectly.

The top plate is held in place by the rotary encoder's screw on nut. The bottom is another PCB held on with M2 spacers and screws.

The bottom of the PCB has the same silkscreen pattern as the top.

The board is running an Arduino Sketch. It uses the Adafruit Neopixel library to control the LEDs. The HID Project library for sending keyboard commands to the host computer. The CommonBusEncoders library is used to talk to the encoder.

Friday, September 11, 2020

SMT assembly

Gherkin Express2 with SMT assembly at JLCPCB

I wanted to try out the SMT assembly service at JLCPCB. They were having a special with a $8 discount coupon.

The first thing to realize with this service is that there are a lot of restrictions:

  • Green solder mask only
  • 1mm, 1.2mm, 1.6mm thick PCB only
  • Assemble one side only. You choose top side or bottom when ordering. Put all your SMT parts on one side if possible.
  • 1oz copper (the usual)
  • 100x100mm max size for the promotional discount, otherwise 480x320mm max size.
  • You need tooling holes added to your PCB. You can add them yourself or let them do it.
  • 2, 5 or 10 pieces assembled, no other options. You either get 2 assembled or all 5, or 10 of your PCB order. If you only get 2 assembled the remainder of the blank PCBs are returned with your order 
  • You do not get the solder stencil with your order
  • Only parts in stock in the JLCPCB inventory are available for assembly. Any other parts even if LCSC has them will be skipped.
  • Extended non-BASIC parts have a $3 setup fee.

Since I could not do a 0.6mm thick PCB like the Gherkin Express I redesigned it to have a regular micro USB connector. JLCPCB does not have any USB connectors in inventory so this is an item that will have to be soldered on manually.

The 5.1mm tactile switches were in their inventory but as an Extended item, so there is a one time $3 charge to use them.

They were also out of stock on the ATmega32U2, but they do have the ATmega328p and it is a BASIC part, so no setup fee. I redesign the Gherkin Express 2 as a V-USB board.

The rest of the items needed I found the BASIC equivalent to save on setup fees. The only items I could not find a BASIC part for were the fuse and the 3.6v zener. I have zener diodes so I left those out but included the Extended fuse part.

$6 total for setup of the tactile switches and the fuse Extended parts.

Designing the PCB using EasyEDA and selecting all the parts through their library makes it easy to export the BOM and pick-and-place file that JLCPCB needs for assembly. It is also in the format they accept so no editing is needed. Just export from the fabrication menu in EasyEDA, save to a file and import to JLCPCB.

There is a demo on JLCPCB that goes through the ordering process.

The preview in JLCPCB shows the placement and orientation of all the parts. The USB connector and the 2 zener diodes are not populated and will not be assembled.You can see the 3 tooling holes in the corners.

This is what was received. Everything as expected. Only the USB connector and zener diodes to be added.

Remaining parts soldered on.

I tried 3 different USB connectors. The one on the left is the incorrect part for this footprint. It does line up enough to work. The middle one is the correct part, it has reinforcing flanges on the front of the connector. The one on the right is the version of the connector without flanges, makes it a little lower profile.

Edge view of the 3 different connectors. Also 2 of the original Gherkin Express above. The highest part of the board are the switches.

5 keyboards in an Altoids tin.

A few more could fit.

Since these have an ATmega328p there is no bootloader. I made a pogo pin jig to connect to the ISP pads. Once flashed with the USBasploader it can be flashed via USB as a USBasp device. The reset and usbasp switches work the same as on the aardvark. It uses the same bootloader as the aardvark.

 

The total cost for 5 assembled boards with all the parts included was $32.32, this is with the $8 coupon applied. Add to that the cost of the PCB $5 and shipping. If you order other PCBs at the same time they will wait the 1-2 days for SMT assembly and all ship together.

Thursday, September 10, 2020

Blue LEDs instead of zener diodes in V-USB

Tested some blue LEDs in the aardvark

For low speed USB the data lines use 3.3 volt logic levels. 0-0.3v is a logic low and 2.8-3.6v is a logic high.

3.6v zener diodes are commonly used in V-USB hardware to clip the 5v output to ~3.3v. Blue LEDs can also have a similar effect.

I got this idea from the Sparkfun AVR Stick. I previously used it in my phantom keystroker.

The blue LEDs are installed in opposite polarity to how the zener diode would have been. I chose the lowest brightness (MCD), diffused LED I could find on Digikey. These are 3mm "ice cube" square LEDs. Not a common size. They are still quite bright.

This may not work with any random blue LEDs. They are being used in a way not intended.

Since the USB signal is differential D+ is high when idle and D- is low. So most of the time the LED on D+ will be lit and D- will be off. When data is being transmitted D+ will flicker low and D- will flicker on.

zener diodes

I hooked D+ and D- to a scope and the voltage levels are within USB spec. This graph is V-USB with 3.6 zener diodes. Green is D+ and Blue is D-. The minor graduations in the graph are 0.2v.

blue LEDs

This graph is the blue LEDs. Voltage are lower than with the zener diodes, but still within range.

Teensy 3.2

For comparison this is a Teensy 3.2 which has a hardware USB transceiver. The Teensy also transmits at a much higher rate than the slow software driven V-USB.

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.