Board index FlightGear Development Aircraft Systems

Smooth out a calculated value in fuel system

Modeling aircraft systems, like electrical stuff, hydraulics, pneumatics? Feel free to ask support.

Smooth out a calculated value in fuel system

Postby benih » Sun Sep 17, 2017 10:13 am

Hello,
i am trying to figure out how to smooth out a calculated value inside a fuel system.

The goal here is to make the priming mixture flow depend on mixture and throttle control levers (works). the resulting flow should not be "there" immediately however, but should be smoothed out depending on where it was before, that is, i want to dampen the value by applying a moving average of the last seconds.
For example, when i set the mixture to 1 and the throttle to 1; the calculated flow is 0.125. I want the resulting value slowly climb from 0 to 0.125 (say in one second) while it is fast at first, slowing don when it reaches the target value of 0.125.

I tried to use a "moving average filter" with no luck, it always gave me "0" as resulting value.
How can i achieve that?

Code: Select all
<fcs_function name="/systems/fuel/priming-mixture-flow-pps">
            <function>
                <product>
                    <property>/controls/engines/engine/mixture</property>
                    <property>/controls/engines/engine/throttle</property>
                    <value>0.125</value>
                </product>
            </function>
            <output>/systems/fuel/priming-mixture-flow-pps</output>
</fcs_function>
benih
 
Posts: 96
Joined: Tue Aug 15, 2017 9:34 am

Re: Smooth out a calculated value in fuel system

Postby Thorsten » Sun Sep 17, 2017 11:23 am

I usually use a <kinematic> tag for things which should adjust to a target value within a given time.
Thorsten
 
Posts: 11108
Joined: Mon Nov 02, 2009 8:33 am

Re: Smooth out a calculated value in fuel system

Postby benih » Sun Sep 17, 2017 1:10 pm

How exactly does this work? Where can i read up on the matter?
benih
 
Posts: 96
Joined: Tue Aug 15, 2017 9:34 am

Re: Smooth out a calculated value in fuel system

Postby Alant » Sun Sep 17, 2017 1:26 pm

For a start see section 3.1.9.1.13 of the JSBsim manual.

Also if you google "jsbsim <kinematic>" you will find some helpful posts.
Alant
 
Posts: 913
Joined: Wed Jun 23, 2010 5:58 am
Location: Portugal
Callsign: Tarnish99
Version: from Git
OS: Windows 10

Re: Smooth out a calculated value in fuel system

Postby benih » Wed Sep 20, 2017 6:53 pm

Ok i played a little with it successfully, but it is not what i need.
the kinematic indeed does introduce the desired lag, however linearly.

What i need it this:
- assume instant value change of the input from 0 to 6.
- the output value should now climb from 0 to 6 in about 3 seconds but degressive in speed, i.e. the first 5 values go nearly linearly in 2 seconds where the last 1 value needs another second...

It has to get slower and slower towards the end, similar to the K(x) courve below:

Image
benih
 
Posts: 96
Joined: Tue Aug 15, 2017 9:34 am

Re: Smooth out a calculated value in fuel system

Postby Alant » Wed Sep 20, 2017 7:50 pm

In this case see this section .3.1.9.1.1 (Filter Component) in the Jsbim manual.

Alan
Alant
 
Posts: 913
Joined: Wed Jun 23, 2010 5:58 am
Location: Portugal
Callsign: Tarnish99
Version: from Git
OS: Windows 10

Re: Smooth out a calculated value in fuel system

Postby Thorsten » Wed Sep 20, 2017 8:18 pm

... or pass the output of the kinematic through a non-linear mapping using a table in an <fcs_function> component

... or (mis)-use a PID controller to solve an integro-differential equation for the rate.

Dependent on your precise needs, there's a gazillion of ways you could code it.
Thorsten
 
Posts: 11108
Joined: Mon Nov 02, 2009 8:33 am


Return to Systems

Who is online

Users browsing this forum: No registered users and 1 guest