Shop OBEX P1 Docs P2 Docs Learn Events
PS2 Wireless Gamepad works with BS2 - Heres how — Parallax Forums

PS2 Wireless Gamepad works with BS2 - Heres how

TechnoRobboTechnoRobbo Posts: 323
edited 2009-07-09 04:09 in BASIC Stamp
Wireless requires a stricter timing. The Ti timing of "shiftout" command·is too long it needs to be 4 microseconds not 46 microseconds as listed in the help file.

Here have fun :hop.gif

' {$STAMP BS2}
' {$PBASIC 2.5}
· psxThumbL VAR Byte ' left thumb buttons
· psxThumbR VAR Byte ' right thumb buttons
· psxJoyRX VAR Byte ' r joystick - X axis
· psxJoyRY VAR Byte ' r joystick - Y axis
· psxJoyLX VAR Byte ' l joystick - X axis
· psxJoyLY VAR Byte ' l joystick - Y axis
· idx VAR Nib
· tmpout VAR Byte
· PsxAtt PIN 9 ' PSX joystick interface
· PsxClk PIN 8
· PsxCmd PIN 10
· PsxDat PIN 11

· MAIN:
· DO
··· GOSUB Get_PSX_Buttons
··· DEBUG HOME, BIN8 psxThumbL," ",BIN8 psxThumbR," ",CR'HEX2 psxID," ",HEX2 psxSta,CR
··· DEBUG "psxJoyRX = ",DEC3· psxJoyRX ,CR
··· DEBUG "psxJoyRY = ",DEC3· psxJoyRY ,CR
··· DEBUG "psxJoyLX = ",DEC3· psxJoyLX ,CR
··· DEBUG "psxJoyLY = ",DEC3· psxJoyLY ,CR
· LOOP
'
[noparse][[/noparse] Subroutines ]

· Get_PSX_Buttons:' This routine REQUIRES inverted clock signal from
··· DIR10=1
··· DIR11=0
··· LOW PsxClk
··· LOW PsxAtt
····· 'GOTO test
······ 'request data
····· tmpout=$01
····· FOR idx=0 TO 7
······· PsxCmd=tmpout.LOWBIT(idx)
······· PULSOUT· PsxClk,2
····· NEXT
····· PAUSE 1
····· tmpout=$42
····· FOR idx=0 TO 7
······· PsxCmd=tmpout.LOWBIT(idx)
······· PULSOUT· PsxClk,2
····· NEXT
····· PAUSE 1
····· tmpout=$00
····· FOR idx=0 TO 7
······· PsxCmd=tmpout.LOWBIT(idx)
······· PULSOUT· PsxClk,2
····· NEXT
····· PAUSE 1
······ FOR idx=0 TO 7
······· psxThumbL.LOWBIT(idx)=PsxDat
······· PULSOUT· PsxClk,1
····· NEXT
····· FOR idx=0 TO 7
······· psxThumbR.LOWBIT(idx)=PsxDat
······· PULSOUT· PsxClk,1
····· NEXT
····· FOR idx=0 TO 7
······· psxJoyRX.LOWBIT(idx)=PsxDat
······· PULSOUT· PsxClk,1
····· NEXT
····· FOR idx=0 TO 7
······· psxJoyRY.LOWBIT(idx)=PsxDat
······· PULSOUT· PsxClk,1
····· NEXT
····· FOR idx=0 TO 7
······· psxJoyLX.LOWBIT(idx)=PsxDat
······· PULSOUT· PsxClk,1
····· NEXT
····· FOR idx=0 TO 7
······· psxJoyLY.LOWBIT(idx)=PsxDat
······· PULSOUT· PsxClk,1
····· NEXT
··· HIGH PsxAtt
·· RETURN
END
«1345

Comments

  • HavoKaneHavoKane Posts: 109
    edited 2006-08-03 20:05
    cool, do you still hook it up the same way?
  • TechnoRobboTechnoRobbo Posts: 323
    edited 2006-08-03 23:23
    You dont have to - I do cause I already hard wired the robot.
    Here's a modified version that doesn't use the transistor in the circuit to invert the clock.

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    · buff VAR Byte(6)
    · idx VAR Nib
    · idy VAR Nib
    · tmpout VAR Byte
    · PsxAtt PIN 9 ' PSX joystick interface
    · PsxClk PIN 8
    · PsxCmd PIN 10
    · PsxDat PIN 11

    · MAIN:
    · DO
    ··· GOSUB Get_PSX_Buttons
    ··· DEBUG HOME, BIN8 buff(0)," ",BIN8 buff(1)," ",CR'HEX2 psxID," ",HEX2 psxSta,CR
    ··· DEBUG "psxJoyRX = ",DEC3· buff(2) ,CR
    ··· DEBUG "psxJoyRY = ",DEC3· buff(3) ,CR
    ··· DEBUG "psxJoyLX = ",DEC3· buff(4) ,CR
    ··· DEBUG "psxJoyLY = ",DEC3· buff(5),CR
    · LOOP
    '
    [noparse][[/noparse] Subroutines ]

    · Get_PSX_Buttons:
    ··· DIR10=1
    ··· DIR11=0
    ··· High PsxClk ' Change this to low if you use the transistor
    ··· LOW PsxAtt
    ··· FOR idy = 0 TO 2
    ····· LOOKUP idy,[noparse][[/noparse]$01,$42,$00],tmpout
    ····· FOR idx=0 TO 7
    ······· PsxCmd=tmpout.LOWBIT(idx)
    ······· PULSOUT PsxClk,2
    ····· NEXT
    ··· NEXT
    ··· FOR idy = 0 TO 5
    ····· FOR idx=0 TO 7
    ······· tmpout.LOWBIT(idx)=PsxDat
    ······· PULSOUT PsxClk,2
    ····· NEXT
    ····· Buff(idy)=tmpout
    ··· NEXT
    ··· HIGH PsxAtt
    ·· RETURN
    END

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Have Fun
  • HavoKaneHavoKane Posts: 109
    edited 2006-08-04 04:15
    err. i dont understand your reply. what i meant was, does one connect the controller the same way you would a wired one?
  • TechnoRobboTechnoRobbo Posts: 323
    edited 2006-08-04 10:29
    Sorry I was taking for granted that everybody had already built the interface.

    In the attached image is the standard interface by Jon Williams that appeared in the Nuts & Volts article.
    Note it has a transistor on the clock pin - don't need it.

    The following section of the second program is the key.
    ···· High PsxClk ' Change this to low if you use the transistor
    if you wish to use the transistor in the diagram change it to this.
    ···· Low PsxClk ' Change this to high if you omit the transistor.

    Jon Williams does recommend that a 220 ohm resistor be used in an output to protect your BS2.
    the second attachment below shows that connection

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Have Fun
    741 x 513 - 32K
    741 x 513 - 39K
  • TechnoRobboTechnoRobbo Posts: 323
    edited 2006-08-04 10:39
    Here's the link to the article i mentioned.

    http://www.parallax.com/dl/docs/cols/nv/vol4/col/nv101.pdf


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Have Fun
  • HavoKaneHavoKane Posts: 109
    edited 2006-08-04 13:23
    thanks. that answers my question exactly. off to ebgames...
  • HavoKaneHavoKane Posts: 109
    edited 2006-08-04 16:36
    im confused though. the schematic doesnt show how to interface it with the BOE-Bot. it only shows the pinout of the PS2 controller and how to prepare it to be attached to the BOE-Bot.


    Fake EDIT: nvm, im retarded. i just read thru the code, now i understand how to hook it up.
    im going to change the pins thouhg. that way i can have a remote bot, then push x for autonomous, then triangle to return to remote.
  • HavoKaneHavoKane Posts: 109
    edited 2006-08-04 23:53
    uhg, the wireless ps2 controller is $40 at EBGames. i could get 3/4 (3 quarters, not 3 of 4) of the motor controller i need for that much.
  • HavoKaneHavoKane Posts: 109
    edited 2006-08-05 00:35
    what do i connect +9 to?

    and i dont see anything in your code that pulses the servos. i have everything hooked up (except +9) and it recognizes the controller and stuff, but the servos wont move

    when i plug +9(grey) into a 9v source, the right vibrator in the contoler turns on (only when i push the analog button)

    Post Edited (HavoKane) : 8/5/2006 12:59:47 AM GMT
  • TechnoRobboTechnoRobbo Posts: 323
    edited 2006-08-05 00:49
    gamestop has pelican chameleons for 15 bucks under the Gamestop Name. The 9Volt works the rumble motors in the wired controller but·isn't necessary on the wireless. Though it was rumored on another website that·it was·necessary for some controller but that website also claimed that the BS2 couldn't read the wireless and that it read the joysticks incorrectly. That website shall remain nameless.tongue.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Have Fun
  • HavoKaneHavoKane Posts: 109
    edited 2006-08-05 01:03
    11111111 11111111
    psxJoyRX = 255
    psxJoyRY = 255
    psxJoyLX = 255
    psxJoyLY = 255

    that shows up in the debug window. no buttons do anything. i tried it on 2 different contollers
  • TechnoRobboTechnoRobbo Posts: 323
    edited 2006-08-05 01:20
    my program reads the wireless reads the joystick and outputs to the PC the values to move the servos you must add code like this (I'm assuming you don't have continous or modified servos on your boe-bot). I don't have a boe-bot I build my own design (currently a tank that fires cork balls with R-134A refrigerant):

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    · buff VAR Byte(6)
    · idx VAR Nib
    · idy VAR Nib
    · tmpout VAR Byte

    · PsxAtt PIN 9
    · PsxClk PIN 8
    · PsxCmd PIN 10
    · PsxDat PIN 11
    · Servo· PIN·12··· 'assuming it is on pin 12
    · ServoPos ·VAR· WORD

    · MAIN:
    · DO
    ··· GOSUB Get_PSX_Buttons
    ····ServoPos··=buff(4) *·2 + 500
    ··· ServoPos··=ServoPos··MIN·500
    ··· ServoPos··=ServoPos··MAX·1000
    ··· PULSOUT Servo,·ServoPos
    ··· PAUSE·10 ' reduce or remove this pause if servo acts erratic

    ··LOOP
    '
    [noparse][[/noparse] Subroutines ]

    · Get_PSX_Buttons:
    ··· DIR10=1
    ··· DIR11=0
    ··· High PsxClk ' Change this to low if you use the transistor
    ··· LOW PsxAtt
    ··· FOR idy = 0 TO 2
    ····· LOOKUP idy,[noparse][[/noparse]$01,$42,$00],tmpout
    ····· FOR idx=0 TO 7
    ······· PsxCmd=tmpout.LOWBIT(idx)
    ······· PULSOUT PsxClk,2
    ····· NEXT
    ··· NEXT
    ··· FOR idy = 0 TO 5
    ····· FOR idx=0 TO 7
    ······· tmpout.LOWBIT(idx)=PsxDat
    ······· PULSOUT PsxClk,2
    ····· NEXT
    ····· Buff(idy)=tmpout
    ··· NEXT
    ··· HIGH PsxAtt
    ·· RETURN
    END

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Have Fun
  • TechnoRobboTechnoRobbo Posts: 323
    edited 2006-08-05 01:22
    can you post your wiring schematic -and remember to press the analog button on the controller
    Oh and of course your code.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Have Fun

    Post Edited (TechnoRobbo) : 8/5/2006 1:35:26 AM GMT
  • HavoKaneHavoKane Posts: 109
    edited 2006-08-05 01:39
    schematic2.PNG

    i did.

    sorry, i dont have a camera, so i drew a schematic in mspaint. lo

    the code is yours, copy + paste

    Post Edited (HavoKane) : 8/5/2006 1:45:21 AM GMT
    867 x 598 - 36K
  • TechnoRobboTechnoRobbo Posts: 323
    edited 2006-08-05 01:45
    yeah the whole female connector male connector right left thing gets confusing - i had to hold the plug facing away from me to get it right.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Have Fun
  • HavoKaneHavoKane Posts: 109
    edited 2006-08-05 01:57
    k, it wasnt backwards.
    i have the parallax modified servos (continous)
  • TechnoRobboTechnoRobbo Posts: 323
    edited 2006-08-05 02:05
    ok now post your code

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Have Fun
  • HavoKaneHavoKane Posts: 109
    edited 2006-08-05 02:08
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    buff VAR Byte(6)
    idx VAR Nib
    idy VAR Nib
    tmpout VAR Byte

    PsxAtt PIN 9
    PsxClk PIN 8
    PsxCmd PIN 10
    PsxDat PIN 11
    Servo PIN 12 'assuming it is on pin 12
    ServoPos VAR WORD

    MAIN:
    DO
    GOSUB Get_PSX_Buttons
    ServoPos =buff(4) * 2 + 500
    ServoPos =ServoPos MIN 500
    ServoPos =ServoPos MAX 1000
    PULSOUT Servo, ServoPos
    PAUSE 10 ' reduce or remove this pause if servo acts erratic

    LOOP
    '
    [noparse][[/noparse] Subroutines ]

    Get_PSX_Buttons:
    DIR10=1
    DIR11=0
    High PsxClk ' Change this to low if you use the transistor
    LOW PsxAtt
    FOR idy = 0 TO 2
    LOOKUP idy,[noparse][[/noparse]$01,$42,$00],tmpout
    FOR idx=0 TO 7
    PsxCmd=tmpout.LOWBIT(idx)
    PULSOUT PsxClk,2
    NEXT
    NEXT
    FOR idy = 0 TO 5
    FOR idx=0 TO 7
    tmpout.LOWBIT(idx)=PsxDat
    PULSOUT PsxClk,2
    NEXT
    Buff(idy)=tmpout
    NEXT
    HIGH PsxAtt
    RETURN
    END


    the servo just sits there and spins. the controller does nothing
  • HavoKaneHavoKane Posts: 109
    edited 2006-08-05 02:09
    im so confused its not even funny
    i have a wire controller plugged in becuase the wireless one was too expensive. does your code not work with wired controllers?

    Post Edited (HavoKane) : 8/5/2006 2:14:04 AM GMT
  • TechnoRobboTechnoRobbo Posts: 323
    edited 2006-08-05 02:16
    Since your using continous servos use this code instead - it's the right joystick I believe and the analog must be "on" on the wireless

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    · buff VAR Byte(6)
    · idx VAR Nib
    · idy VAR Nib
    · tmpout VAR Byte
    · PsxAtt PIN 8
    · PsxClk PIN 9
    · PsxCmd PIN 10
    · PsxDat PIN 11
    · Servo· PIN 12··· 'assuming it is on pin 12
    · MAIN:
    · DO
    ··· GOSUB Get_PSX_Buttons
    ··· IF buff(5)<80 THEN
    ····· PULSOUT Servo,1000
    ··· ELSEIF buff(5)>160 THEN
    ····· PULSOUT Servo, 500
    ··· else
    ····· PULSOUT Servo, 750 ' or whatever your stop position is
    ··· endif
    ··· PAUSE 10 ' reduce or remove this pause if servo acts erratic
    · LOOP
    '
    [noparse][[/noparse] Subroutines ]
    · Get_PSX_Buttons:
    ··· DIR10=1
    ··· DIR11=0
    ··· HIGH PsxClk ' Change this to low if you use the transistor
    ··· LOW PsxAtt
    ··· FOR idy = 0 TO 2
    ····· LOOKUP idy,[noparse][[/noparse]$01,$42,$00],tmpout
    ····· FOR idx=0 TO 7
    ······· PsxCmd=tmpout.LOWBIT(idx)
    ······· PULSOUT PsxClk,2
    ····· NEXT
    ··· NEXT
    ··· FOR idy = 0 TO 5
    ····· FOR idx=0 TO 7
    ······· tmpout.LOWBIT(idx)=PsxDat
    ······· PULSOUT PsxClk,2
    ····· NEXT
    ····· Buff(idy)=tmpout
    ··· NEXT
    ··· HIGH PsxAtt
    ·· RETURN
    END



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Have Fun
  • HavoKaneHavoKane Posts: 109
    edited 2006-08-05 02:22
    ok, well, that fixed one problem. left joystick controls the servo, but the servo never stops moving. and the servos are centered. i just used the servo test program to make sure.
    and the servo movement is kinda erratic. even if i cahnge/remove the pause statement. and the servos doesnt stop moving if i let go of the joystick.

    Post Edited (HavoKane) : 8/5/2006 2:27:57 AM GMT
  • TechnoRobboTechnoRobbo Posts: 323
    edited 2006-08-05 02:48
    in order to use wired controllers with out the transistor do this. also note the the 750 value may differ with your servos.· Wired controllers work faster you use the transistor. the wireless code was specifically designed for wireless since it's timing is different. Also always power cycle (off/on) ·your BS2 after you upload a new program

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    · buff VAR Byte(6)
    · idx VAR Nib
    · idy VAR Nib
    · tmpout VAR Byte
    · PsxAtt PIN 8
    · PsxClk PIN 9
    · PsxCmd PIN 10
    · PsxDat PIN 11
    · Servo· PIN 12··· 'assuming it is on pin 12
    · MAIN:
    · DO
    ··· GOSUB Get_PSX_Buttons
    ··· IF buff(5)<80 THEN
    ····· PULSOUT Servo,1000
    ··· ELSEIF buff(5)>160 THEN
    ····· PULSOUT Servo, 500
    ··· else
    ····· PULSOUT Servo, 750 '<
    Please·Note
    ··· endif
    ··· PAUSE 10 ' reduce or remove this pause if servo acts erratic
    · LOOP
    '
    [noparse][[/noparse] Subroutines ]
    · Get_PSX_Buttons:
    ··· DIR10=1
    ··· DIR11=0
    ··· HIGH PsxClk ' Change this to low if you use the transistor
    ··· LOW PsxAtt
    ··· FOR idy = 0 TO 2
    ····· LOOKUP idy,[noparse][[/noparse]$01,$42,$00],tmpout
    ····· FOR idx=0 TO 7
    ········TOGGLE PsxClk·· ' note the change
    ······· PsxCmd=tmpout.LOWBIT(idx)
    ······· TOGGLE PsxClk
    ····· NEXT
    ··· NEXT
    ··· FOR idy = 0 TO 5
    ····· FOR idx=0 TO 7
    ······· TOGGLE PsxClk
    ······· tmpout.LOWBIT(idx)=PsxDat
    ······· TOGGLE PsxClk
    ····· NEXT
    ····· Buff(idy)=tmpout
    ··· NEXT
    ··· HIGH PsxAtt
    ·· RETURN
    END


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Have Fun
  • TechnoRobboTechnoRobbo Posts: 323
    edited 2006-08-05 02:49
    did you notice the toggle instructions I replaced the pulsout with?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Have Fun
  • HavoKaneHavoKane Posts: 109
    edited 2006-08-05 02:49
    ya, 750 is stopped. i already fiddled with the values. im just gonna go get the transistor, is it a pnp or an npn?
  • TechnoRobboTechnoRobbo Posts: 323
    edited 2006-08-05 02:54
    npn - if your gonna use the transistor the I suggest using the Jon Williams code it will execute faster cause it uses the shiftout shiftin commands - those commands are incompatible with wireless timing but work fast with the wired controllers

    http://www.parallax.com/dl/docs/cols/nv/vol4/col/nv101.pdf

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Have Fun
  • TechnoRobboTechnoRobbo Posts: 323
    edited 2006-08-05 02:56
    NPN

    use the Jon williams code (http://www.parallax.com/dl/docs/cols/nv/vol4/col/nv101.pdf) if your using the transistor it will execute faster.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Have Fun
  • HavoKaneHavoKane Posts: 109
    edited 2006-08-05 03:13
    one more thing. it seems like the program gets confused. when the program starts, it goes in one direction, when i change direction a couple times and let go of the stick, it goes in the other direction. do you know if the wired version only moves while holing the stick down? and when i get the wireless one, id like to have the left stick control the left servo, and the right stick control the right servo. and only move the servos while im holding the stick in a direction. is that how your program works?
  • TechnoRobboTechnoRobbo Posts: 323
    edited 2006-08-05 03:33
    the program is setup to stop the servo when the stick is centered and go forward when swung to one direction and backwards when swung to the other when you let goof the stick it should stop - if it doesnt stop then adjust that 750 number up or down. set that 'pause' amount higher if it's slow in responding. try 10 again

    the actual amount is 20 but the extra instruction add a delay. - I use the PSC servo controller so I dont have to bother with all that.· Leaves more time for the meat of the program.

    http://www.parallax.com/detail.asp?product_id=28023

    trust me you wont regret buying it



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Have Fun
  • aridaiosaridaios Posts: 57
    edited 2006-08-06 07:33
    TechnoRobbo,

    I have tried your code with a wired PS2 controller (logitech). It works fine.
    I switched it with a logitech and a madcarz wireless controller. Nothing happens.
    I use the schematic with the transistor.
    Any suggestions?

    michael
  • TechnoRobboTechnoRobbo Posts: 323
    edited 2006-08-06 07:46
    1. Did you use the very first code?? Or one of the subsequent ones intended for HavoKane?

    2. Note that the 7.6V (commanly referred to as the 9v pin) Green wire Pin 3 has been reported to be necessary on some controllers.· The pelican doesn't need it though.· I can publish the rumble code if someone wants it.

    3. also I did not include the code for automatically turning on the analog mode so make sure you do that manually.

    Oh what the heck here's the code

    ·' {$STAMP BS2}
    ' {$PBASIC 2.5}

    'i/o config
    · 'BUFF VAR Byte(3)
    · PW· VAR Word
    · buff VAR Byte(6)
    · PsxAtt PIN 9 ' PSX joystick interface
    · PsxClk PIN 8
    · PsxCmd PIN 10
    · PsxDat PIN 11
    ·'--equates---
    · tmpout VAR pw.LOWBYTE
    · idx·· VAR pw.NIB2
    · idy·· VAR pw.NIB3

    · 'inits
    ··· PAUSE 250 'give controller time to initialize··
    ··· OUTPUT PsxCmd
    ··· INPUT PsxDat
    ··· LOW PsxClk
    ··· LOW PsxAtt
    ··· FOR idy = 0 TO 8
    ····· LOOKUP idy,[noparse][[/noparse]$01,$43,$00,$01,$00,$00,$00,$00,$00],tmpout
    ····· GOSUB BitSend
    ··· NEXT
    ··· HIGH PsxAtt
    ··· PAUSE 1

    ··· LOW PsxAtt
    ··· FOR idy = 0 TO 8
    ····· LOOKUP idy,[noparse][[/noparse]$01,$44,$00,$01,$03,$00,$00,$00,$00],tmpout
    ····· GOSUB BitSend
    ··· NEXT
    ··· HIGH PsxAtt
    ··· PAUSE 1

    ··· LOW PsxAtt
    ··· FOR idy = 0 TO 8
    ····· LOOKUP idy,[noparse][[/noparse]$01,$43,$00,$00,$00,$00,$00,$00,$00],tmpout
    ····· GOSUB BitSend
    ··· NEXT
    ··· HIGH PsxAtt
    ··· PAUSE 1

    · '[noparse][[/noparse]$01,$43,$00,$01,$00,$00,$00,$00,$00]'config mode enter
    · '[noparse][[/noparse]$01,$44,$00,$01,$03,$00,$00,$00,$00]'set analog
    · '[noparse][[/noparse]$01,$4D,$00,$00,$01,$ff,$ff,$ff,$ff]'Vibration Enable
    · '[noparse][[/noparse]$01,$43,$00,$00,$00,$00,$00,$00,$00],'config mode exit

    · 'program
    · MAIN:
    · DO
    ··· GOSUB Get_PSX_Buttons
    ··· DEBUG HOME,BIN8 buff(0)," ",BIN8 buff(1) ,CR
    ··· DEBUG DEC3 buff(2)," ",DEC3 buff(3) ,CR
    ··· DEBUG DEC3 buff(4)," ",DEC3 buff(5) ,CR
    · LOOP

    '
    [noparse][[/noparse] Subroutines ]
    · Get_PSX_Buttons:' This routine REQUIRES inverted clock signal from
    ··· OUTPUT PsxCmd
    ··· INPUT PsxDat
    ··· LOW PsxClk
    ··· LOW PsxAtt
    ··· FOR idy = 0 TO 2
    ····· LOOKUP idy,[noparse][[/noparse]$01,$42,$00],tmpout
    ····· GOSUB BitSend
    ··· NEXT
    ··· FOR idy = 0 TO 5
    ····· FOR idx=0 TO 7
    ······· tmpout.LOWBIT(idx)=PsxDat
    ······· PULSOUT PsxClk,2
    ····· NEXT
    ····· buff(idy)=tmpout
    ··· NEXT
    ··· HIGH PsxAtt
    ·· RETURN

    · BitSend:
    ··· FOR idx=0 TO 7
    ······ PsxCmd=tmpout.LOWBIT(idx)
    ······ PULSOUT PsxClk,2
    ···· NEXT
    ··· RETURN

    ·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Have Fun

    Post Edited (TechnoRobbo) : 8/6/2006 8:07:22 AM GMT
Sign In or Register to comment.