I'm looking for a way to compute the distance between 2 Arduinos. I'm looking for the cheapest option, here are my constraints :
Must work on the outside, close to a road (sunlight + engine noises)
Precision ~1 meter maximum
Range : 0 to 15 meters at least
Let's say we have arduino A not moving and B moving at ~100 kph. I would like arduino A to know when B is at less than 5 (5 is for example) meters from A.
My researches on the web did not suit my needs because I mostly find solutions involving only one Arduino (like IR range sensors for example).
Maybe a system like GPS works : A zigbee sends a time (the time when the Zigbee sends the message) to the other Zigbee and this one makes the difference between the time in the message and the actual time. But as far as I know it requires nanosecond syncrhonised clocks
Have B broadcast its GPS position to A, A does the math from its own position to determine how far away B was when it broadcast.
If B also broadcasts its speed, or A calculates it based on prior position reports, then A can predict B's position going forward as well.
At 100kph = 1667 meter/minute = 27.7meter/second, you've only got 1/2 second to work with for the 15 meter range you want.
(100000meter/hr * 1hr/60 min * 1 min/60sec)
That sounds pretty difficult, and at those speeds and distances I guess the vehicle would only be in range for a few moments. You don't say why you want to know the distance, but if you're trying to determine when the vehicle reaches the closest point or something like that and if the vehicle is following a known path then perhaps doppler sensing might be a useful approach for you. If the vehicle output a load tone at a known frequency then from the received frequency you could determine the doppler shift and hence the rate-of-change of range. The easiest thing to calculate from that would be when the vehicle reaches the closest point, but if you know the speed and path of the vehicle then it might be possible to estimate range too.
CrossRoads:
Have B broadcast its GPS position to A, A does the math from its own position to determine how far away B was when it broadcast.
If B also broadcasts its speed, or A calculates it based on prior position reports, then A can predict B's position going forward as well.
At 100kph = 1667 meter/minute = 27.7meter/second, you've only got 1/2 second to work with for the 15 meter range you want.
(100000meter/hr * 1hr/60 min * 1 min/60sec)
I guess with a 5Hz or 10Hz GPS refresh rate I'll get a precision close to 3 meters at 100km/h. Sounds good but my accuracy criteria is not respected (~1 meter). I guess I have to deal with it because I can't see any other option
That sounds pretty difficult, and at those speeds and distances I guess the vehicle would only be in range for a few moments. You don't say why you want to know the distance, but if you're trying to determine when the vehicle reaches the closest point or something like that and if the vehicle is following a known path then perhaps doppler sensing might be a useful approach for you. If the vehicle output a load tone at a known frequency then from the received frequency you could determine the doppler shift and hence the rate-of-change of range. The easiest thing to calculate from that would be when the vehicle reaches the closest point, but if you know the speed and path of the vehicle then it might be possible to estimate range too.
It seems very difficult and I won't go in that direction. Thanks for sharing your thoughts.
Why use an arduino at all in the moving object? Use an Android cellphone that constantly sends GPS + speed info to an internet address (URL or IP).
The arduino will have to feature something like a wi-fi shield (so it can be used outside) and have a sketch that is a webserver (so it can read the data sent from the phone).
Actually, since most Android devices have a much higher processing power, the Android device can know beforehand what are the GPS coordinates of the Arduino at only start sending packets when it is within X meters from it. The Android can send the distance as well, so that is one less variable for the Arduino to figure out.
I mentioned Android because that is what I know how to program, and I can tell you that doing something like this is pretty easy with Android. I believe it might be easy to do as well for iPhones.
Advantages: no GPS shield required, only 1 arduino + wi-fi shield. All the difficult calculations are offloaded to a much more capable device (the cellphone), and most cellphones today have prety good GPS built-in.
AlxDroidDev:
Why use an arduino at all in the moving object? Use an Android cellphone that constantly sends GPS + speed info to an internet address (URL or IP).
The arduino will have to feature something like a wi-fi shield (so it can be used outside) and have a sketch that is a webserver (so it can read the data sent from the phone).
Actually, since most Android devices have a much higher processing power, the Android device can know beforehand what are the GPS coordinates of the Arduino at only start sending packets when it is within X meters from it. The Android can send the distance as well, so that is one less variable for the Arduino to figure out.
I mentioned Android because that is what I know how to program, and I can tell you that doing something like this is pretty easy with Android. I believe it might be easy to do as well for iPhones.
Advantages: no GPS shield required, only 1 arduino + wi-fi shield. All the difficult calculations are offloaded to a much more capable device (the cellphone), and most cellphones today have prety good GPS built-in.
It is a good idea to try with a phone, I own a Nexus S. I don't know the Android SDK but I'll take a look at it. As i'm coding in C/C++ and I know assembly it shouldn't be very painful
I can imagine an Android app where the user initialize the position of the Arduino and set a "near distance".
Then the phone does all computations and send (over wi-fi) a signal to the Arduino.
I'm first going to test wi-fi range outside, I should get at least 20 meters which is far enough for me !!
Then I'll test the refresh rate of the GPS chip, I'm afraid its only 1 Hz =(
+100 for your great idea $)
C2:
Are consumer GPS capable of better than 3 meter accuracy?
Most of the actual GPS chip are given for 2.5 meters accuracy.
I've been told that cellphones also use antennas signal power to compute distance from an antenna. With 3 antennas (and their position) you should be able to track a phone I think they use this system for faster GPS fix or GPS correction.
If one of the points is stationary, there doesn't need to be any communication at all. The moving object can do all the calculations and give you a running report of the distance.
If the path is preset, maybe you could use the bar code in white paint on the road technique.
TanHadron:
If one of the points is stationary, there doesn't need to be any communication at all. The moving object can do all the calculations and give you a running report of the distance.
If the path is preset, maybe you could use the bar code in white paint on the road technique.
What I think he wants is the stationary Arduino to act on something just seconds before his arrival, like, for example, opening a garage door, turning the lights on, and so on.
TanHadron:
If one of the points is stationary, there doesn't need to be any communication at all. The moving object can do all the calculations and give you a running report of the distance.
If the path is preset, maybe you could use the bar code in white paint on the road technique.
What I think he wants is the stationary Arduino to act on something just seconds before his arrival, like, for example, opening a garage door, turning the lights on, and so on.
I did not mention at all what was the project, the arduino moving is me on my motorbike, arduino B (stationary) is a camera taking automatic pictures
That explains the 100 km/h (well, that's the down limit )
So how about something simpler - you have a 315MHz transmitter, push a button at some visible point, at which point the stationary unit receives the signal and starts triggering the camera to take pictures at whatever frame rate you want to use.
Simple break-the-beam detector wouldn't work because you don't want pictures of other vehicles on the road?
Maybe a pushbutton on the motorbike. When you get close you push the button, and it arms a break-the-beam detector for more precise timing.
Or, you could print out a bar code on a piece of paper and attach it to the other side of the motorbike. A stationary barcode reader could pick it up from there.
I'm sure toll road technology has mass produced something that would work for this.
CrossRoads:
So how about something simpler - you have a 315MHz transmitter, push a button at some visible point, at which point the stationary unit receives the signal and starts triggering the camera to take pictures at whatever frame rate you want to use.
Its not the easiest thing to trigger a button in that kind of position :
When cornering the rider needs to concentrate on body position etc... not a trigger button
I have already done an OpenCV program that recognize a blue motorbike, It works sometimes but it doesn't work very well because of sunlight
I'm going to work on GPS position because I think its a good start. It may not be precise enough but I'm gonna try and maybe make a combination of 2 solutions (GPS + OpenCV, break-the-beam)
I'd like to use the system on both road and track, that's wy I need to filter other users
I agree with the Android idea, I do programming in both android and arduino. I believe arduino is good when you have to interact with physical world( sensors motors etc) for this project taking picture uploading them etc, you need something that can work with web faster and have ton of memory. Phone is an excellent device for that , better camera quality ,you can program it to upload pics at a website ( which could be basically a hard drive with shit load of memory) after every couple of seconds. That way you don't have to worry about distance measure etc ( if we are talking about a small time interval). If the time gap is bigger , you might need two phones to communicate via website ( api). Will require good knowledge of google maps api , still it will be easier than doing it with arduino.
What you can do is put an accelerometer, you'd want a tri-axis setup, on your bike and start up an arduino attached to it when the bike is stationary. Have the arduino integrate the readings from the accelerometer to get your current velocity and direction. Have a beam setup on the second arduino, when the bike breaks the beam start tracking the bike by getting the velocity readings from the first arduino and integrating over time. You can use a simple euler integration scheme (not great), or store a couple of readings and use a higher order integration scheme. Connecting the two arduinos together could be several different options, but a direct connection would be best.