PS2Keyboard Library with Flexible USB/PS2 Keyboard

Status
Not open for further replies.
I am using a Arduino Leonardo to try to interface a Flexible USB/PS2 Keyboard using the PS2Keyboard Library version 2.4. The keyboard is obtainable from Jaycar an Australian electronics outfit, and is flexible and immersible. It is labelled Digitech and is of Chinese origin. I suspect a link with Freescale or NXP. It works happily as a USB-connected Apple Mac or Windows device. It has a PS2 adapter plug which is just wire to wire passive.

I do not have a CRO, but have adapted the 2.4 code to debug the connection in various ways. I am pretty sure that it is trying to talk PS2 protocol rather than USB, as I can see an 11-bit periodicity in the clock signal, and the initial data it sends is hex AA, which it repeats as though it is expecting a host response, eventually filling the PS2Keyboard 45byte buffer, which is then discarded and refilled ad infinitum. The 'available' and 'read' functions return nothing, presumably because AA is not an expected scan code. The keyboard is also locked, and does not transport any keystrokes.

Assuming that an Ack of some sort was required, I would then require a host command capability. I tried to extend the PS2Interrupt routine to handle an 11-bit output, and provided a 'send' function to make use of it. The input still works, but there is no evidence of my output achieving anything.

I suppose I am asking for any comment (is AA a keyboard to host command and how is it responded to etc), but the extended experimental source might resonate with someone wanting to issue host to keyboard commands.

View attachment PS2Keyboard.cppView attachment PS2Keyboard.hView attachment keybrd.ino
 
I do not know. None of the (admittedly small sample size) PS/2 keyboard I've ever used have done such a thing.

Thanks Paul. I did find a reference in PS2 documentation to hex AA as a keyboard to host command indicating that the keyboard as part of initialisation has completed a hardware self-test. AA ironically is odd-even bit stream.

I decided that I need more tools or chuck it all in the bin. I found a reference to 'Processing' which has a similar IDE to Arduino, and a sketch that implements an oscilloscope. I then used an Arduino UNO to snoop on the keyboard clock and data pins via its analog ports. It will take me days to get anywhere, but it is always interesting how one dead end leads to another magical paradise.

'Processing', 'Arduino', 'Teensy' are all fabulous creations and the inventors are heaven-bound if they are so inclined.

My initial feeling with the clock and data pulses is that their mark/space ratios are all wrong, but I need to elaborate that.

Peter
 
Hi Paul,

I have managed to get the keyboard talking, which is a huge step forward. At this stage, I don't really know what particular software change has got me there. I made changes to PSKeyboard.cpp and .h to introduce a command send facility, and used that to send the keyboard an initial reset. I changed some timing quantities here and there in my own initialisation of the keyboard to make sure it was taking a PS2 route rather than USB.

So I now need to back bits out, and try to pin it down a bit.

Thanks

Peter
 
I have sorted the problem out. I pruned my debug stuff out of the PS2Keyboard library, and gradually removed any extras out of the calling test program, eventually to the point where I had no changes at all, and it was still working. Holy hell..

I then powered the keyboard off (via the Arduino USB) and it failed. I replaced the keyboard send command to reset the keyboard, and it all works very nicely. Because the PS2 protocol drives on the clock provided by the device, and the PS2Keyboard library has an interrupt routine to handle it, I have added the send capability largely within it.

Here are the files if there is any interest.View attachment PS2Keyboard.hView attachment PS2Keyboard.cppView attachment keybrd.ino
 
PS2 and Host Commands

groovy .... I knew that PS 2 was a two way protocol, but there you go ...

Hi Adrian,

Good one to get out of my hair. I have been developing on Mac OSX. I moved it to Windows (XP), and installed my version of the PS2Keyboard library. The extended PS2Keyboard by send method works there as well.

I have been developing an application common enough in Museums where you want to provide a Keyboard input to control a diorama etc, but you don't want to give anyone capability to stuff about with the application. I thought an Arduino controlling a keyboard and passing selected stuff to the host, and doing stuff like ensuring the host is alive would be a good start.

Pete
 
Status
Not open for further replies.
Back
Top