Author Topic: Help! How send/receive data from axon 1  (Read 1182 times)

0 Members and 1 Guest are viewing this topic.

Offline HenriqueTopic starter

  • Jr. Member
  • **
  • Posts: 10
  • Helpful? 0
Help! How send/receive data from axon 1
« on: October 16, 2010, 12:10:07 PM »
Hi again   :-X
how can I send/receive data for the axon??? through the UART
Thanks anyone who can help!
« Last Edit: October 16, 2010, 05:06:40 PM by Henrique »

Offline knossos

  • Robot Overlord
  • ****
  • Posts: 278
  • Helpful? 14
Re: Help! How send/receive data from axon 1
« Reply #1 on: October 16, 2010, 05:51:39 PM »
Have you read this yet?  SoR Microcontroller UART tutorial

Alternatively you can use WebBot's Project Designer and assign the output to the UART for a quick output.
"Never regret thy fall,
O Icarus of the fearless flight
For the greatest tragedy of them all
Is never to feel the burning light."
 
Oscar Wilde

Offline HenriqueTopic starter

  • Jr. Member
  • **
  • Posts: 10
  • Helpful? 0
Re: Help! How send/receive data from axon 1
« Reply #2 on: October 17, 2010, 01:38:31 PM »
hmm, but in case of a connection, for example I need to send some data from the axon to my computer and then send a given computer to the axon. Since this connection is only over when I turn off the axon. Which method do you recommend?
and I need to buy extra hardware for this?
I already do connect to the axon via the usb of my computer.
« Last Edit: October 17, 2010, 02:15:01 PM by Henrique »

Offline knossos

  • Robot Overlord
  • ****
  • Posts: 278
  • Helpful? 14
Re: Help! How send/receive data from axon 1
« Reply #3 on: October 17, 2010, 06:04:12 PM »
UART is bidirectional.  You can use the single USB connection and communicate bidirectionally across it.  If you look at WebBotLib's servosCenter() it gives an example of this.
"Never regret thy fall,
O Icarus of the fearless flight
For the greatest tragedy of them all
Is never to feel the burning light."
 
Oscar Wilde

Offline HenriqueTopic starter

  • Jr. Member
  • **
  • Posts: 10
  • Helpful? 0
Re: Help! How send/receive data from axon 1
« Reply #4 on: October 17, 2010, 11:58:00 PM »
Humm alright!
Thanks a lot!


Offline HenriqueTopic starter

  • Jr. Member
  • **
  • Posts: 10
  • Helpful? 0
Re: Help! How send/receive data from axon 1
« Reply #6 on: October 27, 2010, 06:39:08 PM »
enjoying the topic

I'm programming a serial communication by the Windows API, and I have this code sending an array int to the serial port (COM), and I read the response (by the axon) in the console
  
Code: [Select]
  DWORD BytesLidos = 0;
   int count1=0;
   int count2=100;
   uint8_t c[LEN_BUFFER];
   while(ReadFile( hCom, c, LEN_BUFFER, &BytesLidos, NULL )){
  cout <<"data1: " <<(unsigned short)c[0]<<"\n";
  cout <<"data2: "<< (unsigned short)c[1]<<"\n";
    DWORD BytesEscritos = 0;
  int send[2];
  send[0] = ++count1;
  send[1] = ++count2;

  WriteFile( hCom, send,2, &BytesEscritos, NULL );


   }

in AVRStudio I tryed to read the data from the serial port and send back them to read in the console in the programm above. Unfortunately I can only get the first byte stored, the second byte I can't, my question is how to receive an array of bytes sent by port com.

Code: [Select]

                uint8_t data[2];

data[0] =  GET_DATA_USB;
data[1] =  GET_DATA_USB;

uartSendBuffer(UART1, data, 2);
« Last Edit: October 28, 2010, 08:52:29 AM by Henrique »

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,657
  • Helpful? 169
    • Society of Robots
Re: Help! How send/receive data from axon 1
« Reply #7 on: October 28, 2010, 02:33:11 PM »
in AVRStudio I tryed to read the data from the serial port and send back them to read in the console in the programm above. Unfortunately I can only get the first byte stored, the second byte I can't, my question is how to receive an array of bytes sent by port com.

This is how I put received data into an array:
Code: [Select]
char command[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

//this function stores uart data into an array
//a 'r' character signals the end of a command
void get_wireless_command(void)
{
int data;
uint8_t count=0;

data = ZigBeeGetByte();//read from your UART

if(data!=-1)//check for wireless command
{
while(data!='r')//if command is not complete
{
if(data!=-1)//if data is available
{
command[count]=data;
count++;
}
data = ZigBeeGetByte();
}

//store the r, since it already left the loop
command[count]=data;

process_command();//data recieved, now update state
}
}

 


Get Your Ad Here

data_list