of mice and i2c

I'm recently attempting to get direction data off of an optical mouse.

As far as I've been able to tell, the sensor itself has an i2c connection for the data. This connects to a chip that deals with the USB/PS/2 connection. While I'd like to try to use one with the PS/2 at some point, I already had this one part way ready, so I'm trying the i2c. This is probably something I'll want to use in the future anyway, so the practice is good. Even though the optical mouse library seems to be working with it, I'd like to figure out what's wrong with this setup.

I took the mouse apart, and soldered wires to connect the sensor IO pins directly to the data pins on the small connector that takes the cable that goes to the computer. I also cut the traces connecting the connector pins to the connector, so it wouldn't interfere. I'm now contemplating doing the same between the sensor and the interpretor chip too--the board gives me a connector, the LED, crystal for the sensor, and other stuff I figured would be good.

Here's the code I'm using:

#include <Servo.h>
#include <Wire.h>
#include <WString.h>
#include <SoftwareSerial.h>


String serialString = String(5);//string for taking data from computer
String mouseString = String(10);//i2c data

int deltaX = '0';
int deltaY = '0';
Servo servo;
boolean doloop = true;
boolean maybe = true;

void setup(){
  Serial.begin(9600);
  Serial.println("delta x and delta y");
  Wire.begin();
  servo.attach(2);
  servo.write(90);  
}

void loop(){
  Wire.requestFrom(1, 2);
  while (doloop == true)
  {
    char c = Wire.receive();
    mouseString.append(c);
    deltaX = atoi(mouseString);
    mouseString ="";
    Serial.println("test");
    Serial.println(deltaX);
    doloop = false;
  }
  delay(2000);
  doloop = true;
}

The servo library is in there so I can play with the servo with the mouse later--the intention is to be able to use the sensor to find speed and direction change on a robot, so moving the servo is a good first step.

The problem I'm having is that the code freezes at the requestFrom function call. If I pull out the power lines for the mouse to reset it, it'll loop around, but stop there again(put a println("test1", "test2", etc at places to find the stopping point)the next time around.

I'm not sure it's getting stuff from the mouse. I'm inclined to say I need to send a signal to the mouse beyond the request and receive functions to get an answer, actually tell it to send me stuff or something.

There is no obvious answer.
(1) Is the electrical situation at the I2C o.k. Pull up e.ct.? Best use an oscilloscope.
(2) There are issues with the I2C library wrt to bus time outs. There is thread here somewhere with a workaround...
(3) You of course need to know the protocol... Is it a specific chip in the mouse? Most likely not - it will be a PIC in disguise and EVERYTHING is possible... Search the web for mouse hacks...
(4) But you might get hints from the other side... The I2C USB-PS/2 chip might be well documented...

The "translator" chip in the mouse is a specific one, I found the data sheet for it and it's intended for USB and PS/2 interfacing for stuff like mice. It's not the problem.

Since the mouse library works, I'm guessing it's on the programming side. I'll be studying that more soon.

Start simple and basic. Especially if you are having problems.

I am. I'm getting the data to come out of the mouse, then I'll be getting the data in the right form, then I'll be doing the servo control. Slowly building the bigger projects, until I have everything doing what I need it to for the really big project.

This is off topic, but if there's an i2c to usb chip in there, it could be a dirt cheap way of interfacing the two protocols without a very expensive commercial unit.