Go Down

Topic: Xbee not working with multiple data (Read 2452 times) previous topic - next topic

rogerlette

Hi everybody,


As I am a newbie I have a newbie question :-) I hope that it's not so stupid...

I'm trying to estblish a xbee communication between my arduino and my computer at 115200 bate rate (because I send data from 9DOF gyro/acc/magnetometer sensor board and I need a maximum reactivity).

I folow the X-CTU tutorials, I change the baud rate in the two Xbee module, check the ID and the channel.

I succeed to establish communication for a small amount of data like that :
Code: [Select]
void setup()
{

  Serial.begin(115200);

}
void loop()
{
   Serial.print("hello");
   delay(50);
}


But when I send huge amont of data (which is what I need for my project) it's is working really bad and I receive incomplete data with strange caracter merge in it...
Code: [Select]
void setup()
{

  Serial.begin(115200);

}
void loop()
{
  Serial.print("XXXAAAAAAAA,BBBBBBBB,CCCCCCCC,DDDDDDDD");
  Serial.print("EEEEEEEE,FFFFFFFF,GGGGGGGG,");
  Serial.print("OOOOOOOOOOO,");
  Serial.println("1024,1024,1024,1024,1024,1024");
  delay(50);
}


I hope it's not due to physical limit of my xbee module, or if so, do you know a tips to make it's works?


Thanks by advance for your help



PaulS

Quote
But when I send huge amont of data (which is what I need for my project) it's is working really bad and I receive incomplete data with strange caracter merge in it...

So, where is the receiving code? There are limits to the size of the receive buffer on the Arduino. If you are not receiving data as fast as it is being sent, you may be overrunning the buffer, resulting in incomplete data. You didn't show any output, so we have no idea what the strange characters are, and you didn't show the receiver code, so we have no idea why.

There is a big difference between sending large amounts of binary data, like the device is producing, and sending, receiving, parsing, and converting large amounts of ASCII data. You almost certainly will not be able to obtain the transfer rate you need sending ASCII data.

Jack Christensen

What throughput do you need? See http://arduino.cc/forum/index.php/topic,72672.msg550963.html#msg550963
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

rogerlette

Thank you both for you help,

First, PaulS ;

I dont really understand when you say :
Quote
There are limits to the size of the receive buffer on the Arduino. If you are not receiving data as fast as it is being sent, you may be overrunning the buffer, resulting in incomplete data

Because I dont receivce data on the arduino, I send it with the arduino to the computer?

Quote
You didn't show any output, so we have no idea what the strange characters are, you didn't show the receiver code


I use the arduino Serial Monitor as receiver (or in VVVV software wich is similar to Max) and I obtain that on both software:
Code: [Select]
XXXAAAAAAAA,BBBBBBBB,CCCCCCCC,DDDDDDDDEEEEEEEE,FFFFFFFF,GGGGGGGG,OOOOOOOOOOO,1024,1024,1024,1024,1024,1024
XXXAAAAAAAA,BBBBBBBB,CCCCCCCC,DDDDDDDDEEEEEEEE,FFFFFFFF,GGGGGGGG,OOOOOOOOOOO,1024,1XXXAAAAAAAA,BBBBBBBB,CCCCCCCC,DDDDDDDDEEEEEEEE,FFFFFFFF,GGGGGGGG,OOOOOOOOOOO,1024,1024,1024,1024,1024,1XXXAAAAAAAA,BBBBBBBB,CCCCCCCC,DDDDDDDDEEEEEEEE,FFFFFFFF,GGGGGGGG,OOOOOOOOOOO,1024,1024,1024,1024,1024,1XXXAAAAAAAA,BBBBBBBB,CCCCCCCC,DDDDDDDDEEEEEEEE,FFFFFFFF,GGGGGGGG,OOOOOOOOOOO,1024,1024,1024,1?¢b???¢
XXXAAAAAAAA,BBBBBBBB,CCCCCCCC,DDDDDDDDEEEEEEEE,FFFFFFFF,GGGGGGGG,OOOOOOOOOOO,1024,1024,1024,1024,1?¢
XXXAAAAAAAA,BBBBBBBB,CCCCCCCC,DDDDDDDDEEEEEEEE,FFFFFFFF,GGGGGGGG,OOOOOOOOOOO,1024,1024,1024,1??¢b???¢
XXXAAAAAAAA,BBBBBBBB,CCCCCCCC,DDDDDDDDEEEEEEEE,FFFFFFFF,GGGGGGGG,OOOOOOOOOOO,1024,1????¢b???¢b???¢
XXXAAAAAAAA,BBBBBBBB,CCCCCCCC,DDDDDDDDEEEEEEEE,FFFFFFFF,GGGGGGGG,OOOOOOOOOOO,1XXXAAAAAAAA,BBBBBBBB,CCCCCCCC,DDDDDDDDEEEEEEEE,FFFFFFFF,GGGGGGGG,OOOOOOOOOOO,1024,1024,1024,1XXXAAAAAAAA,BBBBBBBB,CCCCC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,OOOOOOOOOOO,1024,1024,1024,1024,1024,1024
XXXAAAAAAAA,BBBBBBBB,CCCCCCCC,DDDDDDDDEEEEEEEE,FFFFFFFF,GGGGGGGG,OOOOOOOOOOO,1024,1024,1XXXAAAAAAAA,BBBBBBBB,CCCCCCCC,DDDDDDDDEEEEEEEE,FFFFFFFF,GGGGGGGG,OOOOOOOOOOO,1024,1024,1XXXAAAAAAAA,BBBBBBBB,CCCCCCCC,DDDDDDDDEEEEEEEE,FFFFFFFF,GGGGGGGG,OOOOOOOOOOO,1024,1024,1024,1024,1XXXAAAAAAAA,BBBBBBBB,CCCCCCCC,DDDDDDDDEEEEEEEE,FFFFFFFF,GGGGGGGG,OOOOOOOOOOO,1024,1024,1024,1024,1024,1024
XXXAAAAAAAA,BBBBBBBB,CCCCCCCC,DDDDDDDDEEEEEEEE,FFFFFFFF,GGGGGGGG,OOOOOOOOOOO,1024,1?XXXAAAAAAAA,BBBBBBBB,CCCCCCCC,DDDDDDDDEEEEEEEE,FFFFFFFF,GGGGGGGG,OOOOOOOOOOO,1024,1024,1024,1024,1024,1024
XXXAAAAAAAA,BBBBBBBB,CCCCCCCC,DDDDDDDDEEEEEEEE,FFFFFFFF,GGGGGGGG,OOOOOOOOOOO,1024,1024,1024,1024,1024,1XXXAAAAAAAA,BBBBBBBB,CCCCCCCC,DDDDDDDDEEEEEEEE,FFFFFFFF,GGGGGGGG,OOOOOOOOOOO,1024,1024,1024,1024,1024,1024
XXXAAAAAAAA,BBBBBBBB,CCCCCCCC,DDDDDDDDEEEEEEEE,FFFFFFFF,GGGGGGGG,OOOOOOOOOOO,1024,1024,1024,1024,1024,1024
XXXAAAAAAAA,BBBBBBBB,CCCCCCCC,DDDDDDDDEEEEEEEE,FFFFFFFF,GGGGGGGG,OOOOOOOOOOO,1????¢b???¢b???¢b??24
XXXAAAAAAAA,BBBBBBBB,CCCCCCCC,DDDDDDDDEEEEEEEE,FFFFFFFF,GGGGGGGG,OOOOOOOOOOO,1024,1


Sorry but I also dont really get the difference between sending Binary data and ASCII data as for the moment I'm just playing with different tutorial to build my project (wich is a glove music controller) and I dont really have the basic knowledge of all that programming stuff (but I motivated to learn!)

So I just know that I have to send 4+3=7 hexadecimal values wich come from the 9DOF board, I need hexadecimal because It's allows me to have more precision as Fabio Varesano, the inventor of this nice board explain here :http://www.varesano.net/blog/fabio/sending-float-variables-over-serial-without-loss-precision-arduino-and-processing
And and I also have to send 11 char code wich come from my RFID reader, and 6 sensor analog values read on the arduino !

And to answer Jack, all that data have to be send as fast as possible because my 9DOF board is fixed on a player hand. And I would like a quick and precise reaction as different sound will be launch depends of the player movements. It's working well with a cable at 115200 bits/sec, but very bad at 9600 bits/sec (I can heard the sound time reaction).. so I dont really know the throughput I need but the maximum would be the best.
( for information, I have 1-2 meter distance between the computer and the player )

Hope that precision anwser your question.

PaulS

Quote
Because I dont receivce data on the arduino, I send it with the arduino to the computer?

I missed that. I thought you were having 2 Arduinos talk to each other.

Quote
Sorry but I also dont really get the difference between sending Binary data and ASCII data as for the moment I'm just playing with different tutorial to build my project (wich is a glove music controller) and I dont really have the basic knowledge of all that programming stuff (but I motivated to learn!)

ASCII data will require that you convert the floats to strings, to send. Binary data will send the float as 4 bytes.

Quote
So I just know that I have to send 4+3=7 hexadecimal values wich come from the 9DOF board, I need hexadecimal because It's allows me to have more precision as Fabio Varesano, the inventor of this nice board explain here :http://www.varesano.net/blog/fabio/sending-float-variables-over-serial-without-loss-precision-arduino-and-processing
And and I also have to send 11 char code wich come from my RFID reader, and 6 sensor analog values read on the arduino !

7 floats = 28 bytes. 11 characters = 11 bytes. 6 ints = 12 bytes. 28 + 11 + 12 = 51 bytes. Add a pair of packet markers for a total of 53 bytes.

Quote
Serial.print("XXXAAAAAAAA,BBBBBBBB,CCCCCCCC,DDDDDDDD");

That one line is 38 bytes.

It's unlikely that every packet sent by the Arduino will contain RFID data. So, you really should consider 3 types of packets - one for the 7 floats, one for the 11 characters, and one for the 6 ints.

Use different start and end markers for each, so you know what kind of packet it is.

The test you are performing now is unrealistic in terms of the amount of data you really need to send.

Jack Christensen


And to answer Jack, all that data have to be send as fast as possible because my 9DOF board is fixed on a player hand. And I would like a quick and precise reaction as different sound will be launch depends of the player movements. It's working well with a cable at 115200 bits/sec, but very bad at 9600 bits/sec (I can heard the sound time reaction).. so I dont really know the throughput I need but the maximum would be the best.
( for information, I have 1-2 meter distance between the computer and the player )

Hope that precision anwser your question.


I was hoping you would quantify how fast you need to send data. Sounds like 115kbps is enough, but how much is actually being sent and in what period of time. See the link to the other thread I posted earlier. Looks like the best that can be expected is around 35kbps, and that's ideal conditions with no safety margin.
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

rogerlette

#6
Oct 08, 2011, 06:59 pm Last Edit: Oct 08, 2011, 07:01 pm by rogerlette Reason: 1
Hi again,
(sorry for the reply delay I was not at home this week)

So following your advices PaulS, I modify my test which is now more realistic I think :

Code: [Select]

void setup()
{

 Serial.begin(115200);

}
void loop()
{
 int integer = 1024;
 
 Serial.print("!"); // start marker for float packet = 1 byte
 Serial.print("AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDDEEEEEEEEFFFFFFFFGGGGGGGG"); // 7*8 char = 56 bytes (float convert to char)
 Serial.println("#"); // end marker for float packet = 1 byte
 
 Serial.print("&"); // start marker for rfid packet = 1 byte
 Serial.print("OOOOOOOOOOO"); // 11 char = 11 bytes
 Serial.println("*"); // end marker for rfid packet = 1 byte

 Serial.print("+"); // start marker for integer packet = 1 byte
 Serial.print(integer); // 6 int = 12 bytes
 Serial.print(integer);
 Serial.print(integer);
 Serial.print(integer);
 Serial.print(integer);
 Serial.print(integer);
 Serial.println("-"); // end marker for integer packet = 1 byte

 delay(50);
}


I assume that it would be better to not convert all the floats to char because it's less heavy in terms of byte to send. But as they are well transfered (see below) and as I would prefer to receive it as char I want to keep it like this for the moment.

So finally I need to send 85 byte, and here is a result of the test in the serial monitor:
Code: [Select]
!AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDDEEEEEEEEFFFFFFFFGGGGGGGG#
&OOOOOOOOOOO*
+102410241024102410241024-
!AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDDEEEEEEEEFFFFFFFFGGGGGGGG#
&OOOOOOOOOOO*
+10241ó!AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDDEEEEEEEEFFFFFFFFGGGGGGGG#
&OOOOOOOOOOO*
+102410241024102410241024-
!AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDDEEEEEEEEFFFFFFFFGGGGGGGG#
&OOOOOOOOOOO*
+10241ó4102410241024-
!AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDDEEEEEEEEFFFFFFFFGGGGGGGG#
&OOOOOOOOOOO*
+102410241024102410241024-
!AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDDEEEEEEEEFFFFFFFFGGGGGGGG#
&OOOOOOOOOOO*
+102410241024102410241024-
!AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDDEEEEEEEEFFFFFFFFGGGGGGGG#
&OOOOOOOOOOO*
+102410241024102410241024-
!AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDDEEEEEEEEFFFFFFFFGGGGGGGG#
&OOOOOOOOOOO*
+102410241024102410241024-
!AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDDEEEEEEEEFFFFFFFFGGGGGGGG#
&OOOOOOOOOOO*
+102410241ó102410241024-
!AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDDEEEEEEEEFFFFFFFFGGGGGGGG#
&OOOOOOOOOOO*
+10241ó102410241024-
!AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDDEEEEEEEEFFFFFFFFGGGGGGGG#
&OOOOOOOOOOO*
+102410241024102411024-
!AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDDEEEEEEEEFFFFFFFFGGGGGGGG#
&OOOOOOOOOOO*
+1ó10241024102410241024-
!AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDDEEEEEEEEFFFFFFFFGGGGGGGG#
&OOOOOOOOOOO*
+110241024102410241024-
!AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDDEEEEEEEEFFFFFFFFGGGGGGGG#
&OOOOOOOOOOO*
+102410241024102410241024-
!AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDDEEEEEEEEFFFFFFFFGGGGGGGG#
&OOOOOOOOOOO*
+102410241102410241024-
!AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDDEEEEEEEEFFFFFFFFGGGGGGGG#
&OOOOOOOOOOO*
+10241024102411!AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDDEEEEEEEEFFFFFFFFGGGGGGGG#
&OOOOOOOOOOO*
+1024102410241ó41024-
!AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDDEEEEEEEEFFFFFFFFGGGGGGGG#
&OOOOOOOOOOO*
+10241024102411!AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDDEEEEEEEEFFFFFFFFGGGGGGGG#
&OOOOOOOOOOO*
+10241ó



So I have different questions :
- It's seems that the char are always transfered correctly compare to the integer why ? I also observed that phenomena in my previous test (see my previous post above) this is just about sending bytes it should be the same ?
- Anyway I was thinking to reject all the bad packets and just keep the good ones, but of course I have another problem ! This test is working just few second, then the communication is stopped do you have a idea why ?(I tryed two different serial monitor software...)

- To answer Jack C., If I consider that my project works well when I send 85 bytes every 50ms, it's means that I send 85*(1000/50)=1700bps so with 3500bps connexion it should be ok ?


I'm working a lot to understand all that communication stuff so sorry if I misunderstood some stuff...
Thanks for your help.

Jack Christensen


- To answer Jack C., If I consider that my project works well when I send 85 bytes every 50ms, it's means that I send 85*(1000/50)=1700bps so with 3500bps connexion it should be ok ?


I figure it as follows, "bps" (lower case b) in the Digi product manual meaning bits per second.

85 bytes/50ms = 1700 bytes/sec * 8 bits/byte = 13.6k bits/sec

Which seems like it should be OK if only one hop is involved (and I'd keep security disabled, which is the default setting), but I wouldn't be surprised if the occasional retry could possibly gum up the works.
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

rogerlette

Thanks Jack,

I was thinking "bps" was "byte per sec" ... (This illustrate my level with eletronic stuff!)

Anyway the good news is that with 13.6 kbps it still seems to be ok ! But I dont get the details because I'm french so my english vocabulary is poor (and google translate is lost too)... So what do you mean by :
Quote
if only one hop is involved
?

I have keep the security mode of the two Xbee module disable and I understand that the occasional retry can reduce the communication speed but I want to understand the two other questions of my previous post before just give up and reduce the speed...

Jack Christensen

Hey if you hadn't told me, I wouldn't have known, some of us USAnians aren't real great with English either!  XD

If you only have two XBees, then it's only one hop. A hop is counting any intermediate nodes the packet goes through. So if I have three XBees, and if a packet is sent from "A" to "C" and gets routed through "B", then that's two network hops. With multiple nodes, especially with mesh networking, we can never be 100% sure how many hops a packet will take, as the network decides dynamically.
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

rogerlette

Thanks for that clear lesson :-)

Do you have any idea about the causes of that two observations ?
Quote
- It's seems that the char are always transfered correctly compare to the integer why ? I also observed that phenomena in my previous test (see my previous post above) this is just about sending bytes it should be the same ?
- Anyway I was thinking to reject all the bad packets and just keep the good ones, but of course I have another problem ! This test is working just few second, then the communication is stopped do you have a idea why ?(I tryed two different serial monitor software...)

Jack Christensen

I see that, it does seem odd. Which XBees are you using? Do I understand the setup correctly? Arduino with XBee is sending the data, and the other XBee is just connected to a terminal program for testing?
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

rogerlette

Exactly, here is the detailed setup :

On one side :
An arduino
+ Xbee module http://www.sparkfun.com/products/8664
mounted on a Xbee exporer http://www.sparkfun.com/products/9132
(I think my wiring between the Xbee explorer is good because I can read data)

On the other side :
A computer
+ the same Xbee module
mounted on Xbee Dongle http://www.sparkfun.com/products/9819

So I just send data from the arduino to the computer, and I read it with the arduino serial monitor or (other serial monitor software to check that the problem is not the serial monitor)

To configure the Xbee module, I just use X-CTU and change the baud rate (I put the same on both module).

Jack Christensen

I'd offer to try and duplicate the setup and run the test sketch, it wouldn't take long, but I have only S2 XBees. Still I may give it a go as that's a lot more data than I've tried to pump through them before, might be interesting.
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

rogerlette

Hi,


Thanks a lot it could be really nice to you if you could do the same test at home :-) And if it's working with your Xbee module I'll buy the same because after two week spend on this communication problem I begin to be desperate...

Is there an other Xbee module or an other wireless way to send a lot of data from an arduino to a computer?

Go Up