• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FSX Trying to get the IF to work in XML

Messages
8
Country
unitedkingdom
I have started to try and get my head around XML, with a view to try and get the startup of the Caravan 208 looking a bit more realistic. I have setup a switch to represent the external power starter with a view to having a higher NG spin up during the start. My switch is set to change L:ExtPower from 0 to 4.
Code:
<Value>(L:ExtPower, bool) 4 == if{ (A:TURB ENG1 N1, percent) * 1.500 } els{  (A:TURB ENG1 N1, percent) } </Value>
This looks good until the engine starts, then it goes off the scale until you set L:ExtPower to 0 again.

So I tried having two different scales for the gauge.
Code:
<Value>(A:TURB ENG1 N1, percent)</Value>
<Nonlinearity>
(L:ExtPower, bool) 4 == if{
<Item Value="0" X="51" Y="242"/>
<Item Value="6" X="23" Y="204"/>
<Item Value="12" X="9" Y="153"/>
<Item Value="20" X="19" Y="92"/>
<Item Value="40" X="92" Y="25"/>
<Item Value="60" X="130" Y="16"/>
<Item Value="65" X="181" Y="12"/>
<Item Value="80" X="282" Y="125"/>
<Item Value="100" X="250" Y="246"/>
 } els{
<Item Value="0" X="20" Y="203"/>
<Item Value="20" X="20" Y="203"/>
<Item Value="40" X="20" Y="203"/>
<Item Value="60" X="20" Y="203"/>
<Item Value="80" X="20" Y="203"/>
<Item Value="100" X="20" Y="203"/>
 }
</Nonlinearity>
but this just uses the first scale and ignores the 'els'? I have moved the (L:ExtPower, bool) 4 == if{ all over the place and get different results, but not what im looking for.

can this be done? any help pointers would be great
 
I don't believe that you can use 'logic' in a <Nonlinearity> section. You will probably be better off creating two separate elements and then using <Visibility> to hide/show the results.
 
In your first example, you need to swap the * and 1.500, so it reads:

Code:
<Value>(L:ExtPower, bool) 4 == if{ (A:TURB ENG1 N1, percent) 1.500 * } els{  (A:TURB ENG1 N1, percent) } </Value>
 
I'm afraid what you are trying to do is not possible.
First the start up sequence in a turboprop is mostly hard wired in the program.
Second you can not change A:TURB ENG1 N1, percent directly if that is what you wanted to do. Some A vars can be changed by using the appropriate Event but there is no Event that changes N1 directly. Once the engine is running it can be changed by adjusting the throttle or mixture lever. During the start up sequence a change of fuel flow rate using Simconnect seems to work but N1 is doing its own thing during start up, probably due to some form of PID which is in the program code.http://www.fsdeveloper.com/forum/threads/tip-turboprop-startup.441170/
Third even if you could change it the changed value is not being stored so you code does nothing.
However the first reason overrides the others.
Sorry,
Roy
 
Last edited:
I'm afraid what you are trying to do is not possible.
First the start up sequence in a turboprop is mostly hard wired in the program.
Second you can not change A:TURB ENG1 N1, percent directly if that is what you wanted to do. Some A vars can be changed by using the appropriate Event but there is no Event that changes N1 directly. Once the engine is running it can be changed by adjusting the throttle or mixture lever. During the start up sequence a change of fuel flow rate using Simconnect seems to work but N1 is doing its own thing during start up, probably due to some form of PID which is in the program code.http://www.fsdeveloper.com/forum/threads/tip-turboprop-startup.441170/
Third even if you could change it the changed value is not being stored so you code does nothing.
However the first reason overrides the others.
Sorry,
Roy

Hi Roy,

Thanks for the information. I have been down the route of trying to change the N1 and as you say its all hard coded to simulate a turboprop, all be it a poor simulation. So my idea is to ignore the hard code and change the visual simulation. During FSX startup the A:TURB ENG1 N1 will wind up to a value of 12 on the battery. The NG gauge was orignal set that N1@12 shows as 16%RPM. So if i change the gauge so the N1@12 is shown as 18%RPM, it looks more like the real thing. If I toggle a GPU switch into the mix, I have added L:ExtPower via GPU.lua triggered through FSUIPC. Then I can tell the NG guage that N1@12 should be shown as 22%RPM when L:ExtPower=1. If I trap the condition lever so it adds a pause before simulating low/high idele, it will appear more realistic in the time it takes for the engine fire up. The the hard code can still do its thing, but it all looks more realistic. thats my theory anyway.
 
In your first example, you need to swap the * and 1.500, so it reads:

Code:
<Value>(L:ExtPower, bool) 4 == if{ (A:TURB ENG1 N1, percent) 1.500 * } els{  (A:TURB ENG1 N1, percent) } </Value>

Hi Dave WG,
yes you are right, i was adding that from memory to hopefully explain the 2nd code better.
 
I don't believe that you can use 'logic' in a <Nonlinearity> section. You will probably be better off creating two separate elements and then using <Visibility> to hide/show the results.
<Visibility> Thats given me something to go at, cheers ....I'm sure I will be back for more ;)
 
The the hard code can still do its thing, but it all looks more realistic. thats my theory anyway.
Just make sure you have the parking brake on when you start, if not when you look up from the N1 or torque gauges you are likely to be in a different county
Roy
 
Um Roy, I'm not sure making a needle simply display a different value is going to affect aircraft movement... :confused:
 
Bill,
The turboprop start surge in one plane I'm flying takes Torque up to 100% before dropping to about 30 after what feels like 30 seconds. My point, rather badly stated,was that changing the value displayed would have no effect on the darned thing scurrying across the airfield if he had not applied the parking brake. I'd rather fix it but I think sure if it is impossible.
Roy
 
Bill,
The turboprop start surge in one plane I'm flying takes Torque up to 100% before dropping to about 30 after what feels like 30 seconds. My point, rather badly stated,was that changing the value displayed would have no effect on the darned thing scurrying across the airfield if he had not applied the parking brake. I'd rather fix it but I think sure if it is impossible.
Roy

Thats intresting, which Aircraft is that? If you could see how that is achived then it would give some insight into changing the C208 startup.
 
I don't believe that you can use 'logic' in a <Nonlinearity> section. You will probably be better off creating two separate elements and then using <Visibility> to hide/show the results.

<Visibility> simple and works great. I had already made two gauges for NG, 1 simulating a battery start and one simulating the GPU start. So once I had spotted that I had used a lower case v in Visbility, it worked great Doh! ...mind you if i ever need a two needle gauge I'm all over it ;)
 
Bill,
The turboprop start surge in one plane I'm flying takes Torque up to 100% before dropping to about 30 after what feels like 30 seconds. My point, rather badly stated,was that changing the value displayed would have no effect on the darned thing scurrying across the airfield if he had not applied the parking brake. I'd rather fix it but I think sure if it is impossible.
Roy

Just make sure you have the parking brake on when you start, if not when you look up from the N1 or torque gauges you are likely to be in a different county
Roy

Imagine an amphibian on the water!!! :eek: The sim doesn't simulate anchors!
While working with Milton on the FS9 port to FSX version of the Turbo Mallard we had this very problem.
Startup on water = cya later, coming out of "so called" beta while taxiing into shore = hitting the beach.
IMO the turboprop simulation is more like a jet engine with big, multi-bladed fans on the outside.
So with that in mind I created a little bit of code to alleviate the physical responses of the sim. It works well, probably could be optimized though.
BTW I also added a version of this code to the Quest Kodiak, which is notoriously terrible coming out of beta - mucho better.
Also works with CTRL-E start.

Some prerequisites, adjust as needed... (Aircraft.cfg)
Code:
[GeneralEngineData]
engine_type =5                                 //0=Piston, 1=Jet, 2=None, 3=Helo-Turbine, 4=Rocket, 5=Turboprop
min_throttle_limit =-0.25000                     //Minimum percent throttle.  Generally negative for turbine reverser

[propeller]
prop_reverse_available  =1                     //Prop reverse available?  0=FALSE, 1=TRUE

[TurbineEngineData]
reverser_available=1

[turboprop_engine]
// No requirements necessary
And the code -

"-255" = the amount of reverse to alleviate the physical affects of runaway (adjust as needed)
"-0.02 -0.01" = the throttle range while in or out of the above number to prevent constant firing of the THROTTLE#_SET command (adjust as required relative to the above number to prevent constant firing, (-255 16384 /) )
"L:OUBETCHA_#, bool" = a logic flip/flop to keep things in line
NOTE - Any reverse annunciators must be recoded to NOT show while in the "slight reverse" mode.

Code:
<Update>

(A:SIM ON GROUND, bool) if{

<!-- Left start, allows normal fs restarts while in the air, unaffecting the throttle. On ground, during start, command slight reverse. -->

-0.02 -0.01 (A:GENERAL ENG1 THROTTLE LEVER POSITION, number) rng ! (A:GENERAL ENG COMBUSTION:1, bool) ! (A:GENERAL ENG1 STARTER, bool) and and if{ -255 (&gt;K:THROTTLE1_SET) }

<!-- Right start, allows normal fs restarts while in the air, unaffecting the throttle. On ground, during start, command slight reverse. -->

-0.02 -0.01 (A:GENERAL ENG2 THROTTLE LEVER POSITION, number) rng ! (A:GENERAL ENG COMBUSTION:2, bool) ! (A:GENERAL ENG2 STARTER, bool) and and if{ -255 (&gt;K:THROTTLE2_SET) }

<!-- Left side, command slight reverse when coming out of reverse/beta. Reset throttle to 0% after a slight blip to overwrite the slight reverse -->

(A:GENERAL ENG COMBUSTION:1, bool) if{
(A:GENERAL ENG1 THROTTLE LEVER POSITION, number) -0.02 &lt; if{ 1 (>L:OUBETCHA_1, bool) }
(L:OUBETCHA_1, bool) (A:GENERAL ENG1 THROTTLE LEVER POSITION, number) 0 == -0.02 -0.01 (A:GENERAL ENG1 THROTTLE LEVER POSITION, number) rng ! and and if{ -255 (&gt;K:THROTTLE1_SET) 0 (>L:OUBETCHA_1, bool) } } els{ 0 (>L:OUBETCHA_1, bool) }

<!-- Right side, command slight reverse when coming out of reverse/beta. Reset throttle to 0% after a slight blip to overwrite the slight reverse -->

(A:GENERAL ENG COMBUSTION:2, bool) if{
(A:GENERAL ENG2 THROTTLE LEVER POSITION, number) -0.02 &lt; if{ 1 (>L:OUBETCHA_2, bool) }
(L:OUBETCHA_2, bool) (A:GENERAL ENG2 THROTTLE LEVER POSITION, number) 0 == -0.02 -0.01 (A:GENERAL ENG2 THROTTLE LEVER POSITION, number) rng ! and and if{ -255 (&gt;K:THROTTLE2_SET) 0 (>L:OUBETCHA_2, bool) } } els{ 0 (>L:OUBETCHA_2, bool) }

 }
 
 <!-- A general reset once in the air, just in case -->
 
 els{ 0 (>L:OUBETCHA_1, bool) 0 (>L:OUBETCHA_2, bool) }
 
 </Update>


Maybe, just maybe, this can git rid of the turboprop woes....
 
Last edited:
Roman,
I put your update code in the Turboprop I was having trouble with. Started without the parking brake and the rascal did not move until I opened the throttle to taxi out.
You are a genius and a scholar Sir!
Mind you it still had awfully slow throttle response, but that's another story.
Roy
 
Roy,

Glad that worked for you.. The advantage to that code is that it forces the throttle levers, albeit very slight.
Was writing lua code to do the same, for all t-props, so gauge coding is not necessary, and while doing testing found something out.
With NO helper code -
Manual start = runaway on startup.
CTRL-E = NO runaway on startup! What's the deal???
IMO the turboprop simulation is more like a jet engine with big, multi-bladed fans on the outside.
Found out it's exactly that! It's not how much fuel one introduces in to the engine but WHEN.
Just like a regular jet engine.
10.99% N1 seems to be the magic number. (When CTRL-E does it)

Here's some code that works (zero runaway & a nice slow start) but with major drawbacks -
Notes - Doing this 10.99% N1 timing thing only works with the condition (mixture) / cut levers.
It does not work at all using fuel valves like in a regular jet engine, still runs away.
A darn shame as using fuel valves would be hidden from the user and act like a ECU/FCU unit that all t-props have.
Drawback?? It physically moves the condition levers during startup sequence.
Code:
(A:GENERAL ENG1 MIXTURE LEVER POSITION, number) 0 != (A:GENERAL ENG COMBUSTION:1, bool) ! (A:GENERAL ENG1 STARTER, bool) (A:Turb eng1 N1, percent) 10.99 &lt; and and and if{ 0 (>K:MIXTURE1_SET) }
0.39 0.41 (A:GENERAL ENG1 MIXTURE LEVER POSITION, number) rng ! (A:GENERAL ENG COMBUSTION:1, bool) ! (A:GENERAL ENG1 STARTER, bool) (A:Turb eng1 N1, percent) 10.99 &gt; and and and if{ 6554 (>K:MIXTURE1_SET) }
One thing I found in FSUIPC/Lua is that I can write to fuel flow just like XMLTools! So... If I can keep FF at zero until 10.99% N1 then combine with the above "slight reverse" code it just may just fix it all. (Lots more testing required!!) EDIT - Negative :-( it was a bad test.
Mind you it still had awfully slow throttle response, but that's another story
Have you tried this?
You are much more adept than I dealing with the FDE in .air files so this is like using "a hammer on the keyboard keys".. LOL

[TurbineEngineData]
fuel_flow_gain =0.01100 //affects spool up time ****

fuel_flow_scalar or other may need to modded after the above to affect range.. (???)
 
Last edited:
If you want something that would be invisible to the end user, you could consider throwing the FREEZE_LATITUDE_LONGITUDE_SET event to prevent the aircraft from moving until such time as it should be able to move.
 
Roman - maybe this is a daft suggestion as I'm not an XML programmer, but can you not isolate the visual part of the gauge from the code that makes them move? I have just this problem at the moment with a mixture lever setup (two sets of levers) that can be changed by both the pilot and the flight engineer. I did all the calculations etc. in one module, then told the two display modules to read the results to set the lever positions because whereas changing the pilot's lever positions changed the FE's lever positions, the reverse is not true!
 
Last edited:
Hi Dai,
Not doing any modelling here nor have access to a/the model source. Just doing some coding to help alleviate the harsh turboprop simulation, hopefully in any turboprop.
 
Back
Top