Go to Post Geez, now I'm like some all-knowing all-seeing FIRST sage who lives in the moutains waiting for students to venture upwards to my home to ask me if there will ever be a water game....:rolleyes: - Koko Ed [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 10-02-2007, 16:16
paulcd2000's Avatar
paulcd2000 paulcd2000 is offline
Accidentally speaks in C
AKA: Paul Dagnelie
FRC #1719 (The Umbrella Corp.)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Baltimore
Posts: 368
paulcd2000 is a jewel in the roughpaulcd2000 is a jewel in the roughpaulcd2000 is a jewel in the rough
Send a message via AIM to paulcd2000
Re: Servo Values to Degrees... How?

but how can you convert tilt servo values into degrees. sorry, i'm kinda tired, so i might be being dense

EDIT: Would this work?
Code:
				angle= (TILT_SERVO-STOP)*0.75757575;
				distance = HEIGHT_DIFF/atan(angle);
.757575... is the degrees per servo step
__________________
"People don't say 'It's just a game' when their team is winning!" -- Scott Adams

5.5 students (on average)* $7/h *210 hours/student= $8085 of labor, all volunteered (not counting mentors', who are each that much)

We have blades on our robot?! ***sweeeeeet***

There are 11 types of people in the world. Those who can read binary, those who can't, and those who say this joke is supposed to be, "There are 10 types of people in the world. Those who can read binary and those who have a life."

Last edited by paulcd2000 : 10-02-2007 at 16:29. Reason: wait a minute...
  #2   Spotlight this post!  
Unread 10-02-2007, 20:38
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?

So, wait a minute. I wrote this:
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);
}

I read on another thread that the angle has to be in radians for the Tan() function to take in. Also, I put this in Tracking.c. Does it matter where 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 that was stated earlier in this thread (other than I'm looking for tilt rather than pan) Do I have to subtract my pwm07 by 124 like you did in this one? Sorry if I'm being confusing, but I'm trying to understand all of this at once. I also have questions about why my camera doesn't work PERIOD. It's all hooked up but it seems to not be getting power. Anyway, one thing at a time. Please help me if you can! Thanks

Last edited by Ianuser : 10-02-2007 at 20:41.
  #3   Spotlight this post!  
Unread 10-02-2007, 23:15
gnirts gnirts is offline
Suspicious pointer conversion
AKA: Robinson Levin
FRC #1648 (The Gearbox Gangstaz)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2005
Location: ATL
Posts: 116
gnirts will become famous soon enough
Re: Servo Values to Degrees... How?

Quote:
Originally Posted by paulcd2000 View Post
but how can you convert tilt servo values into degrees. sorry, i'm kinda tired, so i might be being dense

EDIT: Would this work?
Code:
                angle= (TILT_SERVO-STOP)*0.75757575;
                distance = HEIGHT_DIFF/atan(angle);
.757575... is the degrees per servo step
I am pretty sure you want tan() and not atan()

Good luck,
Robinson
  #4   Spotlight this post!  
Unread 12-02-2007, 13:32
jdejoannis jdejoannis is offline
Registered User
FRC #1845
 
Join Date: Feb 2006
Location: Atlanta,GA
Posts: 48
jdejoannis will become famous soon enoughjdejoannis will become famous soon enough
Re: Servo Values to Degrees... How?

From "The C Library Reference Guide, 1997, Eric Huss" (available online):
2.7.2.9 tan
Declaration:

double tan(double x);

Returns the tangent of a radian angle x.

Range:

There is no range limit on the argument or return value.
In short - yes, the angle is in radians (and it should be a double).
  #5   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!
  #6   Spotlight this post!  
Unread 13-02-2007, 11:02
jdejoannis jdejoannis is offline
Registered User
FRC #1845
 
Join Date: Feb 2006
Location: Atlanta,GA
Posts: 48
jdejoannis will become famous soon enoughjdejoannis will become famous soon enough
Re: Servo Values to Degrees... How?

Thats an interesting idea. Essentially you prefer to tabulate rather than calculate the tangent. In principle, I have no objections. You can choose whatever step size and range you want for the tracking. Those won't affect the range calculation because they are merely properties of the search algorithm (see tracking.c). You will be taking the pwm value after the search is over and the camera is locked on. I am not sure why you are subtracting 67 from the pwm lookup. Shouldn't it be the tilt min 94?

Jason

Last edited by jdejoannis : 13-02-2007 at 11:07.
  #7   Spotlight this post!  
Unread 04-04-2007, 01:48
#root:'s Avatar
#root: #root: is offline
Registered User
FRC #1622 (Team Spyder)
Team Role: Programmer
 
Join Date: Mar 2007
Rookie Year: 2006
Location: Poway, CA
Posts: 3
#root: is an unknown quantity at this point
Thumbs down Re: Servo Values to Degrees... How?

Hey, I've been having a problem setting the correct degrees to a variable, even though it prints to the terminal correctly.

pan_angle = (((int)PAN_SERVO - 124) * 65)/124;
tilt_angle = (((int)TILT_SERVO - 144) * 25)/50;

I have tried making these variables ints, floats, and doubles (they are global static declared in user_routines.h, set in terminal.c, and used in user_routines_fast.c). Would it help if I cast pan_angle and tilt_angle as ints or changed 124 to 124.0? Maybe if I did

(int) pan_angle = (int) (((int)PAN_SERVO - 124) * 0.5242);

Any help would be appreciated. Thanks!
  #8   Spotlight this post!  
Unread 10-04-2007, 04:47
#root:'s Avatar
#root: #root: is offline
Registered User
FRC #1622 (Team Spyder)
Team Role: Programmer
 
Join Date: Mar 2007
Rookie Year: 2006
Location: Poway, CA
Posts: 3
#root: is an unknown quantity at this point
Arrow Re: Servo Values to Degrees... How?

I would appreciate any help, especially if you had problems using the bells and whistles camera code versus the regular one.

Thanks
  #9   Spotlight this post!  
Unread 10-04-2007, 11:02
jerry w's Avatar
jerry w jerry w is offline
Free Agent Mentor
no team (Team Krunch)
Team Role: Engineer
 
Join Date: Nov 2003
Rookie Year: 2002
Location: dunedin fl
Posts: 113
jerry w has much to be proud ofjerry w has much to be proud ofjerry w has much to be proud ofjerry w has much to be proud ofjerry w has much to be proud ofjerry w has much to be proud ofjerry w has much to be proud ofjerry w has much to be proud ofjerry w has much to be proud of
Re: Servo Values to Degrees... How?

Quote:
Originally Posted by #root: View Post
Hey, I've been having a problem setting the correct degrees to a variable, even though it prints to the terminal correctly.

pan_angle = (((int)PAN_SERVO - 124) * 65)/124;
tilt_angle = (((int)TILT_SERVO - 144) * 25)/50;

I have tried making these variables ints, floats, and doubles (they are global static declared in user_routines.h, set in terminal.c, and used in user_routines_fast.c). Would it help if I cast pan_angle and tilt_angle as ints or changed 124 to 124.0? Maybe if I did

(int) pan_angle = (int) (((int)PAN_SERVO - 124) * 0.5242);

Any help would be appreciated. Thanks!
Be careful when declaring variables. They should not be declared in the header file. The header is used in several places, which can cause copies of variables to occur.
In the user.c you should have;
Code:
int   pan_angle = 0 ;
In user.h you should have;
Code:
extern int   pan_angle ;
Then user_fast.c will see the external variable when the header is read.

Jerry w
__________________
Happiest when people tell the truth... However, I am blessed with many friends.
  #10   Spotlight this post!  
Unread 11-04-2007, 02:03
#root:'s Avatar
#root: #root: is offline
Registered User
FRC #1622 (Team Spyder)
Team Role: Programmer
 
Join Date: Mar 2007
Rookie Year: 2006
Location: Poway, CA
Posts: 3
#root: is an unknown quantity at this point
Re: Servo Values to Degrees... How?

I tried to declare it as an extern, but I was having trouble using and then accessing the variable in both terminal.c and user_routines_fast.c.

Well, hopefully I can figure it out by the time the competition starts!
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Servo behavior question / advanced servo/PIC programming question DanL Electrical 12 18-10-2005 18:33
Servo Compact Design Problems!!! Dominator_Legen Electrical 22 07-04-2005 18:15
Servo Values DanDon Motors 8 14-02-2005 15:49
Dashboard View of Pan and Tilt Servo Values JoeXIII'007 Programming 1 02-02-2005 22:34


All times are GMT -5. The time now is 18:25.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi