View Single Post
  #10   Spotlight this post!  
Unread 12-02-2007, 17:17
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
Re: Value of degree to calculate range?

So this is what I have so far. My pwmTILT is pwm07. My default center Tilt is 144 because the min is 94 and the max is 194. Also, the tilt_serach_step default is 50, so it makes 3 stops for tilt. Here is my code now, does this make sense?
Code:
const rom unsigned short targetRange[] =
{
    USHRT_MAX,  // zero index is undefined
5519,
2759,
1839,
1102,
918,
787,
688,
611,
549,
499,
457,
421,
390,
364,
340,
320,
302,
285,
270,
257,
234,
223,
214,
205,
197,
189,
182,
176,
169,
163,
158,
153,
148,
143,
139,
134,
130,
127,
123,
119,
116,
110,
107,
104,
101,
99,
96,
94,
91,
89,
87,
85,
82,
80,
78,
76,
75,
73,
71,
69,
68,
66,
64,
63,
61,
60,
58,
57,
55,
54,
53,
51,
50,
49,
48,
46,
45,
44,
43,
42,
40,
39,
38,
37,
36,
35,
34,
33,
32,
31,
30,
29,
28,
27,
26,
25,
24,
23,
22,
21,
20,
19,
18,
18,
17,
16,
15,
14,
13,
12,
11,
11,
10,
9,
8,
7,
6,
5,
5,
4,
3,
2,
1,
0
};

unsigned int Find_Distance(void)
{
	return(targetRange[pwm07-67]);
}
I subtracted the pwm07 by 67 because there is a 67 difference between the max_pwm (194) and the number of items in the array, so that means if the pwm is going at 194, then return the 127th item which is 0. So, does that make sense? Did I miss something or make wrong calculations?

(ALSO, my camera does not function properly. It turns on, everything is dandy, but it does not track the light well. It has only locked onto the light once out of many tries. The camera will often face quite to the left of the actual light and then it will go up and down in short steps very fast. Any suggestions?)