Acquiring data with arduino: Sampling frequency and XBee communication speed

Hi,

I'm using Arduino UNO to acquire data and sending it with a Xbee to another Xbee connected to my computer. I'm using the functions SoftwareSerial(), Xbee.begin(9600), Xbee.print() from the library SoftwareSerial.h to connect the Arduino to one Xbee and sending this data to the other Xbee.

I'm using the function millis to see howl ong my code is taking to run each step of the iteration, and it seems that it takes less than 1 ms to run the calculations and over 100 ms to send the information to the other Xbee using the function Xbee.print().

Do you guys know a way to make the communication between the Xbees faster? Because it is messing up with my sampling frequency.

Also, how do you guys using set the sampling frequency when using the arduino? I've been using the delay function but I've heard using interruptions is a better way to implement it.

Thanks for helping!

Look at the blink without delay example in the IDE examples (File, Examples, 02.Digital). That shows how to use millis() to do timing without using delay().

groundfungus:
Look at the blink without delay example in the IDE examples (File, Examples, 02.Digital). That shows how to use millis() to do timing without using delay().

From what I understood, that's what he's been doing.

void loop(){

int t0=millis();
// calculations

int t1=millis();
xbee.print(results); //xbee communication

int t2=millis();

Serial.print("Time spent doing calculations:");
Serial.print(t1-t0);
Serial.println();

Serial.print("Time spent communicating with the other xbee: ");
Serial.print(t2-t1);
Serial.println();

}
[\code]

Do you guys know a way to make the communication between the Xbees faster?

Yes. Once you have posted your code AND your XBee configuration information, we'll share how to make it better.