# Detecting Rate of Change

## Recommended Posts

I would like to detect the rate at which a variable is changing and react to the rate, as opposed to the number in the variable.For instance, if I adjust the throttle too quickly, I would like to make another user defined variable dependant upon the rate it is increased, but if the throttle is adjusted slowly, there would be no impact on the second variable.Any thoughts?Steve

#### Share this post

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

Hi Steve,That's not very complicated.- Read the throttle, and save it's value in a temp variable.- In the next schedule, read the throttle again and compare with the previously saved value. Since the interval time betwen two samples is known (and fixed in in FS) you have a measure for the speed of change.(IN XML: the UPDATE FREQUENCY determines the schedue rate).If you want to make it more accurate:use either a fixed average (calculate the average over a fixed time (eg. 10 or 20 samples), or use a moving average (the average over the last x samples at any point in time).Disadvantage of using an average, is of course a "lag" in response time.Or even more complex (which eliminates this "lag"): make a predictive algoritm (so assume future values based on history); and constantly verify/adapt that.Cheers, Rob Barendregt.

#### Share this post

##### Share on other sites

RobCan you post an example of the xml code??Im lost on this one.Steve

#### Share this post

##### Share on other sites

Steve, (A:GENERAL ENG1 THROTTLE LEVER POSITION,percent) (G:Var1) - (>G:Var2) (* Var2 contains the difference between current read throttle position and previous one *) .... .... (A:GENERAL ENG1 THROTTLE LEVER POSITION,percent) (>G:Var1) Example:if the value of G:Var2 is 2, it means that in this interval the throttle is changing at a rate of 6*2= 12 % per sec.If this doesn't make it clear, I suggest you better describe exactly what you want to accomplish.. That will make it easier to give a good example ..Cheers, Rob

## 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

• Tom Allensworth,
Founder of AVSIM Online

• ### Hot Spots

• Flight Simulation's Premier Resource!

AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

Click here for more information and to see all donations year to date.
• ### Donation Goals

AVSIM's 2018 Fundraising Goal

Donate to our annual general fund. This donation keeps our doors open and providing you service 24 x 7 x 365. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. We reset this goal every new year for the following year's goal.

\$19,480.00 of \$36,000.00 goal reached.
Donate Now