Post by jtwinters on Jan 2, 2007 19:10:24 GMT -5
The Micro Folding Keyboard (Model#: TKB420HP) made by Micro Innovations is a small portable keyboard for attaching to a Jornada PDA. It basically has all keys needed for adapting to a DTV but unfortunately outputs RS-232 instead of PS/2. The following information describes how to interface this keyboard to DTV Hummer and possible the rest of the DTV versions.
Out of the box:
Disassembling the keyboard, you’ll see 5 labeled connections: VCC, RTS, RXD, DCD, and GND. VCC is +5V for this unit. RXD is the line on which data is actually sent, although the keyboard won’t send anything until RTS is pulled high. I do this right on the board by soldering a 1k resistor between the RTS pad and the onboard microcontroller’s Vcc pad (see picture). By doing this, you only need to run three wires from the keyboard (VCC, RXD and Ground).
As far as what mechanical modifications… I chose to cut away a lot of extra plastic from the two folding halves and superglue the sides together. This effectively created one solid piece. I also glued the flexi-ribbon flat against itself to take up less space.
Since this keyboard outputs RS-232 (9600 baud, 8 data bits, 1 stop bit and no-parity), a PIC 16F88 microcontroller is used to convert the data to PS/2 for the DTV. PS/2 keyboards use “make” and “break” codes. One or more “make” codes is sent when a key is pressed and several “break” codes and are sent on key release. The Jornada keyboard kind of works the same way in that it uses make and break codes, unfortunately the codes are not a one for one match and must be re-mapped by the PIC.
On power up, the PIC will check to see if a regular external PS/2 is attached. If so, it will just go into “repeater” mode and pass along any signals from the PS/2 keyboard to the DTV. The PIC adds a one second delay to get rid of the pesky “V”.
Here’s the circuit (thanks to Joe Rey for redrawing it):
The 100k resistor on pin 11 is needed even if you decide not to mess with the external PS/2 connector, so don’t leave it out. The rest is fairly straight forward. The 100uF cap may need to be larger depending on your setup. 100uF worked initially for me until I added an LCD screen to my design. The power surge on start up was too much and the keyboard would not initialize properly until I increased it to 470uF.
For timing, the internal 8 MHz oscillator is used. It seems to work just fine.
Here’s the HEX file: www.picobay.com/picodore64/JornadaKB_16F88.hex
And the source code: www.picobay.com/picodore64/JornadaKB_16F88.txt
Again, this is for a 16F88 and any $15 JDM PIC programmer will work just fine. The source code is written in PicBasic Pro. The code could probably be reduced to half the size by constructing the send codes on the fly instead of hard coding them. The start, stop parity bit could be added automatically and each make/break code would only take up a byte instead of a word. But the 16F88 has 4K of space and I wasn’t tight on space. Maybe as I add more features, I’ll recode that section. And while I’m at it, I’ll switch to using interrupts to get the data from the Jornada keyboard instead of just waiting for data.
Obviously this is an adapted keyboard and I had to switch some of the key assignments:
Today = ESC (RUNSTOP)
Space = INSERT
Windows key = Commodore Key
FN + Right Arrow = HOME
FN + CRTL + Right Arrow = CLR SCN
The 4 keys in the top left are the F1 thru F4 keys, F5 thru F8 with the FN pressed.
I didn't bother to implement the Numlock keypad, there didn't seem to be much point to doing so.
Just for the heck of it I’m posting the PS/2 waveform of a make code for the “A” key. Channel 1 is the clock and Channel 2 is data.
This is from a real PS/2 keyboard.
And here is the PIC’s emulated PS/2 protocol of the same data.
Good luck!
Out of the box:
Disassembling the keyboard, you’ll see 5 labeled connections: VCC, RTS, RXD, DCD, and GND. VCC is +5V for this unit. RXD is the line on which data is actually sent, although the keyboard won’t send anything until RTS is pulled high. I do this right on the board by soldering a 1k resistor between the RTS pad and the onboard microcontroller’s Vcc pad (see picture). By doing this, you only need to run three wires from the keyboard (VCC, RXD and Ground).
As far as what mechanical modifications… I chose to cut away a lot of extra plastic from the two folding halves and superglue the sides together. This effectively created one solid piece. I also glued the flexi-ribbon flat against itself to take up less space.
Since this keyboard outputs RS-232 (9600 baud, 8 data bits, 1 stop bit and no-parity), a PIC 16F88 microcontroller is used to convert the data to PS/2 for the DTV. PS/2 keyboards use “make” and “break” codes. One or more “make” codes is sent when a key is pressed and several “break” codes and are sent on key release. The Jornada keyboard kind of works the same way in that it uses make and break codes, unfortunately the codes are not a one for one match and must be re-mapped by the PIC.
On power up, the PIC will check to see if a regular external PS/2 is attached. If so, it will just go into “repeater” mode and pass along any signals from the PS/2 keyboard to the DTV. The PIC adds a one second delay to get rid of the pesky “V”.
Here’s the circuit (thanks to Joe Rey for redrawing it):
The 100k resistor on pin 11 is needed even if you decide not to mess with the external PS/2 connector, so don’t leave it out. The rest is fairly straight forward. The 100uF cap may need to be larger depending on your setup. 100uF worked initially for me until I added an LCD screen to my design. The power surge on start up was too much and the keyboard would not initialize properly until I increased it to 470uF.
For timing, the internal 8 MHz oscillator is used. It seems to work just fine.
Here’s the HEX file: www.picobay.com/picodore64/JornadaKB_16F88.hex
And the source code: www.picobay.com/picodore64/JornadaKB_16F88.txt
Again, this is for a 16F88 and any $15 JDM PIC programmer will work just fine. The source code is written in PicBasic Pro. The code could probably be reduced to half the size by constructing the send codes on the fly instead of hard coding them. The start, stop parity bit could be added automatically and each make/break code would only take up a byte instead of a word. But the 16F88 has 4K of space and I wasn’t tight on space. Maybe as I add more features, I’ll recode that section. And while I’m at it, I’ll switch to using interrupts to get the data from the Jornada keyboard instead of just waiting for data.
Obviously this is an adapted keyboard and I had to switch some of the key assignments:
Today = ESC (RUNSTOP)
Space = INSERT
Windows key = Commodore Key
FN + Right Arrow = HOME
FN + CRTL + Right Arrow = CLR SCN
The 4 keys in the top left are the F1 thru F4 keys, F5 thru F8 with the FN pressed.
I didn't bother to implement the Numlock keypad, there didn't seem to be much point to doing so.
Just for the heck of it I’m posting the PS/2 waveform of a make code for the “A” key. Channel 1 is the clock and Channel 2 is data.
This is from a real PS/2 keyboard.
And here is the PIC’s emulated PS/2 protocol of the same data.
Good luck!