Read in joystick that outputs serial vlaues.
bboy8012
Posts: 153
I have the logitech wingman 3d the gameport one. I am trying to get pointed in the right direction to read in the data. I seen that it sends the data serialy through the buttons. I am wondering on how to start reading those in. Attached is what I have so far, and info that I found on the joystick. My overall goal is to read in these bits from the joystick, then output them IR to a RC toy (working on the IR protocol for the toy right now).
{{ Read in the serial data from the Logitech Wingman 3d Digital Extreme joystick. Here is some info on the joystick: The LTWMED uses an interesting technique for timing the data stream. It doesn't use a clock bit, but rather uses two bits per data 'channel'. Because there are four buttons available, there are two data channels. Buttons 0 and 1 carry the upper 21 bits of the data packet, buttons 2 and 3 carry the lower 21 bits, making it 42 bits total. It seems that Logitech joysticks are capable of switching into a mode where they only use two of the four buttons. Unlike the other joysticks, LTWMED sends the packet MSB first, except for the buttons, which are sent LSB first ... The two bits are used as follows: When 1 is transmitted, the upper bit changes state, and when 0 is transmitted, the lower bit changes state. Transmission speed is 100 kHz (200 kbit/sec), packet takes 320 us to transmit. Bit breakdown: Bits Meaning 0 .. 3 - Hat (4 bits) 4 .. 9 - Buttons (6 bits) 10 .. 17 - Axis 2 (Twist) (8 bits) 18 .. 25 - Axis 1 (Y) (8 bits) 26 .. 33 - Axis 0 (X) (8 bits) 34 .. 41 - 0x00 (8 bits) }} CON _xinfreq = 6_250_000 _clkmode = xtal1+pll16x 'The system clock is set at 100MHz button0 = 16 'Buttons 0 and 1 carry the upper 21 bits button1 = 17 button2 = 18 button3 = 19 'Buttons 2 and 3 carry the lower 21 bits VAR long Null[1], x, y, twist, slider byte joybuff[42], Rx OBJ fdx : "FullDuplexSerial" 'serial driver PUB readJoystick Null[0] := 0 PUB x_Axis return x PUB y_Axis return y PUB slider_Axis return slider PUB twist_Axis return twist
Comments
I think with a 100kHz frequency you should rather write a driver in PASM. With SPIN this will be tricky.
WAITPNE is propably the instruction you need.
First you read the input pins. And then you wait until one of the pins has changed (per channel). You read the input pins again and check which PIN has been changed. If button 0 has been changed you shift in a 0, if button 1 has been changed you shift in a 1. Then you wait again until you read all 21 bits.
What does button mean in this context?
How are the packets divided from each other? Is there a gap between the packets? How long? What does the gap look like, GND on both PINs or no more high/low transition? Do you have a scope? Are the bits from the different channels in sync?