Help with PS/2 dev library keyboard mouse implementation

Hi, I am trying to emulate the Arduino Uno to behave like a Ps/2 mouse to control the computer. At this point, all I want is to have the Arduino connected to 4 buttons which would then make the cursor go up, down, left, right.

Here’s what I have done so far:

I have downloaded Arduino 1.0 and put the ps/2dev library in the proper Arduino folder.
I have changed all WPrograms.h or WConstants.h to Arduino.h in the library files.
I have obtained a PS/2 to USB converter: http://www.trendnet.com/products/proddetail.asp?prod=155_TU-PS2&cat=49. I know that the PS/2 implementation requires an active adapter, but I am not sure if the one I got is an active one.
I have read through www.computer-engineering.org, however do have some trouble understanding the protocol.

Here’s my problem:

I have connected the arduino to the PS/2 adapter using the right pin layout provided by www.computer-engineering.org. When I plug in the PS/2-USB adapter to the computer, it recognizes the connection and proceeds to install the driver files. In the devices and printers window, a new device shows up as USB keyboard/mouse. However, when I uploaded the sample script provided by the PS/2dev library, nothing happens when I plug in the PS/2-USB converter. I believe the sample script is to move the cursor diagonally.

Here’s what I tested:

I have tried to connect a normal PS/2 mouse to the PS/2-USB adapter to the computer. It works fine. However, I am not sure if the adapter is an active one.
I have used an osccilloscope to test out the signal coming out of the clock and data pin of the Arduino. There are square wave pulses: clock pin provides a burst of what I believe to be clock signals; data pin provides a pattern of square wave signals. However, I am really not sure how to read the wave forms. I do know that mouse signals are 3 bytes, with the 2nd byte and 3rd byte representing x and y movements respectively. When I measure the signal coming out of a normal PS/2 mouse, the signal is similar to the ones created by Arduino, but slightly different.
I have tried to implement the keyboard code provided by royboy from silicon republic. However, the same result ensues.

I have read through the library of the PS/2 and have some trouble understanding the read and write function. They both provide a clock signal, however, I did not understand the operation of the if loops going from i = 0 to i < 8.

I am also not sure about this part:

 unsigned char  c;
  if( (digitalRead(3)==LOW) || (digitalRead(2) == LOW)) {
    while(mouse.read(&c)) ;
    mousecommand(c);
  }

Why does the pins have to be low for both? I though the normal operation is for both to be High? Also, where is the c coming from?

I am really not sure what is casuing problem and hope that someone can shed some light on this.

Thank you very much for your time.

I have exactly the same problem. I know this isn't sovling anything, but i connected it to my laptop, which has a standard built-in PS/2 port, and it doesn't do anything. It does not even recognizes it. I connected all the 4 pins as it should, but still nothing happens.

So that means it won't be the because of your adapter i think..

Thanks for the confirmation. It probably not the adapter's fault, but I really have no idea what is going on? Anyone that can help?

Thank you in advance!

Just a little update, I uploaded the original sample script again and was able to capture a signal on my oscilloscope. If I am reading this correct, then it said FF, FA, AA, 00, which represents reset, ack, passed self test and get mouse ID. The mouse on the screen still does not move....

A little more update here,

I looked through the sample script from the ps2dev library and couldn't help but noticing the variable enabled. It was set to 0 in the beginning and hence the changes to delta_x and delta_y were not made. I changed the initialization of enabled to 1 and sure enough the delta_x and delta_y were changing. Inside that part, the write_packet function was also called.

I changed the delta_x and delta_y in the write_packet function both to 0xFF. On my oscilloscope, the initialization byte FF, FA, AA, 00 came up once. After that, the signal FF for byte 2 and 3 keeps coming up. This is telling me that my problem probably doesn't lie in the script or that the arduino is not producing the right output but rather there is something wrong with the transmission.

My next step is to try finding a ps2 mouse computer and plugging it in. I am also going to try reading through the library to see if there are compatibility problems with script.

Thank you for your time, cyclop_op

Hi, it is me again.

I did more work on this again and have achieved some different results.

First of all, I was able to alter the script to get some more signals out of the Arduino. I had to comment out the enable line in the main loop. Then with the oscilloscope, I was able to capture a steady signal producing what I programmed.

This signal was mistakenly fed into the keyboard PS/2 plug and into the computer using USB. This produced a string of repeating 1s (I commented out the enable and the delay). Sometimes it would be '1’s, sometimes 'i’s, sometimes ‘x’. When the plug was changed back to the mouse, nothing would happen.

I had some other people go through the circuit. We came to the conclusion that the computer is actually not recognizing the USB input of the Arduino, but rather recognized the PS/2-USB converter. This was discovered that even without the Arduino connected to the converter, the computer would still recognize a device when the converter is plugged in.

I also discovered that after plugging in the converter with the Arduino, and then removing just the Arduino, the strings of character would still continue to print. This may be due to the converter itself.

I also try to plug the Arduino into as a computer which uses PS/2 as an input, but that device did not recognize Arduino at all.

So in conclusion:

  1. Although we had something on the screen, this may simply be due to the converter.
  2. The computer did recognize the PS/2-USB converter and not the Arduino.

Anyone else getting these results?

I think the next step is to try reading over the script and looking at how mouse are initialized. Looking into how the mouse and the host device communicates would also be a good idea. I am also thinking of using the oscilloscope to look through the signals of an actual mouse would be a good exercise too. Any suggestions?

Any suggestions, advices and pointers would be deeply appreciated.

cyclop_op

i appreciate your work, since i would like it too. there are people who did this before, o maybe we have to find a code from one that works?

Hey Steen,

I am actually working on this project with a couple other people and moving the mouse with the Arduino is just a part of it. After some more trying and experimenting, we couldn't get it to work. Because of time constrains, we decided to move onto other methods. We ordered a Teensy board which is another processor that allows USB interface and mouse emulation. After we got the chip, we just hook up the inputs from Arduino and the mouse was controlled by the outputs from the Arduino through the Teensy. It was really easy, the soldering, programming and implementation took less than 2 hours. So if you still want to emulate a mouse, I say get a Teensy and Bob's your uncle.

cyclop_op

oh ok then, i'll have a look at it :) thanks for that hint, it sure can be useful