View previous topic :: View next topic |
Author |
Message |
Christophe
Joined: 10 May 2005 Posts: 323 Location: Belgium
|
Interfacing an (AT) 'laptop' keyboard with a PIC |
Posted: Mon May 07, 2007 1:49 am |
|
|
Hello,
we are having a new project. In our existing device ( a notetaker for visual impaired people ) we want to change the existing (braille) keyboard with an AT keyboard. This keyboard has to be as compact as possible. For that reason I'm considering a laptop keyboard.
So in this device:
http://users.[spam].be/chs/Werk/ES20.jpg
we want something like this:
http://img.alibaba.com/photo/11721374/Toshiba___Acer_Laptop_...yboard.jpg
http://www.laptopssales.com/shop/images/KEYBOARD45OSX4.jpg
I have these questions:
* What kind of electronics are there inside of such a keyboard? Or how can I interface that keyboard with my existing PIC16LF877A ? What comes out? Are that matrixlines or is that a PS2 interface? I know there are drivers for a PS2 interface. But what if only the matrixlines are available? Can i use an AT keyboard controller then or do I have to read the matrix in with the PIC?
* How can I obtain such a (custom) keyboard? Does anyone know a company that assembles such keyboards? + interfacing. Are there datasheets available?
* Mostly there is such a plastic flatcable coming out of the device; what is that?
tks |
|
![](templates/subSilver/images/spacer.gif) |
SteveH Guest
|
|
Posted: Mon May 07, 2007 8:21 am |
|
|
A keyboard for a PC uses an AT (older) or PS2 interface - this electrical interface is the same only the connector is different. Typically a PC keyboard runs on 5 volts and has a 8048 CPU or a keyboard ASIC inside of it to decode the matrix and generate the signals for the PC.
You can read about it here -
computer-engineering.org/ps2keyboard/
For a custom keyboard you can try these folks - I've had them make keyboards since before there was a PC! So they have been at it a long time,
cherrycorp.com/
HTH - Steve H. |
|
![](templates/subSilver/images/spacer.gif) |
Christophe
Joined: 10 May 2005 Posts: 323 Location: Belgium
|
|
Posted: Tue May 08, 2007 12:39 am |
|
|
One other small problem is that my PIC runs on 3V and the PS2 interface is 5V. Can I solve that with a resistor divider as it is a one way communication? |
|
![](templates/subSilver/images/spacer.gif) |
Steve H Guest
|
|
Posted: Tue May 08, 2007 8:09 am |
|
|
For a commercial project you should always use a level shifter. For hacking you may get away with a divider. Fairchild and Maxim make fine level shifting products.
My 2 cents worth.
Steve H. |
|
![](templates/subSilver/images/spacer.gif) |
Christophe
Joined: 10 May 2005 Posts: 323 Location: Belgium
|
|
Posted: Tue May 08, 2007 8:19 am |
|
|
Thanks for your advice.
Just wondering, if the PIC transmits a 3V high to the PS2 keyboard controller, will the kb controller recognize it as a high? Data and clock lines are both open collector... |
|
![](templates/subSilver/images/spacer.gif) |
Steve H. Guest
|
|
Posted: Tue May 08, 2007 8:46 am |
|
|
Depends - If the keyboard is using TTL levels then > 2.4 volts will be a high. If it is using CMOS levels then no - CMOS levels are typically 0.7 X Vcc or in this case 0.7 * 5 = 3.5 Volts. So 3 or 3.3 volts won't work AND you must have margin to overdrive the minimum logic high level. Typically using TTL level input devices works well with 3 or 3.3 volt CMOS outputs.
It is easy to make bad interfaces - carefully read all the data sheets before AND during the design of mixed voltage circuits.
HTH - Steve H. |
|
![](templates/subSilver/images/spacer.gif) |
Christophe
Joined: 10 May 2005 Posts: 323 Location: Belgium
|
|
Posted: Tue May 08, 2007 8:49 am |
|
|
Is there an easy way to find that out?
Here I have the tech spec. for a G83-6000 (that is a cherry keyboard I guess). It says that a high should be minimum 2,4V,so that would be TTL voltage levels. Is that always so with AT keyboards? Is it different from PS2 keyboards? |
|
![](templates/subSilver/images/spacer.gif) |
Steve H Guest
|
|
Posted: Tue May 08, 2007 11:19 am |
|
|
I would not assume that all vendors use the same voltage levels for their keyboards. But having said that the IBM PC keyboard spec probably calls out TTL logic levels.
Steve H. |
|
![](templates/subSilver/images/spacer.gif) |
Christophe
Joined: 10 May 2005 Posts: 323 Location: Belgium
|
|
Posted: Fri May 11, 2007 12:47 am |
|
|
Steve H wrote: | I would not assume that all vendors use the same voltage levels for their keyboards. But having said that the IBM PC keyboard spec probably calls out TTL logic levels.
Steve H. |
In that case I would not need a level convertor. Tks for your advice.. |
|
![](templates/subSilver/images/spacer.gif) |
Christophe
Joined: 10 May 2005 Posts: 323 Location: Belgium
|
|
Posted: Fri May 11, 2007 1:28 am |
|
|
Another AT keyboard question; I'm having a BENQ mini AT keyboard here that has a USB connector. There is also a USB to PS2 converter. However when I open the convertor, I see that only the wires are transferred from the USB connector to the PS2 connector, there is no electrical conversion, no logic.
How is that possible? The USB and PS2 protocol are completely different! |
|
![](templates/subSilver/images/spacer.gif) |
Steve H. Guest
|
|
Posted: Sat May 12, 2007 9:29 am |
|
|
Yes that is how it is done - frankly I have never looked at the specifics of this. I did a Google search and found this page though,
computer-engineering.org/ps2protocol/
Here is a link to a Patent that Cypress semi has on this method,
patentstorm.us/patents/6691201-fulltext.html
(put a www. in front of the address).
You might look at what application notes Cypress has on this method of interface.
HTH - Steve H. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Sat May 12, 2007 9:59 am |
|
|
The PS/2/AT spec, requires that the interface to the keyboard is 'enabled', by drawing both clock and data lines high. The keyboard replies with a completion code. This is sufficiently different from the initialisation used in USB, that the chip in the keyboard can tell them apart, and switch modes.
The 2.4v level, is in the original IBM PC documentation for the AT keyboard interface, so keyboards should be pretty reliable at accepting this.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
Christophe
Joined: 10 May 2005 Posts: 323 Location: Belgium
|
|
Posted: Mon May 14, 2007 7:53 am |
|
|
I've succesfully implemented some PS2 library from the forum:
http://www.ccsinfo.com/forum/viewtopic.php?t=25673
Now this code is not working @4Mhz. It's working @12Mhz.
My application is working @4Mhz but has a lot of interrupts, a serial parser,... So now there are some things I can do:
1. My application has to run @20Mhz. Then I should try to get the keyboard routine to work with all other interrupts + my main program is relatively large + slow. I have to modify all timer settings and other to run @20Mhz.
2. I use a seperate small 8-pin PIC _only_ for reading the keyboard and serially communicating (sending the keycodes) with the main PIC16LF877A.
In my main app. I will have to use software UART to communicate with the PS2-PIC.
To me solution 2 is the easiestn but more expensive. however solution 1 would ask more software adaptation. Not sure if it's going to work as timing is critical to read the PS2 packet.
What would you advice to do? |
|
![](templates/subSilver/images/spacer.gif) |
Christophe
Joined: 10 May 2005 Posts: 323 Location: Belgium
|
|
Posted: Mon May 21, 2007 8:32 am |
|
|
Ttelmah wrote: | The PS/2/AT spec, requires that the interface to the keyboard is 'enabled', by drawing both clock and data lines high. The keyboard replies with a completion code. This is sufficiently different from the initialisation used in USB, that the chip in the keyboard can tell them apart, and switch modes.
The 2.4v level, is in the original IBM PC documentation for the AT keyboard interface, so keyboards should be pretty reliable at accepting this.
Best Wishes |
Here I have such a keyboard:
BENQ mini AT keyboard: http://www.benq.nl/products/preview.cfm?id=66078
When I open the housing, I have a small PCB with V+, GND, D+ and D-
When I connect this interface to my PIC interface; It won't send characters.. ( a normal AT keyboard does ) Is there something you have to do to enable PS2 mode? What could be wrong? |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Mon May 21, 2007 9:10 am |
|
|
Have you got the pull-up resistors on the lines?. The PC, normally has a 10K pullup on each line. This is what makes the lines go 'high', when they are set as inputs in the Init code. I'd guess that your other keyboard, has TTL inputs, which just happen to float high, while the CMOS inputs on the latter keyboard, need the pullups present. The normal PC circuit, also has a 47pF on each line to GND, to just help smooth the edges slightly.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
|