Page 1 of 2

Setting control surface positions with XML

PostPosted: Sat May 18, 2019 8:59 pm
by zachary77
Hi, I’m working on a new version of the B777.
I have big plans for it, the most challenging being basic FBW, specifically the roll channel.
As I mentioned before, XML is not my area of expertise.
According to the FCOM and other sources, the primary flight computers (PFCs) maintain bank angle when:
    —Yoke is neutral
    —Bank is less than 33 deg either side
    —PFCs are connected (mapped to avionics master switch)

Some psuedocode I’ve thought out is below.
Code: Select all
if ((abs(aileron_pos) < 0.1 ) && (abs(bank_deg) < 33) && (AV_MASTER=1))
{
tgt_bank=bank_deg;

    if(bank_deg > tgt_bank)
    {
    aileron_trim - 0.2 * abs(tgt_bank - curr_bank);
    }

    if(bank_deg < tgt_bank)
    {
    aileron_trim + 0.2 * abs(tgt_bank - curr_bank);
    }

}

else
{
aileron_trim=0;
}


Could I get help for implementing this in XML?
Thanks,
zachary77

Re: Setting control surface positions with XML

PostPosted: Sun May 19, 2019 7:26 am
by Andiroto
Code: Select all
(A:ATTITUDE INDICATOR BANK DEGREES,degrees) -33 &lt; (A:Avionics master switch,bool) 1 == &amp;&amp;
if{ 100 (>K:AILERON_SET) 1 (>L:AILERON_TRIM_UP,number) } els{ 0 (>L:AILERON_TRIM_UP,number) }
(A:ATTITUDE INDICATOR BANK DEGREES,degrees) 33 &gt; (A:Avionics master switch,bool) 1 == &amp;&amp;
if{ -100 (>K:AILERON_SET) 1 (>L:AILERON_TRIM_DOWN,number) } els{ 0 (>L:AILERON_TRIM_DOWN,number) }
(L:AILERON_TRIM_UP,number) 0 == (L:AILERON_TRIM_DOWN,number) 0 == &amp;&amp; if{ 0 (>K:AILERON_SET) }


100 for the aileron ist only a basic set from my side because i personally never used it (values are setable from -16383 - +16383)!
Here are all basic vars and keys for xml scripting:

Events: https://docs.microsoft.com/en-us/previo ... msdn.10%29
and on the same side the "simulation variables"!

AND i recommend to visit the fsdeveloper site and maybe in your case to join the forum!
I am only a hobby scripter, there are also profi programmer for simulations where you can get for sure much better help!

BTW: What is with your SR-71 project, any plans to plublish it?

Best Regards!

Re: Setting control surface positions with XML

PostPosted: Sun May 19, 2019 7:46 am
by zachary77
Thanks very much! I think I can work with this.
Regarding my SR-71 it’s kinda forgotten. I think it’ll be released soon though, depending on what I find. Thanks for reminding me.

Once again thanks for the reply!
zachary77

Re: Setting control surface positions with XML

PostPosted: Sun May 19, 2019 1:05 pm
by cevans
You 2 guys do so much great work!

Re: Setting control surface positions with XML

PostPosted: Sun May 19, 2019 9:57 pm
by zachary77
We try, as a community, to do what we can.
I mean, I don't feel like I do much, but collaboration does wonders.
It's thanks to everyone here that I learnt and grew.

Re: Setting control surface positions with XML

PostPosted: Mon May 20, 2019 7:51 am
by zachary77
Okay, so I’ve done some tests and found that the controls jam with this method.
I’m looking into simconnect.
https://github.com/NicholasLindsay/SimC ... /README.md

Re: Setting control surface positions with XML

PostPosted: Mon May 20, 2019 12:57 pm
by Andiroto
zachary77 wrote:Okay, so I’ve done some tests and found that the controls jam with this method.


Yes and i think i know why! It was the wrong key event from my side!
Second try with (i hope) better key usage:

Code: Select all
(A:ATTITUDE INDICATOR BANK DEGREES,degrees) -33 &lt; (A:Avionics master switch,bool) 1 == &amp;&amp;
if{ 1 (>K:AILERON_TRIM_LEFT) 1 (>L:LEFT_UP,number) } els{ 0 (>L:LEFT_UP,number) }
(A:ATTITUDE INDICATOR BANK DEGREES,degrees) 33 &gt; (A:Avionics master switch,bool) 1 == &amp;&amp;
if{ 1 (>K:AILERON_TRIM_RIGHT) 1 (>L:RIGHT_UP,number) } els{ 0 (>L:RIGHT_UP,number) }
(L:LEFT_UP,number) 0 == (L:RIGHT_UP,number) 0 == &amp;&amp; if{ 0 (>K:AILERON_TRIM_LEFT) 0 (>K:AILERON_TRIM_RIGHT) }


The values for the key events should may higher than 1, its probably a value in degrees! Its always a bit try and error!

@ChrisEvans
+1 to that what zachary said and i give the ball right back to you and the FS community!

Re: Setting control surface positions with XML

PostPosted: Tue May 21, 2019 7:54 am
by zachary77
Just came back from a long test. Works ok, but after disconnecting AP in a turn the aileron trim jams to one side. Slight but noticeable.

Re: Setting control surface positions with XML

PostPosted: Tue May 21, 2019 5:55 pm
by Andiroto
This is as the script above but this time it works only with active AP and AV!

Code: Select all
(A:ATTITUDE INDICATOR BANK DEGREES,degrees) -33 &lt; (A:Avionics master switch,bool) 1 == (A:Autopilot master,bool) 1 == &amp;&amp; &amp;&amp;
if{ 1 (>K:AILERON_TRIM_LEFT) 1 (>L:LEFT_UP,number) } els{ 0 (>L:LEFT_UP,number) }
(A:ATTITUDE INDICATOR BANK DEGREES,degrees) 33 &gt; (A:Avionics master switch,bool) 1 == (A:Autopilot master,bool) 1 == &amp;&amp; &amp;&amp;
if{ 1 (>K:AILERON_TRIM_RIGHT) 1 (>L:RIGHT_UP,number) } els{ 0 (>L:RIGHT_UP,number) }
(L:LEFT_UP,number) 0 == (L:RIGHT_UP,number) 0 == (A:Autopilot master,bool) 1 == &amp;&amp; &amp;&amp;
if{ 0 (>K:AILERON_TRIM_LEFT) 0 (>K:AILERON_TRIM_RIGHT) }


If you deactivate the AP, the trim is set to 0 one time now and should not be jamed anymore! The Event AILERON_TRIM_SET is not in the list of Key events but found him in another script! Maybe worth a try!

Code: Select all
(A:Autopilot master,bool) 1 == if{ 0 (>L:THIS_LINE_1TIME,number) }
(A:Autopilot master,bool) 0 == (L:THIS_LINE_1TIME,number) 0 == &amp;&amp;
if{ 0 (>K:AILERON_TRIM_LEFT) 0 (>K:AILERON_TRIM_RIGHT) 0 (>K:AILERON_TRIM_SET) 1 (>L:THIS_LINE_1TIME,number) }


BTW: Here are the explanations for the xml operators:
https://msdn.microsoft.com/en-us/library/cc526953.aspx
(Only relevant for FSX, dont know if they also work for P3D)

Re: Setting control surface positions with XML

PostPosted: Wed May 22, 2019 7:49 am
by zachary77
Seems to work, have to test more. Have a question though, are spaces in the parameters allowed? For example, “avionics master switch”?

Re: Setting control surface positions with XML

PostPosted: Wed May 22, 2019 12:48 pm
by Andiroto
zachary77 wrote: Have a question though, are spaces in the parameters allowed? For example, “avionics master switch”?


Not for the K: events but for your L: variables, sure!

Re: Setting control surface positions with XML

PostPosted: Wed May 22, 2019 6:01 pm
by zachary77
Ah, thanks. The system is working so well I’m getting somewhat paranoid :D I’ll do further testing, including non-normal ops, to ensure it continues to perform as it should. Great work!

Re: Setting control surface positions with XML

PostPosted: Thu May 23, 2019 7:22 am
by zachary77
Sorry for the premature assessment. It turns out that the system is not functioning as it should. See the B738 here with a trim gauge.
https://drive.google.com/open?id=1Gz3IFRDTbimzbHtLznAiMZEE7IgvBqnq
It only activates at extreme bank angles (protection mode is good) but does not recenter or hold bank. This occurs with the latest and previous versions.

Any ideas? I'm sorry for not checking adequately before now.

Re: Setting control surface positions with XML

PostPosted: Thu May 23, 2019 2:02 pm
by Andiroto
Had some testing with the default 737-8 and this script works!
I reduced the angle when the aileron trim moves the aircraft back to the center! Again this script is not for holding a bank angle, only to recenter the aircraft from a certain bank angel (left or right)! AV switch must be active!
Code: Select all
  <Element>
    <Select>
      <Value>
          (A:ATTITUDE INDICATOR BANK DEGREES,degrees) -0.5 &lt; (A:Avionics master switch,bool) 1 == &amp;&amp;
          if{ 1 (>K:AILERON_TRIM_LEFT) 1 (>L:LEFT_UP,number) } els{ 0 (>L:LEFT_UP,number) }
          (A:ATTITUDE INDICATOR BANK DEGREES,degrees) 0.5 &gt; (A:Avionics master switch,bool) 1 == &amp;&amp;
          if{ 1 (>K:AILERON_TRIM_RIGHT) 1 (>L:RIGHT_UP,number) } els{ 0 (>L:RIGHT_UP,number) }
          (L:LEFT_UP,number) 0 == (L:RIGHT_UP,number) 0 == (A:Avionics master switch,bool) 1 == &amp;&amp; &amp;&amp;
          if{ 0 (>K:AILERON_TRIM_LEFT) 0 (>K:AILERON_TRIM_RIGHT) 0 (>K:AILERON_TRIM_SET) }
      </Value>
    </Select>
  </Element>



EDIT:
And here is an example for a "Hold Bank" script, tested with default 737-8! It works but Its not perfect!
Please test this script seperate from the "Recenter" Script, currently they dont work well together!
When you activate the AV switch the last bank angle is selected and the trim tries to hold this angle but i must admit this works a bit sluggish . . .

Code: Select all
  <Element>
    <Select>
      <Value>
          (A:Avionics master switch,bool) 0 == -33 33 (A:ATTITUDE INDICATOR BANK DEGREES,degrees) rng &amp;&amp;
          if{ (A:ATTITUDE INDICATOR BANK DEGREES,degrees) (>L:CURRENT_BANK_ANGLE_SET,number) 0 (>K:AILERON_TRIM_LEFT) 0 (>K:AILERON_TRIM_RIGHT) 0
          (>K:AILERON_TRIM_SET) }
          (A:Avionics master switch,bool) 1 == -33 33 (A:ATTITUDE INDICATOR BANK DEGREES,degrees) rng (A:ATTITUDE INDICATOR BANK DEGREES,degrees)
          (L:CURRENT_BANK_ANGLE_SET,number) &lt; &amp;&amp; &amp;&amp;
          if{ 1 (>K:AILERON_TRIM_LEFT) }
          (A:Avionics master switch,bool) 1 == -33 33 (A:ATTITUDE INDICATOR BANK DEGREES,degrees) rng (A:ATTITUDE INDICATOR BANK DEGREES,degrees)
          (L:CURRENT_BANK_ANGLE_SET,number) &gt; &amp;&amp; &amp;&amp;
          if{ 1 (>K:AILERON_TRIM_RIGHT) }
      </Value>
    </Select>
  </Element>

Re: Setting control surface positions with XML

PostPosted: Fri May 24, 2019 8:17 am
by zachary77
The hold bank script works quite well, however, I have a few suggestions:
    — Limit max deflection to 60% trim in normal mode
    — Change the condition of reset to when stick is neutral (it’s quite inconvenient to have to toggle the avionics master to reset target bank)

We’re close, I can feel it! Thanks for all the help so far!