View Single Post
  #11   Spotlight this post!  
Unread 12-02-2007, 10:58
charrisTTI charrisTTI is offline
Ramblin' Wreck
AKA: Charles Harris
FRC #0623
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2003
Location: Vienna, VA
Posts: 106
charrisTTI has a spectacular aura aboutcharrisTTI has a spectacular aura about
Send a message via AIM to charrisTTI
Re: Value of degree to calculate range?

First to clarify: Math functions in the C library work with radians, not degrees.

Here is excerpt from MPLAB C18 libraries manual:

tan
Function: Compute the tangent.
Include: math.h
Prototype: float tan( float x );
Remarks: Computes the tangent of x (in radians). A domain error occurs if the
argument is infinite or NaN. Both cases return NaN.
Return Value: The tangent of x.
File Name: tan.c


Attached is spread sheet for calculating a look-up table. Copy and paste the data from the Range Text column to create your array. See rangelu.c for example of completed array.

When you need to use the array declare as extern in that file.

extern const rom unsigned short targetRange[];


If you use Kevin's changes to increase resolution on the tilt axis. The number of table entries will need to increase and the PWM TO DEGREES factor will need to be changed.
Attached Files
File Type: xls TargetRange.xls (37.0 KB, 31 views)
File Type: c rangelu.c (857 Bytes, 34 views)
__________________
FRC 623 2003,2004,2005,2006,2007,2008, 2009, 2010, 2011
FRC 1900 2007
FVC 60 and 193 2006
FVC 3271 2007
FTC 226 and 369 2008, 2009, 2010, 2011
FTC 3806 2010