Go to Post I've had parents tell me I'm a great role model for their daughters, because I was a female leader. It's a great feeling to hear something like that. - Liz Smith [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
  #16   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.
  #17   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 03:36.

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