Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How can microcontrollers measure distance between themselves

Status
Not open for further replies.

px0

Newbie level 3
Joined
Apr 17, 2003
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
43
measuring distance rf

For my final project for school I have two microcontrollers (pic) that are communicating wirelessly (rf) with one another and are running on 3V batteries. I want to know if it is possible for one of the microcontrollers to know how far it's located from the other one?

Any help would be greatly appreciated.
 

david90

Advanced Member level 1
Joined
May 5, 2004
Messages
423
Helped
9
Reputation
18
Reaction score
4
Trophy points
1,298
Activity points
3,610
Re: measuring distance

u can send out an RF signal and measure it's strength to determine distance.
 

px0

Newbie level 3
Joined
Apr 17, 2003
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
43
Re: measuring distance

How could I do that? Would the method of measuring the distance have to be very precise (for example measurements of .00001), since the microcontrollers are at a distance of 8 to 20 feet away from each other?
 

throwaway18

Advanced Member level 2
Joined
Jun 9, 2005
Messages
596
Helped
101
Reputation
202
Reaction score
24
Trophy points
1,298
Location
Kent, UK
Activity points
8,348
measuring distance

>u can send out an RF signal and measure it's strength to determine distance.

Trying to do this using signal strength will be very inaccurate due to multipath reception. At short wavelength frequencys such as 433MHz or 2.4GHz you can receive the signal both directly and reflected off nearby objects. The two signals can add or subtract depending on the phase difference.

At low frequencys everything around the transmitter will affect the signal strength including distance of the transmitter above the ground.
 

px0

Newbie level 3
Joined
Apr 17, 2003
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
43
Re: measuring distance

How about an RF field meter or ultrasound?
I was thinking of putting a receiver on one side and a transmitter on the other, and measure the time it takes for the ultrasound to get from one place to another
 

artem

Advanced Member level 4
Joined
May 22, 2003
Messages
1,350
Helped
126
Reputation
252
Reaction score
32
Trophy points
1,328
Location
Turkey
Activity points
13,450
measuring distance

Use ultrasound sensors on 2 side . Works as follow :
first one micro sends signal , second receives it and replys back , first receives reply and calculate delay . Distance from delay divided by will give you actual distance you need . But dotn forget to add processing delays in second micro to receive and response signal.
Second method is to use RF itself , but i am not sure that you will be able to calculate delay properly

or third method to find distance for gps or Loran alike coding channel - that needs very stable clock, so forget it .
 

yangxh

Member level 5
Joined
Nov 26, 2004
Messages
94
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Activity points
728
measuring distance

ultrasound sensors,maybe the time delay is the key problem.processing delays and the transmit time may comparable if the distance is small.
 

Igor_S

Member level 1
Joined
Sep 7, 2003
Messages
34
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
324
Re: measuring distance

If you deal with RF, measuring of reflected wave phase (i.e. delay) may be more realistic
 

VVV

Advanced Member level 5
Joined
Nov 26, 2004
Messages
1,582
Helped
384
Reputation
768
Reaction score
88
Trophy points
1,328
Activity points
19,971
Re: measuring distance

yangxh has a good idea. What if you were to transmit simultaneously a burst of ultrasound and an RF one? The RF will be received "instantaneously", while the ultrasound will take a while. So by taking the difference and considering the RF transmission time as negligible, you could measure the distance.

You just need to "listen" for the first burst of ultrasound, not reflections that may come later.
 

Sceadwian

Full Member level 3
Joined
Sep 25, 2005
Messages
174
Helped
15
Reputation
30
Reaction score
0
Trophy points
1,296
Activity points
3,588
measuring distance

At those distances RF distance sensing is virtually useless, you'll get no useful precision out of it, the distance are just too small. Ultrasonic pinging would work pretty well. Depending on how fast your micro controller is you can get a pretty good degree of precision out of it, centimeter or inches maybe. You can throw all the 'air speed velocity' stuff right out the window and calibrate the sensor's at known distances. Simply set up the transmitter to send a pulse as strong as possible that's as short as possible that can sitll be detected. The shorter the pulse the more likley you'll be to detect echo's. Make sure the signal isn't repeated so fast that you'll get harmonic interaction if there are object that cause echo's nearby. Start at 8 feet, find the delay value, move 1 foot away find the delay value etc.. etc.. Mind you if the pulse is short enough and the dimensions and objects of a room are known exact position can actually be determined based on the echo's if you really want to study it.
 

artem

Advanced Member level 4
Joined
May 22, 2003
Messages
1,350
Helped
126
Reputation
252
Reaction score
32
Trophy points
1,328
Location
Turkey
Activity points
13,450
measuring distance

Just another stupid insight in addition to my previous ideas ))

we can try to develop cumulative delay by retransmitting signal in loop on rf . Of course delay for 1 meter is about 3 nanosec (6 nanosec in two way) on RF but repeting such retransmissions sequences numerously and counting cumulative delay we can refine measurement to a needed precision level. retransmission sequence length (code) and speed will affect measurement accuracy. Developing delay for about 1000 tries will give us 6 usec delay added to result which is quite affordable to measure . Of course stable clock will be needed to provide freq wander less than part of delay being developed for needed accuracy . Even clock with one sec deviation per day (~10 micrsec drift per sec) wont be enough but by increasing retransmission speed up to 100 000 per sec - that will be quite suitable.

Please correct me if i am wrong.
 

throwaway18

Advanced Member level 2
Joined
Jun 9, 2005
Messages
596
Helped
101
Reputation
202
Reaction score
24
Trophy points
1,298
Location
Kent, UK
Activity points
8,348
measuring distance

Unless you are using a microwave connection the delay caused by the limited channel bandwidth of a typical license exempt tx/rx pair will be in the range of hundreds of microseconds, not nanoseconds.
 

artem

Advanced Member level 4
Joined
May 22, 2003
Messages
1,350
Helped
126
Reputation
252
Reaction score
32
Trophy points
1,328
Location
Turkey
Activity points
13,450
measuring distance

We are not assuming delay caused by transient processes in circuits , but just wave travel time
1/300 000 000 .

Is this correct ?
 

iscom

Newbie level 5
Joined
Jan 30, 2005
Messages
10
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Activity points
83
Re: measuring distance

This also require acureate and sharp comparison of timing.
 

artem

Advanced Member level 4
Joined
May 22, 2003
Messages
1,350
Helped
126
Reputation
252
Reaction score
32
Trophy points
1,328
Location
Turkey
Activity points
13,450
measuring distance

Yes both of you are right . But i knew that already))

I am keeping going , so, there is another stupid idea )))

First device implements tx runnig on freq f , second device implements receiver on same freq made as LNA with output to PLL (wihtout detection), and PLL is to be locked to the phase of f . PLL output divided by 2 and transmitted to first device . First device implements f/2 receiver with LNA where received signal is amplified and then routed to phase detector. Second input for phase detection is transmitter signal (of first device) divided by 2 . Phase detector output will be directly proportional to delay. If no special coding is done for f freq (if delay exceeds wave length of f) that will allow us to measure distance only up to f wave length. With adding modulation to detect phase number distance detection could be increased , but restricted to environment noise and transmitter receiver characteristics. This method is suitable for short distances.

Added after 1 minutes:

Opinions are wellcome .
 

jallem

Advanced Member level 1
Joined
Jul 23, 2005
Messages
452
Helped
72
Reputation
144
Reaction score
10
Trophy points
1,298
Activity points
4,993
measuring distance

Maybe this book can help.
Reading suggestion: Section 4-2, Range estimation
by W.Lindsey and M.Simon, Telecommunication
Systems Engineering. pp.128-170
 

throwaway18

Advanced Member level 2
Joined
Jun 9, 2005
Messages
596
Helped
101
Reputation
202
Reaction score
24
Trophy points
1,298
Location
Kent, UK
Activity points
8,348
measuring distance

Hmm. Trying to do this with RF carriers instead of impulses will encounter a few difficultlys
but it may work. I think the suggestion to use ultrasonics is a good idea.

I'm not sure if multipath reception would be a problem.
Add together two sinusoids at the same frequency but with different amplitudes
and phases and the result is a single sinusoid with a diferent amplitude and phase.
Refelected signals will cause the apparant phase at the receiver to be different.
It would depend on the enviroment, a room with metal walls might be the worst case.

I think you need the phase shift at maximum distance to be less than half a period
of the rf signal. Speed of light is aproximatley 1nS per foot. 30ft range
means min period is 60nS 1/60nS=16.666MHz

The 13.56MHz and 6.78MHz ISM bands might be suitable. You would need some front
end filtering on the receivers to keep out shortwave radio broadcasts.
Alternativley perhaps 100KHz and 50KHz.

You would need carefull shielding of the VCO to prevent a little bit of the signal
leaking out and getting into the LNA. It would be better to run the PLL VCO at a different frequency to the LNA if possible.

Radio receivers normally use a superhetrodyne system because it is very difficult
to have lots of gain at one frequency without your amplifer becoming an oscillator.
You want as much of the gain at the transmitter end as possible and just enough gain
overall to overcome worst case path loss.

Same problem with the main unit devider and LNA.

You will need to make sure your transponder transmitter dosn't produce 2nd harmonic
output.

I think the devide by 2 means it would have a random 0 or 180degree shift at random.
You could probably detect that and automatically correct it.

EDIT: I forgot it's a round trip measurement, for 30foot range the signal travels 60feet so halve that maximum carrier frequency number.
 

Sceadwian

Full Member level 3
Joined
Sep 25, 2005
Messages
174
Helped
15
Reputation
30
Reaction score
0
Trophy points
1,296
Activity points
3,588
measuring distance

Mind you a micro controller can sample ultra sonic frequencies without dropping a beat and still have time to filter it a little. You require some pretty advanced (read large) external circuitry to process that incoming RF signal down to a useable signal by the MCU, let alone compensate for phase shift. With ultrasonics phase shift can be read directly from the incoming signal with no external circuitry given a few calibration paramaters.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top