Shop OBEX P1 Docs P2 Docs Learn Events
Read in joystick that outputs serial vlaues. — Parallax Forums

Read in joystick that outputs serial vlaues.

bboy8012bboy8012 Posts: 153
edited 2011-01-18 18:22 in Propeller 1
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

  • MagIO2MagIO2 Posts: 2,243
    edited 2011-01-18 15:06
    Hi bboy,

    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?
  • bboy8012bboy8012 Posts: 153
    edited 2011-01-18 18:22
    Yes I have the parallax usb scope, wow, I thought this would be kinda like reading gps data, I guess I have to start my research. Any places to start, especially with PASM, I checked the stickies and there giving me 404 errors? Would this driver be doable by a beginner, barely started getting spin. As for the other information you asked I am in the dark about that. All my info is from this site http://atrey.karlin.mff.cuni.cz/~vojtech/joystick/specs.txt
Sign In or Register to comment.