c172p-team / c172p

A high detailed version of the Cessna 172P aircraft for FlightGear
GNU General Public License v2.0
80 stars 43 forks source link

use airfield elevation to calculate optimal mixture for autostart #791

Closed gilbertohasnofb closed 5 years ago

gilbertohasnofb commented 8 years ago

Currently our autostart function does not take into consideration the elevation of the airport. This means that while trying to start a plane in a high altitude airfield, autostart will always use full mixture and will be cranking the engine forever. Maybe we could try to take the altitude in consideration, something like using full mixture up to a certain altitude, then using some formula to calculate (or guess) the optimal mixture for starting the engine

Inspired by this post here: https://forum.flightgear.org/viewtopic.php?f=25&t=29996

wlbragg commented 8 years ago

Yes, I think this is doable and a worthwhile idea.

wkitty42 commented 8 years ago

On 07/09/2016 11:27 AM, wlbragg wrote:

Yes, I think this is doable and a worthwhile idea.

agreed... we probably should have thought about maybe doing this the last time this came up ;)

gilbertohasnofb commented 8 years ago

I can give it a shot to code it myself. Would anyone know what is the standard procedure in the model P? Until how many feet should one use full rich mixture? And any guesses on what is the minimum mixture percentage one should try to use at extremely high altitudes?

wkitty42 commented 8 years ago

On 07/09/2016 05:41 PM, Gilberto Agostinho wrote:

I can give it a shot to code it myself. Would anyone know what is the standard procedure in the model P? Until how many feet should one use full rich mixture? And any guesses on what is the minimum mixture percentage one should try to use at extremely high altitudes?

well that last one was trying to start at that airport in India that was just over 13000 feet, IIRC... i think someone finally got the craft started there once or twice but no more... @wlbragg maybe??

i believe i also saw something related to this latest topic which said they were able to start at 7000 feet with about 45% mixture or something like that... i'm fairly sure i read it on the forums...

you may be able to do it with a table of mixture values based on ASL... i'm not sure if there is such an existing chart around but if there is, it would be great to convert it to a JSBSIM table if that can be used in the autostart... i'm thinking about how we have to reduce the mixture as we climb higher... i think the lowest i ever got was 60% but i was over 14000 feet and it was extremely touchy up there...

PS: sorry if i'm rambling... we had a storm last night that downed some trees and killed power to about 250 people... i couldn't sleep as it was much too quiet... then the power came back on about 0430 and i've been on my feet ever since... i've only been able to nap a few times today... this lack of sleep might still hurt next week...

gilbertohasnofb commented 8 years ago

@wkitty42 I remember those specific stories of people attempting to use autostart at specific airports, but I am rather asking for the procedures recommended by Cessna. I tried searching for it on the POH but all I found was that the mixture should be rich to start the engine, but somewhere there it must state up to which density altitude. So with that info we can create a table which should take care of every situation.

i couldn't sleep as it was much too quiet...

Lack of sleep makes me ramble terribly as well, so no worries! But most people would say that too much noise would be a problem rather than too much silence :wink:

gilbertohasnofb commented 8 years ago

@onox @wlbragg @Juanvvc @dany93 can you guys give me your opinions here? How would you approach this problem? The issues are:

With that in mind, what if the autostart function would work like this:

  1. apply full mixture, start cranking
  2. if engine still not running after 5 seconds, then continue go to 3., else go to 5.
  3. lower mixture by 5%
  4. if mixture > 0%, then wait 1 second and go to 2., else continue to 5.
  5. end
onox commented 8 years ago

Is it possible at all to start the engine at high altitudes (> 8000 ft)? I don't think we should iteratively try to find the mixture needed to start the engine. That could take too much time and it would be difficult to cancel it.

I think it's easier to have a table to set the mixture to a certain level depending on the altitude. And show a message if the user tries to perform an autostart while the aircraft is above a certain altitude threshold (8000 or 9000 ft?).

Additionally we can set a timer (a couple of seconds) after performing an autostart and then display a message if the engine hasn't started. Something that says that the air is less dense at high altitude and the mixture needs to be leaned. Users might not be aware of this so they need to be educated a bit.

gilbertohasnofb commented 8 years ago

Is it possible at all to start the engine at high altitudes (> 8000 ft)

I don't know. The POH gives take off distances for airports up to 8000 ft, so that altitude should be fine.

I think it's easier to have a table to set the mixture to a certain level depending on the altitude. And show a message if the user tries to perform an autostart while the aircraft is above a certain altitude threshold (8000 or 9000 ft?).

That sounds good. But then again not only we have two engines (and therefore would need two tables), but I believe that altitude alone is not the only factor that affects the engine start up. I think pressure and temperature also affects it, right? So then we need to use density altitude. Would you know if this is correct? As for the warning message, that's clever.

Additionally we can set a timer (a couple of seconds) after performing an autostart and then display a message if the engine hasn't started. Something that says that the air is less dense at high altitude and the mixture needs to be leaned. Users might not be aware of this so they need to be educated a bit.

But I thought we were trying to automate the mixture leaning for the autostart function, so I don't understand what you meant here.

onox commented 8 years ago

But I thought we were trying to automate the mixture leaning for the autostart function, so I don't understand what you meant here.

What I mean is that in the case that our table happens to be insufficient (the engine still doesn't want to start on the user's FG instance for some reason, even with the best possible amount of mixture) that we tell the user that we're very sorry but the user is asking the impossible.

onox commented 8 years ago

That sounds good. But then again not only we have two engines (and therefore would need two tables)

Lets first try to compute one table and see if it works for both engines. After all, they're very similar.

wlbragg commented 8 years ago

So the table will be used to adjust the mixture per altitude of the start up airport?

gilbertohasnofb commented 8 years ago

@onox yes, that sounds clear now! :+1: As for the two engines with one single table, let's try it

So the table will be used to adjust the mixture per altitude of the start up airport?

Yes, but not exactly start up airport, but current location. And I still think we should use density altitude and not altitude.

@onox Do you know where can I read about implementing tables in Nasal? Or should I try to come up with some liner equation, or use a bunch of ifs (if between A and B, then use linear formula1, if between B and C, then use linear formula 2, etc.)?

onox commented 8 years ago

Yes, but not exactly start up airport, but current location.

I don't think latitude/longitude matters. Just altitude or air pressure.

I think you should try to use a table in JSBSim/autopilot in which you map the altitude to a mixture setting. JSBSim/autopilot will then do the interpolation for you. Name the output property something like /path/to/recommended-autostart-mixture-value. The Nasal code that performs the autostart then reads this property and sets the mixture.

onox commented 8 years ago

Try to find airports at 0, 1000, 2000, ..., 8000 ft. Use standard air pressure (29.92).

gilbertohasnofb commented 8 years ago

Yes, but not exactly start up airport, but current location.

I don't think latitude/longitude matters. Just altitude or air pressure.

Oh, what I meant is the current altitude!

I think you should try to use a table in JSBSim/autopilot in which you map the altitude to a mixture setting.

Sounds like a plan, I will read about it (as I am completely unfamiliar with it) and make a first attempt soon.

onox commented 8 years ago

Look at <tableData> in Systems/indicated-airspeed.xml or in c172p.xml.

onox commented 8 years ago

Something like this. Here I assume that at 3000 ft you can still start with 100 % mixture, and at 8000 ft you need 50 % (just guessing, this is an example).

<fcs_function name="fcs/recommended-autostart-mixture">
    <function>
        <table>
            <independentVar>/position/altitude-ft</independentVar>
            <tableData>
                3000    1.0
                4000    0.9
                5000    0.8
                6000    0.7
                7000    0.6
                8000    0.5
            </tableData>
        </table>
    </function>
</fcs_function>

In Nasal/c172p.nas you write:

var recommended_mixture = getprop("/fdm/jsbsim/fcs/recommended-autostart-mixture");
setprop("/controls/engines/current-engine/mixture", recommended_mixture);
onox commented 8 years ago

Near the beginning of the autostart function (below the engine is running check):

if (getprop("/position/altitude-ft") > 8000) {
    gui.popupTip("Cannot start engine above 8000 ft. Find an airport at a lower altitude", 5);
    return;
}
onox commented 8 years ago

And at the end of the autostart function you do:

var engine_running_check_delay = 5.0;
settimer(func {
    if (!getprop("/engines/active-engine/running")) {
        gui.popupTip("Engine failed to start. Adjust (lean) mixture and start manually or find an airport at a lower altitude", 5);
    }
}, engine_running_check_delay);
gilbertohasnofb commented 8 years ago

@onox Ok, I got that part working so now I only need to fill the table. The problem I am having is that TerraSync is awfully slow for some reason so I am having troubles with that :cry: I will try again tomorrow though. Once the table is filled, then it's just using the new property in the Nasal code which should be trivial.

gilbertohasnofb commented 8 years ago

Oh, I just saw your last three posts (I hadn't updated this page). Yeah, that's pretty much what I head in mind for the Nasal code, and I had found how to create a table with a single variable in JSBSim using their documentation. Thanks a lot for the hand!

gilbertohasnofb commented 8 years ago

Guys, TerraSync is simply not working here... it says that it's downloading a tile at a rate of ~150 KBytes/s but the sim never loads. And TerraMaster, which is what I used to use, is simply not working any longer. The only terrain I have on my HD is Europe, and Europe's highest airport is St. Moritz at 5643 feet (and I can start the engine with 100% mixture at that altitude @pressure 1013 mbar).

So can anyone give me a hand filling the table? For instance, all these airports below would be very handy (and all are in Colorado, US). Simply load the plane there, set pressure to 1013 mbar (29.92 inHg) and look for the highest mixture in which the engine starts comfortable (so even if the engine starts but took a while and coughed, turn it off, lower the mixture and try again). The airport list:

In case you guys are also having troubles with TerraSync and don't have these downloaded, then I will have to try working on this later once the issue is fixed.

wlbragg commented 8 years ago

I can try it later tonight. I have most of the world down loded using terramaster. It's running right now, has been for a week or so. I'm not sure why you are having problems with it.

gilbertohasnofb commented 8 years ago

@wlbragg thanks a lot! As for TerraMaster, I am getting the following error:

sync w110n30/w108n38... svn: '/svn/trunk/data/Scenery/Terrain/w110n30/w108n38' path not found: 404 Not Found (http://terrascenery.googlecode.com) svn: '/svn/trunk/data/Scenery/Objects/w110n30/w108n38' path not found: 404 Not Found (http://terrascenery.googlecode.com)

I just didn't have yet time to troubleshoot it.

wkitty42 commented 8 years ago

On 07/23/2016 05:26 PM, Gilberto Agostinho wrote:

@wlbragg https://github.com/wlbragg thanks a lot! As for TerraMaster, I am getting the following error:

sync w110n30/w108n38... svn:
'/svn/trunk/data/Scenery/Terrain/w110n30/w108n38' path not found: 404 Not
Found (http://terrascenery.googlecode.com)
svn: '/svn/trunk/data/Scenery/Objects/w110n30/w108n38' path not found: 404
Not Found (http://terrascenery.googlecode.com)

I just didn't have yet time to troubleshoot it.

that's easy... googlecode is long gone... it closed shop at the same time that gitorious did which was two of the main driving factors for the FGFS project to move to SF back in the beginning of 2015... the terrain is now hosted on SF with a couple of mirror sites...

the old SVN stuff, while still operational, cannot easily switch to a new server like GIT can by editing the config file... if one wants to retain using SVN but switch to the new server(s), they have to delete the old .svn database directory... that means downloading everything all over again even if you already have the actual data files... believe me, i've done it numerous times now and it hasn't been fun at all... especially on a 3Meg DSL line...

this is one of the major reasons why the whole terrasync thing has switched to http... there's no more svn database to eat up drive space (i freed ~100Gig when i deleted my .svn yesterday) and switching between servers or even pulling data from multiple mirrors is no problem... quite unlike cvs, svn, git and others...

gilbertohasnofb commented 8 years ago

@wkitty42 thanks for all the info. As I wrote, I still didn't have the time to troubleshoot this, but I will try to check it out as soon as I can.

onox commented 8 years ago

I can start at KGCN (6600 ft) with 100 % mixture. KAEJ as well. KTEX (9000 ft) ok too. KLXV (9900 ft) not ok. Seems even with 65 % mixture, I cannot start at KLXV. Will try to increase throttle.

onox commented 8 years ago

It seems you have to look at /environment/pressure-inhg. At 20.65 I cannot start the engine even at KTEX. Even with increased throttle and reduced mixture.

21.26 is too low for default settings.

At 21.33 I could start the engine with 45 % throttle and 70 % mixture to 100 % mixture. 20 % throttle with 95 % mixture to 55 % mixture.

At 21.41 needed 40 % throttle and 50 % to 100 % mixture. 20 % throttle and 95 % to 55 % mixture.

At 21.49 needed 35 % throttle and 100 % mixture to 50 % mixture (recommended mixture (good RPM) between 90 % and 60 %). 20 % throttle with 95 % to 55 % mixture.

At 21.56 starts at 25 % throttle and 90 % mixture to 45 % mixture.

At 21.64 starts with 20 % throttle and 90 % mixture to 55 % mixture. At 50 % mixture you need at least 25 % throttle.

At 21.75 starts with default settings (20 % throttle and 100 % mixture) down to 55 % mixture.

onox commented 8 years ago

At 20.65 I can start the engine with 20 % throttle and 95 % mixture.

onox commented 8 years ago

Hmm... I am messing with the air pressure, and now I can suddenly no longer start at 20.65 with 20 % throttle and 95 % mixture :confused:

onox commented 8 years ago

I'm looking at c172p.xml and I see that fcs/mixture-pos-norm[1] uses the primer (value is 1.0) if primer is used at oil temperature is less than 75 F.

If the engine is not running and I'm not starting the engine, then fcs/mixture-pos-norm[1] has the value of the actual mixture control, but engine doesn't run (duh). So what is telling JSBSim to start the engine?

onox commented 8 years ago

I don't have any clue how JSBSim knows when to 'start' the engine, but maybe we should at least multiply fcs/mixture-primer with fcs/mixture-cmd-norm[0] and fcs/mixture-cmd-norm[1]?

onox commented 8 years ago

@dany93 What's the purpose of the primer again? Does it really need to imitate mixture being 100 % or is it just meant to make sure mixture is 0 % if throttle is out of range (10 % to 50 %)?

wlbragg commented 8 years ago

Just a thought that isn't really related to this subject, but, isn't it true that a typical primer is used to supply an "immediate" volume of fuel to the carb or combustion chamber (a choke would give a richer mix)? Almost as a fuel injector does. If this is true then we should still be able to start vehicles without using the primer, it just takes more cranking.

onox commented 8 years ago

I've set the mixture to 95 % instead of 100 %. See branch bug-791.

Now I can start at KLXV (9900 feet) and VNLK (9300 ft) for example.

onox commented 8 years ago

Can somebody try my branch at ZUAL (14000 ft)?

wkitty42 commented 8 years ago

On 07/24/2016 11:45 AM, wlbragg wrote:

Just a thought that isn't really related to this subject, but, isn't it true that a typical primer is used to supply an "immediate" volume of fuel to the carb or combustion chamber (a choke would give a richer mix)? Almost as a fuel injector does. If this is true then we should still be able to start vehicles without using the primer, it just takes more cranking.

Correct. Many of out motorized tools have a primer on them. It is especially useful when they've sat for a while and the fuel chamber is dry where the fuel evaporated. The primer shoves a bunch of fuel into the chamber so that it can be drawn into the cylinders faster and make for a much easier start.

gilbertohasnofb commented 8 years ago

@onox thanks for all these tests and valuable information! :smile:

Can somebody try my branch at ZUAL (14000 ft)?

I will try it and report in a second as soon as I manage to download that tile.

But I think we are maybe over complicating things. First of all, this is being a bit of guesswork given that the POH doesn't say much (or anything at all) about starting an engine and taking off from airfields at high elevation. Then there is the thing that not only the altitude affects the problem, but also the pressure (what about temperature, does it also affect anything?). Then we have two variables to control in our simulated engine (again, just guesswork since no info from the POH): mixture AND throttle. With all this in mind, please remember that we are not improving the engine itself but we are simply talking about a function used by newbs.

So with all that said, what about a much simpler solution: autostart attempts to use 100% mixture and if the engine is not on in let's say 10 seconds, it stops trying and display a warning: "Due to the current altitude and atmospheric conditions the autostart function wasn't able to start the engine. You must attempt to do so manually or change one of those parameters." or something like that. And given that 100% mixture was fine up to 8000 or 9000 ft in onox's tests, I think that's fair enough (the POH only talks about take off distances for airfields up to 8000 ft anyway). That would simplify a lot this whole issue.

So what do you say?

gilbertohasnofb commented 8 years ago

@onox BTW, I tested your autostart function at KLXV with Standard Atmosphere (696.817 mbar) and the engine starts without a problem! Now taking off is a complete different story, what a sluggish take off run and even worse climb! I am finishing downloading ZUAL now and I will test it, but that's quite beyond our ceiling anyway (and unpressurised aircraft without oxygen masks should not fly higher than 12500 feet due to the risk of hypoxia)

gilbertohasnofb commented 8 years ago

@onox ok, so I can't start using your function at ZUAL. I tried using Q595 (which is a standard atmosphere), and I also tried two of the weather scenarios (high pressure and low pressure). Anyway, I would suggest we do the following:

What do you say?

onox commented 8 years ago

What I did in the autostart function is to set mixture at 95 % instead of 100 %. That would mean the difference between successfully starting the engine or not getting the engine started at all.

95 % should work for 9900 ft, but it might not be lean enough for a good takeoff. So perhaps at 9900 ft the mixture should be lower.

Are you saying that 95 % was not sufficient for ZUAL? At what mixture level did you (manually) successfully start the engine?

gilbertohasnofb commented 8 years ago

Are you saying that 95 % was not sufficient for ZUAL? At what mixture level did you successfully start the engine?

After autostart failed, I wasn't able to manually start the engine at all!

95 % should work for 9900 ft, but it might not be lean enough for a good takeoff. So perhaps at 9900 ft the mixture should be lower.

The question that comes to mind is the following: if the engine is off, then one cannot know the ideal mixture before starting the engine (since you can't use the tachometer nor EGT for that). And since the POH doesn't give you info, then I think that probably pilots lean after starting the engine.

onox commented 8 years ago

Did you set magneto's to 3, throttle to 20 %, mixture to level 60 .. 90 % and prime 3 times before holding "s" key?

gilbertohasnofb commented 8 years ago

I am sure I did, but I will test again now.

onox commented 8 years ago

You should put /controls/engines/engine/primer, /engines/active-engine/rpm, and /engines/active-engine/running in the top left corner. That might help.

gilbertohasnofb commented 8 years ago

@onox yes, I can start the engine when I lower the mixture a bit (~ 75%, depending on the atmospheric conditions), sorry for the bogus report

onox commented 8 years ago

What's your /environment/pressure-inhg at ZUAL?

gilbertohasnofb commented 8 years ago

Around 17.5 and 18.

onox commented 8 years ago

I get it started at 80 % mixture when pressure is 17.6

gilbertohasnofb commented 8 years ago

For me it's similar to that, yes. At around 18 inHg I think my mixture was 77%