PDA

View Full Version : Keyboard encoder for the smallest keyboard



Graham Stabler
10-21-2006, 06:13 PM
Some of you may remember that I made a housing for my demoboard, TV and keyboard to fit in a tiny flight case only to discover that the USB keyboard I had purchased was USB only and would not work with the adapters I had used with other keyboards. I discovered that there is sometimes a boot mode that allows the USB keyboard to work in a limited fashion in bios on a PC which could make interfacing easier however I couldn't get confirmation from manufacturer so I'm not going to risk the time and effort.

What I am left with is an array of switches going into a nice edge connector so I thought it might be a better bet to program a keyboard encoder to provide PS/2 from the keyboard.

I have found detailed info on the keycodes and the expected actions from the keyboard:

www.computer-engineering.org/ps2keyboard/ (http://www.computer-engineering.org/ps2keyboard/)

And full details on the PS/2 protocol:

www.computer-engineering.org/ps2protocol/ (http://www.computer-engineering.org/ps2protocol/)

And of course the keyboard object that comes with the propeller has most of what is required, the keycodes, sending and receiving routines etc.

I'll have to work out the mappings between the edge connector and the keys but I'm confident it could be relatively straight forward and would do two things, provide me with the smallest keyboard I can find for any propeller apps I do and also provide some base code for anyone else who wants to make a custom keyboard for the propeller or even a PC.

If anyone has already done this or has a better idea please let me know.

Graham


http://forums.parallax.com/attachment.php?attachmentid=43738

The smallest keyboard in the west, out of its case and resting on the parallax micro keyboard. Its a Keysonic micro BTW, have seen these at very low prices.

Graham Stabler
10-21-2006, 10:46 PM
I have been looking at the keyboard object for inspiration on how to code up my keyboard encoder, there are certainly many elements that can be reused.

One part is used to wait for certain events such as clock_low, clock_high, clock_low and data_low etc etc. This code can do all of these things depending on the state of wcond. It seems you can enter the code block at wait_c0 or at wait, if you enter at wait you set wcond before hand.





wait_c0 mov wcond,c0 '(wait until clock low)

wait mov y,tenms 'set timeout to 10ms

wloop movs napshr,#18 'nap ~4us
call #nap
_c3 test cmask,ina wc 'check required state(s)
_d4 test dmask,ina wz 'loop until got state(s) or timeout
wcond if_never djnz y,#wloop '(replaced with c0/c1/c0d0/c1d1)

tjz y,#reset 'if timeout, reset keyboard
wait_ret
wait_c0_ret ret


c0 if_c djnz y,#wloop '(if_never replacements)
c1 if_nc djnz y,#wloop
c0d0 if_c_or_nz djnz y,#wloop
c1d1 if_nc_or_z djnz y,#wloop





The part I don't understand is that the mov command is used to set wcond when it is the source field of the djnz command that is being modified.

Why isn't movs being used?

Graham

Graham Stabler
10-21-2006, 10:50 PM
Ah, I get it. Its the whole line at wcond that is being replaced.

That's cool.

I wish someone would wite something up on all this self modifying stuff so I can really get it. I'm very confused by what the labels on the lines actually are, is it like the "variable" c0 contains the command on that line or is it just an address or ......

Graham

flapdoodle_dinghy
10-23-2006, 04:40 AM
I have been looking into the smaller keyboard idea too. Only nice one I saw was about $54 US from the UK.
In searching I saw that USB to mini-DIN connectors work on "most" keyboards. I am wondering about that.

I love the feel of the old Thinkpad keyboards made in 1995. Next year they were rubbery feeling and sticky. Since I have an old broke 755c I am planning to salvage the keyboard and interface it directly to a more modern keyboard encode. It will require tracing out all the line but I have done it before. It will give me a keyboard about 11" X 5"

Thanks for sharing with us.
Bill
http://tech.groups.yahoo.com/group/parallax_propeller/

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://tech.groups.yahoo.com/group/parallax_propeller/

Graham Stabler
10-23-2006, 05:15 AM
I was wondering about just using a standard keyboard encoder chip from a duff keyboard but unfortunately a lot of the keys on this one are combined, you have to press the function key to get page up for example.

I'm making steady progress through th keyboard object, its taking me a while as I'm essentially learning how the propeller works at the same time as the code, I got really stuck on the look up table section until I realized that the adresses must all be to 32-bit blocks and the bytes in the table need to be extracted from those.

If I can find a nice way of doing the mapping from pins to lookup on the encoder it could be very handy for things like laptop keyboards or even tiny keyboards from dead PDAs and the like, even my spell ckecker has a keyboard!

Graham

Cliff L. Biffle
10-23-2006, 12:59 PM
You might also consider a PDA keyboard, like the Stowaways. They are (or were, back when I was looking) serial interfaced, with a simple byte-oriented protocol. I wrote a Linux driver for them some years ago, and it was quite straightforward -- the manufacturer even provides protocol docs and keymaps.

You'd have to hack the connector and write a driver, but that's it.

Rob7
10-24-2006, 09:37 PM
Graham,

Where can I purchase a mini keyboard like this ?

I have searched with no great results.

This would work great with my next project.

Rob7

Graham Stabler
10-25-2006, 12:14 AM
Its a keysonic nano, google should find it for you.

Bear in mind using it relies on someone doing an encoder program or someone even dafter tackling a USB driver.

Graham

flapdoodle_dinghy
10-25-2006, 01:19 AM
This appears to be the same thing, but PS/2:
http://www.keyboardco.com/keyboard_details.asp?PRODUCT=179

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://tech.groups.yahoo.com/group/parallax_propeller/

Rob7
10-25-2006, 03:37 AM
Thanks for the info.

Rob7

Graham Stabler
10-25-2006, 04:12 AM
flapdoodle_dinghy said...
This appears to be the same thing, but PS/2:
http://www.keyboardco.com/keyboard_details.asp?PRODUCT=179


The keysonic is 218 X 103mm

That one is 292 X 139

So its quite a lot larger.

Graham

Cliff L. Biffle
10-25-2006, 04:31 AM
Graham Stabler said...

The keysonic is 218 X 103mm

That one is 292 X 139

So its quite a lot larger.



Yours also appears to be a 2mm travel laptop-style keyboard, whereas this one looks to be full-travel.

...which for me, is a good thing. (I'm in the market for a PS/2 keyboard, having disposed of all of mine long since.)