Page 1 of 2
Mini keyboard PS2 and USB
Posted: Wed Aug 04, 2010 12:31 pm
by ChuckT
http://cgi.ebay.com/ws/eBayISAPI.dll?Vi ... 0528390857
This is a cheap keyboard for those of you who want something small for the 6502.
Posted: Wed Aug 04, 2010 5:57 pm
by ElEctric_EyE
I had to get one! It was only $4US dollars, and I've been looking into interfacing a PS2 keyboard with my PWA project. Doesn't seem too difficult, maybe a serial to parallel converter and a couple logic gates, then a lookup table to match data to ascii...
Thanks for posting that Chuck!
Mini keyboard PS2 and USB
Posted: Thu Aug 05, 2010 4:36 am
by BigDumbDinosaur
How the devil are you supposed to type on something that small? You guys have any idea how big my front feet are?
Posted: Thu Aug 05, 2010 5:23 am
by GARTHWILSON
How the devil are you supposed to type on something that small? You guys have any idea how big my front feet are?
It does look like the width of the keys would have to be slightly sub-standard. The keyboard on my HP-71 handheld computer shown below is about 60% of standard size, and I was able to type on it at about 30wpm, almost 60% of what I can do on a full-sized keyboard. My fingers are pretty slim though.
I typed a lot of notes in meetings, typed memos, letters, etc.. I decided I better quit typing on it so much when they discontinued it. I figured that if I ever wore it out, that's it baby.

Posted: Thu Aug 05, 2010 1:13 pm
by 8BIT
Doesn't seem too difficult, maybe a serial to parallel converter and a couple logic gates, then a lookup table to match data to ascii...
It's a little more complicated than that. However, it can be done.
Both Lee Davison and I have published code to decode a PS2 keyboard. I have two versions, one uses two ports of a 6522 and the 6502 to convert the codes and the other uses an AVR to do the processing.
Mine are here:
http://sbc.rictor.org/io/pckb6522.html
http://sbc.rictor.org/io/pckbavr.html
and Lee's is here:
http://members.multimania.co.uk/leeedav ... index.html
Hope this helps. Please let us know how that keyboard works out. I might invest in one too!
Daryl
Re: Mini keyboard PS2 and USB
Posted: Thu Aug 05, 2010 1:31 pm
by ChuckT
How the devil are you supposed to type on something that small? You guys have any idea how big my front feet are?
I used my thumbs to type on my LG env3 cell phone before it got ran over by a car. They're functional and a small child might be able to type on one of them but if you were to price a keyboard for a PDA or Xbox 360 then the price goes way up. This is a bargain.
Posted: Fri Aug 06, 2010 1:27 am
by ElEctric_EyE
Daryl,
I haven't looked into Lee's interface yet, but I have checked yours out. It looks awesomely simple using 1 20 pin AVR ATTiny 26, but my programmer doesn't do those. Seems to only handle the 14 pin AVR's. Could an ATTiny 24, or 44 be made to work?
This website:
http://www.beyondlogic.org/keyboard/keybrd.htm ,explains the basic protocols half way down...
I was thinking along the lines of a serial to parallel shift register, but I would rather not spend time developing it if I don't have to...
Thanks for your help,
EE
Posted: Fri Aug 06, 2010 2:51 am
by 8BIT
Yes, the ATtiny24 should work and it had just enough I/O ( 2 for keyboard, 8 for the data bus, and two for handshaking). You will need to buffer the data - either through a 6522 or 74 series buffer.
The AtTiny26 code uses 778 bytes of flash and only uses RAM for subroutine return-address stack storage. (it uses the registers for data storage).
I have the decoder running in an ATM8 on my SBC-3 and it's pulling double duty by also providing an RS-232 channel as well. It is accessed via the 65SPI controller.
Daryl
Posted: Wed Aug 11, 2010 8:49 pm
by ElEctric_EyE
Yes, the ATtiny24 should work and it had just enough I/O ( 2 for keyboard, 8 for the data bus, and two for handshaking)...
Daryl
I've not had time to research, but do all the ATTiny series have common opcodes? Can I use the same driver or would I have to experiment?
Got the keyboard in today, so I thought I'd share. It's not as small as the ebay link made it out to be.
Nothing works yet but it looks cool, eh?

Posted: Wed Aug 11, 2010 9:55 pm
by 8BIT
If I recall correctly, they all share a common opcode list. However, the onboard resources will be different. My quick look at the ATTiny24 led me to think you should be able to use my ATTiny26 code as-is.
If you end up with errors, let me know I I can help you work throught them.
Daryl
Re: Mini keyboard PS2 and USB
Posted: Sun Dec 09, 2012 2:18 pm
by YT2095
if you don`t mind me asking, I`m curious as to Why your using the PS2/USB adapter and not just plugging it in directly to a USB socket?
very few of these adpters are Active devices and are merely pass-through, with D+/D- going directly to Clk and Data, GND/+5V remain the same.
a simple beep test with a continuity meter will confirn this easily, and removes the bulky sticky-outy thing with one less segway for error.
also, if anyone`s interested I`ll post the source code I use on NINA-6502 for the USB keyboard interface that uses a PIC Chip, then there`ll be 3 ways to do it

Re: Mini keyboard PS2 and USB
Posted: Sun Dec 09, 2012 4:32 pm
by ElEctric_EyE
Wow, this was a long time ago...
And thanks for your offer!
What I wound up doing for the PS2 interface was to use a controller core from opencores.org and put it in the FPGA.
Regarding interfacing a project to a PC through USB, several of us have used ICs, that come with free drivers for Windows. I'm sure they have Linux by now...
Re: Mini keyboard PS2 and USB
Posted: Sun Dec 09, 2012 5:14 pm
by Dajgoro
I have a USB keyboard for my SBC, and i have to use the green USB to PS/2 adapter. PS/2 is simple, and mouse as well.
Re: Mini keyboard PS2 and USB
Posted: Sun Dec 09, 2012 6:00 pm
by YT2095
yeah, SBC to PC is pretty easy with the FTDI chips (about £2 on ebay), or even the PIC 18f22k50, 18f2550/4550.
the s/ware I did was the other way around, where it parses a USB Keyboards data into Parallel and Serial output for the SBC to use.
as for the green adapters I`v no idea if they`re different at all, but it would be worth checking with a continuity tester to see if it is just a simple pass-through type.
on the off chance that it May help someone in the future doing a search for such a thing, my code is here:
;Chip Settings
#chip 18F4685,20
#config OSC=HS, PWRT=ON, WDT=OFF
;Defines (Constants)
#define PS2Clock PORTB.1 'to D+ on USB socket
#define PS2Data PORTB.0 'to D- on USB socket
#define SerOutPort PORTB.7
#define SendAHigh Set SerOutPort Off
#define SendALow Set SerOutPort On
dir portc out
DIR PS2Clock IN
DIR PS2Data IN
Dir SerOutPort Out
InitSer 1, r9600, 1 + WaitForStart, 8, 1, None, Invert
Main:
KeyIn = INKEY
if KeyIn = 0 then
goto Main
end if
portc = KeyIn
SerSend 1, KeyIn
wait 1 ms
goto Main
all you need is to download GCBasic (it`s free and quite small), hook up a PIC 18F4685 with a 20MHz crystal to a PicKit2 and go to `Compile an download with PicKit2` in the pulldown menu and it`s done!
this will do both USB and/or PS2 directly with or without the use of adapters.
it hardly even deserves to be called "Code"

Re: Mini keyboard PS2 and USB
Posted: Sun Dec 09, 2012 6:48 pm
by ElEctric_EyE
...as for the green adapters I`v no idea if they`re different at all, but it would be worth checking with a continuity tester to see if it is just a simple pass-through type...
It is a pass thru type and I ohmed out the adapter I have. The pin numbers for
PS2 and the
USB are referenced to wikipedia, although they were mirrored in my case. I think I have it right:
Code: Select all
USB PS2
1 (5V) 4 (5V)
2 (D-) 1 (+data)
3 (D+) 5 (+clk)
4 (GND) 3 (GND)