CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

IR Returned Value

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
NivNavick



Joined: 01 Nov 2010
Posts: 47

View user's profile Send private message

IR Returned Value
PostPosted: Thu Feb 03, 2011 2:06 pm     Reply with quote

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

View user's profile Send private message MSN Messenger

PostPosted: Thu Feb 03, 2011 2:14 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Feb 03, 2011 3:01 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Feb 03, 2011 3:35 pm     Reply with quote

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

View user's profile Send private message MSN Messenger

PostPosted: Thu Feb 03, 2011 4:00 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Feb 03, 2011 4:07 pm     Reply with quote

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

View user's profile Send private message MSN Messenger

PostPosted: Thu Feb 03, 2011 4:19 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group