|
|
|
|
September 10, 2010, 02:03:23 AM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
: SoR Robot Chat every friday night. Join us! (forum integration fix coming when I have time)
http://www.societyofrobots.com/robotforum/chat/
Robot Forum
Home
Help
Search
Login
Register
Robot Forum
>
Electronics
>
Electronics
>
Problems connecting PS2 controller to Axon
Pages: [
1
]
Print
Author
Topic: Problems connecting PS2 controller to Axon (Read 867 times)
0 Members and 1 Guest are viewing this topic.
JadeKnight
Beginner
Helpful? 0
Offline
Posts: 8
Problems connecting PS2 controller to Axon
«
on:
September 24, 2009, 02:03:19 AM »
I followed the tutorial on this site exactly (cut and paste the code), however I can't seem to get it to work. It basically loops forever trying to confirm the controller is in analog mode. The PS2 controller (genuine sony brand) does get put into analog mode (red led turns on), however the data received from the controller is always 0 causing the init loop to go on forever.
Here's the real kicker, if I turn off the Axon, I correctly get the 0x73 confirmation byte EVERY TIME, along with a few frames of valid controller data before the telnet connection, and the Axon, die out...
Something about turning off the Axon causes the code to work, in it's last dying breaths...
Any help would be appreciated.
Logged
Admin
Administrator
Supreme Robot
Helpful? 110
Offline
Posts: 9,851
Re: Problems connecting PS2 controller to Axon
«
Reply #1 on:
September 24, 2009, 09:15:33 PM »
dunk, the guy who wrote the PS2-Axon code, went crazy, colored his hair blue, quit his job, and decided to travel the world with his girl for a year. In other words, send him an email and cross you fingers for help.
dunk didn't use a genuine Sony brand PS2 controller, he used one of the fakes. He mentioned that there is a good chance that they aren't fully compatible. I recommend reading through the PS2 communication protocol and comparing it to the code, to see how things are different.
You might also be able to get some help from:
http://forums.trossenrobotics.com/showthread.php?t=3365&highlight=axon+ps2&page=4
http://forums.trossenrobotics.com/showthread.php?t=3394&highlight=axon+ps2&page=2
I call this multi-forum double posting
http://forums.trossenrobotics.com/showthread.php?t=3579
(linked for reference)
Logged
subscribe to SoR's YouTube account
JadeKnight
Beginner
Helpful? 0
Offline
Posts: 8
Re: Problems connecting PS2 controller to Axon
«
Reply #2 on:
September 25, 2009, 10:24:20 AM »
No, he was using a genuine Sony brand controller in the tutorial (as I am). He said the fake ones might have different timing...
I've worked on this for several hours before posting, and I've read many sites and other forum posts on how the PS2 controller communicates. As far as I can see, my pin setup and dunk's code is correct. And as I said the TX seems to works, it's just the RX from the controller that seems to be failing. This appears to be the case anyways. If I move the code around too much, the controller doesn't even go into analog mode.
My main concern is why would the controller RX suddenly WORK when I kill the power, but not normally? What is special about the state of the Axon powering down that makes the code work? I figure if I had the hardware pins wrong or something, it would NEVER work.
(And as far as the 'double-forum' thing goes, I figured different people visit different forums. Get better coverage, and a possible answer. If that was taboo, then I apologize)
Logged
Admin
Administrator
Supreme Robot
Helpful? 110
Offline
Posts: 9,851
Re: Problems connecting PS2 controller to Axon
«
Reply #3 on:
September 25, 2009, 12:34:56 PM »
Hmmm I'm not really sure, mostly guessing . . .
Does it give you a baud rate option? If so, drop it to be slower. What baud is it at?
Quote
And as I said the TX seems to works, it's just the RX from the controller that seems to be failing.
Short the Tx and Rx of your Axon on the UART you are using, then using hyperterminal see if what you type is what gets echoed back to you using USB. You'll have to write a few lines of code to do this (loop back test).
Quote
(And as far as the 'double-forum' thing goes, I figured different people visit different forums. Get better coverage, and a possible answer. If that was taboo, then I apologize)
nah thats ok. Just add a cross link in case its solved in one forum but not the other. It basically encourages cross-forum collaboration.
Logged
subscribe to SoR's YouTube account
JadeKnight
Beginner
Helpful? 0
Offline
Posts: 8
Re: Problems connecting PS2 controller to Axon
«
Reply #4 on:
September 25, 2009, 12:41:43 PM »
There is no baud rate, as I am not using a UART. It is a 'bit-banging' approach using 5 digital I/O pins A3-A7 (and drawing 5v power from ADC-15).
I say the 'TX' works, because it appears that the axon is successfully telling the PS2 controller data (it correctly goes into analog mode).
The 'RX' is the data line bits I'm trying to receive from the PS2 controller. It always stays '0' (until I power down).
«
Last Edit: September 25, 2009, 12:53:00 PM by JadeKnight
»
Logged
JadeKnight
Beginner
Helpful? 0
Offline
Posts: 8
Re: Problems connecting PS2 controller to Axon
«
Reply #5 on:
September 25, 2009, 01:09:57 PM »
Something just occurred to me. All the digital I/O pins are set to output by default.
Is this the correct way to set up the data and acknowledge pins as input?
Code:
#define PSclock 3 // PA3 blue wire
#define PSdata 4 // PA4 brown
#define PSacknowledge 5 // PA5 green
#define PScommand 6 // PA6 orange
#define PSattention 7 // PA7 yellow
...
// PSx controller I/O pin setup:
sbi(DDRA, PSclock); // clock. output. (blue)
cbi(DDRA, PSdata); // data. input. (brown)
sbi(PORTA, PSdata); // enable pullup resistor
cbi(DDRA, PSacknowledge); // acknowledge. input. (green)
sbi(PORTA, PSacknowledge); // enable pullup resistor
sbi(DDRA, PScommand); // command. output. (orange)
sbi(DDRA, PSattention); // attention. output. (yellow)
If this is incorrect, could turning off the axon be changing the data/acknowledge pins to input pins somehow?
Do the defines need to be in the form of 'PA#' instead of just '#' (is the 'PA' prefix required for setting I/O direction)?
«
Last Edit: September 25, 2009, 01:13:05 PM by JadeKnight
»
Logged
JadeKnight
Beginner
Helpful? 0
Offline
Posts: 8
Re: Problems connecting PS2 controller to Axon
«
Reply #6 on:
September 26, 2009, 01:09:36 AM »
Problem solved!
I swapped the 'CLOCK HIGH' and the 'read PSdata pin and store' lines in the gameByte function, and now it works!
Still not sure why turning the Axon off made it work though...
This is the fixed gameByte function (from the tutorial) that works for me, in case anyone else has troubles:
Code:
int gameByte(short int command)
{
short int i ;
delay_us(1);
short int data = 0x00; // clear data variable to save setting low bits later.
for(i=0;i<8;i++)
{
if(command & _BV(i)) sbi(PORTA, PScommand); // bit bang "command" out on PScommand wire.
else cbi(PORTA, PScommand);
cbi(PORTA, PSclock); // CLOCK LOW
delay_us(1); // wait for output to stabilise
sbi(PORTA, PSclock); // CLOCK HIGH
if((PINA & _BV(PSdata))) {sbi(data, i);} // read PSdata pin and store
//else {cbi(data, i);}
}
sbi(PORTA, PScommand);
delay_us(20); // wait for ACK to pass.
return(data);
}
Logged
Pages: [
1
]
Print
Jump to:
Please select a destination:
-----------------------------
General Misc
-----------------------------
=> Misc
=> Robot Videos
-----------------------------
Software
-----------------------------
=> Software
-----------------------------
Electronics
-----------------------------
=> Electronics
-----------------------------
Mechanics and Construction
-----------------------------
=> Mechanics and Construction
Related Topics
Subject
Started by
Replies
Views
Last post
Connecting a speed controller to an Arduino
Electronics
Mega
16
2337
December 19, 2007, 12:55:55 PM
by
Mega
Problems connecting servo to power adaptor
Electronics
SixRingz
9
1353
June 25, 2008, 03:15:03 PM
by
Admin
Connecting Comparator to Axon
Electronics
airman00
2
513
June 09, 2009, 07:26:31 PM
by
Admin
Connecting an Xbee to the Axon
Electronics
adasta
13
929
January 06, 2010, 03:41:23 PM
by
KurtEck
Advertise on this Forum
Loading...