Shop OBEX P1 Docs P2 Docs Learn Events
Interfacing with a Sony Playstation 2 Controller — Parallax Forums

Interfacing with a Sony Playstation 2 Controller

Jim FouchJim Fouch Posts: 395
edited 2009-02-17 13:04 in General Discussion
I've seen some code for interfacing an older PS controller w/ a BS2.

Does anyone have any details to do the same with a PS2 & the SX?

I'm not looking to use any of the force feedback features. Just read the buttons and Joystick positions.

I'd even be interested in doing the same for any other game controllers. (XBox or Game Cube)

Thanks,

Jim Fouch

Comments

  • SeanLSeanL Posts: 10
    edited 2005-10-04 19:38
    As far as the Game Cube controller goes, I have no clue. I've never seen anything about them.·But I can tell you that·the XBox controller is a USB v1.0 device. In order to connect one of them to an SX would mean that at the very least you would have to create a USB v1.0 compatible·master. Unfortunately, I've never seen any examples this. I don't think it would be impossible to connect either the XBox or Game Cube controllers to an SX. But, I do think you would be treading new waters.

    I'm pretty sure the PSX and PS2 controllers·are interchangable. The only code I've seen for connecting a PSX controller to a BS/2 was a Nuts & Volts column located here: http://www.parallax.com/dl/docs/cols/nv/vol4/col/nv101.pdf
    I'm going to guess thats probably what you saw also, if not you might want to check it out. I imagine you should be able to port the code using SX/B without too much difficultly.
  • Jim FouchJim Fouch Posts: 395
    edited 2005-10-04 19:48
    Thanks,

    This is some good info. Basically, I'm looking for·a quick & cheap way to control my camera & mount for video recording. Controllers can be picked up for $10 or so and a few dollars more to interface it with an SX.· :-)
  • SeanLSeanL Posts: 10
    edited 2005-10-04 20:23
    Since you didn't say what kind of camera you are using, this may not·work for what you are doing. But, you might want to check out this·thread: http://forums.parallax.com/showthread.php?p=540998

    If that thread does nothing for you·might want to consider·something else. It would involve a bit of work, but you could take one of those $10 controllers and rip the thumbsticks out and use them with a few cheap pushbuttons to make you own custome controller. If you're clever enough, you could use the original controller housing and just build a new circuit board to put inside it. That would eliminate the need to build an interface since you would be wiring the thumbsticks and the pushbuttons directly to the SX. That would·cut down on the coding quite a bit. Heck, if·theres enough room inside the controller housing you could go all out and make it battery powered and use an IR or RF interface to control everything.
  • Jim FouchJim Fouch Posts: 395
    edited 2005-10-04 20:46
    That's funny....· I'm the one that posted and wrote that code to control the camera....· ;-)

    I'm looking at interfacing also to a JVC camera too. It also uses an IR control. I don't have the JVC yet, but I hope it uses the same 38Khz or 40Khz carrier signal.
  • SeanLSeanL Posts: 10
    edited 2005-10-05 00:24
    LOL, that is funny. smilewinkgrin.gif
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-10-05 00:29
    When I return to Dallas I will be writing an SX interface for the PSX controller, and I will include force feedback control. My project is a one-wire serial to PSX converter for BASIC Stamps. The module will let the user communicate with four individual PSX controllers.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • cbmeekscbmeeks Posts: 634
    edited 2005-10-06 12:58
    Jon Williams (Parallax) said...
    When I return to Dallas I will be writing an SX interface for the PSX controller, and I will include force feedback control. My project is a one-wire serial to PSX converter for BASIC Stamps. The module will let the user communicate with four individual PSX controllers.

    That would be AWESOME!!!

    Please post it in the main forum....or better yet, add me to a mailing list when it is done...I have a ton of projects that would benefit from using a PSX controller...

    Thanks!

    cbmeeks

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    http://metroidclassic.com

    =========
    DMCA Sucks
    RIAA Sucks
  • PJMontyPJMonty Posts: 983
    edited 2005-10-06 17:10
    Jim,

    It sounds like you're looking for code to control the SX, but if you're interested/willing to roll your own, here's a page with all the tech specs on PSX controllers:

    www.gamesx.com/controldata/psxcont/psxcont.htm
      Thanks, PeterM
  • Jim FouchJim Fouch Posts: 395
    edited 2005-11-18 15:50
    I have been able to interface with a standard PS2 wired controller pretty nicely. However, I'd like to get a wireless Logitec to work. For some reason it does not talk back like the wired one.

    Has anyone else ever done a wireless one?

    Once I get my code looking nice, I'll post what I have so far.

    I'm also making a DLL that will read from the SX's serial port all the readings from the PS2 controller. This will allow easy intergration with VB or any ActiveX aware software. Right now I have my readings down to about 2ms.

    Jim
  • TD-LinuxTD-Linux Posts: 33
    edited 2005-11-19 18:00
    I have been able to interface with a PS2 controller, but I never have been able to get the force feedback working. I thought that the motor speeds were sent at the same time as the buttons were read in, but I could not get that to work.

    Did anyone ever win the Basic Stamp in the contest to get force feedback working? (September 2003 Stamp Applications)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    SX-Key + SX52 + Proto Board + SX-Key Software + Computer + USB to Serial Adapter + LED = Blinky LED!
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-11-19 23:16
    I spent all day messing around and could not get force feedback working either.... I guess I will have to up the ante, perhaps offering PDB to the first person who gives me code that I can port to the SX. My version is like our AppMods in that it communicates back-and-forth over one wire, and I allow the Stamp to setup and control the bits on RC (read and write) as well.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Jim FouchJim Fouch Posts: 395
    edited 2005-11-19 23:21
    I've worked all day and have found that the Playstation 2 controllers give alot more information then the 6 bytes in the N&V column from a few years ago. I have found pressure readings on ALL buttons. I'm working on making an SX program to dump all the data exchange between the PS2 & controller. I should have the codes that the make to motors spin by later tonight. smile.gif

    Post Edited (Jim Fouch) : 11/19/2005 11:30:59 PM GMT
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-11-19 23:42
    I'm not sure I follow. I found lots of code around the 'net and there is never more than six bytes returend: two for the pad buttons and four for the analog joysticks. I don't have a Playstation otherwise I would build a breakout cable and connect a logic analyzer -- that would answer a whole bunch of questions.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Jim FouchJim Fouch Posts: 395
    edited 2005-11-19 23:50
    I thought the same thing.... I was wrong. I'm using a Playstation 2 (Slim one) and a Logitech wireless and also an off brand controller.

    If you use the samples from the web it will report back just like they say. But, if you hook a scope to a PS2 that's talking to a controller, you will see that the PS2 will have a longer conversation with the controller. It's like 21 bytes in length. Starting With Byte Zero being the PS2 sending a $01, the Controller (Both that I have tried) will send back the normal info, then starting with the 8th byte it will send the pressure (how hard you are pressing the buttons) for each button!!!! There are 12 extra bytes send. Each being a value from 0-255. This seems to only work when the controller is in the digital mode.

    It was like finding GOLD. I didn't know the controllers even had sensors for how hard you were pressing the buttons.

    Jim
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-11-19 23:54
    Hmmm ... I couldn't get it to read anything after the normal packet except 255 -- no matter what mode the controller was in.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax

    Post Edited (Jon Williams (Parallax)) : 11/20/2005 12:00:02 AM GMT
  • TD-LinuxTD-Linux Posts: 33
    edited 2005-11-20 02:03
    What data request byte is the Playstation 2 using? Maybe there are different ones for PS1 controllers (digital, analog) PS1 DualShock, and PS2 Dualshock (the one with pressure-sensitive buttons). Right now, the PS1 compliant interface we are using has $42 as the data request byte.

    FYI - ony PS2 controllers can measure the pressure of each button. That's one of the most useful things to come out of a Best Buy video game department salesman. turn.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    SX-Key + SX52 + Proto Board + SX-Key Software + Computer + USB to Serial Adapter + LED = Blinky LED!
  • Anvilus9Anvilus9 Posts: 2
    edited 2005-12-06 05:24
    I am new to this forum and have successfully interfaced a Basic Atom to Playstation PS2 game controllers.

    My code can read the mode, buttons and joysticks, and it can set both rumble motors. The problem with setting rumble motors is that the PS2 controller clocks the button bytes out at the same time it clocks the motor control bytes in. Consequently, you must read the buttons with one request, and then set the motors and read the joysticks with another request.

    I have tried to read pressure values from the buttons but have not been successful.

    The code works for cord controllers that I have tried, but did not work for a LogiTech cordless. I just ordered a Madcatz cordless to try based on several posts at Lynxmotion.

    My goal is a cheap short range radio for 1/6 scale RC paint ball tank combat www.rctankcombat.com

    I can provide Atom code if you wish.
  • BeanBean Posts: 8,129
    edited 2005-12-06 12:10
    Anvilus9,
    Yes please post that code. I'd love to see it, and I'm sure Jon Williams will too.
    Thanks. And Welcome to the Forums.
    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video·Module" Now available from Parallax for only $28.95

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

    "SX-Video OSD module" Now available from Parallax for only·$49.95
    http://www.parallax.com/detail.asp?product_id=30015

    Product web site: www.sxvm.com

    Those that would give up freedom for security will have neither.
    ·
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-12-06 12:38
    Yes, do post your code (or send it to me offline and I'll translate it)·as I have not been able to find reliable motor-control information (I can make the motors run, but there is no real control or repeatability).· My SX project is here: http://forums.parallax.com/showthread.php?p=559762

    You'll see there's a subroutine called PSX_SHIFTIO that can send and receive data at the same time.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax

    Post Edited (Jon Williams (Parallax)) : 12/6/2005 12:58:03 PM GMT
  • T&E EngineerT&E Engineer Posts: 1,396
    edited 2005-12-06 12:44
    The XBOX controller has a straight USB signal with an extra control line (tells which 1 of the 4 are plugged into the XBOX) which can be ignored. They sell XBOX to USB adapters for PC's.
  • ShadowDragonShadowDragon Posts: 51
    edited 2005-12-13 15:12
    I think i might have found some useful info on the wireless controllers, this might be a littl confusing but, go to http://forums.parallaxinc.com/gullfoss2.fcc.gov/prod/oet/cf/eas/reports/GenericSearch.cfm and for the Grantee code enter in "P25" and in the product code box enter in "Gomc82". then press enter, and click on the detail link of the first item in the list. then click ok, then there will be a list of useful data for the madcatz wireless contoller.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I watch how the moon sits in the sky on a dark night,
    shining with the light from the sun,
    The sun doesn't give light to the moon,
    Assuming the moons gonna owe it one,
  • ShadowDragonShadowDragon Posts: 51
    edited 2005-12-13 15:13
    I think that this link might work also: http://forums.parallaxinc.com/gullfoss2.fcc.gov/prod/oet/forms/blobs/retrieve.cgi?attachment_id=517748&native_or_pdf=pdf

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I watch how the moon sits in the sky on a dark night,
    shining with the light from the sun,
    The sun doesn't give light to the moon,
    Assuming the moons gonna owe it one,
  • Anvilus9Anvilus9 Posts: 2
    edited 2005-12-20 04:48
    I modified Jon's code from his Nuts and Volts article to set motors and read button pressures on a PS2 controller using a Stamp SX. The file "ps2_motor.bsx" sets and locks standard analog mode and sets rumble motors. The file "ps2_pressure.bsx" sets and locks analog DS2 native mode (?) and can also read button pressures. I did not include the hardware inverter for the CLK line discussed in Jon's article so this code runs very slowly. Both programs work great for my tethered PS2 controller but do not work for a cordless MadCatz.

    Joe
  • TechnoRobboTechnoRobbo Posts: 323
    edited 2006-08-03 03:27
    ps2 wireless with a bs2:

    ' {$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
  • holorobholorob Posts: 1
    edited 2009-02-17 13:04
    I've seen this code in several posts.· It works fine on my wired controller with inverted clock.· Not as lucky with the wireless one.· It's a Mad Catz 2.4ghz.· I get confirmation that the controller is talking to the receiver however, the receiver isn't talking to the BS2.· Lots of 1's and 255's. I hear timing might be an issue.· Can you give me an idea about how to tweak the timing to match my controller?· I want o use your code because it looks cleaner that the others.



    Thanks
Sign In or Register to comment.