Go to Post I don't actually have any hex shaft stock in my house (I live in an unusual household). - ollien [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

 
Reply
Thread Tools Rating: Thread Rating: 22 votes, 5.00 average. Display Modes
  #16   Spotlight this post!  
Unread 01-02-2013, 10:30
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

Thank you Jefferson, Ether. You have helped me understand this greatly.
Reply With Quote
  #17   Spotlight this post!  
Unread 01-02-2013, 11:19
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,102
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Gyro PID Programming

Quote:
Originally Posted by Jefferson View Post
So, get the input corrected to match the suggested range. This isn't just scaling or constraining, btw. You will need to add or subtract the extra turns if they are in there (fmod).
remainder(x,360) takes any angle and normalizes it to the range -180..+180. In other words, it finds the equivalent smallest-magnitude angle. fmod does not do this.

Once your angle is in the range -180..+180, you can simply divide it by 180 to put it in the range -1..+1 if you want.

If your C compiler does not have a remainder(x,y) function per per IEC 60559
as specified on Page 235 Section 7.12.10.2 of ISO/IEC 9899:TC3 ,
you can create your own as I showed in a previous post.


Reply With Quote
Reply


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 13:41.

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