Hoping somebody can help point me in the right direction.....
Note: Code Attached
I'm working with a Teensy 3.1, the latest Teensyduino, the latest Arduino, and am using a self-rewritten version of the Arduino PS2 Mouse library to interface with several PS2 mice.
I built an adaptor for PS2 connectors, and have the mice directly connected to the Teensy 3.1, powered off 5v from VUSB. Level shifting is not needed for IO as 3.3v is logic high for 5v systems.
I know my implementation of the protocol is correct as I receive correct responses(specific acks, data) to commands.
The following applies to 3 entirely different PS2 mice I've tried (2 ball, 1 optical)...
When moving, particularly in a negative direction, I'm receiving odd data packets. The movement bytes, representing ticks of movement in x/y will, very often, be far larger than they should and/or in the wrong direction.
The following is my data conversion code, adapted from a linux driver:
I've tried different equations and algorithms, several adapted from linux drivers, and most output the same results as the above code.
I've spent the last two days fiddling with my code trying to figure this out and I've run out of ideas.
While the PS2 protocol is fairly simple, troubleshooting seems very esoteric. I'd appreciate it if anyone could help give me some insight as to what's going on.
I've formatted my data out as x/y columns with coding for sign bits and overflow (s = sign bit, o = overflow bit, v = ?Delta value).
Moving west I receive odd data:
Moving south-west I received odd data:
Moving north-west I received good data:
Note: Code Attached
I'm working with a Teensy 3.1, the latest Teensyduino, the latest Arduino, and am using a self-rewritten version of the Arduino PS2 Mouse library to interface with several PS2 mice.
I built an adaptor for PS2 connectors, and have the mice directly connected to the Teensy 3.1, powered off 5v from VUSB. Level shifting is not needed for IO as 3.3v is logic high for 5v systems.
I know my implementation of the protocol is correct as I receive correct responses(specific acks, data) to commands.
The following applies to 3 entirely different PS2 mice I've tried (2 ball, 1 optical)...
When moving, particularly in a negative direction, I'm receiving odd data packets. The movement bytes, representing ticks of movement in x/y will, very often, be far larger than they should and/or in the wrong direction.
The following is my data conversion code, adapted from a linux driver:
Code:
int xDelta = ((byte_status & 0x10) ? 0xFFFFFF00 : 0) | byte_x;
int yDelta = ((byte_status & 0x20) ? 0xFFFFFF00 : 0) | byte_y;
I've tried different equations and algorithms, several adapted from linux drivers, and most output the same results as the above code.
I've spent the last two days fiddling with my code trying to figure this out and I've run out of ideas.
While the PS2 protocol is fairly simple, troubleshooting seems very esoteric. I'd appreciate it if anyone could help give me some insight as to what's going on.
I've formatted my data out as x/y columns with coding for sign bits and overflow (s = sign bit, o = overflow bit, v = ?Delta value).
Moving west I receive odd data:
Code:
x=s0o0v245 Y=s0o0v255
X=s0o0v245 Y=s0o0v0
X=s1o0v-11 Y=s0o0v0
X=s0o0v246 Y=s0o0v255
X=s0o0v0 Y=s0o0v255
X=s1o0v-11 Y=s0o0v0
X=s1o0v-256 Y=s0o0v0
X=s1o0v-256 Y=s0o0v0
X=s1o0v-7 Y=s0o0v0
- (s)ign bits are mostly correct, but some oddities
- (v)alues are partially correct given the sign
Moving south-west I received odd data:
Code:
x=s0o0v246 Y=s0o0v0
X=s0o0v246 Y=s0o0v228
X=s0o0v245 Y=s0o0v0
X=s0o0v0 Y=s0o0v231
X=s0o0v0 Y=s0o0v231
X=s0o0v0 Y=s0o0v231
X=s0o0v246 Y=s0o0v231
X=s0o0v243 Y=s0o0v231
X=s0o0v0 Y=s0o0v0
X=s0o0v243 Y=s0o0v231
X=s0o0v0 Y=s0o0v231
X=s0o0v0 Y=s0o0v231
X=s0o0v243 Y=s0o0v232
X=s0o0v243 Y=s0o0v231
X=s0o0v243 Y=s0o0v232
- (s)ign bits should be 1, not 0
- (v)alues should be negative, not massive positive values
Moving north-west I received good data:
Code:
x=s0o0v0 Y=s0o0v9
X=s0o0v0 Y=s0o0v9
X=s0o0v9 Y=s0o0v10
X=s0o0v10 Y=s0o0v10
X=s0o0v9 Y=s0o0v9
X=s0o0v10 Y=s0o0v10
X=s0o0v10 Y=s0o0v0
X=s0o0v10 Y=s0o0v10
X=s0o0v0 Y=s0o0v12
X=s0o0v10 Y=s0o0v0
- (s)ign bits are correct
- (v)alues are correct and of the correct magnitude.
Attachments
Last edited: