c172p-team / c172p

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

Low oil pressure on startup #918

Closed gilbertohasnofb closed 7 years ago

gilbertohasnofb commented 7 years ago

After starting the engine, the oil pressure does not rise to the green arc if the throttle remains at idle. If more throttle is applied then the pressure does come to the green arc and remains stabilizes there. According to the checklist, the oil pressure should reach the green arc (50 PSI) after 30 seconds from engine startup (or 60 seconds at most during cold weather).

@stuartbuchanan wrote:

I don't know enough about the Cessna, but certainly on my aircraft the oil pressure comes up within a couple of seconds when the engine starts, and stays in the green arc irrespective of the throttle position.

On the ground, the oil pressure falling below the green arc would be a reason to immediately stop the engine to avoid engine damage.

gilbertohasnofb commented 7 years ago

For the discussion related to this issue, see: https://github.com/c172p-team/c172p-detailed/pull/917#issuecomment-292799296

Feedback from RL 172 pilots would be most welcomed, as well as suggestions on how to tackle this issue or why it is happening.

dany93 commented 7 years ago

I'd guess it starts from the JSBSim or FG value of oil-pressure-psi vs RPM, hard coded. After that, the needle is animated by an alias or something calculated (?? it has a delay) from this value. engines/active-engine/indicated-oil-pressure-psi

c172p/Models/Interior/Panel/Instruments/FuelOilAmps/c172oil.xml If I understand well, Lines 57 - 89

    <animation>
        <type>rotate</type>
        <object-name>OilPressNeedle</object-name>
        <property>engines/active-engine/indicated-oil-pressure-psi</property>
        <interpolation>
       (....)

does the needle animation, which can be non-linear. IMHO, that would be the most likely and easier way (although that's cheating).

Otherwise, somewhere in the transformation (??) from oil-pressure-psi to indicated-oil-pressure-psi, but it seems more intricate.

wlbragg commented 7 years ago

I had a similar comment, see: https://github.com/c172p-team/c172p-detailed/pull/917

gilbertohasnofb commented 7 years ago

Yes, I have tested that and it is not a problem of the indicator: both oil-pressure-psi and indicated-oil-pressure-psi are always very similar and they are below 50 PSI at low RPM. See:

oil-172-1

oil-172-2

oil-172-4

oil-172-5

So it seems that the true oil pressure (not indicated) property is really tied to the RPM, and the values change really dramatically when RPM changes, so I suppose this has to be fixed in JBSim

gilbertohasnofb commented 7 years ago

What would be really useful would be to have a small table of oil pressure vs RPM (giving time for the gauge to stabilize). If anyone gets a chance to fly a real 172, that would be extremely useful I suppose.

onox commented 7 years ago

The oil pressure is computed in src/FDM/JSBSim/models/propulsion/FGPiston.cpp as follows:

 921 void FGPiston::doOilPressure(void)
 922 {
 923   double Oil_Press_Relief_Valve = 60; // FIXME: may vary by engine
 924   double Oil_Press_RPM_Max = MaxRPM * 0.75;    // 75% of max rpm FIXME: may vary by engine
 925   double Design_Oil_Temp = 358;          // degK; FIXME: may vary by engine
 926   double Oil_Viscosity_Index = 0.25;
 927 
 928   OilPressure_psi = (Oil_Press_Relief_Valve / Oil_Press_RPM_Max) * RPM;
 929 
 930   if (OilPressure_psi >= Oil_Press_Relief_Valve) {
 931     OilPressure_psi = Oil_Press_Relief_Valve;
 932   }
 933 
 934   OilPressure_psi += (Design_Oil_Temp - OilTemp_degK) * Oil_Viscosity_Index * OilPressure_psi / Oil_Press_Relief_Valve;
 935 }

As you can see there are various hard-coded constants.

You can try the following Python code to play with various values:

oil_basic_pressure = lambda RPM: min(60.0, 60.0/(2700.0*0.75)*RPM)
oil_final_pressure = lambda oil_temp_k, oil_psi: oil_psi + (358.0 - oil_temp_k) * 0.25 * oil_psi / 60.0

oil_final_pressure(304, oil_basic_pressure(763))

I'm not sure how they came up with the values of Design_Oil_Temp and Oil_Viscosity_Index. In the O-320 manual I found the following:

Never exceed the maximum red line cylinder head temperature limit. For maximum service life, cylinder head temperatures should be maintained below 435°F (224°C) during high performance cruise operation and below 400°F (205°C) for economy cruise powers

If I change Design_Oil_Temp to 497 K (~ 435 F) then I get a PSI of about 48. But I'm not sure what they mean with that constant, cylinder head temp or oil inlet temp?

gilbertohasnofb commented 7 years ago

@onox thanks a lot for the info and for the Python code, that's very handy to play around with.

But do I understand correctly that the only two variables in those functions are the oil temperature and the engine RPM? I am really not familiar at all with how FDM works in FG, but if those bunch of parameters are hard coded in JBSim and the only variables we have in hand are RPM and oil temp (both of which are responding as expected as far as I can tell), then what else could be done to fix this?

dany93 commented 7 years ago

Thanks @onox for pointing our attention to this part of code. However, I do not understand how to use your suggestion of Python code (I'm ignorant of Python code and C++).

@onox wrote

I'm not sure how they came up with the values of Design_Oil_Temp and Oil_Viscosity_Index. (....) If I change Design_Oil_Temp to 497 K (~ 435 F) then I get a PSI of about 48. But I'm not sure what they mean with that constant, cylinder head temp or oil inlet temp?

I'd rather think that, by Design_Oil_Temp, they mean some typical reference oil temperature (a basis to calculate the viscosity at a each temperature, multiplying by the viscosity index). After that, the oil temperature is probably lower than the cylinder head temperature. But a correct value for the design oil temperature is hard to choose without a good understanding of this characteristic (which I don't have). And, for this, I don't like the trial and error method.

If I understand well, if we would decrease the (hard-coded) Oil_Press_RPM_Max, e.g. Oil_Press_RPM_Max = MaxRPM * 0.375 the OilPressure_psi would increase faster with RPM (higher factor). Thus, it would reach the green arc at lower RPMs. Nevertheless limited (rather its intermediate, "basic" value) by Oil_Press_Relief_Valve. In a second step, Its final value is corrected (an additive term) for the effect of oil temperature on viscosity and OilPressure_psi / Oil_Press_Relief_Valve.

Correct ??

The question is, can we change a hard-coded constant (Oil_Press_RPM_Max) from outside ?

If that's not possible, a workaround might be to "copy" the C++ calculation in a nasal code, making a c172_oil_pressure_psi, sent to the Internal properties as c172-oil-press-psi. Thus, we could change the Oil_Press_RPM_Max in the nasal code and keep the main qualities of the initial code.

gilbertohasnofb commented 7 years ago

However, I do not understand how to use your suggestion of Python code (I'm ignorant of Python code and C++).

If I understand correctly, that Python code is just for us to play around with the values, as to see what the original C++ code does. Since Python can be dynamically typed, it's easy to change the variables and see the output immediately.

About the issue itself, I have checked a lot of different checklists for the 172 and many say that the throttle should be at 1000 RPM for the oil check (e.g. this and this), though the POH does not; it only says that the throttle should be OPEN 1/8 INCH on p. 4-7. But the POH is quite confusing concerning this issue, since it simply says Oil Pressure -- CHECK but not that the oil should be on the green arc. To add more confusion to it, on p. 4-12 it says:

After starting, if the oil gauge does not begin to show pressure within 30 seconds in the summertime and about twice that long in very cold weather, stop the engine and investigate.

(my emphasis in the quote). So nothing again about the green arc or 50 PSI, just about the gauge being alive. This is perhaps the reason those checklists include the 1000 RPM figure, perhaps the engine is not able to give 50 PSI or more of oil pressure when at idle. But even if that would be the case, our aircraft here is reaching 50 PSI only at around 1500 RPM.

dany93 commented 7 years ago

You seem willing to play with the hard-coded constants (at least to see what it does). About the RPM dependency, I still think that the first one, most straightforward I would try is:

if we would decrease the (hard-coded) Oil_Press_RPM_Max, e.g. Oil_Press_RPM_Max = MaxRPM * 0.375 the OilPressure_psi would increase faster with RPM (higher factor). Thus, it would reach the green arc at lower RPMs.

It sets the RPM/MaxRPM ratio at which the basic OilPressure_psi reaches 60 (= the Oil_Press_Relief_Valve, its max value).

gilbertohasnofb commented 7 years ago

Concerning the values, I posted this question on the Aviation page of Stack Exchange, and I got some very helpful answers including from an instructor with 8000h experience, please see: https://aviation.stackexchange.com/questions/37389/cessna-172-at-which-rpm-should-the-oil-pressure-reach-the-green-arc/

So it seems to me that we need the following:

Would any of you be interested in implementing this? I am really unfamiliar with FDM and engine code and with the code solutions being proposed here.

geoffmcl commented 7 years ago

Using the current equation to calculate pressure as a factor of RPM and Temperature, I have constructed a crude graph...

[image: Inline image 1]

And unless I slipped up somewhere in the maths, it seems at -

In my estimation our current simulation works quite well, according to all things read to date... What needs to be changed, if anything?

Just my 2 bits ;=))

Geoff.

gilbertohasnofb commented 7 years ago

What needs to be changed, if anything?

@geoffmcl at 1000 RPM the needle is very much below the green arc starting at 50 PSI, when most procedures seem to indicate it should be at least 50 PSI. We currently need at least 1500 RPM for the oil pressure to get into the green arc. So that is what needs to be changed.

wlbragg commented 7 years ago

At 1000 RMP the oil pressure is 34.6. A quick fix would be to change the interpolation table for the oil pressure something like the following

from
<entry>
                <ind>0</ind>
                <dep>-27</dep>
 </entry>
<entry>
                <ind>50</ind>
                <dep>2</dep>
</entry>
<entry>
                <ind>90</ind>
                <dep>16</dep>
</entry>

to
<entry>
                <ind>0</ind>
                <dep>-27</dep>
</entry>
<entry>
                <ind>30</ind>
                <dep>-17</dep>
</entry>
<entry>
                <ind>33</ind>
                <dep>2</dep>
</entry>
<entry>
                <ind>50</ind>
                <dep>3</dep>
</entry>
<entry>
                <ind>90</ind>
                <dep>16</dep>
</entry>

But that doesn't address the fact that at 1000 RPM the engine only produces 34.6 oil pressure. That would take some investigation.

This is the mapping of both the RPM and the Oil Pressure rpm

wlbragg commented 7 years ago

Results https://www.dropbox.com/s/nptxketj4b3vjaw/2017-04-25%2017-53-57.mp4?dl=1

gilbertohasnofb commented 7 years ago

@wlbragg although this would solve the visual side of the problem (i.e. the instruments would display the correct values), I am really not sure about using a hack to solve the problem, in particularly since those oil pressure properties would still have the current values which would then differ from what the gauges display.

A quick fix would be to change the interpolation table for the oil pressure

In my opinion, this issue isn't breaking the aircraft so we don't necessarily need to rush with a PR, I would much rather if we found the issue with the modelling of the oil parameters. That's my two cents.

wlbragg commented 7 years ago

I agree, I'm just not sure this is fixable without some kind of a hack. Either the one above or an intervention in the FDM overriding the oil pressure with a interpolation table of the rpm mapped to what we think oil pressure should be, but that seems like it would also be a hack.

dany93 commented 7 years ago

I am trying to implement a nasal script based on the C++ calculation. It would enable us to play with the (currently) hard-coded parameters (Oil_Press_Relief_Valve, Oil_Press_RPM_Max coefficient, Oil_Viscosity_Index) if we wish to. It would end to a /engines/active-engine/c172-oil-pressure-psi Internal Property.

var Oil_Press_Relief_Valve = 60;            # FIXME: may vary by engine
var MaxRPM = 2700;
var Oil_Press_RPM_Max = MaxRPM * 0.45;      # 45% of max rpm FIXME: may vary by engine
var Design_Oil_Temp = 358;                  # degK; FIXME: may vary by engine
var Oil_Viscosity_Index = 0.25;             # oil-viscosity variation with temperature

var RPM = getprop("/engines/active-engine/rpm");
var OilTemp_degF = getprop("/engines/active-engine/oil-temperature-degf");
var OilTemp_degK = (OilTemp_degF + 459.67) * 5/9;

print("  ");
print ("RPM=", RPM);
print ("OilTemp_degF=", OilTemp_degF);
print ("OilTemp_degK=", OilTemp_degK);

OilPressure_psi = (Oil_Press_Relief_Valve / Oil_Press_RPM_Max) * RPM;

if (OilPressure_psi >= Oil_Press_Relief_Valve) {
    OilPressure_psi = Oil_Press_Relief_Valve;
    }

print ("OilPressure_psi-basic=", OilPressure_psi);

OilPressure_psi += (Design_Oil_Temp - OilTemp_degK) * Oil_Viscosity_Index * OilPressure_psi / Oil_Press_Relief_Valve;

print("OilPressure_psi-final=", OilPressure_psi);

The best would be having access to the hard-coded constants but it would be a hard task (asking the developers). For lack of this, this nasal code would replace the hard-coded calculation by a more upstream way than cheating with the animation or intermediate values.

This nasal script (rather simple) already works in autonomy. You can see that I have already changed the var Oil_Press_RPM_Max = MaxRPM * 0.45 coefficient (0.45 instead of 0.75). I still have to insert it in the nasal c172p file to have it run continuously and connect its output to the internal properties. I'm not very good at this...

Some questions:

gilbertohasnofb commented 7 years ago

@dany93 sounds good to me!

onox commented 7 years ago

I'll write to the mailing list to ask if the JSBSim devs can make the variables in FGPiston::doOilPressure configurable.

dany93 commented 7 years ago

Thanks @onox.

wlbragg commented 7 years ago

@dany93 in case you haven't seen yet, @onox asked and Erik acted so you can directly manipulate oil-pressure-relief-valve-psi design-oil-temp-degK oil-pressure-rpm-max oil-viscosity-index

Thanks all!

dany93 commented 7 years ago

Yes, thank you @wlbragg, but how can I get the update ? If I understand well Erik's message, it is not yet in the FG git repository ?

wlbragg commented 7 years ago

I see it in the svn repo https://sourceforge.net/p/flightgear/flightgear/commit_browser I use download and compile script on Linux and simply run it again to get any changes from next or master (or whatever it is called on svn). How do you update your FG?

dany93 commented 7 years ago

I also use the download and compile script. I'm running it now, I will see.

Thanks, I see the commit in the commit browser.

dany93 commented 7 years ago

It works ! Thank you all, Erik, and once more thank you @onox for having asked the devs. This brings the ideal solution.

Just for memory, the parameters are:

oil-pressure-relief-valve-psi
design-oil-temp-degK
oil-pressure-rpm-max
oil-viscosity-index

To be written, added in each engine configuration file c172p/Engines/ eng_io360.xml and eng_io320.xml

At this day, I think that oil-pressure-rpm-max = 2700 x 0.45 = 1215 RPM <oil-pressure-rpm-max> 1215 </oil-pressure-rpm-max> is already a good value. (was 2700 x 0.75 = 2025 previously, by default)

gilbertohasnofb commented 7 years ago

:tada: :clap: :+1:

dany93 commented 7 years ago

I will do a commit, probably tomorrow.

dany93 commented 7 years ago

Done, PR #919