Author Topic: Axon II USB Communication  (Read 1632 times)

0 Members and 1 Guest are viewing this topic.

Offline olegyefTopic starter

  • Beginner
  • *
  • Posts: 2
  • Helpful? 0
Axon II USB Communication
« on: March 31, 2011, 06:10:22 PM »
Hello, so i recently got an Axon II and started messing around with it. I'm trying to communicate with Tera Term over the usb, that comes out of the axon. I tried different things for hours and thought id finally ask some one. I know there are built in libraries to make this stuff easier but i wanted to get it working on my own. All i'm getting out of Tera Term is junk. I'm assuming that the rates are some how off but i have no idea how to fix it. Thanks, Oleg.


/*
 * test_serial.c
 *
 * Created: 3/31/2011 1:56:42 AM
 *  Author: Oleg
 */

#include <avr/io.h>
#include <util/delay.h>

#define FOSC 16000000ul //Clock Speed
#define BAUD 115200
#define MYUBRR (FOSC/16/BAUD-1)



void USART_Init( unsigned int ubrr){
   /* Set baud rate */
   UBRR1H = (unsigned char)(ubrr>>8);
   UBRR1L = (unsigned char) ubrr;
   /* Enable receiver and transmitter */
   UCSR1B = (1<<RXEN1)|(1<<TXEN1);
   /* Set frame format: 8data, 1stop bit */
   UCSR1C = (0<<USBS1)|(3<<UCSZ10);
   

}

void USART_Transmit( unsigned char data )
   {
   /* Wait for empty transmit buffer */
   while ( ( UCSR1A & (1<<UDRE1))==0 );
   /* Put data into buffer, sends the data */
   UDR1 = data;
}


int main(void)
{
   USART_Init (MYUBRR);
   while(1){
   
        USART_Transmit('A');
      _delay_ms(2000);
      
   }         
   
}



Offline klims

  • Robot Overlord
  • ****
  • Posts: 190
  • Helpful? 2
Re: Axon II USB Communication
« Reply #1 on: March 31, 2011, 08:52:00 PM »
Look into webbotlib for your Axon  :)

Also check out the Axon Tutorial on SoR

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Axon II USB Communication
« Reply #2 on: April 04, 2011, 06:54:13 AM »
Junk from UART means either mis-matched baud, or on rare chance a *lot* of electrical noise interfering with the UART. On quick glance your code looks fine.

I strongly recommend using WebbotLib . . . but if not, it's still open source and having a look through it could help you pinpoint your mistake in your code.

Offline olegyefTopic starter

  • Beginner
  • *
  • Posts: 2
  • Helpful? 0
Re: Axon II USB Communication
« Reply #3 on: April 05, 2011, 04:11:54 PM »
Thanks i think i solved it. The issue was with "#define MYUBRR (FOSC/16/BAUD-1)" at 115.2k it would give me a UBRR of 7 instead of 8. So i just removed the -1 and and it works.


 


Get Your Ad Here