Arduino/XBee Max Communication Speed


i'm taking 3 analog inputs arduino , using xbee w/shield send inputs xbee connected laptop. i've increased baud rate 115200 (which believe max). however, i'm able receive data on laptop @ 700hz. use hyperterminal read serial input 10 seconds , count number of data points get. thought can read data @ least 5,000 hz. math used is:
xbee max throughput/(size of data) = sampling rate.

250,000(bits/sec)/(16bits*3samples)=5,208 hz


am doing inefficient code/communication methodology, or inherently limited xbee or arduino? code shown follows:

code: [select]
#include <xbee.h>
#include <softwareserial.h>
xbee xbee = xbee();

#ifndef cbi
#define cbi(sfr, bit) (_sfr_byte(sfr) &= ~_bv(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_sfr_byte(sfr) |= _bv(bit))
#endif

  uint16_t  packet[]={0,0,0};
  uint16_t  sensorvalue1;
  uint16_t  sensorvalue2;
  uint16_t  sensorvalue3;

void setup() {
  serial.begin(115200);
  xbee.setserial(serial);

  cbi(adcsra,adps2) ;
  cbi(adcsra,adps1) ;
  sbi(adcsra,adps0) ;
}

void loop() {

  sensorvalue1= analogread(a1); 
  sensorvalue2= analogread(a2); 
  sensorvalue3= analogread(a3);
 
 serial.print(sensorvalue1);
 serial.print(sensorvalue2);
 serial.print(sensorvalue3);
}



thanks can provide!

quote
the math used is:
xbee max throughput/(size of data) = sampling rate.

250,000(bits/sec)/(16bits*3samples)=5,208 hz
where did 250,000 come from? @ 115200, start bit , stop bit, can send 11,520 bytes per second. if each value 2 bytes, , there 3 bytes per packet, that's 1920 packets per second assuming nothing else gets sent. which, of course, not valid assumption, since xbees have acknowledge packets. since 1 xbee has tell got packet, has know xbee got from, there overhead involved, cuts down on packet rate (since packets larger 6 bytes).

the assumption there 6 bytes per packet wrong, since sending data ascii text, not binary data.

you have no way of making sense of data in packets sending, because there no delimiters between values in packet , no delimiters between packets.

finally, xbees need time acknowledge packets. not allowing that, ramming data out fast possible. you'll better throughput if give xbees breathing room.


Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > Arduino/XBee Max Communication Speed


arduino

Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code