Stall avoidance / engine cut logic


im using Ardupilot in an aircraft with a gas engine for automated missions.
i have a question regarding engine cut / stall avoidance.

is there any way to detect engine cut (via the RPM sensor i have connected) and trigger some logics such as maintain optimal glide ratio / pitch down with predefined airspeed, to avoid a stall and potential crash of the aircraft?

in the mission itself the plane flies a predetermined route in GUIDED mode, and if the engine cuts it tries to maintain altitude and may very well stall.

thanks for reading.

Have you read about Stall Prevention: Stall Prevention — Plane documentation

@Allister yes i have, its all about bank angle in auto modes. and level stall is only addressed in FBWA and AUTOTUNE modes,
but what happens when you have a long straight flight in GUIDED and you loose an engine? the plane will try to maintain altitude in level flight, lower the airspeed and stall.

what i would like it to do is:

  1. identify engine cut
  2. trigger an alert in telemetry
  3. maintain minimum predefined airspeed (even at the expense of loosing altitude, after all - there is no choice right?)

any idea if this is achieveable somehow? it seems like a pretty basic feature for stall prevention which is missing,

The only somehow relevant ICE parameters that iam aware of, are:

ICE_RPM_CHAN = (1 or 2, to whatever you have set your RPM input)
ICE_RPM_THRESH = Below your idle RPM, So that AP knows were the engine to be considered running.

Nevertheless, these parameters seems to impact only Starter Actions (ie if its not running then the starter will attempt to restart the engine). I dont know if they impact a FS State, where after an X amount of attempts considers the engine failed.

I don’t know for sure with an ICE but I suspect that the TECS system will keep the plane in the proper speed range in an engine failure. You could adjust settings such as TECS (Total Energy Control System) for Speed and Height Tuning Guide — Plane documentation to prioritize how this is handled.

I suspect that it is impossible to prevent stall on engine failure only by adjusting the TECS parameters in GUIDED mode (or any other flight mode that controls altitude). In these modes the FC will just try to keep a given altitude. Furthermore, the TECS parameters do not know a parameter for the best glide speed of the respective aircraft.
In a similar problem (RTL in an unpowered glider), where it is also important to maintain the best glide angle, this was achieved by using TECS_PITCH_MIN/MAX parameters very close to each other to make the glider fly with the best glide angle: What parameters to set for a glider? - #7 by Rolf

The solution should succeed with a LUA script:
As soon as the engine is idling and speed drops below a defined value, the two TECS parameters TECS_PITCH_MIN/MAX are set e.g. ± 1° than the best glide angle.

In addition, if a correctly calibrated compass and an airspeed sensor are available, the wind direction and thus the headwind component could be determined. In case of strong headwinds it is important to fly with higher speed than that of the best glide in calm conditions, so that the angles can be selected accordingly more pitch down.


@Rolf very interesting proposition regarding the LUA script.
can you offer an example LUA script which can change a parameter in ardupilot thhrough mission planner? i would like to explore this option.

nevertheless, this seems like a very basic safety critical feature which is missing from Ardupilot. how do i open a request to implement it?

The standard procedure for most pilots and applications in the event of an engine failure is probably to switch to manual mode or FBWA mode. At least within visual range. I guess your application is BVLOS ? One question is, do you have a FPV connection, a GCS connection and or a normal radio connection. You should not only keep the aircraft from stalling in case of engine failure, but you should be able to navigate to a predefined safety landing site (rally point).

In the LUA examples there are quite a few scripts that change parameters. Why should this be done via MissionPlanner ? The LUA scripts run in the flight controller. A start can be found in the WIKI: Lua Scripts — Plane documentation

You have already found the way: Stall prevention in a straight line in AUTO / GUIDED modes · Issue #22757 · ArduPilot/ardupilot · GitHub