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

Auto Start / Auto Shutdown

Messages
10,163
Country
us-arizona
Hey all,

I have posted on this before, and still having some bugs with this system. I have tried a great many different variations, but I still have the same issues.

I have a code that mimmicks (replicates) an electric planes propulsion system, ie, when you are at zero throttle, the engine (motor) stops turning, prop comes to a stand still. Give it a bit of throttle, and the motor kicks in. Very realistic.

But the bugs are that not always will it start, and sometimes, you just cant get the motor to turn off/shut down. I have experimented with mixture also into the mix of things, trying to get the darn thing to quit, but it makes a 'stutter', cycling, (like bad gas) where every 1+ second, it blips, like it just tried to stop, but keeps running (electric sound effect 'whirrr' noise still going', blip,run,blip,run, etc... To get it out of the loop, I give it a quick good throttle stab, then back to zero throttle, and sometimes that will kill the engine.

Does anyone have any idea's? Any neat tricks I could try? Something that both auto-starts and auto-stops an engine?

Also, I figure in the battery 'on' factor. If battery is turned off, the motor also dies. If zero fuel, (battery power) the motor dies, etc, (as it should, as the template is actually running on fuel).


A version of code I landed with last night, same results...


Code:
  <Element>
    <Select>
      <Value>                 
               (A:General eng throttle lever position:1,percent) 8 >   
               (A:Electrical Master Battery,bool) 1 ==
               and
                  if{
                    1 (>K:ENGINE_AUTO_START,bool) 
                    1 (>K:MIXTURE_SET_BEST,bool)
                    }
       </Value>
    </Select>
   </Element>

  <Element>
    <Select>
      <Value> 
               (A:General eng throttle lever position:1,percent) 5 &lt;   
               (A:Electrical Master Battery,bool) 0 ==
               ||
                  if{ 
                    1 (>K:ENGINE_AUTO_SHUTDOWN,bool)
                    (>K:MIXTURE_SET,number) 0
                    }
       </Value>
    </Select>
   </Element>



This has been a slight nightmare, as last week, I worked on this for 2 days, only to find that the gauge wasnt linked into the panel config. 8-0)))) What an 'extreme' nightmare that was.
 
Note above, the gap in percentages of throttle;
* 8 >.........auto start
* 5 <.........auto shutdown

My thoughts are that the bug could be a blip or spiking of the joystick throttle where it could be scanning/reading several degree's of the throttle zone at once, like 0 to 4 to 0 to 6 to zero to 4, etc. (When one tunes the joysticks, sometimes you have one that is giving wild spikes, and tuning it resets the thing), but this seems to be continuous. (seems.... ) Thus I gave it gaps as an experiment to see if that would shut down the engine.

There must be a couple of tricks I havent tried that would be 'sure fire' on getting this system to be more 'reliable' and dependable, one that always worked. Zero throttle, prop comes to a stop. Bit of gas, and she starts up without fail...



Bill
 
(>K:MIXTURE_SET,number) 0
should probably be
0 (>K:MIXTURE_SET,number)

I'm also not sure what will happen if the throttle is at say 6% as it falls between the two options.
Have you tried just having an if els statement? I.e if the throttle is above 8% and the battery is on it auto-starts and if it isn't it stops.
Finally, as it is you're effectively sending the auto start command 18 times a second if the throttle is above 8% and the battery is on, I don't know if that would actually cause any problems but it would annoy me! You'd just need to add a check that the engine wasn't running before sending the auto start command and the reverse for the auto stop command.
 
Ahhh...!

Thanks SB. I am off to try that.

Yes on the engine running. I did have 'engine combustion' as a condition.

Thanks man.



Bill.
 
Ok... I have something that is now working. Whewww...

Please note that it is almost beautifully simple. Not quite, but getting there. One single Element, use of 'els', and at first, this wasnt working, as my 'els' was nested with the first main 'if' and making it into its own stand-alone 'els' circuit allowed the els to properly shut off the engine.


Its still hanging about 1 time out of 4, but that is better then 2 or 3 times out of 4.

I also added Mag's into the shut down process. Anything to cause a shut down, lol...

Code:
  <Element>
    <Select>
      <Value>                 
               (A:General eng throttle lever position:1,percent) 5  >   
                   if{
                       (A:Electrical Master Battery,bool) 1 ==
                         if{
                           1 (>K:ENGINE_AUTO_START,bool) 
                           1 (>A:FUEL_SELECTOR_ALL,bool) 
                           }
                     }
                  els{
                           1 (>K:ENGINE_AUTO_SHUTDOWN,bool)
                           1 (>A:FUEL_SELECTOR_OFF,bool) 
                           1 (>A:MAGNETO1_OFF,bool)
                       }

       </Value>
    </Select>
   </Element>


<-- getting the hang of if/els now. Very cool stuff...
 
Just to note that this is incorrect gauge coding, because you are constantly either sending the autostart or autostop commands (K: variables) to the sim. This will not only block any multi key commands (like Shift E 2 or even E 1 2 3 4), but will also slow the sim down.

Adding a test for engine combustion would fix that...
 
Well, I tried several variations and the engine will not react via going through the engine combustion condition.

One example;



Code:
  <Element>
    <Select>
      <Value>                 
              (A:General eng throttle lever position:1,percent) 5  >   
                   if{
                      (A:GENERAL ENG COMBUSTION:1,bool) 0 ==                
                           if{
                               (A:Electrical Master Battery,bool) 1 ==
                                   if{
                                     1 (>K:ENGINE_AUTO_START,bool) 
                                     }
                             }
                     }
       </Value>
    </Select>
   </Element>

  <Element>
    <Select>
      <Value>                 
               (A:General eng throttle lever position:1,percent) 4 <   
                   if{
                       (A:GENERAL ENG COMBUSTION:1,bool) 1 ==                
                       (A:Electrical Master Battery,bool) 0 ==
                       or
                         if{
                            1 (>K:ENGINE_AUTO_SHUTDOWN,bool)
                            1 (>A:FUEL_SELECTOR_OFF,bool) 
                            1 (>A:MAGNETO1_OFF,bool)
                           }
                     }

       </Value>
    </Select>
   </Element>



Without the stagger setting


<Element>
<Select>
<Value>
(A:General eng throttle lever position:1,percent) 5 >
if{
(A:GENERAL ENG COMBUSTION:1,bool) 0 ==
if{
(A:Electrical Master Battery,bool) 1 ==
if{
1 (>K:ENGINE_AUTO_START,bool)
}
}
}
</Value>
</Select>
</Element>

<Element>
<Select>
<Value>
(A:General eng throttle lever position:1,percent) 4 <
if{
(A:GENERAL ENG COMBUSTION:1,bool) 1 ==
(A:Electrical Master Battery,bool) 0 ==
or
if{
1 (>K:ENGINE_AUTO_SHUTDOWN,bool)
1 (>A:FUEL_SELECTOR_OFF,bool)
1 (>A:MAGNETO1_OFF,bool)
}
}

</Value>
</Select>
</Element>

If you know of a way to get the engine to reliably start and stop by just throttle lever position being greater then or less then say 5 percent, I would be massively greatful.
 
Got it working, lol...

By accident, I checked it with IE and it didnt fire up. I forgot you cannot use < as a operator condition (top statement or condition at the end).

Works great. Thanks for the heads up Tom.

How does one know how to check for loops?

Flaw is here;

<Element>
<Select>
<Value>
(A:General eng throttle lever position:1,percent) 4 &lt; <<<repaired.. Was <
if{
(A:GENERAL ENG COMBUSTION:1,bool) 1 ==
(A:Electrical Master Battery,bool) 0 ==
or
if{
1 (>K:ENGINE_AUTO_SHUTDOWN,bool)
1 (>A:FUEL_SELECTOR_OFF,bool)
1 (>A:MAGNETO1_OFF,bool)
}
}

</Value>
</Select>
</Element>
 
1 (>A:FUEL_SELECTOR_OFF,bool)
1 (>A:MAGNETO1_OFF,bool)

I don't think you can do that, they should be K:Var not A:Var, generally the only way you can set A:Var values is by using SimConnect.
As it's working I'm assuming the (>K:ENGINE_AUTO_SHUTDOWN,bool) is taking care of it, although you don't need the bool bit as Event IDs don't have types.
 
Glad to help.

Yeah, whenever you see (>A: in your code you know something is wrong... :)
 
Yep. Thanks Skippy. I did that also with some Gmax code yesterday. Totally messed me up. I think I need to take breaks during the day from this to refresh my view of code. It starts to blend in after a few long hours.
 
Just wanted to tell you all, that it is now working smoothly after all these months. As of the other day, while I was 'stairing down' the code wondering with a blank face why the darn code wasnt reliable, it came to me, that it was 'acting' like the sim was 'forgetting' to look at the throttle position.

I wondered how I could keep it 'refreshed' and then it again occurred to me, to place a 'refresh rate' in the gauge, and I did, and now the girl always starts when you move the throttle past 5%, and shuts down under 2%.

Hallelujah!


So, if anyone does an electric plane that shuts down at zero throttle, be sure to use a refresh rate.



Bill
 
Back
Top