• 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.

FSXA XML Loop Challenge!

n4gix

Resource contributor
I need some ideas on how to script an XML loop such that it will loop in a count of 10, but with controllable starting and stopping values.

I have a 'vibration' node that is currently 40 frames long. I need to loop between 0 - 9, but be able to slide the start/stop variables upwards, thereby shifting the range all the way to 31 - 40. Each "block" of 10 frames has decreasing periods of oscillation so that at the highest range the 'vibration' has smoothed out to a steady but subtle vibration.

I'm thinking to modulate this 'vibration node' via throttle levers. Here is a simplified diagram.

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ... 41
|______________| ----->

As the start/stop vars increase, the animation block will gradually increase from 0/9 until it reaches 31/40
 
Last edited:
Ok, your actual loop should always be from 0 to 9... it should not need to ever change.

Then you take the output from that loop and add in an offset that ranges from 0 to 30... thus all you need to control is the base offset that gets added to the loop value.
 

Heretic

Resource contributor
If your loop is always between 0 and 9 and you want to use throttle as a control variable (instead of engine RPM percentage?), 100% throttle should set the starting keyframe to 41-9 = 32 and the end to 32+9 = 41 keyframes. Throttle lever range is from 0 to 100, so a result of at 100% 32 requires a divider of 3 (leaving a remainder of 4). The starting key frame is put to stack 1, and offset by 10 (instead of 9 to take proper modulo).
Each loop, the current keyframe is tested for its numerical value. If it has been reset due to the modulo (difference greater than 9), the starting value of the current number range is assigned to the vibration variable so the cycle can begin anew.

Code:
(A:GENERAL ENG THROTTLE LEVER POSITION:1, percent) 3 / near 32 min d s1 10 + s2

(L:Vibration Anim, number) l2 - 9 > if{ l1 (>L:Vibration Anim, number) }
(L:Vibration Anim, number) + l2 %  (>L:Vibration Anim, number)

No idea if this actually works and covers all scenerios, but that's all I can come up with at the moment.
 
I'm using such a code in the F-4 for cockpit vibration.
I'm using the formula:

amplitude=A*sin(w*t)
A=the maximum amplitude of oscillation
t=the time
w=the angular velocity

How you can set it up:
Amplitude (A):
This should be half your desired range. In this case from +/- 4.5 to +/-20.

(THROTTLE_LEVER/100)*15.5+4.5
This will produce a result of 0+4.5=9 when throttle is idle, 20 when full, which will oscillate between its positive and negative values smoothly as time changes.

Time (t):
Just be sure that is in seconds. Use an FSX time variable and use its decimal part.

Angular velocity (w):
A value of 2xpi will give you 1Hz (1 oscillation from 0-to-max-to-0 every second).
You can scale it up/down using the throttle variable as well.

I.e. Throttle 0=10Hz, Throttle 100=100Hz.
This would mean that w=max(1,(THROTTLE_LEVER/10))*10

Bias:
As the formula produces results between -4.5/+4.5 up to -20/+20, you need to add a bias to make it 0-9 to 0-40.

Thus, add this: (THROTTLE_LEVER/100)*15.5+4.5

Thus the end result would be:
Code:
((THROTTLE_LEVER/100)*31+9)*sin(max(1,(THROTTLE_LEVER/10))*10*(LOCAL_TIME mod 1))+((THROTTLE_LEVER/100)*15.5+4.5)

In XML format for your modeldef that would be:
Code:
THROTTLE_LEVER 100 / 31 * 9 + 1 THROTTLE_LEVER 10 / 1 max 10 * LOCAL_TIME 1 % * sin * THROTTLE_LEVER 100 / 31 * 9 + +

This scales smoothly. You need to keyframe your model for the maximum oscillation (kf0-40). The code will limit it to the appropriate range.

You can modify any of the parameters to make it as dynamic as you like, or even add a second oscillation there (2nd engine?) and add the two to get combined results.
 

n4gix

Resource contributor
Thank you gentlemen for the fresh ideas. Ed and Bjoern have both suggested pretty much the same idea, which is simple and keeps to my goal of following the K.I.S.S. principle.

I will likely have to expand the idea to use a second block of 'vibrations' since I was just tasked by the boss to cut the vibration period when wheels are off the ground.

I also like Alexis' idea and may wind up trying this out should the simpler method not be satisfactory. This however would have to be done in a C gauge, since XML is limited to around 18 Hz rate. :(

The reason why I've begun using blocks of 10 frames is to induce some bit of randomness to the vibration, since each frame has a slightly different amount of 'movement' from the neutral position.
 
Last edited:

n4gix

Resource contributor
Okay, here is what I wound up with. I think it will satisfy most admirably. I did make a bit of a compromise in that when off ground the starting frame is biased by +8. This reduces the vibrational period by simply using the last three frames of each block of ten rather than the entire block.

Code:
<!-- SHAKE RATTLE LOOP -->
    (A:GENERAL ENG COMBUSTION:1,bool)
    (A:GENERAL ENG COMBUSTION:2,bool) or
    if{
    (A:SIM ON GROUND,bool) if{ 0 (>L:OffGrnd,enum) } els{ 8 (>L:OffGrnd,enum) }

    (A:GENERAL ENG THROTTLE LEVER POSITION:1, percent) (A:GENERAL ENG THROTTLE LEVER POSITION:2, percent) + 2 / 3 / near 32 min d s1 10 + s2
    l1 (L:OffGrnd,enum) + (>L:Vibration1, number)
    l2 (>L:Vibration2, number)
    (L:T38_BuffetShake1,enum) (L:Vibration2, number) &lt;
    if{ (L:T38_BuffetShake1,enum) ++ (>L:T38_BuffetShake1,enum) }
    els{ (L:Vibration1, number) (>L:T38_BuffetShake1,enum) }
    }
    els{ 0 (>L:T38_BuffetShake1,enum) }
 

Roy Holmes

Resource contributor
Gents,
A few things about vibration in jet aircraft. All military jets have measured vibration environments that are used when qualifying it and its equipment.
The test procedures are in MIL-STD-810. Vibration test procedures and environments are in paragraph 514.7.

This is what 810 says about vibration in Fixed wing jet aircraft:
"The vibration environment for materiel installed in jet aircraft (except engine-mounted (see paragraph 2.11 of this
annex)), and gunfire-induced, (see Method 519.7) stems from four principal mechanisms. These are (1) engine
noise impinging on aircraft structures; (2) turbulent aerodynamic flow over external aircraft structures, (3) turbulent
aerodynamic flow and acoustic resonance phenomena within cavities open to the external airflow, particularly open
weapon bays, and (4) airframe structural motions due to maneuvers, aerodynamic buffet, landing, taxi, etc.
Vibration can also be produced by installed materiel items. These vibrations are generally important only locally at
or near the source and may not be significant even in that local area."

Of the 4 principle mechanisms (4) is dominant. (1) is insignificant. The engines are installed material items.

Alexis mentions the F-4. I did 839 take-offs and the same number of landings in the F-4 and while you could hear the engine noise you never felt vibration or saw any visual effects from engine vibration. If you had felt vibration even on the ground when there was no other source, you would not have accepted the aircraft. Engine noise perception is inversely proportional to the distance between the cockpit and the source and that was a long way in the F-4. The airplane was big heavy and did not transmit high frequency vibrations. Cockpit instrumented panel mounted equipment vibration spectrum is from roughly 30 to 80 hertz, engines are typically 100 to 200 hertz.
Increasing throttle will reduce vibration, not the other way round.

Bottom line is that jet engines are smooth, it can be tough to work out the RPM without checking the gauges. When an engine fails the gauges usually are the first indication.

Gunfire is another thing, depends on the installation.
The Hunter had four 30mm cannon right under the cockpit. When you fired all four guns the airplane decelerated from the recoil and circuit breakers would pop out. The cordite smell was strong. The guns had a lot of moving parts in the longitudinal axis and fired 20 rounds per second so the vibration was in the frequency range that could affect humans
Most pilots instinctively released the trigger the first time they fired because it just felt wrong.

Our F-4 had a 20mm six-barrel Gatling gun in a pod on the centreline way behind and below the cockpit. If you listened real hard you could hear a small buzz but that was it. It fired 100 rounds per second so the vibration was above that felt by humans. Its mechanisms were mainly rotational not longitudinal like the Hunter Aden.

Airframe vibration is also aircraft dependent.
The noisiest thing in the Hunter was the nosewheel vibrating against its door after it was raised. Airframe vibration was mostly sensed through the controls when pulling g at the buffet onset.

The F-4 had wall to wall low frequency buffet when maneuvering. The instrument panel moved up and down enough to see. The outboard wing panels could be seen flapping. Even when on-speed on the approach, there was buffet.

So for the sake of realism you should seriously reconsider before linking perceived jet aircraft vibration effects to engine throttle position.

The same does not hold for helicopters which generally have enough vibration to make your voice quaver.
Roy
 

n4gix

Resource contributor
Um Roy, I appreciate the valuable information. However, I'm scripting this 'vibration' for a 1935 Cessna T-50 Bobcat. A wood and cloth doped aircraft with two 7 cylinder radial engines. Trust me, they shake a lot, especially with both engines at idle. They have a bit more subtle but still noticeable high-frequency vibration at cruise power. :laughing:

My first approach was based on power (a mix of throttle position and prop rpm), but rapidly came to the conclusion that the end effect was scarcely distinguishable from simply applying a scalar bias to two mixed throttle percent values.

Oddly enough the final scalar bias the beta testers came up with was 24.4 instead of my initial guesstimate of 8... Many folks still do not understand that we can specify "fractional frames". That is why I can still have a smoothly moving "needle" using as little as three frames! It all comes down to the scalar one applies. The sim is perfectly happy to interpolate for us. :idea:

The only jet I've ever added some buffeting vibration to was the venerable T-38A and then only when approaching a stall condition. As the AoA increases, so too does the amplitude of the vibration! :coffee:
 
Last edited:

Roy Holmes

Resource contributor
Bill,
I apologize for somewhat hijacking your thread. The only airplane type that was in your initial post was the T-38. That plus the two other contributors just gave me the silly idea that the throttle inputs referenced might be for jets. I still remember my first dual trip in a Vampire T-11 after being trained on the radial engined Provost. It was so quiet and when you closed the throttle it just kept going.

I imagine that the Bobcat gives two earfulls of vibration.

T-38 venerable?
Roy.
 

n4gix

Resource contributor
Actually, I didn't mention any aircraft in my first post. I probably should have to better set the stage for the discussion/suggestions. :D

Yes, I think the T-38 "White Rocket" deserves the adjective venerable! :rotfl:
 
Top