Merge pull request #7671 from dronejunkie/rpm-osd
[betaflight.git] / docs / Failsafe.md
blob5a714b182535291d59f0ed47073f1b632f8ec25a
1 # Failsafe
3 There are two types of failsafe:
5 1. Receiver based failsafe
6 2. Flight controller based failsafe
8 Receiver based failsafe is where you, from your transmitter and receiver, configure channels to output desired signals if your receiver detects signal loss and goes to the __failsafe mode__. The idea is that you set throttle and other controls so the aircraft descends in a controlled manner.  See your receiver's documentation for this method.
10 Flight controller based failsafe is where the flight controller attempts to detect signal loss and/or the __failsafe mode__ of your receiver and upon detection goes to __failsafe stage 1__. The idea is that the flight controller starts using __fallback settings__ for all controls, which are set by you, using the CLI command `rxfail` (see [rxfail](Rx.md#rx-loss-configuration) section in rx documentation) or the cleanflight-configurator GUI.
12 It is possible to use both types at the same time, which may be desirable.  Flight controller failsafe can even help if your receiver signal wires come loose, get damaged or your receiver malfunctions in a way the receiver itself cannot detect.
14 Alternatively you may configure a transmitter switch to activate failsafe mode. This is useful for fieldtesting the failsafe system and as a **_`PANIC`_** switch when you lose orientation.
16 ## Flight controller failsafe system 
18 This system has two stages.
20 __Stage 1__ is entered when __a flightchannel__ has an __*invalid pulse length*__, the receiver reports __*failsafe mode*__ or there is __*no signal*__ from the receiver. Fallback settings are applied to __*all channels*__ and a short amount of time is provided to allow for recovery.
22 __Note:__ Prior to entering __stage 1__, fallback settings are also applied to __*individual AUX channels*__ that have invalid pulses.
24 __Stage 1__ can also directly be activated when a transmitter switch that is configured to control the failsafe mode is switched ON and `failsafe_switch_mode` is set to `STAGE1`. Stage 1 will be aborted if the switch is moved to the OFF position before Stage 2 is engaged (see next).
26 __Stage 2__ is entered when your craft is __armed__ and __stage 1__ persists longer then the configured guard time (`failsafe_delay`). All channels will remain at the applied fallback setting unless overruled by the chosen stage 2 procedure (`failsafe_procedure`).
28 __Stage 2__ is not activated until 5 seconds after the flight controller boots up.  This is to prevent unwanted activation, as in the case of TX/RX gear with long bind procedures, before the RX sends out valid data.
30 __Stage 2__ can also directly be activated when a transmitter switch that is configured to control the failsafe mode is switched ON and `failsafe_switch_mode` is set to `STAGE2`.
32 __Stage 2__ will be aborted when it was due to:
34 * a lost RC signal and the RC signal has recovered.
35 * a transmitter failsafe switch was set to ON position and the switch is set to OFF position (and `failsafe_switch_mode` is _not_ set to `KILL`).
37 Note that:
38 * At the end of the stage 2 procedure, the flight controller will be disarmed and re-arming will be locked until the signal from the receiver is restored for specific amount of time depending on the procedure (see below) AND the arming switch is in the OFF position (when an arm switch is in use).
40 * Prior to starting a stage 2 intervention it is checked if the throttle position was below `min_throttle` level for the last `failsafe_throttle_low_delay` seconds. If it was, the craft is assumed to be on the ground and is only disarmed. It may be re-armed without a power cycle.     
42 Some notes about **SAFETY**:
43 * The failsafe system will be activated regardless of current throttle position. So when the failsafe intervention is aborted (RC signal restored/failsafe switch set to OFF) the current stick position will direct the craft !
44 * The craft may already be on the ground with motors stopped and that motors and props could spin again - the software does not currently detect if the craft is on the ground.  Take care when using `MOTOR_STOP` feature. **Props will spin up without warning**, when armed with `MOTOR_STOP` feature ON (props are not spinning) **_and_** failsafe is activated !
46 ## Configuration
48 When configuring the flight controller failsafe, use the following steps:
50 1.  Configure your receiver to do one of the following:
52 * Upon signal loss, send no signal/pulses over the channels
53 * Send an invalid signal over the channels (for example, send values lower than `rx_min_usec`)
55 and
57 * Ensure your receiver does not send out channel data that would cause a disarm by switch or sticks to be registered by the FC. This is especially important for those using a switch to arm.
59 See your receiver's documentation for direction on how to accomplish one of these.
61 * Configure one of the transmitter switches to activate the failsafe mode.
63 2.  Set `failsafe_off_delay` to an appropriate value based on how high you fly
65 3.  Set `failsafe_throttle` to a value that allows the aircraft to descend at approximately one meter per second (default is 1000 which should be throttle off).
70 These are the basic steps for flight controller failsafe configuration; see Failsafe Settings below for additional settings that may be changed.
72 ## Failsafe Settings
74 Failsafe delays are configured in 0.1 second steps.
76 1 step = 0.1sec
78 1 second = 10 steps
80 ### `failsafe_delay`
82 Guard time for failsafe activation after signal lost.  This is the amount of time the flight controller waits to see if it begins receiving a valid signal again before activating failsafe.
84 ### `failsafe_off_delay`
86 Delay after failsafe activates before motors finally turn off.  This is the amount of time 'failsafe_throttle' is active.  If you fly at higher altitudes you may need more time to descend safely.
88 ### `failsafe_throttle`
90 Throttle level used for landing.  Specify a value that causes the aircraft to descend at about 1M/sec. Default is set to 1000 which should correspond to throttle off.
92 ### `failsafe_switch_mode`
94 Configure the RC switched failsafe action. It can be one of:
95 * `STAGE1` - activates Stage 1 failsafe. RC controls are applied as configured for Stage 1 and the `failsafe_delay` guard time will have to elapse before Stage 2 is activated. This is useful if you want to simulate with a switch the exact signal loss failsafe behavior.
96 * `STAGE2` - skips Stage 1 and activates the Stage 2 procedure immediately (see `failsafe_procedure`). Useful if you want to assign instant auto-landing to a switch.
97 * `KILL` - disarms instantly (your craft will crash). Re-arming is locked for 1 second AND until the arming switch (if used) is moved to the OFF position. Similar effect can be achieved by:
98   * setting `failsafe_switch_mode` to `STAGE2` and `failsafe_procedure` to `DROP`. The difference is that `DROP` locks re-arming for 3 seconds instead of 1.
99   * setting `failsafe_switch_mode` to `STAGE2`, `failsafe_procedure` to `AUTO-LAND`, setting `failsafe_throttle` to 1000 and `failsafe_off_delay` to 0 (basically initiates an auto-landing but cuts it short immediately). This is not preferred method, since the reaction is slower and re-arming will be locked for 30 seconds.
100   * using arm switch. This does not introduce re-arming locking.
102 ### `failsafe_throttle_low_delay`
104 Time throttle level must have been below 'min_throttle' to _only disarm_ instead of _full failsafe procedure_.
106 Use standard RX usec values.  See [Rx documentation](Rx.md).
108 ### `failsafe_procedure`
110 * `DROP`: Just kill the motors and disarm (crash the craft). Re-arming is locked until RC link is available for at least 3 seconds and the arm switch (if used) is in the OFF position.
111 * `AUTO-LAND`: Enable an auto-level mode, center the flight sticks and set the throttle to a predefined value (`failsafe_throttle`) for a predefined time (`failsafe_off_delay`). This should allow the craft to come to a safer landing. Re-arming is locked until RC link is available for at least 30 seconds and the arm switch (if used) is in the OFF position.
113 ### `rx_min_usec`
115 The lowest channel value considered valid.  e.g. PWM/PPM pulse length 
117 ### `rx_max_usec`
119 The highest channel value considered valid.  e.g. PWM/PPM pulse length 
121 The `rx_min_usec` and `rx_max_usec` settings helps detect when your RX stops sending any data, enters failsafe mode or when the RX looses signal.
123 With a Graupner GR-24 configured for PWM output with failsafe on channels 1-4 set to OFF in the receiver settings then this setting, at its default value, will allow failsafe to be activated.
125 ## Testing
127 **Bench test the failsafe system before flying - _remove props while doing so_.**
129 1. Arm the craft.
130 1. Turn off transmitter or unplug RX.
131 1. Observe motors spin at configured throttle setting for configured duration.
132 1. Observe motors turn off after configured duration.
133 1. Ensure that when you turn on your TX again or reconnect the RX that you cannot re-arm once the motors have stopped.
134 1. Power cycle the FC.
135 1. Arm the craft.
136 1. Turn off transmitter or unplug RX.
137 1. Observe motors spin at configured throttle setting for configured duration.
138 1. Turn on TX or reconnect RX.
139 1. Ensure that your switch positions don't now cause the craft to disarm (otherwise it would fall out of the sky on regained signal).
140 1. Observe that normal flight behavior is resumed.
141 1. Disarm.
143 **Field test the failsafe system.**
145 1. Perform bench testing first!
146 1. On a calm day go to an unpopulated area away from buildings or test indoors in a safe controlled environment - e.g. inside a big net.
147 1. Arm the craft.
148 1. Hover over something soft (long grass, ferns, heather, foam, etc.).
149 1. Descend the craft and observe throttle position and record throttle value from your TX channel monitor.  Ideally 1500 should be hover. So your value should be less than 1500.
150 1. Stop, disarm.
151 1. Set failsafe throttle to the recorded value.
152 1. Arm, hover over something soft again.
153 1. Turn off TX (!)
154 1. Observe craft descends and motors continue to spin for the configured duration.
155 1. Observe FC disarms after the configured duration.
156 1. Remove flight battery.
158 If craft descends too quickly then increase failsafe throttle setting.
160 Ensure that the duration is long enough for your craft to land at the altitudes you normally fly at.
162 Using a configured transmitter switch to activate failsafe mode, instead of switching off your TX, is good primary testing method in addition to the above procedure.