please dont rip this site

Hardware Input/Output Port: Keyboard

Din Connector Gotcha

John Hansen says:

Thanks to everyone who offered suggestions about how to help me solve the problem of hooking up an AT keyboard to a PIC. I have found the problem and I thought that I would report the results back here because I have not found this information in any FAQ on the subject.

As you will recall, I had a number of different AT keyboards. I had written software to decode their scan codes and some of them worked and some did not. Some didn't even initialize properly... they just keep flashing their LED's or leaving them on permanently.

As luck would have it, the problem lay in the connector that I was using. I had purchased a PC mount 5 pin DIN socket (Mouser Cat # ME161-0503). This socket was obviously designed for a world in which pin 2 of the DIN connector (the one in the middle of the 5 pins) was supposed to be ground. I say this because when the plug is fully inserted into the socket, this socket connects pin 2 to the metal shell of the DIN connector. But PC keyboards don't use Pin 2 for ground; rather pin 2 is the data line. So, if the keyboard grounds this shell, then the data line is effectively grounded all the time. The Gateway keyboard (and an e-machines keyboard) apparently leave this shell floating, which is why they worked. The keyboards that wouldn't even initialize apparently won't initialize when the data line is pulled low. The keyboard that initialized, but often recognized data 1's as 0's apparently had an intermittent connection.

Anyway, I reached in with a screwdriver and bent the part of the socket that makes contact with the keyboard plug shell so that it no longer makes contact with the shell. When I did this all of the keyboards worked just fine. Upon review of the Mouser catalog, I notice that it offers "shielded" and "unshielded" DIN sockets. The one I bought isn't listed as being either shielded or unshielded, but I think next time for this type of project I'll buy the "unshielded". I suspect it will work fine.

Thanks again to everyone who helped with this project. I stumbled on the solution through dumb luck... I noticed that when the connector was plugged half-way in, it worked fine.

file: /Techref/io/keyboard/gotchadin.htm, 2KB, , updated: 2002/10/21 07:41, local time: 2024/7/16 04:59,

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF=""> Hardware Input/Output Port: Keyboard Din Connector Gotcha</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.

Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?


Welcome to!


Welcome to!