PS2 Controllers (Updated 2/11/2007)

bulkheadbulkhead Posts: 405
edited 2009-10-22 - 18:41:33 in Robotics
Last Updated: February 11, 2007

Well, after my experiences with using PS2 controllers, I thought I'd start a "project thread" for the general advancement of the use of these controllers. Here, I'll post links and code that are known to work currently. Feel free to respond with any comments/questions and especially your observations or discoveries on anything about PS2 controllers.


Caption: Incase you are unfamiliar with PS2 controllers, these are what they look like. Left: Dualshock 2 clone, center: Pelican Chameleon wireless (PL-669), right: Sony Dualshock. Right Picture: Pelican Afterglo (see EDIT 2/11/2007 at bottom of post)

CURRENTLY KNOWN: Here is what information is already known about using PS2 controllers
Excellent Nuts & Volts article explaining the serial communication involved with PS2 controllers, there is code at the end for the BS2.
www.parallax.com/dl/docs/cols/nv/vol4/col/nv101.pdf

Here is a post from the BS2 forums that has updated code with the "rumble" feature enabled, as well as an "auto analog on and lock" feature. This is nice because you don't have to press the "analog" button each time you power up (If you didn't know, "analog" mode allows the 2 joysticks to be read, "digital" mode just reads the buttons).
http://forums.parallax.com/showthread.php?p=571503

For Javelin users...see attached code, it doesn't utilize rumble or auto analog on/lock (at least not yet...) but reads everything else fine.
EDIT: 10/8/2006: I have also attached the code that works for both wired and (Pelican) wireless controllers, auto analog on/lock works but I haven't tested the rumble feature (although there is code for it). The wireless Pelican doesn't have rumble anyways.

Here is a post for the SX that describes wireless control somewhat, as well as retrieving pressure readings from the buttons (there is code for the SX at the bottom).
http://forums.parallax.com/showthread.php?p=552280





CURRENTLY UNKOWN: Ok, hopefully those links should cover everything about using PS2 controllers. Now for what still needs to be figured out/done/verified.
Wireless control-after getting the wired controller working, we all wish for a wireless controller. However, it's not that simple. It seems that the playstation communicates differently with wireless controllers than it does wired controllers. I haven't been able to get a wireless controller working, and I've read mixed reviews on people getting a wireless controller to work.
EDIT 8/15/2006: see http://forums.parallax.com/showthread.php?p=599358
EDIT 10/8/2006: I got it working for the Pelican Chameleon wireless, see attached code.

Button pressure reading-perhaps not that useful, but a cool built-in feature that could could be tapped into...

Why sometimes certain Sony brand controllers won't work?-It's as simple as that. It may be the "newer" generation of controllers, or slight differences in manufacturing, but not ALL controllers seem to work.





MY EXPERIENCE: Ok, and finally...here is my experience with using PS2 controllers
DDR (Dance Dance Revolution) pad - it's a no name brand pad, and it works great! Shows up as a digital controller.

Clone of Sony Dualshock 2 controller - I think it's the same one you see on ebay for around $10. These look exactly like the Sony's but don't say "Sony" in the middle where it should (it's blank instead). Mine works great except that I've had quality issues with them (I had one where the joystick would not rebound. Perhaps the resolution isn't as good as on a real Sony too? Not sure, but if these are all you can get working, they will do the job.

Original Sony DualShock controller - I could NOT get this to work, but I know that lots people use these. For me, it won't read anything, not even the ID. Has a model letter "A". Refer to this post http://forums.parallax.com/showthread.php?p=571131 for this "model" issue. If you don't care to look at the link, basically, it seems that there are two different "models," designated by an "A" or an "H" at the bottom right of the box of text on the underside of the controller. EDIT 8/15/2006: appears that only the dual shock 2 controllers work (not DS1), although sometimes the DS2's dont work either.

Pelican Chameleon wireless controller- I could NOT get this to work either. The LED on the reciever blinks when I push a button, so the Tx to Rx communication seems to work fine. In addition, I can read the ID of this controller. I don't remember what byte its ID is returned as, but I know it changes if I push the analog button. However, I can't seem to initiate the data transfer, the status never comes back as "ready."
EDIT 8/15/2006: mountaineer has got this controller working, also see the thread about wireless controllers (linked above).
EDIT 10/8/2006: I got it working, see attached code.
EDIT 2/11/2007: Warning: don't connect the receiver to more than +5V (other controllers seem fine up to +7V, but mine stopped working)

Pelican Afterglo wired controller (ADDED 2/11/2007)-This works like a regular wired controller EXCEPT the "Set_Mode_Analog();" needs to be commented out from the constructor of the psxWiredAndWireless.java class. For some reason, this function locks the controller in digital mode instead of in analog mode. This controller, like the Pelican wireless, appears to have better quality joysticks that center at the same position everytime. The controller lights up blue when you connect the +7.5V wire that's supposed to power the rumble feature to another power source (don't connect it to a stamp's regulated +5V).

EDIT 2/11/2007:
1) Added Pelican Afterglo controller, but I did NOT update the psxWiredAndWireless.java class. To use this controller, the Set_Mode_Analog(); call in the constructor must be commented out.
2) Added warning for Pelican Chameleon wireless

EDIT 10/8/2006: I edited the attachments:
1) "psx.java" is the code I was using that has auto analog on/lock and code for rumble (although I haven't tested)
2) "psxWiredAndWireless.java" is "psx.java" modified to work with Pelican wireless controllers and the regular wired controllers. It is exactly the same as psx.java except for 3 new data fields (boolean analogOn, pluggedIn, wireless) and data shifting for the wireless controller. When you use it, you should call "psx.update()" or "psx.Get_PSX_Packet_Fast()" so that it will automatically run the function to shift the data for the joystick values; otherwise, you will need to insert the code for the shifting function elsewhere. (Slightly changed 10/10/06)
3) "WirelessPS2.txt" contains my notes for my observations of the wireless Pelican controller
4) (Added 10/10/06) Small test class "psxWiredAndWirelessTest.java" added for use with "psxWiredAndWireless.java"

Post Edited (bulkhead) : 2/12/2007 6:42:24 AM GMT
«1

Comments

  • mountaineermountaineer Posts: 27
    edited 2006-03-03 - 07:39:49
    I tried translating the BS2 code into Javelin code for force feedback and "analog on and lock" (I wrote the BS2 code for this and don't own a Javelin($uperior))
    It will probably have to be debugged since I haven't coded in Java in almost a year, so I don't remember all of the syntax.

    My Experience with controllers:
    __________________________
    MadCatz 400 series wired controller: Works great. The joysticks don't have quite as good of resolution as the Sony DualShock2. Always center at 128 so dead band not a issue. Has a dead band around the physical limits. "Analog on and lock" and rumble work well. Cheap.

    MadCatz 440 series wireless controller: Doesn't work. Link light turns on and off on the receiver as I turn on and off the controller but no information comes through. Supposedly wireless version of above controller(400).

    Sony DualShock 2 wired controller: "H" version works but "A" doesn't.(New ones I could find are "A." I bought the "H" about a year ago.) Joysticks have very high resolution (0-255 on each axis) but doesn't center in the same spot every time so software dead band is needed.


    My Wireless theory: The wireless ones probably don't work because they need more strict timing than wired. Most parallax-product based programs require varying time intervals for their read/write cycles. Other controllers(see Lynxmotion.com) have gotten wireless to work with the MadCatz Lynx wireless controller. These controllers have the same timing throughout the read/write cycle. The wireless controllers might not even use the clock line and instead use a asynchronous protocol, which is dependant on timing. It would be nice if someone could read the frequency on their clock line on their playstation(I don't have one). Also, there are varying reports on what voltage the force feedback motors run on, so it would be nice if someone could take the time to measure it on a playstation that supports a wireless controller. The wireless sender could be receiving power from this line.
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-03-03 - 09:07:52
    I corrected the compiler errors.
    regards peter
  • bulkheadbulkhead Posts: 405
    edited 2006-03-05 - 07:23:21
    Thanks mountaineer for translating the code, and Peter for fixing the compile errors. I just ran the psxCont2.java, and the auto-analog and lock feature works great! Everything else works fine too, except the rumble. I hooked the rumble power line to 6V (the same I'm using for the controller's power) and it didn't work. Perhaps I need a separate power source or higher voltage?

    I don't think the "A" is necessarily the newer version of controllers, because I got my "A" version several years back (at least 3 or 4 years). Anyone else have problems with the "A" version?
  • mountaineermountaineer Posts: 27
    edited 2006-03-05 - 21:51:41
    Heres a new version of both versions. It turns on analog and rumble each time the controller is plugged in so you can plug and unplug the controller as much as you want. I also added a couple methods to the Java version to detect if the controller is plugged in, so read the comments at the top.

    I run my rumble features on 7.2v unregulated. Make sure that you call the right method with _Vibrate appended to the end of the method name to use the rumble feature. Also make sure that you are assigning values to either vibSmall or vibLarge.

    Bulkhead- Since my "A" version was a Sony DualShock2, while yours was the original Sony DualShock, I wouldn't make anything of the time difference.
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-03-05 - 22:29:16
    Compiler errors fixed.
    What is the purpose of
    psxOut = (char)(0x00 + VibSmall);
    One could simply write psxOut =·VibSmall;

    regards peter
  • mountaineermountaineer Posts: 27
    edited 2006-03-05 - 22:49:21
    When you fixed the compiler errors last time you changed the data type of vibsmall to char. I assumed you did that because it was the wrong data type. In order to conserve memory, I changed vibsmall back to boolean and made it add 0 (0x00) in order to dodge the data type problem. I haven't coded in java in a while and forgot if you could cast upwards in the memory hierarchy or whether you had to add to the type you want. I guessed add, but i guess i was wrong. Try changeing the data type back to boolean and casting to a char. When programming with microcontroller you want to keep the variables as small as possible in order to conserve memory.

    -mountainieer
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-03-05 - 23:31:22
    You can't cast boolean to int or char.
    Instead, use char values 0 and 1 for false and true,
    then use value == 0 and value == 1 to generate
    boolean values.
    Each type (boolean,char,byte,int,short) each occupy
    2 bytes, the exception being array of char or byte
    where each element occupies·1 byte.

    regards peter
  • aridaiosaridaios Posts: 57
    edited 2006-03-19 - 16:01:39
    I have started to experiment with a sony PS2 controller.
    I have a question.
    what does"...the clock signal is inverted between the Stamp and·the controller..." mean in the PSX_Demo.BS2 file description?

    Thank you
    Michael
  • mountaineermountaineer Posts: 27
    edited 2006-03-20 - 05:44:50
    Hi Michael

    When communicating with the playstation controller the Basic Stamp requires an inverted clock signal to read the controller with any reasonable speed. This inverted line allows us to use the Basic Stamp's native functions in communications. The inverted clock line means that there is a hardware inverter between the Basic Stamp's clock out line and the Playstation controller's clock in line.

    To see a schematic of the inverter, take a look at the Nuts&Volts playstation article. I think there is a link to it in the first post in this thread. I have also attached a diagram of the hardware lines coming out of the playstaion controller. It is actual the wiring diagram for the Playstation controller hookup cable from Lynxmotion.

    Have fun, botguy
  • MiltonMilton Posts: 1
    edited 2006-04-14 - 18:52:18
    Hey everyone, I have some potentially bad news on the wireless controller front.
    I hooked up the clock output of my playstation to a oscilloscope and it looks like the official clock speed is 2.5MHz. If the wireless controllers are designed to operate only around that speed the slower chips are not going to work at all.

    Unless anyone has a wireless controller that runs fully synchronously, only people that have a quick chip will be able to match the clock.

    Its .4 us puse width, the duty cycle is 50% as would be expected.

    Post Edited (Milton) : 4/14/2006 6:57:16 PM GMT
  • mountaineermountaineer Posts: 27
    edited 2006-04-14 - 20:49:17
    The Pelican Accessories Chameleon wireless controller works with a modified version of the code that I got working on a BS2. I am using it in a competition so I will post the wireless code after the competition is over (I want to keep my competitive edge).

    Thanks for finding out that information, Milton. I've been wondering about that for a long time but couldn't find out as I do not have a PlayStation nor a oscilloscope.

    botguy
  • mountaineermountaineer Posts: 27
    edited 2006-04-14 - 20:52:39
    Oh yeah... I forgot to mention: the Pelican Accessories Chameleon Wireless controller can be seen in the picture at the beginning of this thread... its the one in the middle

    botguy
  • aridaiosaridaios Posts: 57
    edited 2006-04-25 - 20:35:52
    I tested my application with a Logitech wired controller.
    It works fine.
    I tried a Logitech cordless action controller.
    I can not receive any information but the controller ID from it.
    It seems that the controller can not establish communication with the receiver.
    Does anyone have met anything similar?

    Regards
    Michael
  • mountaineermountaineer Posts: 27
    edited 2006-04-26 - 00:10:05
    Michael,

    You can get your wirelesses controller working, with a little experimentation. Here is how:

    1. Read the raw data from your controller in binary on your computer. Press each of the buttons and write down what each one does. Each button should only change one bit and a joystick should be a byte. The Joystick's bytes may not correspond with the output bytes(i.e., the joystick info may start in one byte and finish in another).
    2. Compare your information gathered in step one to the output in the nuts and volts article, which is probably where you found your code (if not, there should be a link to in the above posts). There should be a pattern between them (i.e., the all bits have been shifted right 5)
    3. Using the pattern from step 2, make a algorithm that converts the wireless controllers data format to the standard, wired data format.
    4. Use a 'IF' statement to recognize the wireless controller's status or id. If it finds it, call gosub on the algorithm from step 3
    5. Add everything into your code.

    This model of coding will allow you to hot-swap your controllers (change controller with the BS on) and plug in different controllers without having to change your code (i.e., if your wireless has interference, you can unplug it, plug in the wired, and keep going). Hopefully, we can get a database of all different controller conversion functions going in this tread.

    What kind of basic stamp are you using?

    I promise to post my conversion algorithm for the Pelican Accessories Chameleon wireless controller right after the competition I'm in ends (may 20th).

    botguy
  • aridaiosaridaios Posts: 57
    edited 2006-04-26 - 20:45:43
    I have used BS2 and BS2p.·( PSX_Demo.BS2·)

    The results on debug window show that there is controller present (different ID from the wired one , 4 pots shows 127) but the green light on the receiver

    flashes green. I think that green light on the receiver must go off when communication with the controller·has been·established.

    Still haven't solved my problem. I will try your suggestion mountaineer, but I think I will not achieve anything till May 20th.

    I will keep trying....

    Thanks

    Michael
  • rockin_rickrockin_rick Posts: 32
    edited 2006-04-27 - 21:44:54
    I have experimented with both the OEM sony DS2 wired controller and the logitech cordless action controller (further referred to as 'logitech'). I've spent considerable testing and tweaking my routines on the logic analyzer (but never with either connected to an actual playstation). I'm clocking the CLK at ~100k, with it high for 5us and low for 5us. (The transfer of an entire extended (full analog button data, ~20 bytes) 'packet' in about 2ms).

    I can get the wired one to fully work, with all analog button data read/sent and vibrations, but the logitech doesn't work. I also believe that it is the wireless connection as the receiver sends and responds correctly. I can change the mode of the logitech (to analog or ds2 native) and it acts (reports it's mode) as expected. It (seemingly) communicates flawlessly in extended data mode by sending all '128' for the joy position data, all '0' for the analog button data, all 'off' for the digital button data (in those 2 bytes), and also ACKs for each byte transferred to it. But pushing buttons or moving the joys doesn't cause the data output to change, just like there was the wired sony was connected to it and it wasn't being touched (except the joy values.... logitech is dead on '128' for each). The green light just flashes the whole time. I thought that maybe the 'vibration power' was the key, but I've tried it with both power on it and not, no change.


    I read in the manual for the logitech:


    Step 3 "Turn on console, and then load the software. Receiver Status light blinks slowly."

    I think that this slowly blinking is what the receiver does the entire time. I wonder if the 'software' that this is referring to is just the game, or if it is software for the controller????


    Step 4 "To establish a connection with receiver, press any action button on controller. Receiver Status light turns solid green for 2 seconds (then off) when connection has been made. If controller does not connect, press Connect button on receiver, and then press any action button on controller."

    My light just always flashes no matter if I push the button on receiver, or whatever....


    I think that there must be some command sent to the controller in the initilization sequence that were missing. But, since the logitech says it works with the PS1 also, I'd GUESS that there wasn't an "advanced" code needed (based on my ASSUMPTION that the PS1 used simpler commands....) but still different than what we/I am using.

    Perhaps the CLK speed is critical, but based on the logic analyzer data, it is communicating correctly, just not changing the data.

    I've never connected the logitech to an actual playstation, just experiemented with it with a micro. I wonder if it needs to be connected once to an actual playstation to 'load the software' as referred to in the manual. Perhaps this initilizes it, and it will then work.... i'm doubtful as it's most likely not going to matter, but at this point I might just try it to rule that out as I'm running out of ideas...

    Rick
  • mountaineermountaineer Posts: 27
    edited 2006-04-28 - 00:52:52
    Hi Rick,

    You seem to have left out some information. What do you mean by "the green light" in "The green light just flashes the whole time."(2nd paragraph) What is this green light supposed to mean, and is it on the controller or the receiver. From my experience with my wireless controller, which is not made by logitech, when the receiver and controller are powered up, there should be some kind of light that comes on, either when a button is pressed or the power is turned on in the receiver or the transmitter. I realize that this is vague, but I do not own a logitech, so just look for a light that shows some kind of connection status. If you cannot turn on said light, you may have to supply a higher voltage to it through the force feedback motor supply. Take a look at the diagrams posted earlier if you do not know which pin this is. Once you get the connection light(signifying the transmitter and receiver are talking), then you should try to talk to the controller. Like I said in a earlier post, read the button data in binary and see if any of the information changes when you press a button. You should be able to work off that. From my experience, which is only 2 wireless controllers, wireless controllers use a different communications protocol than wired, but still use synchronous serial.

    What kind of Basic Stamp are you using? I'm using a BS2 and I know it takes more than the times you talked about.

    If all else fails, you could try borrowing a PlayStation and using a Oscilloscope on the output. The concept of the PlayStation loading software onto the controller seams fairly absurd to me since the controller is designed for any PlayStation and there are different firmware editions of PlayStation(I'm assuming, as there are different versions of the PlayStation controller).

    Hope this helps, mountainieer2000
  • rockin_rickrockin_rick Posts: 32
    edited 2006-04-28 - 22:32:00
    mountaineer said...
    Hi Rick,

    You seem to have left out some information. What do you mean by "the green light" in "The green light just flashes the whole time."(2nd paragraph) What is this green light supposed to mean, and is it on the controller or the receiver.

    Any and all light references in my last post was the Receiver Status light on the receiver of the logitech wireless action controller. My understanding of that light is only what the manual describes (which I posted). I've never used that logitech controller before buying it to connect to my circuit.
    mountaineer said...
    From my experience with my wireless controller, which is not made by logitech, when the receiver and controller are powered up, there should be some kind of light that comes on, either when a button is pressed or the power is turned on in the receiver or the transmitter. I realize that this is vague, but I do not own a logitech, so just look for a light that shows some kind of connection status. If you cannot turn on said light, you may have to supply a higher voltage to it through the force feedback motor supply. Take a look at the diagrams posted earlier if you do not know which pin this is.

    There is a green light on the receiver and a red light on the controller.

    I've tried power on the 'force feedback motor supply' wire, and without power on that, no difference. I tried between ~7.5V and 9V, no difference. I've measured the current drawn on that wire with the logitech and it doesn't appear to pull any current.
    mountaineer said...
    Once you get the connection light(signifying the transmitter and receiver are talking), then you should try to talk to the controller. Like I said in a earlier post, read the button data in binary and see if any of the information changes when you press a button. You should be able to work off that. From my experience, which is only 2 wireless controllers, wireless controllers use a different communications protocol than wired, but still use synchronous serial.

    I've got a 24 channel logic analyzer that can store and display timing waveforms of all the comm lines to and from the controller down to the nanosecond level. The logitech will properly communicate with my software just like a regular Sony DS2. It responds to config commands and will send 'packets' correctly. The button data in binary is always $FF - $FF (all off) no matter what you are pushing on the controller.
    mountaineer said...

    What kind of Basic Stamp are you using? I'm using a BS2 and I know it takes more than the times you talked about.

    I'm not using a stamp, but rather a midrange PIC in assembly.
    mountaineer said...

    If all else fails, you could try borrowing a PlayStation and using a Oscilloscope on the output. The concept of the PlayStation loading software onto the controller seams fairly absurd to me since the controller is designed for any PlayStation and there are different firmware editions of PlayStation(I'm assuming, as there are different versions of the PlayStation controller).

    Hope this helps, mountainieer2000

    I've thought about that and it's probably the next step if no one has already figured this out.... (although the oscope is not preferred to a logic analyzer....)

    Rick
  • aridaiosaridaios Posts: 57
    edited 2006-04-29 - 13:27:47
    Dear friends,

    I have already contacted Logitech technical department. They do not support other uses of their wireless controllers·except for PS2. Bad answer for logitech wireless controller.

    I have contacted Madcatz technical department and I am still waiting for their answer.

    I did some searching and will try some ideas out.

    Does anyone know why the wires #8(white) and #9(green) of the PSX socket are not connected?

    Michael

  • gelfling6gelfling6 Posts: 60
    edited 2006-05-29 - 21:41:39
    mountaineer said...

    MadCatz 440 series wireless controller: Doesn't work. Link light turns on and off on the receiver as I turn on and off the controller but no information comes through. Supposedly wireless version of above controller(400).
    (split)
    My Wireless theory: The wireless ones probably don't work because they need more strict timing than wired. Most parallax-product based programs require varying time intervals for their read/write cycles. Other controllers(see Lynxmotion.com) have gotten wireless to work with the MadCatz Lynx wireless controller. These controllers have the same timing throughout the read/write cycle. The wireless controllers might not even use the clock line and instead use a asynchronous protocol, which is dependant on timing. It would be nice if someone could read the frequency on their clock line on their playstation(I don't have one). Also, there are varying reports on what voltage the force feedback motors run on, so it would be nice if someone could take the time to measure it on a playstation that supports a wireless controller. The wireless sender could be receiving power from this line.

    Here's a question, bouncing on the 440.. Inside, both the controller, and the console module, there is a postage-stamp sized transceiver..

    Has anyone figured out the pin-out of that little transceiver? it appears to be a multi-signal 2.4Ghz, but as of yet, I can't figure the wiring..

    I'd love to at least see if the transceiver module, from both, could be used as a 2.4Ghz serial link, allowing a BS2 (BOE-Bot) to communicate
    back to a PC. (send video, sound, position, etc.)

    Stephen (gelfling6)
  • evergreenevergreen Posts: 43
    edited 2006-06-17 - 22:13:27
    PS2 Joysticks!

    Has anyone used a PS2 joystick? I've search for posts with joysticks, and it seems like it's difficult to perform with the average USB joystock. Check this out:
    http://www.pricerunner.com/games/game-controls/222157/prices
  • TechnoRobboTechnoRobbo Posts: 323
    edited 2006-08-03 - 03:21:12
    Yes it can be done 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
  • CelticLordCelticLord Posts: 50
    edited 2006-08-14 - 17:49:13
    I cannot get the PS2 controller working. I have tried 3 different controllers and the code has been looked over with a fine tooth comb. I need help??????
  • bulkheadbulkhead Posts: 405
    edited 2006-08-15 - 20:28:05
    First, verify if the controllers do work on a playstation.

    Next, make sure that they are dual shock 2 controllers, not the original dual shock.

    Finally, check your wiring, this is where the most things can go wrong. If you can, check every connection with a multimeter.

    If it still doesn't work, try changing to different pins. You may have a dead pin.

    The code posted should work, so I don't think it needs to be changed. For wireless controllers (or further explanation as to how communication works) see this new thread in the BS2 forums: http://forums.parallax.com/showthread.php?p=599358.
  • CelticLordCelticLord Posts: 50
    edited 2006-08-16 - 02:55:36
    The connections are correct and the controllers are all Dual Shock 2. I used the wireless code ........
    _____________________________________________________________________________________________
    ' {$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
    ______________________________________________________________________________________________________

    and not Jon Williams code since it dosent work at all with it. This made it work but I have no Y axis on the left joystk. It just idles at 255. The others respond eroneously as well. Dont understand why williams code dosent work with any of them.
  • bulkheadbulkhead Posts: 405
    edited 2006-08-16 - 04:08:37
    The Y-axis problem is something to do with it not reading the last byte using the SHIFTIN function. You have to manually get the data from that byte.

    That is strange, did you using a transistor to invert the clock when you used Jon William's code?
  • TechnoRobboTechnoRobbo Posts: 323
    edited 2006-08-21 - 13:17:09
    Controllers:
    Pelican & Thrustmaters work fine - MadCatz is an issue.
    MadCatz may require a faster clock pulse than the BS2 generates. Pelican drops out at 16 microseconds thats why I suggested a pulsout of 1 (2 microseconds).

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


    TR
  • CJCJ Posts: 470
    edited 2006-09-28 - 11:23:04
    got some info on the official logitech one,

    it seems to want to be powered from 3.3 and not be polled for a packet more than about 40 ~ 50 times a second.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Who says you have to have knowledge to use it?

    I've killed a fly with my bare mind.
  • Nick_GradyNick_Grady Posts: 2
    edited 2006-10-10 - 01:59:49
    I am just trying to find a past article I thought I saw Mountaineer address. I got the code to work with Mountaineer's help on a wireless controller. The only problem now is a bit shift with the right arrow and the square key. I thought I saw a fix somewhre for this. If anyone knows could they point me in the right direction.
  • bulkheadbulkhead Posts: 405
    edited 2006-10-11 - 02:56:25
    Did you take a look at the last attachment I added in the original post? It lists the bits and their corresponding buttons for the pelican wireless controller. I am not sure if the data arriving 2 bits earlier (shift right or left, whatever you want to call it) is a phenomenon with all pelican controllers or just the use of the pelican with the javelin stamp's native shift functions. Could someone verify this on a BS2?

    If all else fails, you could just print all of the raw data in the debug window on one line, and just refresh the controller data every 1/5 second or something and look for changes when you press buttons.
Sign In or Register to comment.