Keyboard Lab

For this lab you will connect a PS/2 keyboard to your Z8 developers kit and write a program that will decode the data stream and display the proper characters or scan code on the LED array. I have keyboards if you need one and I have a connector for the keyboard so you can add the necessary pullups and wire that to your Z8 development kit. You should have the necessary resistors in the parts kit already.

You will need to use at least one button. Pressing this button will switch between displaying scan codes and displaying the key pressed. When you press the button you will emit a short, distinctive tone on the speaker to indicate the mode (2 modes, 2 tones). When displaying scan codes, you will display the numeric code (in hex). If the scan code is more than 4 digits (some are) you can either scroll them on the display or you can make some special characters (so that “E0” and “F0” can be shown on 1 array). When displaying keys you should display the name of the key pressed and you should interpret the shift/control keys (so that pressing shift + a results in a capital A, and control-a results in “ctl-a” being displayed).

The color codes for the connectors you have is:

  • Brown – pin #1 – Clock
  • Red – pin #3 – Ground
  • Yellow – pin #4 – 5 volts
  • Green – pin #5 – Data

  • Look up the proper pinouts for the keyoard if you need to:
    • Note that there are many different diagrams floating around for the PS/2 pinout. They are not all the same. Many of them use different pin numbering schemes. Also, some of the schematics you find will refer to the connector on the back of the PC (the female connector) and some refer to the keyboard connector (the male connector). If you don’t know which, your pin ordering may be reversed. This page: http://www.mp3car.com/vbulletin/attachments/hardware-development/27594d1... seems to be the proper numbering (and note that this is the keyboard port so it refers the connector on the computer not the cable on the keyboard, so its the female connector).
  • Use this page for information on how to decode the serial data stream: http://www.beyondlogic.org/keyboard/keybrd.htm

Answer these questions:

  • What value resistor did you use for pullups?
  • What technique did you use for watching the data and clock lines? Why did you choose that?
  • Did you use the oscilloscopes in the class room to help debug your lab setup?
  • What difficulties did you have keeping track of when to sample the data line? What did you try that didn’t work?

  • Last updated: Mon, 02/11/2008 - 15:07