PS2 Controller problems with Atom pro 28

I am having problems getting the PS2 Controller working using the Atom Pro 28. At first I had connection problems (the computer telling us that it’s not connected to the board) so I fixed it by using a ZIF (Zero Insertion Force) to connect the board (mini Atom Bot Board) with the Chip (Atom pro 28). With the connection problem fix I was able to program the board with the Code by Laurent Gay that I found in Beth Frye’s “PS2 Robot Control: Establishing Communication”, but instead of getting the 79, 255, 255, 128, etc that I should be getting I get FF, 255, 255, 255… instead. Because I have two Atom pro 28 chips, two mini Atom bot boards, and two PS2 controllers I was able to use this interchangeably to see is this was caused by a hard wear or connection problem but I have been getting the same results every time and that is the FF, 255, 255, 255… showing up on terminal 1 table. So dose anyone have any suggestions to what I should do next?

The code you are referring to is not Pro code, but Atom 28 code. Did you make any changes to the code? If so please post it here. Laurent is not available to help for two weeks, he’s on vacation. There are users here who have sucessfully used a PS2 controller with the Atom Pro. Which controller are you using? Lynxmotion, Mad Catz, Pelican, etc.

I am using a Wired PS2 controller that one buy sony. I have not made any changes to the code because from my understanding the only difference betweent he atom pro and atom is that the atom pro have more functions.

Well people are going to ask, so I will get it out of the way. Which IDE are you using?

7.2.0.6 or 8.0.0.0

There are differences in the commands that are timing intensive. I’m not even sure the Atom code will compile with a Pro IDE.

I am using the 8.0.0.0

it did compile.

Ok the code was written for the Atom 28 using the 2.2.1.1 (16 bit) IDE. You are trying to program an Atom Pro using it’s 32 bit IDE. The main difference is in the commands that require timing. The old IDE uses mS timing, and the new IDE uses uS tming. So a command in the old IDE for 1(mS) would need to be changed to 1000(uS) for the new IDE. The only exception is the pause and pauseus which was already in uS.

There are other differences besides that. Some functions of the Atom PRO work a bit differently and/or have higher resolution than those for the Basic Atom. The Atom PRO has more functionality in the hardware (like HSERIAL and HSERVO) than the Basic Atom has, so can do more stuff in the background and is also much faster with more program memory.

8-Dale

My Hex with the Pro and the PS2 controller is currently slightly disassembled so I can not currently try the code on the latest version of the Pro. It was working on the 8.0.0. I have not tried it ont he 8.0.1. Not sure if he changed any more of the commands timings in the last changes. For example the Sound commands were converted to microseconds on the new IDE for the Atom, but were still in miliseconds on the 8.0.0.0 version of the PRo. But that is a bit off topic.

The code that was working had this at the start of the main loop

[code]
;DualShock
DAT con P12
CMD con P13
SEL con P14
CLK con P15

DeadZone con 28
PadMode con $79
-------------Main loop
main

;Ps2Query
low SEL
shiftout CMD,CLK,FASTLSBPRE,$1\8]
shiftin DAT,CLK,FASTLSBPOST,[DS2Mode\8]
high SEL
pause 1

low SEL
shiftout CMD,CLK,FASTLSBPRE,$1\8,$42\8]	
shiftin DAT,CLK,FASTLSBPOST,[DualShock(0)\8, DualShock(1)\8, DualShock(2)\8, DualShock(3)\8, |
	DualShock(4)\8, DualShock(5)\8, DualShock(6)\8]
high SEL
pause 1	

if DS2Mode <> PadMode then
	low SEL
	shiftout CMD,CLK,FASTLSBPRE,$1\8,$43\8,$0\8,$1\8,$0\8] ;CONFIG_MODE_ENTER
	high SEL
	pause 1

	low SEL
	shiftout CMD,CLK,FASTLSBPRE,$01\8,$44\8,$00\8,$01\8,$03\8,$00\8,$00\8,$00\8,$00\8] ;SET_MODE_AND_LOCK
	high SEL
	pause 1

	;low SEL
	;shiftout CMD,CLK,FASTLSBPRE,$01\8,$4D\8,$00\8,$00\8,$01\8,$FF\8,$FF\8,$FF\8,$FF\8] ;VIBRATION_ENABLE
	;high SEL
	;pause 1

	low SEL
	shiftout CMD,CLK,FASTLSBPRE,$01\8,$4F\8,$00\8,$FF\8,$FF\8,$03\8,$00\8,$00\8,$00\8] ;SET_DS2_NATIVE_MODE
	high SEL
	pause 1

	low SEL
	shiftout CMD,CLK,FASTLSBPRE,$01\8,$43\8,$00\8,$00\8,$5A\8,$5A\8,$5A\8,$5A\8,$5A\8] ;CONFIG_MODE_EXIT_DS2_NATIVE
	high SEL
	pause 1

	low SEL
	shiftout CMD,CLK,FASTLSBPRE,$01\8,$43\8,$00\8,$00\8,$00\8,$00\8,$00\8,$00\8,$00\8] ;CONFIG_MODE_EXIT
	high SEL
	pause 144   ;  nap 3

	goto main
endif[/code]

Note at times I had problems getting the Lynxmotion version of the PS2 to initialize properly. My Sector 7 one appeared to be a bit more forgiving. But since you are using a wired one that probably should not be much of an issue.

Kurt

I have tried Robot Dude’s advice of turning the 1(mS) to 1000(uS) and all it did was to slow down the data that was coming in.

I also tried Kurte’s Code however, there appears to be some bugs with the code. I am having trouble with
“shiftin DAT,CLK,FASTLSBPOST,[DS2Mode\8]”,
“shiftin DAT,CLK,FASTLSBPOST,[DualShock(0)\8, DualShock(1)\8, DualShock(2)\8, DualShock(3)\8, |
DualShock(4)\8, DualShock(5)\8, DualShock(6)\8]”,
and "if DS2Mode <> PadMode then ". I think the issue was the use of “DS2Mode” and “DualShock”. If would be great if some one can explain to me the functions of these two words and if it is used correctly in this program.

Although I was not successful in fixing the problem I am having however, I would like to thank Robot Dude, and kurte for your advice.

You are welcome. I forgot to include the data variables when I extracted this code.

They should have defined something like:

DualShock var Byte(7) DS2Mode var Byte

where should
DualShock var Byte(7)
DS2Mode var Byte
be placed in the code?

As with any variable in basic anywhere before it is used.

Thanks Kurte for helping us the extra code really helped us fixed the errors that we had. But I have one more question. What out pot should we see? Is this a control program for motors or servos? And what are the output conditions?

If you look at the Atom Tutorial on this:
lynxmotion.com/images/html/build034.htm

You will see how the different bits and status such as if any button is pressed, where the joysticks are, etc.

The code that extracted here was from the Hex robot, which started out with the Powerpod program which output code for an Atom. I then converted it to run on my Atom Pro. It controls the 18 servos for the 6 legs and will control a couple more for pan/tilt.

Kurt

Although the program was bug free however, I was not receiving any numbers in Terminal 1 when the Baud Rate was set to 57.6 kbs. Is this a problem? If it is then how can I fix it? If it isn’t a problem then what should I do to get those numbers in Terminal 1?

Thank you Kurte for your helps.

I am having some difficulity understanding what you are saying here, but here are my assumptions:

  1. When you say it is bug free - you meant to say that it compiles. Believe me, most if not all non-trivial programs are not bug free :confused:
  2. You are talking about the program in the tutorial I mentioned in the previous post:
  3. You translated the parameters to the Serout to S_OUT to the appropriate baud stuff for a Atom Pro. - Looks like the tutorial may have this covered with the new IDE.
  4. You still have the serial cable you used to download the software to your atom pro connected to the ABB with the PRO.
  5. In the Pro IDE - Terminal 1 window, you have the appropriate Com port selected, you have the baud rate set to 57.6kbs and NO parity.
  6. You have clicked the connect button to activate the comm port.

If all of these assumptions are true and you still do not receive anything in the terminal window, you might start experimenting around. Doing things like:

Put a serout at the start of your program (before main), maybe something like:
serout S_OUT, i57600, “Hello World”, 13]

If you receive the text, then you know the communications are working.

If you keep getting multiple lines of the Hello World you know your program is failing and rebooting the micro controller.

If you only see the message once (even if it is missing part of the text), and you do not see any more output, then maybe the program is hanging somewhere. You might use the debug mode and step the code through to see where it is hanging or rebooting. Or you can add more serout S_OUT messages at different locations to try to issolate where things may be going wrong…

Good Luck

I have tried your advice and it have shown that the communication ran smoothly. Could it be posible that there was some part of the program that you have forgot to give me? Also, what kinds of changes do I need to make to Laurent Gay’s codes to make it work on a Atom pro?