Sign in to follow this  
Guest Patrick_Waugh

Dampening in C

Recommended Posts

Well, to control the bank indicator I tried this:double dampening = 0.91;FLOAT64 FSAPI Attitude_Bank_cb(PELEMENT_SPRITE pelement){ FLOAT64 bank_degs; lookup_var(&bank); // MODULE_VAR defined above if(isPowerOn & isGyroPowerOn) { // Battery ON AND Gyro switch ON -track toward var_value bank_degs = bank.var_old.n * dampening + bank.var_value.n * ( 1.0 - dampening ); bank.var_old.n = bank.var_value.n; } else { // Gyro not powered -track toward 28 degrees bank bank_degs = bank.var_old.n * dampening + 28 * ( 1.0 - dampening ); bank.var_old.n = bank.var_value.n; } return bank_degs;}but while the bank indicator moves as desired with both Gyro and Battery off, the second I turn on the Battery, it starts tracking to 0 bank (level) even though the Gyro switch is OFF.Any ideas on why? This seems to be impossible given the code above. Also, I hard coded two returns in the if statement, and they worked as expected. So, must be my formula.Patrick

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

Thanks Arne, but even after correcting this mistake it doesn't work.Hmmmm I'll look at it later today, must be something I am missing.Patrick

Share this post


Link to post
Share on other sites

After being more awake, correcting the error Arne spotted for me (thanks Arne), and further testing, I have concluded that actually the code was working, only so fast, it syncs up right away, and made me think it was not working.So, I just need to play more with it.Patrick

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this