PS2 Controller on a Propeller

I am not sure how many people will be interested in this, so I will apologize in advance for my ramblings :blush: . But just in case someone else will get some useful information out of this…

I thought I would try another diversion, so I started playing with a Parallax Propeller Microcontroller using one of their Proto boards and accessory kit. I first added some LEDs to make it easy to test some stuff and wrote my first Hello World programs…

I would like to make one of my robots run using this. I am not sure yet, if I will try the Rover first or the Hex…

So my first step toward this was to get the Lynxmotion PS2 controller to work. Luckily someone already wrote an object to do this and I was able to download the initial code for this from the Propeller Object exchange. After soldering in some 1K resistors between each of the data lines and the IO pins of the propeller to make sure the propeller does not get +5v and add a 10K pull-up resistor to the data line, I was ready to try.

Side Note: I have never worked with this type of solder proto board, so was not sure the best way to connect two holes. I ended up bending the two component leads or wires to each other and making a solder bridge. Not pretty, but it appears to work…

The PS2 object and the demo program using it worked. At first all I was not getting any valid data, but after I hit the analog button on the controller I started to get valid data. So I decided it was now time to understand PS2 Initialization code that is used in several of the Atom or Atom Pro programs, and update my PS2 object on the Propeller to Initialize the controller properly.

I found these two links very helpful to understand the PS2 controller: curiousinventor.com/guides/ps2 and gamesx.com/controldata/psxcont/psxcont.htm

It took me a lot longer than it should have to add this initialization code. So far I have found it easier to work in their assembly language than with Spin, but I ran into a few things in the learning curve. Things like in their DAT blocks (where you put assembly language as well as initialized variables), you need to have all of the initialized variables defined before any of the initialized variables… Also it took me awhile to figure out you have to use self modifying code to do the equivalent of indirect memory addressing… But I am now outputting the same initialization strings as the lynxmotion rover code is:

$1,$43,$0,$1,$0] ;CONFIG_MODE_ENTER
$01,$44,$00,$01,$03,$00,$00,$00,$008] ;SET_MODE_AND_LOCK
$01,$4F,$00,$FF,$FF,$03,$00,$00,$00] ;SET_DS2_NATIVE_MODE
$01,$43,$00,$00,$5A,$5A,$5A,$5A,$5A] ;CONFIG_MODE_EXIT_DS2_NATIVE
$01,$43,$00,$00,$00,$00,$00,$00,$00] ;CONFIG_MODE_EXIT

What I am now trying to understand is do I really need all of these command strings to work properly?

I think we may only need the CONFIG_MODE_ENTER, SET_MODE_AND_LOCK, CONFIG_MODE_EXIT strings to work properly. If this is right this will leave us in mode $73 (7=Analog, 3=3 words of data returned following the header).

I believe the other two commands configure the PS2 to be in mode ($79=7=Analog, 9=Words of data) return additional information about how much force the user is putting on the up/down/left/right/cross/X/Circle/triangle buttons. I updated the PS2 object and demo program on the propeller to return this additional information and the output confirms this.

So far I have not seen any Lynxmotion program use this additional information. So do you think it would be safe to simplify this or am I missing something?

Thanks,
Kurt

If you don’t get into DS2 Native mode you won’t get the pressure sensor readings back from teh controller. If those aren’t needed then yes, you can skip that line. In fact you can ignore all those settings and just start reading($42 command) the controller. You will get all the button presses and IIRC you should also get the joystick readings(if you put the controller in analog mode by pressing the button on the controller). No analog pressures and no vibration motor control though.