Roboduino: Arduino Compatible / Freeduino
for Robotics. Standard Sensors and Servos
plug in without extra wiring.

Forums > How To > Viewing Thread

topic: PS2 Controller to PIC24
flag
PS2 Controller to PIC24
by blazz Nov 05 2008

After reading your article on how to interface a PS2 controller to a microcontroller,

http://www.curiousinventor.com/guides/ps2

I decided to try and connect my wireless PS2 controller to a PIC24.

The idea is to wirelessly control a mobile robot, the PS2 controller is a very tempting option due to the joysticks and the large ammount of buttons.

Since the PS2 controller protocol seems to be SPI I used the PIC24 SPI2 module to do the communication.

I followed all the specifications you described to prepare the SPI2 module but when I turn everything on the data line allways remains high, so the controller never talks back to the PIC24.

I am doing a simple 0×42 poll request, and my scope looks like the ones from your article, everything seems to be in place, except for the data line that never moves.

There is yet another difference. My command line is usualy low, however your command line is usualy high, and only goes low when the clock starts ticking.
I tried to look for a bit in the configuration that allowed me to make the command line idle state high, but with no success.

After this I downloaded your PIC18 software, and the code is almost the same as mine, except for the PIC18/PIC24 differences in configuring the SPI modules.

Is this command line issue a problem or should I be looking somewhere else for the cause of such silence?

Thanks :)

flag
Re: PS2 Controller to PIC24
by scott (admin) Nov 05 2008

Do you see anything on the acknowledge line either? I was going to suggest adding a pull-up resistor somewhere, but it sounds like you’ve already confirmed all the correct signals going in with a scope.

I’ve heard from some people that sometimes the coloring on the wires isn’t always consistent. What kind of controller do you have?

flag
Re: PS2 Controller to PIC24
by blazz Nov 05 2008

I am using a wireless controller, so I got some connectors directly on the controller receiver board.

I am using a 1k pull-up resistor for the data line since its open collector.

The acknowledge line is not being used, I havent connected it anywhere, would that prevent the controller from working properly? Maybe connectig it to VCC so it would be normaly high?

I have also tried connecting power to the motor power input, but it makes no difference.

My controller is wireless, blue with black rubber on the sides, and I dont think it has any brand anywhere. It has 2 extra buttons above start and select, that look the same. It has been connected to a PS2 so it works properly.

flag
Re: PS2 Controller to PIC24
by scott (admin) Nov 05 2008

hmm, I wouldn’t connect the ack line to VCC, as that’s a signal coming from the controller.

Just to double check, you’re using the “Attention” line, right? Dropping it low for commands

flag
Re: PS2 Controller to PIC24
by blazz Nov 05 2008

Yes Im dropping the Att line before the command goes to the controller. I might take some pictures from the scope at the Lab tomorrow, as well as from my setup, that should help :)

flag
Re: PS2 Controller to PIC24
by blazz Nov 06 2008

Here we go, a couple of pictures from what my scope is showing…

And a picture of the controller Im using,

Any thoughts?

  • Scope1_thumb
  • Scope2_4_thumb
  • Controller_thumb
flag
Re: PS2 Controller to PIC24
by scott (admin) Nov 06 2008

are you using 3.3V? We found that 5V didn’t work on some wireless brands. Otherwise I’m thinking it might be time to try another controller … :( Or, see if u can “listen in” while that controller is connected to a playstation.

I spliced into the cable and put the control lines on a scope to start out… That way you’ll be able to double check the wire coloring, etc.

Sorry I don’t have a magic bullet!

flag
Re: PS2 Controller to PIC24
by blazz Nov 10 2008

I got it! Yes I am using 3.3V because the pic also works at 3.3.

The problem was quite simple actually, the PS2 controller communication protocol is very flexible in many ways, however, if we sent the bits backwards, the controller is not going to recognize the command :D

I was sending the command bits in the wrong order, all I had to do was invert the order of the outgoing (and incoming) bit packages and everything started to work like magic :)

flag
Re: PS2 Controller to PIC24
by scott (admin) Nov 10 2008

nice! um, should have caught that myself :)

posting anonymously, log in to change this - anonymous posts may be reviewed before they go public

post a response

examples:  "my link":http://www.google.com = my link    |    *bold text* = bold text
(complete instructions)

(insert in text with !!1!!) upload another file