|
| 1 | +.. _aerial_platform_betaflight_setup: |
| 2 | + |
| 3 | +================== |
| 4 | +Betaflight Setup |
| 5 | +================== |
| 6 | + |
| 7 | +.. contents:: Table of Contents |
| 8 | + :depth: 3 |
| 9 | + :local: |
| 10 | + |
| 11 | + |
| 12 | +----------------------------------- |
| 13 | +0. Connect to Betaflight controller |
| 14 | +----------------------------------- |
| 15 | + |
| 16 | +The Aerostack2 Betaflight platform has only been tested using Betaflight 4.4.0 version of the firmware, so first make sure this is the version you are working with. To do so, connect to the controller via USB to your PC. |
| 17 | +Go to https://app.betaflight.com/ (requires a chromium based browser like Chrome or Edge) and click on the ‘Select your device’ dropdown menu. |
| 18 | + |
| 19 | +.. figure:: resources/1-btfl_home.png |
| 20 | + :scale: 50 |
| 21 | + :class: with-shadow |
| 22 | + |
| 23 | +If it is the first time you are connecting to the controller, you will not see it on the menu so click on ‘-- I can’t find my USB device --’. A window will pop up with the different devices detected, presumably only the one you want to connect to. Select it and then click ‘Connect’ on the top right corner |
| 24 | + |
| 25 | +.. figure:: resources/2-btfl_device.png |
| 26 | + :scale: 50 |
| 27 | + :class: with-shadow |
| 28 | + |
| 29 | +On the top left corner, you can check what Betaflight version your controller has. In this case, it’s 4.5.1 BTFL. |
| 30 | + |
| 31 | +.. figure:: resources/3-btfl_version.png |
| 32 | + :scale: 50 |
| 33 | + :class: with-shadow |
| 34 | + |
| 35 | +0.1 Flash New Firmware |
| 36 | +====================== |
| 37 | + |
| 38 | +To flash a different version of the firmware, click on ‘Update Firmware’ at the top right corner. Focus on the top left part of the Firmware Flasher menu. Use the ‘Detect’ option next to the ‘Choose a board’ menu to automatically pick your board, and look for the specific version you want to install (in our case it’s 4.4.0). |
| 39 | + |
| 40 | +.. figure:: resources/4-1-btfl_firmware_version.png |
| 41 | + :scale: 50 |
| 42 | + :class: with-shadow |
| 43 | +.. figure:: resources/4-2-btfl_firmware_version.png |
| 44 | + :scale: 50 |
| 45 | + :class: with-shadow |
| 46 | + |
| 47 | +In the downside menu, select ‘GHOST’ as the ‘Radio Protocol’ and don’t change the default ‘Telemetry Protocol’. Select ‘Digital’ as the ‘OSD Protocol’ and check that the ‘Motor Protocol’ is set to ‘DSHOT’. Don’t forget to add the ‘ESC Serial (SK) inc. 4way’ option to the ‘Other Options’ menu. To add it, click on the menu bar next to the rest of options to open the dropdown. In the end, your Build Configuration should look like this |
| 48 | + |
| 49 | +.. figure:: resources/5-btfl_firmware_options.png |
| 50 | + :scale: 50 |
| 51 | + :class: with-shadow |
| 52 | + |
| 53 | +You can now click on ‘Load Firmware [Online]’ to set up the firmware, and click on ‘Flash Firmware’ once it is ready |
| 54 | + |
| 55 | +.. figure:: resources/6-btfl_firmware_flash.png |
| 56 | + :scale: 50 |
| 57 | + :class: with-shadow |
| 58 | + |
| 59 | +To check that the new version has been correctly flashed, reload the page and connect to the controller to see that the version is ‘4.4.0 BTFL’ now. The first time you reconnect, a pop up will appear. Select the option ‘Apply custom defaults’ to close the window. |
| 60 | + |
| 61 | +------------------ |
| 62 | +1. Configure Ports |
| 63 | +------------------ |
| 64 | + |
| 65 | +.. warning:: FROM NOW ON AND UP UNTIL STEP 8, AFTER EACH STEP, REMEMBER TO CLICK ON SAVE AT THE BOTTOM RIGHT OF EACH SCREEN BEFORE MOVING TO A NEW SCREEN. |
| 66 | + |
| 67 | +On the ‘Ports’ menu, the following ports must be enabled: |
| 68 | + |
| 69 | +- UART 2: enable the ‘Serial Rx’ check |
| 70 | +- UART 3: enable the ‘Configuration/MSP’ check so that NX can connect to the controller |
| 71 | +- For competition purposes, UART 7 needs the ‘Configuration/MSP’ check enabled and the ‘Peripherals’ dropdown set to ‘VTX (MSP + Displayport)’. If the drone is not going to be using VTX, this port can be left disabled. |
| 72 | +- UART 1: disable the 'Configuration/MSP' check |
| 73 | + |
| 74 | +.. note:: You may notice there is a big warning message telling you to NOT disable the first serial port unless you know what your are doing. Well, we DO know what we are doing so be not afraid and disable it. |
| 75 | + |
| 76 | +.. figure:: resources/7-btfl_ports.png |
| 77 | + :scale: 50 |
| 78 | + :class: with-shadow |
| 79 | + |
| 80 | + |
| 81 | +------------------------------ |
| 82 | +2. Check General Configuration |
| 83 | +------------------------------ |
| 84 | + |
| 85 | +On the ‘Configuration’ screen, check the following options: |
| 86 | + |
| 87 | +- On the ‘System configuration’ menu, disable ‘Magnetometer’. This is not really important, but since the controller we are using does not have a magnetometer there is no point in leaving this enabled. |
| 88 | +- On the ‘Board Alignment’ menu, set ‘Yaw Degrees’ to 180 as the IMU is turned around when mounted on the drone. |
| 89 | +- On the ‘Other Features’ menu, disable ‘AIRMODE’ and enable ‘LED STRIP’, if you want to use the LED lights on the drone, and ‘OSD’. |
| 90 | + |
| 91 | +.. figure:: resources/8-1-btfl_general_configuration.png |
| 92 | + :scale: 50 |
| 93 | + :class: with-shadow |
| 94 | +.. figure:: resources/8-2-btfl_general_configuration.png |
| 95 | + :scale: 50 |
| 96 | + :class: with-shadow |
| 97 | + |
| 98 | +--------------- |
| 99 | +3. Set Failsafe |
| 100 | +--------------- |
| 101 | + |
| 102 | +On the Failsafe Switch menu, set the ‘Failsafe Switch Action’ to ‘Kill’ so that the drone fully stop when ‘Failsafe’ is activated from the controller. |
| 103 | + |
| 104 | +.. figure:: resources/9-btfl_failsafe.png |
| 105 | + :scale: 50 |
| 106 | + :class: with-shadow |
| 107 | + |
| 108 | +----------------------- |
| 109 | +4. Set Controller Rates |
| 110 | +----------------------- |
| 111 | + |
| 112 | +On the ‘PID Tuning’ screen, select the ‘Rateprofile Settings’ menu and set the ‘RC Rate’ for each ROLL, PITCH and YAW to 1.80. Set every other fields to 0. The result should be three lineal curves ranging from –360 to 360 deg/s like the ones on the image |
| 113 | + |
| 114 | +.. figure:: resources/10-btfl_rates.png |
| 115 | + :scale: 50 |
| 116 | + :class: with-shadow |
| 117 | + |
| 118 | +------------------------------- |
| 119 | +5. Check Receiver Configuration |
| 120 | +------------------------------- |
| 121 | + |
| 122 | +On the ‘Receiver’ screen, set the ‘Receiver Mode’ to ‘Serial (via UART)’ and the ‘Serial Receiver Provider to ‘IRC GHOST’. |
| 123 | + |
| 124 | +.. figure:: resources/11-btfl_receiver.png |
| 125 | + :scale: 50 |
| 126 | + :class: with-shadow |
| 127 | + |
| 128 | +----------------------- |
| 129 | +6. Set Controller Modes |
| 130 | +----------------------- |
| 131 | + |
| 132 | +On the ‘Modes’ screen, search for the following modes and set them to the next channels and values: |
| 133 | + |
| 134 | +- ARM: set the ‘ARM’ mode to channel ‘AUX 1’ and select a range that includes the 2000 value, for instance the 1700 – 2100 shown on the image. |
| 135 | +- ANGLE: this is the mode for ACRO flights using the RC controller. Set it to channel ‘AUX 2’ and select a range that includes value 1000, like the range 900-1600 shown on the image. By setting it this way, the RC controller has control of the drone as long as the ‘Offboard’ switch is not activated. |
| 136 | +- FAILSAFE: set this mode to channel ‘AUX 5’ and select a range that includes value 2000. This switch will kill the motors in case the drone loses control of itself. |
| 137 | + |
| 138 | +.. warning:: REMEMBER TO CLICK SAVE BEFORE LEAVING THIS SCREEN |
| 139 | + |
| 140 | +There is one more mode to set but it is not visible yet. For this mode to be set, click on the ‘CLI’ screen of the left side menu. On the command prompt of this screen, type the next command: |
| 141 | + |
| 142 | +.. code-block:: |
| 143 | +
|
| 144 | + set msp_override_channels_mask=15 |
| 145 | +
|
| 146 | +The value 15 is the decimal codification of the first for channels of the RC controller, this is, the ones used for Thrust, Roll, Pitch and Yaw. Once ‘Offboard’ switch is activated, MSP stops listening to the RC controller channels selected using this mask and listens to messages sent from the onboard computer. If this channels are not specified, all the channels would be overridden and it would be impossible for the pilot to recover control of the controller. |
| 147 | + |
| 148 | +Type the command |
| 149 | + |
| 150 | +.. code-block:: |
| 151 | +
|
| 152 | + save |
| 153 | +
|
| 154 | +on the CLI command prompt and go back to the ‘Modes’ screen. You should be able to find a new mode: |
| 155 | + |
| 156 | +- MSP OVERRIDE: set this new mode to channel ‘AUX 2’, same as the ‘ANGLE’ mode, and select a range complementary to the ‘ANGLE’ one that includes value 2000, like shown on the image. |
| 157 | + |
| 158 | +.. figure:: resources/12-btfl_modes.png |
| 159 | + :scale: 50 |
| 160 | + :class: with-shadow |
| 161 | + |
| 162 | +The channels specified for each mode correspond to the sticks and buttons shown in the following image |
| 163 | + |
| 164 | +.. figure:: resources/botones.png |
| 165 | + :scale: 50 |
| 166 | + :class: with-shadow |
| 167 | + |
| 168 | +This is the configuration used by us, but you can change it to the one you feel the more comfortable with. Just make sure each mode is attached to the channel of the stick you want to use. |
| 169 | + |
| 170 | +---------------------------- |
| 171 | +7. Check Motors Mixer Matrix |
| 172 | +---------------------------- |
| 173 | + |
| 174 | +On the ‘Motors’ screen, verify that the ‘Mixer’ matrix (rotors configuration) is the same as the image: |
| 175 | + |
| 176 | +.. figure:: resources/13-btfl_mixer.png |
| 177 | + :scale: 50 |
| 178 | + :class: with-shadow |
| 179 | + |
| 180 | +Additionally, a rotor test can be performed to double check the rotors configuration. |
| 181 | + |
| 182 | +.. warning:: Do NOT perform the rotor test with propellers mounted |
| 183 | + |
| 184 | +Connect a battery and ‘understand the serious risks of injury’. This will enable the first for slide bars that control each rotor. One by one, move them to a value of approximately 1150 (never more than 1200) and check that the rotor is turning in the right direction. Once you are done testing, click on ‘Stop motors’. |
| 185 | + |
| 186 | +.. figure:: resources/14-btfl_motors.png |
| 187 | + :scale: 50 |
| 188 | + :class: with-shadow |
| 189 | + |
| 190 | +-------------------------- |
| 191 | +8. Additional CLI commands |
| 192 | +-------------------------- |
| 193 | + |
| 194 | +There is a couple final steps to be followed on the ‘CLI’ screen. |
| 195 | + |
| 196 | +- To increase the IMU (and any other serial message publication) frequency, a parameter has to be set using the command |
| 197 | + |
| 198 | +.. code-block:: |
| 199 | +
|
| 200 | + set serial_update_rate_hz=500 |
| 201 | +
|
| 202 | +This parameter can be set to up to 2000, but 500 is enough for the IMU to publish at 200 Hz. The IMU publication rate can be set in the as2_platform_betaflight configuration file, but increasing the rate there without setting the serial_update_rate_hz will result in the IMU not being able to reach the desired publication rate. |
| 203 | + |
| 204 | +- After everything is set, the ‘Save to File’ option can be used to save all configuration parameters to a .txt file that can later be loaded from this same CLI screen to automatically configure the controller after the correct version has been flashed (steps 1-8 of this guide). In fact, a .txt file with the 4.4.0 BTFL with all the A2RL configuration already exists that can be loaded, but it is a better idea to follow the complete guide and learn to set the Betaflight controller 😊 |
| 205 | + |
| 206 | +.. warning:: REMEMBER TO RUN THE COMMAND |
| 207 | + |
| 208 | + .. code-block:: |
| 209 | +
|
| 210 | + save |
| 211 | + SO YOUR CHANGES ARE NOT LOST. |
0 commit comments