Mini keyboard PS2 and USB

For discussing the 65xx hardware itself or electronics projects.
ChuckT
Posts: 491
Joined: 20 May 2009

Mini keyboard PS2 and USB

Post 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.
ElEctric_EyE
Posts: 3260
Joined: 02 Mar 2009
Location: OH, USA

Post 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!
User avatar
BigDumbDinosaur
Posts: 9428
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Mini keyboard PS2 and USB

Post 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?
x86?  We ain't got no x86.  We don't NEED no stinking x86!
User avatar
GARTHWILSON
Forum Moderator
Posts: 8775
Joined: 30 Aug 2002
Location: Southern California
Contact:

Post by GARTHWILSON »

Quote:
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.

Image
Image
User avatar
8BIT
Posts: 1787
Joined: 30 Aug 2002
Location: Sacramento, CA
Contact:

Post by 8BIT »

ElEctric_EyE wrote:
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
ChuckT
Posts: 491
Joined: 20 May 2009

Re: Mini keyboard PS2 and USB

Post by ChuckT »

BigDumbDinosaur wrote:
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.
ElEctric_EyE
Posts: 3260
Joined: 02 Mar 2009
Location: OH, USA

Post 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
User avatar
8BIT
Posts: 1787
Joined: 30 Aug 2002
Location: Sacramento, CA
Contact:

Post 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
ElEctric_EyE
Posts: 3260
Joined: 02 Mar 2009
Location: OH, USA

Post by ElEctric_EyE »

8BIT wrote:
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?

Image
User avatar
8BIT
Posts: 1787
Joined: 30 Aug 2002
Location: Sacramento, CA
Contact:

Post 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
User avatar
YT2095
Posts: 16
Joined: 01 Dec 2012
Location: England.

Re: Mini keyboard PS2 and USB

Post 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 :)
Also on Twitter as "YT2095".
ElEctric_EyE
Posts: 3260
Joined: 02 Mar 2009
Location: OH, USA

Re: Mini keyboard PS2 and USB

Post 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...
User avatar
Dajgoro
Posts: 808
Joined: 08 Aug 2011
Location: Croatia
Contact:

Re: Mini keyboard PS2 and USB

Post 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.
User avatar
YT2095
Posts: 16
Joined: 01 Dec 2012
Location: England.

Re: Mini keyboard PS2 and USB

Post 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" :wink:
Also on Twitter as "YT2095".
ElEctric_EyE
Posts: 3260
Joined: 02 Mar 2009
Location: OH, USA

Re: Mini keyboard PS2 and USB

Post by ElEctric_EyE »

YT2095 wrote:
...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)
Post Reply