I am having fun with my Axon2 mounted on my Lynxmotion Brat. I had it walking using my DIY remote control over XBEE. I did some major rewrite of some of my code which I am now in the process of debugging.

I thought it would next be fun to integrate on to it the PS2 controller as many more people have these than the DIY remote.

A couple of questions. I believe the Atmega640 have pull-up resistors on each of the IO pins, which you can enable by setting the appropriate pin in the PortX pin to high, while the pin is configured for input. But looking at the Webbotlib documentation, it sounds like setting the pin to high, will give a run-time error if the pin is not configured for output. Is this correct? If so is there a prescribed way in webbotlib to enable a pull-up resistor.

2nd has any one played much with the pull-ups? Do you know if it is strong enough to use to pull-up the data line for the PS-2 controller, or should I add an external pull-up.

I would be curious to hear when you get this working. With all the tutorials for interfacing PS2 controllers, i though it would be easy. I tried 3 different libraries and 2 tutorials and could never get it to work. (granted on a arduino not an Axon. )

I would be curious to hear when you get this working. With all the tutorials for interfacing PS2 controllers, i though it would be easy. I tried 3 different libraries and 2 tutorials and could never get it to work. (granted on a arduino not an Axon. )

Will post more when I have had a chance to play with this. One thing I know is not all PS2 controllers are the same. I have tried out several of them with the Atom Pro. Some work well like the one Lynxmotion now sells, madcatz... Never did get the one from Logitech to work. Not sure of my starting point here yet.1) The code that is mentioned in the forum that you can download from trossen.2) Some c++ classes I wrote awhile ago when I was playing with the BDMicro Maveric 1B (Atmega128)3) try writing a new version using some of the SPI support within webbotlib. My guess is I will start with 3) and then add in my stuff from 2)...

I just started playing with the code to try the PS2. I started off with some code I had working earlier on a BDMicro Mavric (Atmega128). But I thought it would be good to try out the SPISW as I found when I was working on PS2 stuff with Basic Atom Pros in assembly language that the protocol was pretty close...

I have some stuff coded but not sure of the best way to do things here. For example you have a device list, but I don't see anywhere in the docs on how you are supposed to use it. I did find a function in the header files that looks like it is supposed to be used: (spiDeviceSelect), but I tried passing my device to it, with both direct or by getting it's address and neither compiled... Will look more later. My current code that compiles I simply use pin_high/pin_low to set the select line. I also am trying to see if the internal pull-up will work for the DAT line. Will hopefully start debugging later (Will probably first set up logic analyzer to see what is generated). Also need to add test code to get it to work...

Thanks, if nothing else it did answer that the built-in pull-up resistors are probably sufficient. IE I don't have to wire up an external one...

Currently playing with SPI doing it, but so far the dat line is not talking back to me. Fixed first problem that I was outputing MSB first, should be LSB... Not sure if the next problem is I am talking too slow for the PS2. It looks like my clk is going at about 54khz and from earlier work I think the PS2 defaults to about 250khz... Will check to see about changing the SPI timing values otherwise I may simply import dunks stuff. If it works, it is good enough for me!

I think I have it working now. I started off with a cross between your code and some previous code of mine. Using webbotlib I found that I could not easily use system port variables like: PORTK, PINK, etc, so I converted to using the pin_high/pin_low/pin_is_high type of calls. Also I found that delay_us(1) for example was delaying a lot more than that... So I just did some time waster in the code...

I know from some different platforms that sometimes the controller can fall out of analog mode, so I merged the init code into the query code. Also I had a simple function that passed in an array of init bytes to call of to output instead of individual calls. Will probably next move those to PROGMEM...

void PS2_Init(void) {pin_make_input(PS2_DAT, TRUE); // make the dat line input But also enable pull-uppin_make_output(PS2_CMD);// Make command pin be outputpin_make_output(PS2_SEL);// init the select pinpin_high(PS2_SEL);// Initialize to high...pin_make_output(PS2_CLK);// Make clock be output};