View previous topic :: View next topic |
Author |
Message |
NivNavick
Joined: 01 Nov 2010 Posts: 47
|
IR Returned Value |
Posted: Thu Feb 03, 2011 2:06 pm |
|
|
hi
I have a function that detect if the IR sensor is detecting an IR that
generate by a ball.
Code: |
while(input(pin)==0);
set_TIMER5(0);//
while(input(pin)==1);
set_TIMER5(0);//
while(input(pin)==0);
return get_timer1();
|
I am using timer 5
my question is how do I know by the value timer what is distance from the ball? |
|
|
vinniewryan
Joined: 29 Jul 2009 Posts: 154 Location: at work
|
|
Posted: Thu Feb 03, 2011 2:14 pm |
|
|
what is your method for calculating the distance? Typically you would use an IR LED to emit a pulse of light, and at that moment timer5 would begin counting. Then once your IR sensor recieves the IR signal back and (preferably) triggers an interrupt, timer5 will stop and you can calculate the distance based on the value of timer5.
Does this sound like what you're trying to do? _________________ Vinnie Ryan |
|
|
gpsmikey
Joined: 16 Nov 2010 Posts: 588 Location: Kirkland, WA
|
|
Posted: Thu Feb 03, 2011 3:01 pm |
|
|
With ultrasonics you can measure distances like that, but with light at around 300,000,000 meters/second, you are going to be hard pressed to have a processor fast enough to be able to measure anything close to you (same ranging as RADAR ).
mikey _________________ mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3 |
|
|
NivNavick
Joined: 01 Nov 2010 Posts: 47
|
|
Posted: Thu Feb 03, 2011 3:35 pm |
|
|
vinniewryan wrote: | what is your method for calculating the distance? Typically you would use an IR LED to emit a pulse of light, and at that moment timer5 would begin counting. Then once your IR sensor recieves the IR signal back and (preferably) triggers an interrupt, timer5 will stop and you can calculate the distance based on the value of timer5.
Does this sound like what you're trying to do? |
Kind of, my teacher told me not to measure the distance by formula.
He told me to do the following.
If timer5 value is between 600-800 the robot is X from the ball (not exact distance) etc...
What I can understand is there is no formula to calculate the distance between the ball and the sensor.
What do you think about my teacher's method?
Thanks |
|
|
vinniewryan
Joined: 29 Jul 2009 Posts: 154 Location: at work
|
|
Posted: Thu Feb 03, 2011 4:00 pm |
|
|
Are you using an IR LED to emit the light being received by the IR sensor?
I'm assuming your teacher wants you to use the speed of timer5 to calculate distance IE. Ball is 1 foot away, timer5 stops at 600, you now know 1 foot is equal to 600 ticks, now do the same thing at 3 feet, then find the curve between both numbers. This method will give you a general relationship between the distance of the ball versus the speed of timer5, and you now have an estimate from any distance between 1 and 3 feet. _________________ Vinnie Ryan |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Thu Feb 03, 2011 4:07 pm |
|
|
You will learn if you do the math yourself:
How fast can you get timer5 to run?
How long is each timer5 tick?
How much distance is each tick, keeping in mind that the IR goes 2 ways, out to the ball and then back in?
What sort of distance are you trying to measure? (I hope it is a lot longer than 1 to 3 feet!) _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
vinniewryan
Joined: 29 Jul 2009 Posts: 154 Location: at work
|
|
Posted: Thu Feb 03, 2011 4:19 pm |
|
|
and considering light travels over 983 million feet per second, your processor would have to be faster than 450 Mhz to measure 1 foot (2 including bounce back) in only 1 timer tick. This is obviously an unrealistic scenario. _________________ Vinnie Ryan |
|
|
|