View Single Post
  #1   Spotlight this post!  
Unread 11-02-2007, 13:34
Ianuser Ianuser is offline
Registered User
FRC #0570
 
Join Date: Feb 2007
Location: new york
Posts: 64
Ianuser is an unknown quantity at this point
Value of degree to calculate range?

Hi everyone. I'm not sure if what I'm doing to get the degree for the tilt_servo to find the range of the bot to the rack is correct.
I wrote this in tracking.c at the very bottom:

Code:
unsigned float Find_Distance(void)
{
   float radian;
   float range;
   radian = ((((angle I will measure in degrees that the tilt servo has to offer from down to up) / 256) * pi) / 180) * pwm07(which is my tilt_servo pwm);
   range = (116 - (distance I have yet to measure between the floor and my camera because we haven't placed it yet)) / tan(radian);
   return(range);
}
I read on another thread that the angle has to be in radians for the Tan() function to take in. Also, does it matter in which source file I place this function? SO, my real questions are, Does anything about what I wrote make sense? And how does this compare to the:
pan angle = ((current pan PWM) - (pan center PWM)) * degrees/pan PWM step ?(other than I'm looking for tilt rather than pan). Do I have to subtract my pwm07 by something like you did in this one? Sorry if I'm being confusing, but I'm trying to understand all of this at once. (My team is made up of 5 people and I'm the only electrician and the only programmer and I don't have much experience as a junior in high school.)