BasicMicro - Forums

www.basicmicro.com
It is currently Mon May 21, 2012 12:34 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: PS2 Dualshock troubles
PostPosted: Wed Aug 10, 2011 1:10 pm 
Offline
Guru

Joined: Mon Apr 19, 2010 9:13 am
Posts: 63
Where are the good resources for using the PS2 dualshock controller with a uC? I'd like to know the meaning of things like controller id, controller status, etc. I have modified BS2 code from Nuts and Volts Issue 101 to work with a Nano 40 and a Pelican PL-6688 dualshock2 compatible controller. Miraculously, it works, but I want to know exactly what's going on. It appears to shift out a $01 for what is commented as a 'start' command. From there, a $42 is manually shifted out while shifting in the controller ID simultaneously. Shifting may be the wrong term, as it is just a For/next loop transferring a bit at a time. My understanding is that this is necessary because the DS2 controller starts transmitting before the uC is finished transmitting. What if I don't care about controller ID? Can I just shiftout $01, $42 then shiftin the data I want? From what I've gathered (which isn't much) the following information is true, but I still have more questions...

Sending $01 starts the communication from the controller to the uC
What is the purpose of sending $42 while retrieving the controller ID?
The code included with Studio has the following lines included. They seem to be similar in function as they all send a $01 followed by a $4#
Code:
shiftout PS2_CMD,PS2_CLK,LSBPRE,[$1\8,$43\8,$0\8,$1\8,$0\8] ;enter config mode
shiftout PS2_CMD, PS2_CLK, LSBPRE, [$01\8, $44\8, $00\8, $01\8, $03\8, $00\8, $00\8, $00\8, $00\8] ;set and lock analog mode
shiftout PS2_CMD, PS2_CLK, LSBPRE, [$01\8, $4D\8, $00\8, $00\8, $01\8, $FF\8, $FF\8, $FF\8, $FF\8] ;Enable Vibration motors
shiftout PS2_CMD, PS2_CLK, LSBPRE, [$01\8, $4F\8, $00\8, $FF\8, $FF\8, $03\8, $00\8, $00\8, $00\8] ;set 18byte reply
shiftout PS2_CMD, PS2_CLK, LSBPRE, [$01\8, $43\8, $00\8, $00\8, $5A\8, $5A\8, $5A\8, $5A\8, $5A\8] ;exit config mode


Are there more commands that can follow a 'start?' What is the information after the $4#? It's commented to tell me what the complete line does, but I'd like to know what each bit does, if anything. What data is in an 18 byte reply? I am only receiving 7 bytes after the manual shifting; controller status, left buttons, right buttons, Right JSX, Right JSY, Left JSX, Left JSY.

If controller ID is $73, its a DS1 controller (my Pelican returns $73 even though it says its a DS2 controller)
If controller ID is $79, its a DS2 controller
Are there other valid controller IDs?

_________________
Studio 2.0.0.16 on Win 7 Home x64 updated daily - Original Roboclaw 5A V1.3.9
Mostly a Nano40 for prototyping, but I have others in my bins


Top
 Profile  
 
 Post subject: Re: PS2 Dualshock troubles
PostPosted: Wed Aug 10, 2011 2:23 pm 
Offline
Master

Joined: Tue Nov 21, 2006 9:34 am
Posts: 527
One of the best sources for info on PS2s is at: http://store.curiousinventor.com/guides/ps2


Top
 Profile  
 
 Post subject: Re: PS2 Dualshock troubles
PostPosted: Wed Aug 10, 2011 2:45 pm 
Offline
Guru

Joined: Mon Apr 19, 2010 9:13 am
Posts: 63
Thank you very much. Looks like I have some reading to do this evening.

_________________
Studio 2.0.0.16 on Win 7 Home x64 updated daily - Original Roboclaw 5A V1.3.9
Mostly a Nano40 for prototyping, but I have others in my bins


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO