The initial aim of this project is to replace the archaic firmware in a DataHand DH200-6 keyboard with an ARM-based micro-controller and USB interface and use this as a test-platform for an integrated laser trackball using the ADNS-9800 LaserStream gaming sensor fitted closely below the finger cluster. The trackball is intended for finger control with the mouse buttons included in a special mode and mapped to the thumb-cluster keys. The proposed layout of ball and switches is reminiscent of the excellent but obsolete Logitech TrackMan Marble FX trackball which I used for 15years: Logitech TrackMan video.
Once the initial aim is fulfilled the trackball hardware and software could be fitted to the DodoHand as an alternative to the proposed TrackPoint pointing device. Details of this project may be found in the same thread: TrackHand with some discussion concerning the suitability of the 2 1/4” trackball for the DodoHand.
Here are the upgraded units with a trackball in the right-hand unit only, mouse buttons mapped to the right-hand thumb-cluster in function mode and current legends: Here is the inside of the right-hand unit showing the new micro-controller and trackball with the ADNS-9800 sensor:
The Teensy-3.1 micro-controller is used in this project. Any of the Teensy boards could be used but I wanted to play around with this latest and most powerful offering from PJRC and the price is very reasonable. The installation notes are really for my own reference but they may be useful to others. I am developing software under OpenSuSE but all these tools are available for other GNU/Linux distributions.
Open firefox and follow instructions on
- http://software.opensuse.org/package/cross-avr-gcc
- Use the 1-click install of CrossToolchain:avr
Or add the repository and use zypper
- sudo zypper addrepo http://download.opensuse.org/repositories/CrossToolchain:/avr/openSUSE_13.1/
zypper in cross-avr-gcc avr-libc cross-avr-binutils
The udev rule file gives non-root users permission to use the Teensy device. Download 49-teensy.rules
sudo cp 49-teensy.rules /etc/udev/rules.d/
Add user to uucp and dialout groups
uucp:x:14:<username>
dialout:x:16:<username>
Teensyduino is the annoying Java interface to building and loading teensy applications. This is the only method supported directly by PJRC on the Teensy-3.1. However, other people are maintaining CLI support software for the Teensy-3.1 based on the applications released by PJRC for the Teensy-2.
Install the arduino libraries and make file for Teensy-3.x
This repository started from the teensy-template repository, so you do not need this step unless you want to write code for another project.
To test simply
make
make upload
- Press the button
Download the latest CLI app for teensy-3.1
git clone
https://github.com/texane/teensy3.gitcd teensy3/src/teensy_loader_cli
make
- Install somewhere in your
PATH
eg:cp teensy_loader_cli ~/bin/linux
On OpenSuSE the USB serial device /dev/ttyACM0
is created following
Serial.begin()
and may be interrogated using screen
or just plain old
cat
:
screen /dev/ttyACM0
cat /dev/ttyACM0
Sometimes there is a problem with the connection and printing stops due to buffering. To remedy this change the tty settings:
- stty -F /dev/ttyACM0 9600 raw
This library is included: libraries/i2c_t3
I2C is used to connect the right-hand unit to the left-hand MCP23018 IO-expander.
- SCL: pin 19 with 4k7 pull-up resistor
- SDA: pin 18 with 4k7 pull-up resistor
To connect two teensys connect SCL to SCL and SDA to SDA with the pull-up resistors.
This library is included: libraries/spi4teensy3
This is included: libraries/LowPower_Teensy3
Interface to the MCP23018 IO-expander used to scan the optical switch matrix in the left-hand unit and send the data to the Teensy-3.1 micro-controller in the right-hand unit via the I2C connection. This library is an incomplete but sufficient interface to the MCP23018 chip created for this project with reference to the MP23018 datasheet.
The ADNS-9800 LaserStream Gaming Sensor is used to scan the motion ball. The Kicklighter breakout board is used
- https://www.kickstarter.com/projects/1034145369/high-speed-laser-optical-sensor
- https://www.tindie.com/products/jkicklighter/adns-9800-optical-laser-sensor/
Teensy interface for the ADNS-9800 used in this project is based on that provided by John Kicklighter and connects to the Teensy-3.1 via the SPI
with updates for the Teensy-3.1 from
and is included: libraries/TrackBall
The DataHand keyboard receiving this extreme makeover is a second-hand 1993 DH200-6 is decent condition and basically working. All the existing electronics are removed leaving just the thumb and finger switch clusters. The leds on the key map panel are also be reused.
The 8-pin IDC header on thumb-cluster has the following connections and proposed Teensy-3.1 pin allocation
Pin | Line | Switches | Connections | Teensy pin |
---|---|---|---|---|
1 | Vcc | |||
2 | XD0 (column 0) | 1 3 5 | 14 | |
3 | Row 0 | 1 2 | ->D1k->(D1)->D2k->R1->Vcc | 5 |
4 | XD1 (column 1) | 2 4 6 | 15 | |
5 | Row 1 | 3 4 | ->D3k->(D3)->D4k->R1->Vcc | 6 |
6 | Row 2 | 6 | ->D3k->R1->Vcc | 8 |
7 | Row 3 | 5 | ->D5k->R1->Vcc | 7 |
8 | GND | 1-6 |
- Connect 1 to Vcc
- Connect 8 to GND
- Connect columns 0 and 1 to INPUT pins each with a 4k7 pull-up to Vcc.
- Set rows 0-3 to HIGH
- Scan rows by setting each to LOW in turn
- Read state of each column, LOW is on.
The 14-pin IDC header on finger-cluster has the following connections and proposed Teensy-3.1 pin allocation
Pin | Line | Teensy pin |
---|---|---|
1 | Vcc | |
2 | XD0 (column 0) | 14 |
3 | Row 4 | 1 |
4 | XD1 (column 1) | 15 (now 16 but should be put back to 15) |
5 | Row 5 | 0 |
6 | Row 6 | 16 (now 15 but should be put back to 16) |
7 | Row 7 | 3 |
8 | Row 8 | 17 |
9 | Row 9 | 2 |
10 | Row 10 | 20 |
11 | Row 11 | 23 |
12 | Row 12 | 21 |
13 | Row 13 | 22 |
14 | GND | |
- Connect 1 to Vcc
- Connect 14 to GND
- Connect columns 0 and 1 to INPUT pins each with a 4k7 pull-up to Vcc. (NOTE: columns 0 and 1 are the same for finger and thumb clusters)
- Set rows 4-14 to HIGH
- Scan rows by setting each to LOW in turn
- Read state of each column, LOW is on.
The following tables provide the column, row and combined indices for each of the thumb and finger switches:
Thumb Switch | Column/Row/index | ||||
---|---|---|---|---|---|
Knuckle | 0 0 0 | ||||
Nail | 1 0 1 | ||||
Down | 0 1 2 | ||||
DOWN | 1 1 3 | ||||
Pad | 0 3 6 | ||||
Up | 1 2 5 | ||||
Finger | Down | North | South | East | West |
1 | 0 5 10 | 1 4 9 | 0 7 14 | 1 5 11 | 0 4 8 |
2 | 0 11 22 | 1 9 19 | 1 7 15 | 1 11 23 | 0 9 18 |
3 | 0 12 24 | 1 13 27 | 0 10 20 | 1 12 25 | 0 13 26 |
4 | 0 6 12 | 1 8 17 | 1 10 21 | 1 6 13 | 0 8 16 |
The ADNS-9800 LaserStream Gaming Sensor Kicklighter breakout board connects to the Teensy 3 on the SPI interface using 4 pins + 1 pin for interupt:
Pin | ADNS | Teensy | Description | Teensy pin |
---|---|---|---|---|
1 | MI | MISO | Data input | 12 |
2 | VI | Vcc | 3.3V | |
3 | SC | SCK | Clock | 13 |
4 | AG | GND | Ground | |
5 | MO | MOSI | Data output | 11 |
6 | DG | GND | Ground | |
7 | SS | SS | Select device | 10 |
8 | MOT | – | Motion interupt | 9 |
The LEDs on the key map panel on the DataHand case are reused with the following pin allocation on the Teensy-3.1:
LED | Teensy pin |
---|---|
Shift | 24 |
Caps Lock | 25 |
– | 26 |
– | 27 |
Cursor/mouse mode | 28 |
Function mode | 29 |
NAS mode | 30 |
Normal mode | 31 |
– | 32 |
– | 33 |
- Note: LOW is on
Pin requirements:
Purpose | #pins |
---|---|
I2C (comms between teensys) | 2 |
SPI (comms with trackball) + interupt | 5 |
Key matrix column inputs | 2 |
Thumb row outputs | 4 |
Finger row outputs | 10 |
Mode and modifier indicator LEDs | 6 |
Wake-up GPIO pin | 1 |
Total | 30 |
To provide the best shape for the finger-driven trackball fitted is the curve of the finger-cluster I found that the standard 2 1/4” pool-ball to be the best compromise. From a curvature point of view a slightly larger ball might be more comfortable but then it would need a higher case and would require further re-arrangement of the thumb switches. Also the 2 1/4” pool-ball is the largest high-quality ball readily available. Even with this size of ball a significant change needed to be made to the thumb-cluster to fit it in a suitable position, starting with the relocation of the “up” switch further in to allow aggressive trimming of the PCB and re-routing of cut tracks. Slight trimming of the finger-cluster PCB was also required but this did not require the cutting and re-routing of any tracks.
For convenient prototyping and testing I made the cup supporting the trackball by hand using Polymorph (known as Friendly Plastic in the US) by rolling a thick-ish sheet and molding around the ball with a thick rubber glove stretched over it to ensure the cup is slightly larger that the ball. I created flattened regions on the cup for the fitting of the laser sensor and to fit it to the case using a belt-sander. The lugs to attach the laser sensor and fix the unit to the case are attached using hot-glue. Three 2mm rubys support the ball and are fitted to the cup through 2mm drilled holes and pushed so they protrude using 2.5mm self-tapping screws.
Initially I tried a cue-ball but the sensor could not detect the motion reliably if the ball moves fast. This may be an issue with inaccurate positioning of the sensor. I now use an Aramith “Golden-8” ball with metallic finish which the sensor can follow more reliably. This is the closes to the balls which Kensignton use but readily available and reasonably priced.
To save power, IR LEDs and in particular the laser sensor it is important to include a sleep mode. Sleep functionality in the ARM-based Teensy 3.1 is completely different to the AVR-based Teensy 2 and a special library is needed:
There are various modes of operation supported from reduced clock low-power modes to interruptable deep-sleep and hibernate modes. The problem with the reduced clock modes is that the IR LEDs will still be powered although it would be possible to reduce the scanning frequency of the matrix. The interruptable deep-sleep mode looks most appropriate but a pin would need to powered to interrupt the sleep which is not possible using the optical switched of the DataHand which would all be off during sleep. The easiest solution is to provide a dedicated wake-up push-button switch attached to a dedicated wake-up pin on the Teensy 3.1. Note that only a subset of the pins may be used for this purpose:
GPIO pin | |
---|---|
1. | PIN_2 |
2. | PIN_4 |
3. | PIN_6 |
4. | PIN_7 |
5. | PIN_9 |
6. | PIN_10 |
7. | PIN_11 |
8. | PIN_13 |
9. | PIN_16 |
10. | PIN_21 |
11. | PIN_22 |
12. | PIN_26 |
13. | PIN_30 |
14. | PIN_33 |
A push-button switch is attached to pin 33 for wake-up which works fine but it would be good to use the normal keys. Given that the trackball laser is switched-off during sleep it is not possible to wake by moving the ball. An alternative would be to use one of the rest modes of the ADNS9800 for laser saving and still support wake-up by moving the ball but this would require the SPI to be running, i.e. the Teensy 3.1 in sleep rather than deep-sleep mode which would be OK if it wired directly to the computer rather than wireless and battery powered.
The complete source code for the firmware may be found in the TrackHand
directory and support libraries in the libraries
directory. The complete
code may be compiled, linked and loaded using make
:
- Compile only:
make PROGRAM=TrackHand
- Compile and upload:
make PROGRAM=TrackHand load
The program defaults to TrackHand
so
- Compile only:
make
- Compile and upload:
make load
is sufficient.
To initialize the configuration parameters stored in EEPROM it is necessary to
compile and load with the INITIALIZE=1
set on command line the first time
the firmware is loaded:
- Compile and upload:
make INITIALIZE=1 load
After initialization the standard firmware may be loaded which uses the current configuration stored in EEPROM:
- Compile and upload:
make load
I have created a Dvorak-like layout based on the Kinesis and DataHand Professional II Dvorak layouts adjusted for programming convenience. To allow parentheses to be typed without shift they are included in the normal key-map directly with the shift being generated automatically. Also to allow complete flexibility for shifted keys the shift and shift-lock keys enable a shift-mode rather than simply applying the shift-modifier. While the locations of the normal characters is fairly obvious it is less clear where the symbols should be located and this is still in a state of flux.
The CAD and PS files for the keyboard legends are in the KeyboardLegends
directory. Here are the current keyboard legends for the right-hand and
left-hand units:
I am using klavaro to learn to touch-type on the TrackHand. I can already
touch-type on the Kinesis Advantage with the Dvorak layout and the I have
created a layout for the TrackHand which is reasonably similar which has
been helpful when learning the normal keys but the layout of the symbols is
VERY different. I set the keyboard to USA dvorak
and found that the
tutorials corresponded well to the layout of keys for both the alphabetic
characters and reasonably well to the symbols.
thconf
is a simple command-line utility provided to configure the
TrackHand. It is complied using the Makefile
in the TrackHand directory and
provides the following options:
Usage: thconf [OPTION]... -h --help Print this usage information. -d --dev <name> Name of the serial device used to communicate with the TrackHand. -p --print Request that the TrackHand prints the current configuration. -r --resolution <val> Set the pointer motion resolution in increments of 50cpi in range 1-168. -s --scroll <val> Set the scroll divider to reduce the scroll speed. -t --timeout <val> Time of inactivity after which power saving is enabled.