Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Gyro PID Programming (http://www.chiefdelphi.com/forums/showthread.php?t=112462)

UriF 01-02-2013 10:30

Re: Gyro PID Programming
 
Thank you Jefferson, Ether. You have helped me understand this greatly.

Ether 01-02-2013 11:19

Re: Gyro PID Programming
 
Quote:

Originally Posted by Jefferson (Post 1225804)
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.




All times are GMT -5. The time now is 14:32.

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