go away spammer

Author Topic: Axon UART Protocol problem?  (Read 4981 times)

0 Members and 1 Guest are viewing this topic.

Offline vidamTopic starter

  • Supreme Robot
  • *****
  • Posts: 423
  • Helpful? 1
  • Robotronics.org
    • DC/MD/VA Robotics and Automation Team
Axon UART Protocol problem?
« on: September 14, 2008, 04:27:46 PM »
Hello,

My setup involves the Axon micro-controller, the Dimension Engineering Sabertooth speed controller, and 1 DC brushless motor.

I'm trying to control motor direction and speed via the Axon UART0 port and the Dimension Engineering Sabertooth speed controller in Simplified Serial Mode.

I am able to send only one command to the motors to initialize the speed and direction.

Code: [Select]
int main(void){

int left_side = 0;
int go_back = 45;
int go_forward = 90
int stop = 64;

uartInit();
rprintfInit(uart0SendByte);
uartSetBaudRate(left_side, 38400);
while(1){
uart0SendByte(go_forward);
delay_ms(60000); //delay 1 minute
uart0SendByte(stop);
delay_ms(60000); // 1 minute delay
uart0SendByte(go_back);
delay_ms(60000); // 1 minute delay
} // end while

return 0;

} // end main

The problem is that only the first command "go_forward" actually runs. The commands to stop and go_back are ignored. So this means the wheels are always turning forward at the same speed.

I tried restarting the program in "go_back" mode and the motors reverse but ignores the stop and go_forward command.

So it is like the sabertooth is *not* able to recogniize the Axon UART protocol.

Looking at the datasheet for the sabertooth in simplified serial mode it says the following:

"Simplified Serial operates with an 8N1 protocol – 8 data bytes, no parity bits and one stop bit."

Is the UART0 on the Axon not set up for 8N1 protocol?

I checked the baud rate and both devices are configured for 38400. So this is not the problem.

I also tried shorter delays like delay_ms(5000). That didn't work either.

in effect this means I have to download a new program to the Axon in order to change motor speed and direction.

I also tried to take take the code above out of loop and do it to do once and then finish but that didn't work either.

I tried changing to UART3 but I encounter the same issues.

I even have a spare Dimension Engineering Sabertooth that I tested. The same behavior occurs for both speed controllers. So I know there is nothing wrong with the speed controllers.

Can anyone help me, please? Is there a way to clear the buffer in between motor commands?

Thanks,

Melanie
« Last Edit: September 14, 2008, 10:09:32 PM by vidam »

Offline Ro-Bot-X

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,431
  • Helpful? 25
  • Store: RoBotXDesigns.ca
    • Ro-Bot-X Designs
Re: Axon UART Protocol problem?
« Reply #1 on: September 14, 2008, 06:29:14 PM »
Melanie, I am not completly sure how delay_ms work in C, but in Arduino C the max value is 1000 (one second). If you need to delay for a minute, you should use a repeat 60 times one second loop to delay one minute. Your code sends the first serial command but then gets stuck with a overwhelming parameter and never gets to execute the second serial command.
Check out the uBotino robot controller!

Offline vidamTopic starter

  • Supreme Robot
  • *****
  • Posts: 423
  • Helpful? 1
  • Robotronics.org
    • DC/MD/VA Robotics and Automation Team
Re: Axon UART Protocol problem?
« Reply #2 on: September 14, 2008, 06:38:51 PM »
Ro-Bot-X,
I tried delay_ms(500) and delay_ms(5000).

Did not work either.

edit

Just for kicks I tried the following code:

Code: [Select]
int i=0;

uartInit();

rprintfInit(uart2SendByte);

uart2SendByte(go_forward);

while(i<10){i++;}

uart2SendByte(stop);
i=0;
while(i<10){i++;}

uart2SendByte(go_back);
i=0;
while(i<10){i++;}



I get the same issue. The motors stay in the go-forward mode. They never stop or reverse.
« Last Edit: September 14, 2008, 08:49:16 PM by vidam »

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Axon UART Protocol problem?
« Reply #3 on: September 15, 2008, 05:56:59 AM »
Instead of 'go_forward', 'stop', and 'reverse', try using numbers.


Also, its a good idea to attach uart0 to Hyperterminal and see what it outputs.

Offline vidamTopic starter

  • Supreme Robot
  • *****
  • Posts: 423
  • Helpful? 1
  • Robotronics.org
    • DC/MD/VA Robotics and Automation Team
Re: Axon UART Protocol problem?
« Reply #4 on: September 15, 2008, 06:12:11 AM »
Instead of 'go_forward', 'stop', and 'reverse', try using numbers.


Also, its a good idea to attach uart0 to Hyperterminal and see what it outputs.

I tried using numbers instead of variables. Didnt work

How do I attach uart0 to hyperterminal? I'm using that USB to uart cable for hyperterminal.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Axon UART Protocol problem?
« Reply #5 on: September 15, 2008, 06:28:28 AM »
Use your serial to USB adaptor.

Offline airman00

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,650
  • Helpful? 21
  • narobo.com
    • Narobo.com - Mechatronics and related
Re: Axon UART Protocol problem?
« Reply #6 on: September 15, 2008, 07:54:03 AM »
or perhaps have the USB uart be a "copy" of the uart you are using.

For example if your uart is outputing "1" then the USB uart  should also be transmitting "1"
Then just open up Hyperterminal( or Bray Terminal, my favorite ) and see whats really getting sent out
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline vidamTopic starter

  • Supreme Robot
  • *****
  • Posts: 423
  • Helpful? 1
  • Robotronics.org
    • DC/MD/VA Robotics and Automation Team
Re: Axon UART Protocol problem?
« Reply #7 on: September 15, 2008, 06:19:43 PM »
Use your serial to USB adaptor.

Hyperterminal is showing a series of repeating
(P across the screen. It looks like this:

(P(P(P(P(P(P(P
(P(P(P(P(P(P(P
(P(P(P(P(P(P(P
(P(P(P(P(P(P(P
(P(P(P(P(P(P(P
(P(P(P(P(P(P(P
(P(P(P(P(P(P(P
(P(P(P(P(P(P(P
(P(P(P(P(P(P(P
(P(P(P(P(P(P(P
(P(P(P(P(P(P(P
(P(P(P(P(P(P(P
(P(P(P(P(P(P(P
(P(P(P(P(P(P(P
(P(P(P(P(P(P(P
(P(P(P(P(P(P(P
(P(P(P(P(P(P(P
(P(P(P(P(P(P(P
(P(P(P(P(P(P(P
(P(P(P(P(P(P(P
(P(P(P(P(P(P(P

Admin, could you explain your UART initialization routines?

Mike B on AVRFreaks posted a question that I do not know how to answer since i did not design the Axon.

Here you go Admin.

http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=489478#489478

« Last Edit: September 15, 2008, 06:22:09 PM by vidam »

Offline vidamTopic starter

  • Supreme Robot
  • *****
  • Posts: 423
  • Helpful? 1
  • Robotronics.org
    • DC/MD/VA Robotics and Automation Team
Re: Axon UART Protocol problem?
« Reply #8 on: September 15, 2008, 07:03:55 PM »
or perhaps have the USB uart be a "copy" of the uart you are using.

For example if your uart is outputing "1" then the USB uart  should also be transmitting "1"
Then just open up Hyperterminal( or Bray Terminal, my favorite ) and see whats really getting sent out


Airman,

Tried it. No dice.
Code: [Select]
uartSetBaudRate(0, 38400);
uartSetBaudRate(1, 38400);

while(1)
{

rprintfInit(uart0SendByte);
uart0SendByte(80);
i=0;
while(i<120){i++;}
i=0;
rprintfInit(uart1SendByte);
uart1SendByte(80);
while(i<120){i++;}
i=0;
}


I'm still seeing the repeating characters

(P(P(P(P(P

« Last Edit: September 15, 2008, 07:04:27 PM by vidam »

Offline vidamTopic starter

  • Supreme Robot
  • *****
  • Posts: 423
  • Helpful? 1
  • Robotronics.org
    • DC/MD/VA Robotics and Automation Team
Re: Axon UART Protocol problem?
« Reply #9 on: September 15, 2008, 07:48:27 PM »
Airman and I realized the '(P' is 40 and 80 in decimal in the ASCII conversion table. The same byte commands I sent to the motors and the hyperterminal.

Airman and I also tried adding a carriage return after each motor command. From the ascii table that is decimal 13 for CR.

See the http://www.asciitable.com/

However this didn't cause the motors to recognize the commands. They still do not change speed or direction unfortunately.

Any other ideas out there?

Offline vidamTopic starter

  • Supreme Robot
  • *****
  • Posts: 423
  • Helpful? 1
  • Robotronics.org
    • DC/MD/VA Robotics and Automation Team
Re: Axon UART Protocol problem?
« Reply #10 on: September 15, 2008, 08:57:58 PM »
Many thanks --- Brijesh discovered the solution to the problem as to why the motors only turn one direction and speed.

In the code there needs to be a timer0Init();

This is to initialize TCNT0 such that delay_ms(500) might work.

Don't know why the while(i<1200000){i++;} didnt' work.

Oh well, I can move on to the next problem now.  :D

Here is the final code:

Code: [Select]
int main(void)
{

int go_back, go_forward, stop;
go_back = 45;
go_forward = 80;
stop = 64;

uartInit();
uartSetBaudRate(0, 38400);

timer0Init(); // very important to initialize timers

while(1) {

rprintfInit(uart0SendByte);
uart0SendByte(go_forward);
delay_ms(500);
delay_ms(500);
delay_ms(500);

rprintfInit(uart0SendByte);
uart0SendByte(stop);
delay_ms(500);
delay_ms(500);
delay_ms(500);

rprintfInit(uart0SendByte);
uart0SendByte(go_back);
delay_ms(500);
delay_ms(500);
delay_ms(500);

}//end while

return 0;

}//end main





« Last Edit: September 15, 2008, 09:05:00 PM by vidam »

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Axon UART Protocol problem?
« Reply #11 on: September 15, 2008, 09:32:13 PM »
Quote
while(i<1200000){i++;} didnt' work
Your i was probably initialized as an int, meaning it can't go higher than 255.

Remember to *always* output with USB to debug your problem, even before posting here. You would have easily found the timing problem when you saw no delay in the output to hypterminal ;)

Offline vidamTopic starter

  • Supreme Robot
  • *****
  • Posts: 423
  • Helpful? 1
  • Robotronics.org
    • DC/MD/VA Robotics and Automation Team
Re: Axon UART Protocol problem?
« Reply #12 on: September 16, 2008, 05:50:05 AM »
Quote
while(i<1200000){i++;} didnt' work
Your i was probably initialized as an int, meaning it can't go higher than 255.

Remember to *always* output with USB to debug your problem, even before posting here. You would have easily found the timing problem when you saw no delay in the output to hypterminal ;)

ok
« Last Edit: September 16, 2008, 08:50:58 AM by vidam »

 


Get Your Ad Here