See if you can guess if this message is about it working or not working... I am at my wit's end!
@boriz & Larry: I'm interfacing directly with the chip so I don't need the PS/2 info, although I appreciate the thought and am sure others will find it useful.
And boriz, I'll let you know when I'm rich and have firm patent down!
Haku, you're awesome! It arrived this morning and I've been working on it all this afternoon. However, you guessed it, no luck as yet. So here's the low down...
These are the various datasheets and sources I'm using:
Arduino program for this exact chip that works.
This is useful for seeing the timing of the serial protocol, as it has been bit-banged: https://github.com/jgrahamc/mcs12085/blob/master/mcs-12085.cpp
This is for a slightly different chip. The only difference seems to be that my chip needs and has an external resonator.
Page 4 gives a circuit diagram which is compatible with my chip: http://forums.parallax.com/attachment.php?attachmentid=67975&d=1266753768
Datasheet for the previously mentioned Parallax kit with the previously mentioned slightly different sensor.
Pages 10 and 11 are also useful for serial timings and register addresses: http://www.parallax.com/Portals/0/Downloads/docs/prod/hardware/28560-MouseSensorKit-v1.0.pdf
What I know about the sensor's serial protocol...
- The max clock frequency is probably 2Mhz so all hspi speeds should work. (1st link "cycle time" and 2nd link p6)
- Clock idles high. (3rd link page 11 and 1st link code)
- MSB first.
- Standard operating program would be:
- Power on and wait 100ms
- Set resolution (optional)
- Check "status" register
- If "status" indicates movement, check "dx" and "dy" registers
- Back to 3
- To read "Status" register, you clock out "register address as eight bits, most significant bit first, with bit 7 cleared to zero." So in this case you would use
then you clock in the next 8 bits.
Things I'm not sure about:
- When bits are sampled by the sensor relative to the clock. 3rd link p10 would indicated that data is sampled on the rising clock edge however I don't know that and can't test it - hspisetup has no way of changing when the data is sent relative to the clock pulses, and when I try to bit bang, I just get random results [more later].
- When bits are sent by the sensor relative to the clock. Again 3rd link p10 would indicated it's on a rising clock edge, but I haven't successfully read any data form it so don't know.
Given the above, I think this should work as a setup and don't know why it doesn't:
Code:
SYMBOL rw = bit0
SYMBOL dx = b1
SYMBOL dy = b2
SYMBOL quality = b3
SYMBOL status = b4
SYMBOL config = b5
SYMBOL operation = b6
startup: hspisetup spimode10e, spislow
sertxd ("start",cr,lf)
pause 500
main:
gosub mousestatus
sertxd (#status,cr,lf)
goto main
mousestatus:
hspiout (%00010110)
hspiin (status)
return
However, all I get from the terminal is "Start 0 0 0 0 0 0 0 0..."
One thing of note though is that I was able to take my soundcard scope to this a very low speeds and if the sensor does indeed read on the rising edge of the clock, it will have trouble as the data line switches on the rising edge. No way of changing this that I can find. I've attached the scope screenshot. I've filpped the image because for some reason the soundcard reads everything inverted (tested 100% certain). The red is data, green is the clock and the first 3 bits of data are 0's decaying across the three bits.
I've tried all the different hspimodes though I'm pretty certain it should be "10e" and i've tried slowing the speeds right down using all three spispeeds (and "255") and using setfreq as low as "k31".
I have also tried completely bit banging everything with high's and lows (second attached code). However, all I just get seemingly random numbers from the terminal window on reading, I don't know why. I've also tried using the spiin and spiout bit bang commands but the spiin command doesn't work with a clock that idles high, on the firmware I'm using (sod's law). So I can't test if that's working either.
I'm using a 40X1 with apparently quite old firmware. I'm sure of the circuitry. The sensor is still in the mouse with all of that circuitry except, I've cut through the two communication lines (clock and bi-data) and have soldered long wires to those two legs which are breadboarded to the PICAXE. I've with and without pullup/down resistors (1kohm). The USB cable of the mouse is connected to the breadboard securely by it's ground and VDD, on the same supply as the breadboard. Power supplys are steady and well used and tested.
Any ideas because i'm completely stuck and shattard from trying.
Huge thanks in advance, I could really use some help on this as I don't fell I have any leads or ideas at all.
David