Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

AT or PS/2 Keyboard Interface

Status
Not open for further replies.

andre2000

Newbie level 3
Newbie level 3
Joined
Nov 24, 2007
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,313
ps2 keyboard parity bit

Hi guys, noob here.
I'm trying to make a module to capture keyboard characters from a keyboard connected to the PS/2 port on my Altera board.

I need to know exactly how the signals come in from the keyboard when a key is pressed. The internet is great, and I searched and searched and found a lot of info. But much of it is incomplete, inconsistent, or not clear.

So what comes out of the serial data pin when a key is pressed? Some sites say that just the scan code comes out (framed in 11 bits). Others say that the scan code comes out and is followed by a break code when the key is released (code $F0), also framed.
Another site says that when you press a key the following comes out "$E0 $F0 x x", how unclear is that!?! Is the "x x" the data? If so it doesnt make sense!

Then another site says that if you hold down the key, it sends out the scan code repeatedly "10 times per second" until a release (break) code is seen. That can't be true because we can all hit the key for exactly 1 second and this doesnt happen!

All the sites say that the keyboard clock rate can be from 10kHz to 30kHz, if thats true, then if you hit a key for 1 second, it actually has sent out 333 of the same scan code in that time (assuming 30kHz). How is that possible? Do I have to make my module over come this or is there something else going on?
 

it will be for ps2 9600baud 8bit 1 start 1 stop bits 1 parity bit

adhear to ps2 keyboard protocol {look at the net for the standard}

only the adidtion of device specific drivers will maybe alter this normal setup

you simply send the keyboard a byte or a toggle to init it
... see ps2 protocal for keyboards
so put another way you can use ANY serial port and even hyperterminal
to init and get data froma keyboard for practice etc....
**broken link removed**

the data pins are at ttl 5v level as opposed to the standard +-12v rs232 levels
most rs232 serial coms devices
will switch to 5v ttl level upon detection
{modern pc made after 2000}
the data is usualy 'clocked in and out' the buffers on the keyboard and port
on interrupt

...

data from keyboard / mouse etc
is usualy sent in packets to allow multiple byte to be sent for what level of keyboard key is set {shift or not ctrl pressed or not etc}
each has its address it sends and is decoded to give the right intimation of key press
 

    andre2000

    Points: 2
    Helpful Answer Positive Rating
VSMVDD said:
so put another way you can use ANY serial port and even hyperterminal to init and get data froma keyboard for practice etc....
It will be hard to plug in a PS/2 6-pin connector into a COM port 9-pin connector.

A PS/2 keyboard (unlike a mouse) needs no initialization to work.

With a clock period fixed at 80 microseconds, the PS/2 protocol is nominally 12.5kbps. It is extremely tolerant, allowing 25% variation in clock frequency.

A correct implementation of PS/2 requires a 100 microsecond start bit.

Some of the scan codes are multibyte. Each byte is framed with a start and stop bit. There is a scan code when the key is pressed, and a related scan code when the key is released.
 

    andre2000

    Points: 2
    Helpful Answer Positive Rating
Thanks for your responses!
I have learned much of about the PS/2, and I am confident my code will interface with it.

Another queston,
Once I get the data I would like to convert it from scan code to ASCII. I don't care about the multibyte keys, just the basics. I know a need a lookup table for a keycodes->ASCII converter. Does this mean making a mux with 127 inputs (8bytes ea) and an 8 bit select? It just doesnt sound right....
 

Actually, i ran into a problem with my design. I really do need to care about the multibyte codes because of the release code! When you release a key, the keyboard sends a 2 byte release code framed by a start bit, parity, and stop bit.

The first byte is E0h, followed by the 1 byte scan code of that key that was released.
I designed it so that a statemachine sees E0h, knows its a break, and then just ignores the rest of the release code.

The only problem is it is becoming too big of a design now, and I'm worried about how it's going to synthesize. Can anyone give me some design tips?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top