View Single Post
  #12   Spotlight this post!  
Unread 12-02-2007, 21:22
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: Servo Values to Degrees... How?

This is what I have now, I have no idea if it is going to work. Please help if you can.
My tilt_servo is pwm07, my default MAX for tilt is 194, min is 94, center is 144, step is 50. QUESTION: if I change the step to 25, will it automatically make twice as many steps? will it cut the time in half? how is that programmed. ALSO, DOES THIS MAKE ANY 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]);
}
Those numbers in the array are the distance for each pwm index all the way up to 127 (90 degrees approximately). How does this relate to my 94 min, 194max for my tilt servo? Don't i have to change those to make this work? I'm a little confused. THanks!