Differences between revisions 86 and 87
Revision 86 as of 2012-06-15 19:58:08
Size: 21739
Editor: fungi
Comment:
Revision 87 as of 2012-06-15 20:07:50
Size: 2083
Editor: fungi
Comment:
Deletions are marked like this. Additions are marked like this.
Line 11: Line 11:
== Breadboard ==

[[attachment:SpiffChorderBreadboard.jpg|{{attachment:SpiffChorderBreadboardThumb.jpg|SpiffChorder breadboard}}]]

I started on a solderless breadboard, shown above, but those really aren't suited for higher-frequency prototyping and so I was getting stray USB device resets at random (particularly if I inadvertently brushed the ground line while not grounding myself first). I used the components in Greg Priest-Dorman's Digikey bill of materials, including the suggested 9x pull-up resistor SIP array (even though I was only testing with 7 keys). I also chose poorly on a preformed bank of 3 yellow LEDs which were somewhat larger than I expected; their rather rigid leads weren't quite a multiple of 0.1" standard breadboard pitch, causing them to crack superficially upon insertion. I used the excellent [[http://www.adafruit.com/products/601|AVR ATmegaXX8 Pinout Stickers]] from [[http://www.adafruit.com/|Adafruit Industries]] to more easily keep track of what I was connecting.

== Programming ==

I picked up a [[http://www.adafruit.com/products/46|USBtinyISP AVR Programmer Kit]], [[http://www.adafruit.com/products/174|Barebones AVR dev. board]] and [[http://www.adafruit.com/products/382|28-pin ZIF socket]] from Adafruit on the theory that it would be easier to preprogram the Atmega168 on a dedicated target board. Unfortunately, I followed the !SpiffChorder instructions slightly out of order and burned the external clocking fuse before writing the firmware, thus rendering the unclocked devboard useless... so instead I programmed the microcontroller in-circuit later once the 12MHz crystal and associated components were in place to clock it correctly. I used a machine running [[http://www.debian.org/|Debian GNU/Linux]] and installed their packages for [[http://packages.debian.org/avrdude|avrdude]] and [[http://packages.debian.org/avr-libc|avr-libc]]. You can test the rig after connecting the 6-pin USBtiny cable to ''CON1'' with it set to provide power (and make sure nothing is connected on ''CON2'').

{{{
$ sudo avrdude -c usbtiny -p atmega168

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9406

avrdude: safemode: Fuses OK

avrdude done. Thank you.
}}}

Assuming it's all working, unpack the latest !SpiffChorder sources (I used 0.99) modify the ''USBaspLoader'' firmware Makefile, program the IC and set its fuses.

{{{
$ unzip -q SpiffChorder-0.99.zip
$ cd SpiffChorder/USBaspLoader.2008-02-05/firmware
$ sed -i 's/^\(PROGRAMMER = -c\) .*/\1 usbtiny/' Makefile
$ make
avr-gcc -Wall -Os -I. -mmcu=atmega168 -DF_CPU=12000000 -x assembler-with-cpp -c usbdrv/usbdrvasm.S -o usbdrv/usbdrvasm.o
avr-gcc -Wall -Os -I. -mmcu=atmega168 -DF_CPU=12000000 -c usbdrv/oddebug.c -o usbdrv/oddebug.o
avr-gcc -Wall -Os -I. -mmcu=atmega168 -DF_CPU=12000000 -c main.c -o main.o
usbdrv/usbdrv.h:198: warning: ‘usbFunctionDescriptor’ used but never defined
avr-gcc -Wall -Os -I. -mmcu=atmega168 -DF_CPU=12000000 -o main.bin usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o -Wl,--section-start=.text=3800
rm -f main.hex main.eep.hex
avr-objcopy -j .text -j .data -O ihex main.bin main.hex
avr-size main.hex
   text data bss dec hex filename
      0 2134 0 2134 856 main.hex
$ cp hexfiles/mega168_12mhz.hex main.hex
$ sudo make flash
avrdude -c usbtiny -p atmega168 -U flash:w:main.hex:i

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9406
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "main.hex"
avrdude: writing flash (16342 bytes):

Writing | ################################################## | 100% 9.58s



avrdude: 16342 bytes of flash written
avrdude: verifying flash memory against main.hex:
avrdude: load data flash data from input file main.hex:
avrdude: input file main.hex contains 16342 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 8.56s



avrdude: verifying ...
avrdude: 16342 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done. Thank you.

$ sudo make fuse
avrdude -c usbtiny -p atmega168 -U hfuse:w:0xd5:m -U lfuse:w:0xff:m -U efuse:w:0x00:m
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9406
avrdude: reading input file "0xd5"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xd5:avrdude: load data hfuse data from input file 0xd5:
avrdude: input file 0xd5 contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xff"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.00s
avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xff:
avrdude: load data lfuse data from input file 0xff:
avrdude: input file 0xff contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude: reading input file "0x00"
avrdude: writing efuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0x00:
avrdude: load data efuse data from input file 0x00:
avrdude: input file 0x00 contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.00s
avrdude: verifying ...
avrdude: 1 bytes of efuse verified

avrdude: safemode: Fuses OK

avrdude done. Thank you.

$ sudo make lock
avrdude -c usbtiny -p atmega168 -U lock:w:0x2f:m

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9406
avrdude: reading input file "0x2f"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x2f:
avrdude: load data lock data from input file 0x2f:
avrdude: input file 0x2f contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of lock verified

avrdude: safemode: Fuses OK

avrdude done. Thank you.
}}}

Now '''disconnect''' the programmer and '''then''' hold down all three thumb buttons (or short ''N'', ''C'' and ''F'' to ''GND'') while connecting the circuit via USB. If you have the LEDs wired, you should see ''LN'' and ''LF'' light up, indicating it's ready for programming through the virtual USBasp programmer.

{{{
$ sudo avrdude -c usbasp -p atmega168

avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9406

avrdude: safemode: Fuses OK

avrdude done. Thank you.

$ cd ../..
$ sudo make program

Compiling: main.c
avr-gcc -c -mmcu=atmega168 -I. -gdwarf-2 -DF_CPU=12000000UL -Iusbdrv -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=main.lst -std=gnu99 -MD -MP -MF .dep/main.o.d main.c -o main.o -Ikeymaps/ -include nasa_us.h

Compiling: usbdrv/usbdrv.c
avr-gcc -c -mmcu=atmega168 -I. -gdwarf-2 -DF_CPU=12000000UL -Iusbdrv -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=usbdrv/usbdrv.lst -std=gnu99 -MD -MP -MF .dep/usbdrv.o.d usbdrv/usbdrv.c -o usbdrv/usbdrv.o

Compiling: usbdrv/oddebug.c
avr-gcc -c -mmcu=atmega168 -I. -gdwarf-2 -DF_CPU=12000000UL -Iusbdrv -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=usbdrv/oddebug.lst -std=gnu99 -MD -MP -MF .dep/oddebug.o.d usbdrv/oddebug.c -o usbdrv/oddebug.o

Assembling: usbdrv/usbdrvasm.S
avr-gcc -c -mmcu=atmega168 -I. -x assembler-with-cpp -Wa,-adhlns=usbdrv/usbdrvasm.lst,-gstabs -DF_CPU=12000000UL usbdrv/usbdrvasm.S -o usbdrv/usbdrvasm.o

Linking: spiffchorder.elf
avr-gcc -mmcu=atmega168 -I. -gdwarf-2 -DF_CPU=12000000UL -Iusbdrv -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=usbdrv/usbdrv.o -std=gnu99 -MD -MP -MF .dep/spiffchorder.elf.d usbdrv/usbdrv.o usbdrv/oddebug.o main.o usbdrv/usbdrvasm.o --output spiffchorder.elf -Wl,-Map=spiffchorder.map,--cref -Wl,-u,vfprintf -lprintf_min -Wl,-u,vfscanf -lscanf_min

Creating load file for Flash: spiffchorder.hex
avr-objcopy -O ihex -R .eeprom spiffchorder.elf spiffchorder.hex

Creating load file for EEPROM: spiffchorder.eep
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" \
        --change-section-lma .eeprom=0 -O ihex spiffchorder.elf spiffchorder.eep
avr-objcopy: --change-section-lma .eeprom=0x00000000 never used
avrdude -p atmega168 -c usbasp -U flash:w:spiffchorder.hex

avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9406
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: reading input file "spiffchorder.hex"
avrdude: input file spiffchorder.hex auto detected as Intel Hex
avrdude: writing flash (5922 bytes):

Writing | ################################################## | 100% 1.33s



avrdude: 5922 bytes of flash written
avrdude: verifying flash memory against spiffchorder.hex:
avrdude: load data flash data from input file spiffchorder.hex:
avrdude: input file spiffchorder.hex auto detected as Intel Hex
avrdude: input file spiffchorder.hex contains 5922 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.95s



avrdude: verifying ...
avrdude: 5922 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done. Thank you.
}}}

== Chords ==

Since I spend most of my time in a text terminal, I put together a chord chart which fits safely into a standard 80x24 character screen (I made it 78x22). I also left four empty entries to accommodate custom macros.

{{{
 +----------+---F-N-CN+ +----------+---F-N-CN+ +----------+------F>CF----+
 | -RMI -C- | a A + | | PR-- --- | u U "" | | P--- --F | ret kp ret |
 | P--I --- | b B \ | | | PR-- -C- | v V ] } | | ---- --F | lshf kp + |
 | --M- -C- | c C 7 & | | P--- --- | w W 5 % | | PRMI --F | caps kp ins |
 | --MI --- | d D / ? | | P--I -C- | x X & | | -R-I --F | tab kp - |
 | -RMI --- | e E = + | | -R-- --- | y Y 4 $ | | --M- --F | bksp kp beg |
 | P--- -C- | f F 9 ( | | PR-I --- | z Z ` ~ | | -RM- --F | del kp del |
 | -R-- -C- | g G 8 * | | ---- -C- | spc 1 ! | | P-MI --F | sclk kp / |
 | -RM- --- | h H 00 | | PR-- N-- | ; : | | P-M- --F | ptsc kp * |
 | ---I --- | i I 2 @ | | --M- N-- | , < | | -R-- --F | rght kp rght |
 | -R-I -C- | j J () | | -RM- N-- | . > | | PR-- --F | down kp down |
 | -R-I --- | k K $ | | -RMI N-- | ' " | | PRM- --F | pgdn kp pgdn |
 | ---I -C- | l L 6 ^ | | P--- N-- | fnc | | ---I --F | left kp left |
 | --MI -C- | m M * | | -R-- N-- | esc | | --MI --F | up kp up |
 | PRM- -C- | n N [ { | | PRM- N-- | lal ral | | -RMI --F | pgup kp pgup |
 | PRMI -C- | o O 0 ) | | P--I N-- | ins | | PR-I --F | home kp home |
 | -RM- -C- | p P % | | PR-I N-- | lct rct | | P--I --F | end kp end |
 | PR-I -C- | q Q ? | | PRMI N-- | nml | | | |
 | --M- --- | r R 3 # | | PRMI NC- | num | | | |
 | PRM- --- | s S - _ | | ---- N-F | brk | | | |
 | PRMI --- | t T 000 | | ---- NCF | rst | | | |
 +----------+---------+ +----------+---------+ +----------+--------------+
}}}

== Perfboard ==

In an effort not to limit my capabilities with the keyer's software, I wanted to make sure whatever prototype I eventually built could double as a development board. To that end, I implemented all optional components of the !SpiffChorder circuit (programming header, LEDs, pull-up resistors and screw terminals for all 8 chord keys and 3 modifier keys). I tried to keep the layout as compact as possible while still working on single-sided pad-per-hole perfboard, using entirely right-angle traces so as not to make stray contact with corners of square pads. It fits in a 17x21-hole grid including a ground bus all the way around the perimeter. Here's a top-down view showing the logical supply, ground and signal paths colored for easy identification, the front showing just silkscreen markings and jumpers, and one with the traces on the back (mirrored for easier visual reference).

[[attachment:SpiffChorderPerfboardCircuit.png|{{attachment:SpiffChorderPerfboardCircuitThumb.png|SpiffChorder perfboard circuit}}]]
[[attachment:SpiffChorderPerfboardLayoutFront.png|{{attachment:SpiffChorderPerfboardLayoutFrontThumb.png|SpiffChorder perfboard front}}]]
[[attachment:SpiffChorderPerfboardLayoutBack.png|{{attachment:SpiffChorderPerfboardLayoutBackThumb.png|SpiffChorder perfboard back}}]]

A revised Digikey bill of materials including all the parts I used:

||<style="background-color: green;">'''index'''||<style="background-color: green;">'''quantity'''||<style="background-color: green;">'''part number'''||<style="background-color: green;">'''description'''||<style="background-color: green;">'''customer reference'''||
||1||2||490-3709-ND||CAP CER 22PF 50V 5% RADIAL||C1-2||
||2||2||399-4328-ND||CAP CER 0.1UF 100V 10% RADIAL||C3,5||
||3||1||493-1767-ND||CAP ALUM 10UF 16V 20% RADIAL||C4||
||4||1||609-2846-ND||CONN HEADER 6POS DUAL R/A PCB||CON1||
||5||5||A98335-ND||TERM BLOCK 4POS SIDE ENT 2.54MM||CON2-4||
||6||1||96018-ND||TOOL SCREWDRIVER SLOTTED 1.8MM||screwdriver for CON2-4||
||7||2||1N5227BDICT-ND||DIODE ZENER 3.6V 500MW DO-35||D1-2||
||8||1||ATMEGA168-20PU-ND||IC AVR MCU 16K 20MHZ 28DIP||IC1||
||9||1||ED90054-ND||IC SOCKET 28PIN MS TIN/TIN .300||socket for IC1||
||10||1||OD222JE-ND||RESISTOR 2.2K OHM .25W CARB COMP||R1||
||11||1||OD472JE-ND||RESISTOR 4.7K OHM .25W CARB COMP||R2||
||12||2||OD820JE-ND||RESISTOR 82 OHM .25W CARB COMP||R3-4||
||13||3||OD102JE-ND||RESISTOR 1.0K OHM .25W CARB COMP||R5-7||
||14||1||CSC10KW-ND||RES ARRAY 10K OHM 8 RES 9-SIP||R8-15||
||15||3||OD103JE-ND||RESISTOR 10K OHM .25W CARB COMP||R16-18||
||16||1||XC1380-ND||CRYSTAL 12.000 MHZ 18PF CYL||X1||
||17||7||CH196-ND||SWITCH PUSH SPST-NO 0.01A 12V||key switches||
||18||1||67-1062-ND||LED 3MM 5V SHORT LENS GREEN DIFF||near thumb lamp||
||19||1||67-1080-ND||LED 3MM 5V SHORT LENS YEL DIFF||center thumb lamp||
||20||1||67-1068-ND||LED 3MM 5V SHORT LENS RED DIFF||far thumb lamp||
||21||1||V2025-ND||BOARD 2-SIDE PPH 2.0X3.0||project board||

I initially sketched the layout on graph paper and transferred it into [[https://live.gnome.org/Dia|Dia]] by hand. [[attachment:spiffchorder.dia|Here's the multi-layer original from which the above graphics were exported.]] Installing all those tiny traces without accidentally shorting any together was painfully time-consuming. This is designed assuming a keyed through-hole 2x3 right-angle shrouded header of the correct size for the USBtinyISP AVR Programmer (CON1), and 5x 0.1" pitch through-hole 4-line right-angle screw terminals (these take a 1.8mm jeweler's screwdriver) to connect leads for all the switches, LEDs and USB (CON2-4).

{{attachment:RightAngleShroudedHeader.jpg|right-angle shrouded header}}
{{attachment:RightAngleScrewTerminals.jpg|right-angle screw terminals}}
[[attachment:SpiffChorderPerfboardFront.jpg|{{attachment:SpiffChorderPerfboardFrontThumb.jpg|SpiffChorder perfboard front}}]]
[[attachment:SpiffChorderPerfboardBack.jpg|{{attachment:SpiffChorderPerfboardBackThumb.jpg|SpiffChorder perfboard back}}]]

You'll notice this layout uses an 8-resistor array instead of Greg Priest-Dorman's 9x (to save on space). I also show couple of 3-resistor arrays (R5-7, R16-18)... Digikey has no such beast, but I bussed individual resistors mounted vertically by soldering the common leads together above the board (only passing one of the three through the board).

== PCB ==

The printed circuit version is in progress using [[http://fritzing.org/|Fritzing]], and an order has been placed to [[http://fab.fritzing.org/|Fritzing Fab]] for a prototype to QA. I'll post pictures once it arrives in a couple weeks, but here are some tidbits to tantalize:
 * [[attachment:SpiffChorder.fzz|Fritzing file]]
 * [[attachment:SpiffChorderEtchable.pdf|combined etchable PDF]]
 * [[attachment:SpiffChorderGerber.zip|compressed ZIP archive of Gerber files]]

== Handset ==

I hacked up an old telephone handset from my junk pile so I could have something vaguely ergonomic into which to mount the keys. Once I'd separated the front and back of the handset, I opened up tracks for the keys using a small cutting wheel on a Dremmel and also used it to drill a couple holes for a hand strap, then added epoxy in a few places to get the tolerances just right. I sanded the pieces and sprayed them black with a few clear layers of top coat. I ordered 7x [[http://www.wasdkeyboards.com/index.php/row-2-size-1x1-cherry-mx-keycap.html|Row 2, Size 1x1 Cherry MX Keycaps]] from [[http://www.wasdkeyboards.com/|WASD Keyboards]] and popped them onto the stems. I drilled holes near the tops of the three thumb keycaps lining up with the LEDs, and filled each with a dab of clear epoxy. A decorative ribbon was added for the hand strap, and a small block of foam was inserted on top of the circuit board to keep it in place.

[[attachment:SpiffChorderHousingPieces.jpg|{{attachment:SpiffChorderHousingPiecesThumb.jpg|SpiffChorder housing, pieces}}]]
[[attachment:SpiffChorderHousingInside.jpg|{{attachment:SpiffChorderHousingInsideThumb.jpg|SpiffChorder housing, inside}}]]
[[attachment:SpiffChorderHousingAssembledSide.jpg|{{attachment:SpiffChorderHousingAssembledSideThumb.jpg|SpiffChorder housing, assembled, side}}]]
[[attachment:SpiffChorderHousingAssembledUnderside.jpg|{{attachment:SpiffChorderHousingAssembledUndersideThumb.jpg|SpiffChorder housing, assembled, underside}}]]
[[attachment:SpiffChorderHousingAssembledTop.jpg|{{attachment:SpiffChorderHousingAssembledTopThumb.jpg|SpiffChorder housing, assembled, top}}]]
[[attachment:SpiffChorderHousingAssembledStrap.jpg|{{attachment:SpiffChorderHousingAssembledStrapThumb.jpg|SpiffChorder housing, assembled, strap}}]]
 * [[/KeyerBreadboard|Breadboard]]
 * [[/KeyerProgramming|Programming]]
 * [[/KeyerChords|Chords]]
 * [[/KeyerPerfboard|Perfboard]]
 * [[/KeyerPCB|PCB]]
 * [[KeyerHandset|Handset]]
  • Man Machine, pseudo human being; Man Machine, super human being.

Kraftwerk, The Man-Machine (1978)


Chronicling fungi's steady descent into cyberpsychosis....

Septambic Chording Keyer

Inspired by Greg Priest-Dorman's Chorder wiki, I'm building a handheld chorded keyboard based on Spaceman Spiff's Chording Keyboard Experiment (SpiffChorder) with some earlier influence from Steve Mann's septambic keyer. Photos and designs published in this section are licensed under the terms of the GPL (3.0), same as the SpiffChorder project itself (since they could be considered derivative works).

Monocular Headmount Display

As I begin work on a wearable display, I'll flesh out this section. Here are some interesting links for components I'm considering:

Single-Board Wearable Computer

Right now I just go everywhere with an Asus Eee PC netbook running Debian GNU/Linux, but intend to transition soon to a low-power single-board computer. Some links for reference:

Portable Power Supply and Charger

Portable power will also be critical:

CCL: ManMachine (last edited 2015-04-26 19:16:13 by fungi)

CC0 To the extent possible under law, the creator of this work has waived all copyright and related or neighboring rights to it.