go away spammer

Author Topic: PlayStation 2 Controller Arduino Library  (Read 45744 times)

0 Members and 1 Guest are viewing this topic.

Offline KurtEck

  • Robot Overlord
  • ****
  • Posts: 217
  • Helpful? 12
Re: PlayStation 2 Controller Arduino Library
« Reply #60 on: August 15, 2010, 07:41:08 AM »
Hi Bill,

If the file is in the directory where your library files are .cpp/.h, when you load your sketch with the sketch editor, the keywords will be appropriately colored.  

So for example with this code:
Code: [Select]
   ps2x.read_gamepad();          //read controller and set large motor to spin at 'vibrate' speed

    // Wish the library had a valid way to verify that the read_gamepad succeeded... Will hack for now
    if ((ps2x.Analog(1) & 0xf0) != 0x70) {
        // Controller did not return Analog mode...
        byte szTemp[80];
        int ich;
        ich = Sprint((char*)szTemp, "PS2 - error(%x): %x %x: %x %x %x %x\r\n", ps2x.Analog(1), ps2x.Analog(3), ps2x.Analog(4),
                ps2x.Analog(5), ps2x.Analog(6), ps2x.Analog(7), ps2x.Analog(8));
        Serial.write(szTemp, ich);      
        return 100;
    }
...
    if(ps2x.ButtonPressed(PSB_START)) { // OK lets try "0" button for Start.

The methods: read_gamepad, Analog and ButtonPressed will show up in red.  Likewise the constant PSB_START will show up in blue.  It adds nothing to the functionality, but it does help to know I typed in something correctly...

Side note: I was running into cases where I was dropping out of Analog mode so added the above to detect it and not process the data like it was valid...

Thanks again for your work, I will download and try the new version.  I like that you added the button shapes as alternatives.  I normally used those in the past!

Kurt

P.S. - I updated my keywords.txt file to include the new stuff...
Code: [Select]
#######################################
# Syntax Coloring Map PS2X
#######################################

#######################################
# Datatypes (KEYWORD1)
#######################################

PS2X KEYWORD1

#######################################
# Methods and Functions (KEYWORD2)
#######################################
Button KEYWORD2
ButtonDataByte KEYWORD2
NewButtonState KEYWORD2
ButtonPressed KEYWORD2
ButtonReleased KEYWORD2
read_gamepad KEYWORD2
config_gamepad KEYWORD2
enableRumble KEYWORD2
enablePressures KEYWORD2
Analog KEYWORD2

#######################################
# Constants (LITERAL1)
#######################################
PSB_SELECT LITERAL1
PSB_L3 LITERAL1
PSB_R3 LITERAL1
PSB_START LITERAL1
PSB_PAD_UP LITERAL1
PSB_PAD_RIGHT LITERAL1
PSB_PAD_DOWN LITERAL1
PSB_PAD_LEFT LITERAL1
PSB_L2 LITERAL1
PSB_R2 LITERAL1
PSB_L1 LITERAL1
PSB_R1 LITERAL1
PSB_GREEN LITERAL1
PSB_RED LITERAL1
PSB_BLUE LITERAL1
PSB_PINK LITERAL1
PSB_TRIANGLE LITERAL1
PSB_CIRCLE LITERAL1
PSB_CROSS LITERAL1
PSB_SQUARE LITERAL1
PSS_RX LITERAL1
PSS_RY LITERAL1
PSS_LX LITERAL1
PSS_LY LITERAL1

PSAB_PAD_RIGHT LITERAL1
PSAB_PAD_UP LITERAL1
PSAB_PAD_DOWN LITERAL1
PSAB_PAD_LEFT LITERAL1
PSAB_L2 LITERAL1
PSAB_R2 LITERAL1
PSAB_L1 LITERAL1
PSAB_R1 LITERAL1
PSAB_GREEN LITERAL1
PSAB_RED LITERAL1
PSAB_BLUE LITERAL1
PSAB_PINK LITERAL1
PSAB_TRIANGLE LITERAL1
PSAB_CIRCLE LITERAL1
PSAB_CROSS LITERAL1
PSAB_SQUARE LITERAL1
« Last Edit: August 15, 2010, 08:04:28 AM by KurtEck »

Offline madsci1016Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
    • Personal Website
Re: PlayStation 2 Controller Arduino Library
« Reply #61 on: August 15, 2010, 08:29:18 AM »
Side note: I was running into cases where I was dropping out of Analog mode so added the above to detect it and not process the data like it was valid...

My library locks the controller so you can't change it's mode using the analog button, so how are you dropping out of analog? The only way i know of is if you are not polling it enough, and if so, the read function will catch it not in the correct mode and reconfigure it before returning.

I'll try the keywords file again to see if i can get it to work, and add it to the lib release.

Offline KurtEck

  • Robot Overlord
  • ****
  • Posts: 217
  • Helpful? 12
Re: PlayStation 2 Controller Arduino Library
« Reply #62 on: August 15, 2010, 09:30:36 AM »
My library locks the controller so you can't change it's mode using the analog button, so how are you dropping out of analog? The only way i know of is if you are not polling it enough, and if so, the read function will catch it not in the correct mode and reconfigure it before returning.
Not sure how it is happening.  I find that it sometimes reports no PS2 is available at startup, but then the read_gamepad works fine. Will Investigate.  Maybe the internal pull-ups are not strong enough and need external one on data line.  I had to do this on one of my robots connected to a BasicMicro Basic Atom Pro 28.

As for keywords.txt: If you goggle "Arduino keywords.txt" one of the returned entries is: http://www.arduino.cc/en/Hacking/LibraryTutorial .  In this tutorial it mentions:
Quote
Each line has the name of the keyword, followed by a tab (not spaces), followed by the kind of keyword

Kurt

Offline madsci1016Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
    • Personal Website
Re: PlayStation 2 Controller Arduino Library
« Reply #63 on: August 15, 2010, 11:49:56 AM »
I did find that via google, and skimmed it, but couldn't get the words to change color in the arduino ide. I only spent 10 minutes on it, so it may have just been i didn't do something right. I'll have to try it again.


Version 1.4 fixes an issue where some modes are not detected at startup, that may have been your issue as well. If you did a hard reset and it came back as not detected, it was because the controller was still in analog and my lib didn't like that.

there's also a //#define PS2X_DEBUG  and //define PS2X_COM_DEBUG you can un-comment that will dump all communications to serial if you think there's some wiring issue.

Offline madsci1016Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
    • Personal Website
Re: PlayStation 2 Controller Arduino Library
« Reply #64 on: September 13, 2010, 04:21:15 PM »
I've got a heck of a youtube message asking for help, i'm going to bring it here to answer, so it can help others with similar problems.

The message:

Was actually up till 4am last night fighting my Duemilanove trying to get it to recognize the PS2 controller. Still haven't had any luck on that.

I used an PS2 Controller extension cord to save my PS2 Controller from having it's connector cut off. I'm starting to think the signal strength isn't good enough over that long of cable?


---------------------------------------------------------------------------------------------------------------------------



I've also been having a hard time sorting out the correct wiring on the Duemilanove. I've included a description of what I've been doing if you have time to look over it.

From your video it looked like you were numbering pins based off the silk screened numbers on the Pro Mini.

According to the example sketch:
"error = ps2x.config_gamepad(13,11,10,12); //setup GamePad(clock, command, attention, data) pins, check for error"

Which I assume means:
13=clock
11=command
10=attention
12=data

Based on the Pro-Mini's schematic: I translated those pin numbers to the following values:

PD5=clock
PB3=data
PB4=command
PB5=attention

Which on the Duemilanove:
PD5=digital 5
PB3=PWM 11 ?digital?
PB4=?digital? 12
PB5=?digital? 13


This is the error message that results from that setup:(along with every other setup I've tried)
"OUT:IN
1:FF
42:FF
0:FF
0:FF
0:FF
0:FF
0:FF
0:FF
0:FF
OUT:IN
1:FF
42:FF
0:FF
0:FF
0:FF
0:FF
0:FF
0:FF
0:FF
Controller mode not matched or no controller found
Expected 0x41 or 0x73, got FF
No controller found, check wiring, see readme.txt to enable debug. visit www.billporter.info for troubleshooting tips"

There was one exception to this FF error and that was when I simply followed the silk screened pin numbers on the Duemilanove, I got this msg:(from memory)
"Controller mode not matched or no controller found
Expected 0x41 or 0x73, got 0
No controller found, check wiring, see readme.txt to enable debug. visit www.billporter.info for troubleshooting tips"

The distinction being the 0 instead of the FF.


I have the controller's "5. red: power 3.3v" going to the Duemilanove's "3V3" next to "5V"
"4.black:ground" is going to the "Gnd" next to "5V" and "3V3".

I don't have "9. green: acknowledge"; "8. white unknown" or "3. grey: vibration motor power" connected to anything at the moment. I tried running the "3. grey" to both "5V" and a 9VDC powersupply and that didn't seem to improve anything.

I'm using a genuine Sony controller, but I've also tried using 5.6K and 180ohm resistors based on the comments on your blog. I did not have any of the 3rd type of resistor, but since I had a "3V3" 3.3VDC power source on my arduino it didn't seem necessary.

I hate to cut my extension cord short or even resort to cutting the extension cord out and removing the PS2 controller connector: but they seem to be the most significant distinction between my procedure and what everyone else has been doing.

Any advice is appreciated.
« Last Edit: September 13, 2010, 04:30:36 PM by madsci1016 »

Offline madsci1016Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
    • Personal Website
Re: PlayStation 2 Controller Arduino Library
« Reply #65 on: September 13, 2010, 04:27:01 PM »

According to the example sketch:
"error = ps2x.config_gamepad(13,11,10,12); //setup GamePad(clock, command, attention, data) pins, check for error"

Which I assume means:
13=clock
11=command
10=attention
12=data

Based on the Pro-Mini's schematic: I translated those pin numbers to the following values:

PD5=clock
PB3=data
PB4=command
PB5=attention

Which on the Duemilanove:
PD5=digital 5
PB3=PWM 11 ?digital?
PB4=?digital? 12
PB5=?digital? 13

This is your problem if I understand correctly. You don't need to do any sort of port:pin translating across different Arduino's. The library uses the Arduino's built in port:pin mapping scheme, so you just need to change the Arduino pin numbers ps2x.config_gamepad() call to whatever Arduino pins you are using. Pin 13 = clock for me, will also be pin 13 = clock for you; not pin 5.

So if you don't change
Code: [Select]
ps2x.config_gamepad(13,11,10,12); then you will be wiring your Duemilanove the same way I wired my pro-minil using pins 10-13.

Offline Striker121

  • Beginner
  • *
  • Posts: 6
  • Helpful? 0
Re: PlayStation 2 Controller Arduino Library
« Reply #66 on: September 14, 2010, 06:19:48 PM »
I'm having the EXACT same problem as you mentioned before with the "Expected 0x41 or 0x73, got FF" error. I have no idea what's wrong. The Arduino is a Duemilanove and it is an original Sony PS2 controller. It works on the PS2 fine and the wires are ALL wire correctly as far as both ports and a solid connection go. I've even tried modifying it so that the pins used are all PWM capable pins on the off chance that that might do something...it didn't. Any ideas as to what could be wrong? I'm really looking forward to getting my bot moving for once :) http://letsmakerobots.com/node/22451 There for anyone wondering what it is. EDIT: There is also a large bundle of copper wire in the center of the cord... no idea what that's for.
« Last Edit: September 14, 2010, 06:27:40 PM by Striker121 »

Offline KurtEck

  • Robot Overlord
  • ****
  • Posts: 217
  • Helpful? 12
Re: PlayStation 2 Controller Arduino Library
« Reply #67 on: September 14, 2010, 08:04:41 PM »
One thing that you might try is an external pull-up resistor on the data line.  I have found that sometimes the weak pull-ups that are part of a processor are not sufficient on for some PS2 controllers.  I have found that one controller may work and another may not... This helped one one of my Arduino Megas.  I soldered in the pull-up inside the case of the wireless receiver.

Kurt

Offline Striker121

  • Beginner
  • *
  • Posts: 6
  • Helpful? 0
Re: PlayStation 2 Controller Arduino Library
« Reply #68 on: September 14, 2010, 08:11:34 PM »
Well, that should be fairly easy to test, I'll likely get back to you tomorrow on how that worked (Or didn't, who knows).
« Last Edit: September 14, 2010, 09:00:38 PM by Striker121 »

Offline madsci1016Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
    • Personal Website
Re: PlayStation 2 Controller Arduino Library
« Reply #69 on: September 15, 2010, 05:23:34 PM »
I've noticed all the people having problems are using a Duemilanove board. I'm going to try it on a Duemilanove to see if that has anything to do with it.

Offline madsci1016Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
    • Personal Website
Re: PlayStation 2 Controller Arduino Library
« Reply #70 on: September 15, 2010, 07:07:53 PM »
Well, i'll still try but this shows the Duemilanove works ok.

Scanalogic 2 Logic Analyzer Review / Tutorial / Demo

Full blog link

Offline Striker121

  • Beginner
  • *
  • Posts: 6
  • Helpful? 0
Re: PlayStation 2 Controller Arduino Library
« Reply #71 on: September 18, 2010, 08:47:55 AM »
Okay, I just tried using a 10K pullup between Data and VCC (Both 5v and 3.3V) Neither one worked. All gave the same "FF" etc error. Any ideas? EDIT: Perhaps taking the controller apart and soldering the pullup closer? (I think I've heard of that mattering with pullups(?))
« Last Edit: September 18, 2010, 09:23:34 AM by Striker121 »

Offline madsci1016Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
    • Personal Website
Re: PlayStation 2 Controller Arduino Library
« Reply #72 on: September 18, 2010, 09:02:53 AM »
Striker121, start by changing all the wires back to the same pins used in the example sketch. Double check the pin positions in the diagram on my website.

What voltage are you running your controller at? 3.3V, or 5V?

EDIT:

Here's a quote from CuriousInventor regarding power:

"Red - Power: Many sites label this as 5V, and while this may be true for Play Station 1 controllers, we found several wireless brands that would only work at 3.3V. Every controller tested worked at 3.3V, and the actual voltage measured on a live Playstation talking to a controller was 3.4V. McCubbin  says that any official Sony controller should work from 3-5V. "
« Last Edit: September 18, 2010, 09:44:54 AM by madsci1016 »

Offline Striker121

  • Beginner
  • *
  • Posts: 6
  • Helpful? 0
Re: PlayStation 2 Controller Arduino Library
« Reply #73 on: September 19, 2010, 12:04:31 PM »
Holy crap it actually works now. Apparently it needed BOTH the pullup resistor AND the pins in the original positions.
« Last Edit: September 19, 2010, 08:31:55 PM by Striker121 »

Offline madsci1016Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
    • Personal Website
Re: PlayStation 2 Controller Arduino Library
« Reply #74 on: September 19, 2010, 12:16:18 PM »
This was using the Arduino mega, correct?

So moving the pins around, and changing the pin numbers in the example sketch doesn't work?

Offline Striker121

  • Beginner
  • *
  • Posts: 6
  • Helpful? 0
Re: PlayStation 2 Controller Arduino Library
« Reply #75 on: September 19, 2010, 08:32:03 PM »
No, this is on a Duemilanove. But yes, it would seem editing the pins in the sketch doesn't actually work. Had to move the wires to the original pins to get it working + have the 10K pullup on data.

Offline cyberdynewins

  • Jr. Member
  • **
  • Posts: 16
  • Helpful? 0
Re: PlayStation 2 Controller Arduino Library
« Reply #76 on: September 20, 2010, 06:30:42 PM »
I've got a heck of a youtube message asking for help, i'm going to bring it here to answer, so it can help others with similar problems.

The message:

Was actually up till 4am last night fighting my Duemilanove trying to get it to recognize the PS2 controller. Still haven't had any luck on that.

I used an PS2 Controller extension cord to save my PS2 Controller from having it's connector cut off. I'm starting to think the signal strength isn't good enough over that long of cable?


---------------------------------------------------------------------------------------------------------------------------



I've also been having a hard time sorting out the correct wiring on the Duemilanove. I've included a description of what I've been doing if you have time to look over it.

From your video it looked like you were numbering pins based off the silk screened numbers on the Pro Mini.

According to the example sketch:
"error = ps2x.config_gamepad(13,11,10,12); //setup GamePad(clock, command, attention, data) pins, check for error"

Which I assume means:
13=clock
11=command
10=attention
12=data

Based on the Pro-Mini's schematic: I translated those pin numbers to the following values:

PD5=clock
PB3=data
PB4=command
PB5=attention

Which on the Duemilanove:
PD5=digital 5
PB3=PWM 11 ?digital?
PB4=?digital? 12
PB5=?digital? 13


This is the error message that results from that setup:(along with every other setup I've tried)
"OUT:IN
1:FF
42:FF
0:FF
0:FF
0:FF
0:FF
0:FF
0:FF
0:FF
OUT:IN
1:FF
42:FF
0:FF
0:FF
0:FF
0:FF
0:FF
0:FF
0:FF
Controller mode not matched or no controller found
Expected 0x41 or 0x73, got FF
No controller found, check wiring, see readme.txt to enable debug. visit www.billporter.info for troubleshooting tips"

There was one exception to this FF error and that was when I simply followed the silk screened pin numbers on the Duemilanove, I got this msg:(from memory)
"Controller mode not matched or no controller found
Expected 0x41 or 0x73, got 0
No controller found, check wiring, see readme.txt to enable debug. visit www.billporter.info for troubleshooting tips"

The distinction being the 0 instead of the FF.


I have the controller's "5. red: power 3.3v" going to the Duemilanove's "3V3" next to "5V"
"4.black:ground" is going to the "Gnd" next to "5V" and "3V3".

I don't have "9. green: acknowledge"; "8. white unknown" or "3. grey: vibration motor power" connected to anything at the moment. I tried running the "3. grey" to both "5V" and a 9VDC powersupply and that didn't seem to improve anything.

I'm using a genuine Sony controller, but I've also tried using 5.6K and 180ohm resistors based on the comments on your blog. I did not have any of the 3rd type of resistor, but since I had a "3V3" 3.3VDC power source on my arduino it didn't seem necessary.

I hate to cut my extension cord short or even resort to cutting the extension cord out and removing the PS2 controller connector: but they seem to be the most significant distinction between my procedure and what everyone else has been doing.

Any advice is appreciated.

Went out and bought a controller I was willing to cut the connector off of. Didn't work. I'm now blaming the Duemilanove as it's the only component which hasn't been swapped out yet.

Just ordered a 5v Pro Mini 16mhz.

Pending this new information on the 10K resistors: while the pro mini is in the mail: I'll have something to experiment with.

The good news is: this seems to vindicate the extension cord as a source of problems.(superstitious as it may have been.)

Edit:
new test.

Setup:
All pins normal
Extension Cord: YES
Resistors:
10K on data
Unconnected Wires:
Acknoledge, Unknown, Motor
Power:
5V & neighbor ground.

Output:
Code: [Select]
OUT:IN
1:FF
42:1
0:10
0:FE
0:FF
0:FF
0:FF
0:FF
0:FF
OUT:IN
1:FF
42:1
0:10
0:FE
0:FF
0:FF
0:FF
0:FF
0:FF
Controller mode not matched or no controller found
Expected 0x41 or 0x73, got 1
No controller found, check wiring, see readme.txt to enable debug. visit [url=http://www.billporter.info]www.billporter.info[/url] for troubleshooting tips
OUT:IN
1:FF
42:63
0:10
0:FE
0:FF
0:60
0:70
0:48
0:2
OUT:IN
1:FF
42:63
0:10
0:FE
0:FF
0:60
0:70
0:48
0:2
Controller mode not matched or no controller found
Expected 0x41 or 0x73, got 63
No controller found, check wiring, see readme.txt to enable debug. visit [url=http://www.billporter.info]www.billporter.info[/url] for troubleshooting tips
« Last Edit: September 20, 2010, 07:27:44 PM by cyberdynewins »

Offline madsci1016Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
    • Personal Website
Re: PlayStation 2 Controller Arduino Library
« Reply #77 on: September 20, 2010, 06:37:33 PM »
cyber,

Using the controller you are willing to damage,

power it off 5V, use the original pin positions, and add a 1-5K resistor between the data pin and 5V. It could be the same problem as Striker.


Offline cyberdynewins

  • Jr. Member
  • **
  • Posts: 16
  • Helpful? 0
Re: PlayStation 2 Controller Arduino Library
« Reply #78 on: September 21, 2010, 02:19:02 AM »
 ;D ;D ;D

If you could see my face right now. I couldn't be more happy if I had figured it out myself.

I used a 5.6K resistor from 5v to data., and there's a 10k resistor between the 5.6k+data and the arduino pin.

THANK YOU SO MUCH! Now I can get back to programming instead of sitting on my hands waiting for a package.(all too familiar of a feeling)

Offline madsci1016Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
    • Personal Website
Re: PlayStation 2 Controller Arduino Library
« Reply #79 on: September 21, 2010, 08:27:38 AM »
Glad it worked!

I used a 5.6K resistor from 5v to data., and there's a 10k resistor between the 5.6k+data and the arduino pin.

Can you explain this a little better? Did you use one resistor or two? How did you wire it?

Offline cyberdynewins

  • Jr. Member
  • **
  • Posts: 16
  • Helpful? 0
Re: PlayStation 2 Controller Arduino Library
« Reply #80 on: September 21, 2010, 12:39:44 PM »
Glad it worked!

I used a 5.6K resistor from 5v to data., and there's a 10k resistor between the 5.6k+data and the arduino pin.

Can you explain this a little better? Did you use one resistor or two? How did you wire it?

I maintained the original 10K resistor between the data wire and the arduino, and I used a 5.6K resistor to jumper from 5vdc to between the data wire and the 10k resistor.

The data wire has 2 resistors attached to it. A 5.6k going to 5vdc, and a 10K going to pin 12 on the arduino.

Offline madsci1016Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
    • Personal Website
Re: PlayStation 2 Controller Arduino Library
« Reply #81 on: September 21, 2010, 02:59:32 PM »
Hmm, this might be my fault, but there's no need for the 10k resistor on the data wire.

Only the other wires need the resistors to drop the 5V from the Arduino down to 3.3V for the controller, but the data wire come from the controller's 3.3V to the Arduinio's 5V.

You might find it works ok if you remove both the 10k and 5k resistors, as all the 5k is doing is pulling up the voltage that the 10k is blocking the Arduino's own internal pull up resistor from doing.

Offline cyberdynewins

  • Jr. Member
  • **
  • Posts: 16
  • Helpful? 0
Re: PlayStation 2 Controller Arduino Library
« Reply #82 on: September 21, 2010, 03:57:46 PM »
Negative. Spent most of troubleshooting time without either resistor. 10K is a relatively new addition. I could try removing the 10K resistor and using 5.6k alone?

Is their any measurements I can take with my fluke-meter to help explain why it's working?


Offline madsci1016Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
    • Personal Website
Re: PlayStation 2 Controller Arduino Library
« Reply #83 on: September 21, 2010, 04:43:24 PM »
I could try removing the 10K resistor and using 5.6k alone?

Yes, try it.

Fluke won't be much good, it's better to have an oscope.

Offline Striker121

  • Beginner
  • *
  • Posts: 6
  • Helpful? 0
Re: PlayStation 2 Controller Arduino Library
« Reply #84 on: September 21, 2010, 07:15:21 PM »
Well, in my case it ran fine off of 3.3v and the Arduino read it fine, just needed the 10K resistor between data and VCC, nothing else.
EDIT: YOU SAW NOTHING! No mistakes here.
« Last Edit: September 23, 2010, 03:23:54 PM by Striker121 »

Offline madsci1016Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
    • Personal Website
Re: PlayStation 2 Controller Arduino Library
« Reply #85 on: September 21, 2010, 09:06:40 PM »
10K resistor between data and ground.

do you mean data and Vcc?

Playstation controllers can only pull the data line down to ground, they need something else to pull it high. For me, the internal pull-up in the Arduino was enough.

Offline KurtEck

  • Robot Overlord
  • ****
  • Posts: 217
  • Helpful? 12
Re: PlayStation 2 Controller Arduino Library
« Reply #86 on: September 22, 2010, 07:56:08 AM »
I am pretty sure he wired it as a pull-up.

I have run into this a couple of times, where sometimes the internal pull-up was sufficient and other times it was not. For example I was able to use a lynxmotion PS2 receiver hooked up to a basic atom pro 28 on pins 1-4 be enabling the built in pull-up. On another robot I wanted to do it again, So used same brand lynxmotion receiver and another Pro 28 and this time it did not work...

With your library with Arduino Mega/Seeeduno Mega, It was working most of the time for me without it...

Kurt

Offline madsci1016Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
    • Personal Website
Re: PlayStation 2 Controller Arduino Library
« Reply #87 on: September 24, 2010, 08:47:03 PM »
EDIT: YOU SAW NOTHING! No mistakes here.

LOL, guess so then.

Offline madsci1016Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
    • Personal Website
Re: PlayStation 2 Controller Arduino Library
« Reply #88 on: January 16, 2011, 12:14:22 AM »
Version 1.5 out.

Now with more Guitar Hero!

PlayStation 2 Guitar Hero Controller Arduino Library Demonstration

Added terms for Guitar Hero Controller. RED_FRET, GREEN_FRET, WHAMMY_BAR, etc.
Added controller detecting function to see if it's DualShock or Guitar Hero controller that's connected.
Fixed an issue with DEBUG mode.

All source for this demonstration available for download @ http://www.billporter.info/playstation-2-controller-arduino-library-v1-0/

Offline tpalmieri

  • Beginner
  • *
  • Posts: 1
  • Helpful? 0
Re: PlayStation 2 Controller Arduino Library
« Reply #89 on: January 16, 2011, 08:49:06 AM »
Good Morning Bill,
Here is the code I started. I am really new to this and did what I could with my very limited knowledge. Hopefully you can get the idea of what I am trying to do in the code. This is for a robotic arm with 7 servo's controlled by a wireless lynxmotion PS2 controller . (4 servos controlled by joysticks, 2 controlled by pad and gripper servo from 2 buttons). I have the PS2 controller working using your library. I appreciate your time and help in pointing me in the right direction.

The code is attached in the .txt doc.

Thanks, Tom

 


Get Your Ad Here