Go to Post Wait is that how they got there, well how does one spotlight? - AlexD744 [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rating: Thread Rating: 22 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #3   Spotlight this post!  
Unread 31-01-2013, 14:52
UriF UriF is offline
Registered User
FRC #2213
 
Join Date: Jan 2012
Location: Israel
Posts: 27
UriF is an unknown quantity at this point
Re: Gyro PID Programming

Alright, I don't currently have the code with me so this is an approximation:
Code:
#define GYRO_SCALE(x) ((x) / 360)

/*
 * This fixes the Angle overflow problem, so the angle is always in the range
 * -360 to 360 
 */
float Gyro_FixAngle(float Angle)
{
   int Laps = Angle / 360;
   return (Angle - (Laps * 360));
}

double PIDGet()
{
   return GYRO_SCALE(Gyro_FixAngle(Gyro1->GetAngle()));
}
Reply With Quote
 


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


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

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