Servers by jDrones

How to modify firmware for motors power loss

(Veronica B) #1

Hi all,
We are a university team and need to simulate a motor failure of a drone throught the modification of the firmware. Can anybody help us in finding which class can be useful for us? We just need to decrease the power of a single motor.
We use a Pixhawk 2, the drone is the DJI F450.

Thank you!

(Khancyr) #2


You can grab a branch here that implement a motor failure on RC switch.
To use it set MOT_FAIL_NUM to the motor number you want to make fail. Set the faillure percentage on MOT_FAIL_PCT. Use switch, let’s say channel 8, by setting RC8_OPTION to 99. Now, putting the switch at HIGH will cut MOT_FAIL_NUM output pwm by MOT_FAIL_PCT.

This is a dangerous code, so please use SITL first to test the behavior ! And validate the complet mission you will make on SITL first ! That way, no surprise !

We will be interested in the result and the study you will make on this behavior, would you share it ?

(rmackay9) #3

If you do choose to test in the simulator, you can set the SIM_ENGINE_MUL parameter to reduce the power to one motor (I think it’s always motor #1).

We have this PR that we think improves redundancy on a hexacopter or octacopter (or any multicopter with at least 6 motors). Here’s a video of a simulator test of this PR:

(Andre-K) #4

@khancyr should be in master, that would help users test and learn what a given RPAS , with a given payload , will do…

(Veronica B) #5

Thank you for the fast answers. Unfonrtunately, we are not able to find MOT_FAIL_NUM and MOT_FAIL_PCT. Where are they? In the Mission Planner? Because we don’t see where they are supposed to be changed.
In any case, when the test will succeed, we will let you know the results.
Thank you!

(Khancyr) #6

I won’t push it into master as it is dangerous … it is pretty simple to implement (I have another version with a potentiometer to chose the power)

(Khancyr) #7

You need to clone the branch I give you and compile the firmware from that source (I can rebase it on the last RC , if you want)
You need to set you GCS (mission planner or other) to advanced user to see those parameter.

(Andre-K) #8

By dangerous, do you mean because people could configure it by mistake (not more dangerous than emergency stop) - or are there any adverse effects of adding it ?

(Khancyr) #9

Yep, I don’t trust most user as I saw here that the majority of failure are misconfigurations, so on critical behavior like this, it is better not to include it by default … If we had a dev mode compile time option, maybe I will be more confident to propose it.

(Andre-K) #10

Let me suggest that you change working FAIL_NUM from 1…8 to 101…108 , that should be foolproof enough for most fools.
Remember; as engineer you should not aim to make this perfectly foolproof, nature always will beat you by creating a better idiot.

Giving this option to semi-advanced users will have a positive effect on better understanding of redundancy , as-is , too many think that >4 motors == redundancy, and expect miracles or some alternative laws of physics.

(swansong) #11

I would also suggest this motor fail testing feature be added, specifically to diagnose individual motors for vibration from ESC or prop issues. I was thinking to disconnect the ESC signal wire to all but one of my octocopter motors to test them individually, but if there’s a better way I’d be all for it!

(Veronica B) #12

Okey, thank you! We had an issue with the github sudmodules, but now it works and the values appears in the Mission Planner. The last doubt that we have is: how do we set the Radio Controller switch? I mean, we just have to go to “Mixer” options and set CH8 to our switch? Or there are some additional tasks? We use the Taranis plus X9D.

(rmackay9) #13

I think Tridge has recently added a way to test GPS failure on real vehicles and so, because this is such an often requested feature, I also think we should add it to master. My view previously was just like @khancyr - I was worried we would lose vehicles… but I think with the suggestion from @Andre-K we could avoid most mistakes. There was a similarly fatal feature added to Plane (sorry I forget the exact feature) and Tridge used a similar magic number method to protect from misuse and he’s told me that he’s seen a number of logs with the parameter set to “1”… people just like to try stuff out :-)… as far as I know, so far he hasn’t seen any mishaps.

(Andre-K) #14

@rmackay9 I think you mean AFS_TERM_ACTION which requires the number that is the answer to “Ultimate question of life, the universe, and everything” to enable flight termination, at least the only magic number I know in ArduPlane :slight_smile:

  • and yes, I too support GPS fail-test-option very much too… all of these are highly welcome,(maybe with some foolproofing) - they make thing easier for professional users, and helps others learn and understand their RPAS better.