Pages: [1]   Go Down
Author Topic: Xbee time of flight problem  (Read 1293 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey everyone background on our project. We are trying to get the time of flight of two xbees for different distances using round trip time of a character.  Each xbee is hooked to an arduino we send a character start a timer then when the other xbee returns the character the timer stops.  The problem seems to be that the xbees have some default timing inside of the radio of about 6s each from my understanding.  Also the distance does not seem to be effecting the readings at all of the round trip time.  We are not sure why the timing is not increasing with distance possibly because the speed at which it is traveling is just to fast to really keep track of?

Here is the code and some data from serial.  We are using the clock cycle on the arduino to keep track of timing which is about 1 clock cycle = 62.5nanoseconds

#include <SoftwareSerial.h>

SoftwareSerial xbee(10,11);

// avr-libc library includes

#include <avr/io.h>

#include <avr/interrupt.h>


int overflows = 0;


void setup()

{
Serial.begin(19200);
xbee.begin(19200);


// initialize Timer1

cli();         // disable global interrupts

TCCR1A = 0;    // set entire TCCR1A register to 0

TCCR1B = 0;

// enable Timer1 overflow interrupt:

TIMSK1 = (1 << TOIE1);

// Set CS10 bit so timer runs at clock speed:

TCCR1B |= (1 << CS10);

// enable global interrupts:

sei();

xbee.write('c');
while(xbee.read()!='c'){}
TCCR1B = 0;

Serial.print("NanoSeconds: ");
Serial.println((overflows*4096000)+(TCNT1*62.5));

}

void loop(){}


ISR(TIMER1_OVF_vect){
  overflows++;
  }


NanoSeconds: 12888688.00
NanoSeconds: 12826812.00
NanoSeconds: 12942312.00
NanoSeconds: 12956750.00
NanoSeconds: 12956750.00
NanoSeconds: 12872188.00
NanoSeconds: 13037188.00
NanoSeconds: 13008312.00
NanoSeconds: 12901062.00
NanoSeconds: 12833000.00
NanoSeconds: 13008312.00
NanoSeconds: 12870125.00
NanoSeconds: 12748438.00
NanoSeconds: 12849500.00
NanoSeconds: 12952625.00
NanoSeconds: 12818562.00
NanoSeconds: 13086688.00
NanoSeconds: 13074312.00
NanoSeconds: 12839188.00
NanoSeconds: 13049562.00
NanoSeconds: 12771125.00
NanoSeconds: 12911375.00
NanoSeconds: 12979438.00
NanoSeconds: 12901062.00

Thanks.
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 597
Posts: 33328
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Also the distance does not seem to be effecting the readings at all of the round trip time.  We are not sure why the timing is not increasing with distance possibly because the speed at which it is traveling is just to fast to really keep track of
Because Xbee is a protocol that involves processing data. The time of the physical transmission is insignificant compared to all that.
If you are trying to measure the distance between two Xbee systems by measuring delays then forget it, you can't do it. Do some sums and work out what you would expect to see, you will find it is a tiny fraction of the clock speed of your processors, there is no chance of measuring it.
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3942
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I typically see 25-30ms between sending an API packet to receiving the ACK, as measured by the sending sketch. Low power XBees have a maximum range of about 400 feet. I didn't do the maths, but the radio propagation time at maximum range can't be more than a handful of (16MHz) clock cycles, which would hardly amount to a rounding error. Plus, XBees really aren't designed to do such a measurement. So as Mike says, I'd forget it.
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Alright so my understanding is that the physical transmission time is so tiny that it would be impossible to measure therefore the only time I am really seeing is the processing time it takes for each radio to receive and transmit along with the code correct?  Is there any way reliably to quantize distance of the xbees in the network?  Would RSSI be a viable option or will it suffer the same fate?  I am just trying to find a way to know the distance one xbee is from another one.

Thanks!
Logged

New River, Arizona
Offline Offline
God Member
*****
Karma: 19
Posts: 928
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Let's see, the speed of light is something 300 million meters/second.  So, the maximum range of an XBee is about 300 meters, so you should see about 1 millionth of a second pass one way and another coming back for transmission time.  As far a RSSI goes, it varies a lot based on what's between the two XBees and how that whatever changes from one transmission to the next.  Set two of them 30 meters apart in the middle of the desert and you'll have a reading that varies as the wind blows.  I know, I live in the middle of the desert.

There just isn't any way to actually measure how far apart two XBees are aside from hooking each of them to a GPS, and then only if you have a really good GPS.
Logged

Trying to keep my house under control http://www.desert-home.com/

Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ya thats what I figured was hoping someone had a clever idea I could implement haha!
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 597
Posts: 33328
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

We are good but not better than the laws of physics. Go with a GPS system.
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3942
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

We are good but not better than the laws of physics. Go with a GPS system.

PSA: 300 million meters/second. It's not just a good idea, it's the law.
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Go with a GPS system.
Even a GPS system has positional variations. Typically, a GPS will tell you where you are +/- 10 meters. At 60 mph, rolling down the highway, that's great. If you are trying to measure the distance between two devices, +/- 20 meters might be good enough or might be absolutely useless.
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 597
Posts: 33328
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Typically, a GPS will tell you where you are +/- 10 meters
It depends, a good GPS system can get down to about 6".
Logged

Earth
Offline Offline
Edison Member
*
Karma: 52
Posts: 1758
My browser no longer is binding static IP, Floating is the way to go.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Civilian GPS Accuracy

6"=15.24cm

Do you know what you talking about?
Logged

New River, Arizona
Offline Offline
God Member
*****
Karma: 19
Posts: 928
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I was going to comment that a cheap little gps chip I have is always accurate to a foot or so.  It isn't moving though, just setting on a table.  Of course, I live in the middle of nowhere with no obstructions and it always gets the maximum number of satellites, so that may be a special case.
Logged

Trying to keep my house under control http://www.desert-home.com/

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 597
Posts: 33328
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Civilian GPS Accuracy

6"=15.24cm

Do you know what you talking about?

Yes do you?
Logged

Pages: [1]   Go Up
Jump to: