Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 21st February 2005, 08:44 PM   #1
Default RF Time of Flight Measurements using a PIC

Hi,

I've been trying to use a PIC to measure RF time of flight thru this method:

I start TIMER0 and then transmit my data over RF to another PIC. The other PIC processes the data and replies. Upon receiving the data, i stop the timer. Taking the difference between the timer0 readings, and taking away all appropriate processor delays, I should be able to find the time-of-flight.

However, TIMER0 increments every instruction cycle(ie 4 clk cycles). With a processor speed of 40MHz, that gives 0.1us per increment. Leading to a very low accuracy. Each increment in TIMER0 will mean a 15m increase in distance.

I'm trying to reduce this value.

Anyone has any suggestions? OR am i doing this wrongly?

Thanks!!
jfunkie is offline  
Old 21st February 2005, 09:41 PM   #2
Default

You may try to use external input to you counter/timer... This should improve accurancy, but the external frequency should be as fast as you can provide.
__________________
"I share, thus I am"
Jay.slovak
Read this!
ICD2 Clone
Best PIC/DsPIC Bootloader

Read my Inchworm ICD2 review!
Jay.slovak is offline  
Old 21st February 2005, 11:22 PM   #3
Default

Yup. i've thought of that. But can the external oscillator be set faster than the internal processor?
jfunkie is offline  
Old 22nd February 2005, 09:11 AM   #4
Default

As much as I found out from datasheet:
Timer 1 asynchronus external clock input should have 60ns+ period. So the maximum frequency is around 16Mhz..
__________________
"I share, thus I am"
Jay.slovak
Read this!
ICD2 Clone
Best PIC/DsPIC Bootloader

Read my Inchworm ICD2 review!
Jay.slovak is offline  
Old 22nd February 2005, 06:13 PM   #5
Default Re: RF Time of Flight Measurements using a PIC

Quote:
Originally Posted by jfunkie
However, TIMER0 increments every instruction cycle(ie 4 clk cycles). With a processor speed of 40MHz, that gives 0.1us per increment. Leading to a very low accuracy. Each increment in TIMER0 will mean a 15m increase in distance.

I'm trying to reduce this value.

Anyone has any suggestions? OR am i doing this wrongly?

Thanks!!
What kind of accuracy are you looking for?
The simple solution would be to ping it back and forth 1000 times before stopping the timer, thus increasing your resolution 1000x.

It is a tricky circuit. You would need to know exactly how long the RX and TX take, as well as the RF-to-PIC circuit delays. Some of that will just be an ad-hoc calibration adjustment. You will need to be sure that it takes the exact same number of clocks every time, so the code cannot experience an interrupt, etc.

[edit] - Multiple pings won't change the fact that when the RF crosses in and out of the PIC domain that it will have to sync with the PIC clock, which still means there is a significant quantification error. i.e. it's either going to picked up on one clock or the other so the finer points of the delay through each cycle will be lost. Perhaps the averaging effect of so many pings will be able to increase the resolution again.
Oznog is offline  
Reply

Tags
flight, measurements, pic, time

Thread Tools
Display Modes




All times are GMT. The time now is 09:09 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker