NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Project Help and Ideas » PS2 keyboard project not working

February 23, 2013
by Johnny544
Johnny544's Avatar

Hi-

I'm a newbie who has successfully completed 4 projects. I decided to try the PS2 keyboard project, but I can't get it to work. When I run it, all I get is a repeating symbol on the LCD (about 1 per second). When I type, nothing happens.

Just for fun I tried swapping the data and clock lines, and I got a repeating question mark.

I'm not sure this is pertinent, but I bought a USB/PS2 combo keyboard. It came with a USB connector and a USB-to-PS2 adapter. I was able to identify the four wires as per the instructions by plugging in the adapter.

When I power up the breadboard, the green lights flash on the keyboard, but when I press Numlock or Capslock the green lights don't come on.

I apologize for cross-posting this. I tried the Support forum first but didn't get any suggestions.

Thanks in advance for your help,

John

February 24, 2013
by Rick_S
Rick_S's Avatar

How many wires are in the cable for your keyboard? It may be firing up in USB mode causing your problem. I'd suggest getting a true PS/2 only keyboard and giving it a go.

Rick

February 24, 2013
by Johnny544
Johnny544's Avatar

Thanks Rick. I was thinking along these lines when I started to research USB-to-PS2 adapters. There are 4 wires and a chassis ground, so it seemed at first that it would work. I used a continuity tester and found a one-to-one relationship between the 4 wires and the appropriate pins in the PS2 connector. Anyway, I think my next step is to pick up a real PS2 keyboard.

One more question. In the code I downloaded, there is a line that is commented out that maybe shouldn't be?

Screenshot of keyboard code

It's:

DDRC &= ~(1<<PC4);

Doesn't this need to be included to make PC4 an input pin? Also, shouldn't there be a similar line for PC2, which is the data line input?

Here's a link to the project:

PS2 Keyboard Project

Thanks again for the help,

John

February 25, 2013
by pcbolt
pcbolt's Avatar

Hi John -

When I was working on wiring up a PS2 mouse to the MCU, I found out the hard way that the connections to the PS2 cables have to be really solid or you don't get the logic levels you need. Also, if your USB/PS2 adapter works with your PC, you should be able to get it to function with the MCU. I found a pin out diagram HERE that may help you. The one thing I found that was invaluable for my project was using an oscilloscope to test the clock and data lines. If you willing to spend some money, you can get a cheaper logic analyser HERE that will do the trick and is a good investment.

The DDRC &= ~(1<<PC4) line should be included in your code to make PC4 an input pin, but when the MCU is powered up, all I/O pins are set as input by default, so it isn't really needed in this case.

February 26, 2013
by Johnny544
Johnny544's Avatar

pcbolt, thanks so much for the very helpful information. I think I'm going to spring for the logic analyser. Just curious-- what features does it lack that a full-fledged oscilloscope has?

Regarding the code, another thing I was wondering about-- there's a line to turn on the pullup resistor for PC4, the clock input, but there isn't one for PC2, the data input. Is this also a case where by default the pullup resistor is on?

Thanks again,

John

February 26, 2013
by pcbolt
pcbolt's Avatar

The pullups are turned off by default. I looked through my PS2 mouse code and it looks like I set the data port pull-up on. Not sure why the NK code does not have this set.

As far as the difference between an oscilloscope and the logic analyzer, the o-scope can be used to study analog signals and the effects of filtering components such as caps and inductors. Very good scopes go for over $2k and can analyze high frequency signals (at or near the GHz range). It would take a while to go into every aspect, but if you feel the need to go to the next level, my advice would be to invest in a good oscilloscope and not go the cheap route. Until then, the logic analyzer should serve you well. (You should check out the video on the link above to see what they can do). You can get some cheap PC-based oscilloscopes like a "Picoscope" but just be aware they have some limitations.

February 27, 2013
by Johnny544
Johnny544's Avatar

Success! I replaced the keyboard, added the line to turn on the resistor for PC2, and it's working now. pcbolt, thanks for all the detailed info. I'll have to decide how serious I am about this hobby :) Rick, thanks again for the suggesion about replacing the keyboard.

February 27, 2013
by pcbolt
pcbolt's Avatar

Nice job John.

All in all, compared to other hobbies, this is fairly cheap and doesn't take up too much space. Of course all that can change pretty quickly :-)

Post a Reply

Please log in to post a reply.

Did you know that NerdKits make a great parent/child activity? Learn more...