avatarDavid Such

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

6205

Abstract

e and the red nuts anticlockwise. To minimise the amount of work, you should mount the motors in the configuration shown in Figure 4.</p><figure id="2579"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/0*nGYEa46GfGKUCiAC.jpeg"><figcaption><b>Figure 5. Quad ESC wired to the motors.</b></figcaption></figure><p id="e8f4">Once you have mounted the motors you can then wire them to the Quad ESC (Figure 5). While you are doing this, also solder the ESC battery connection to the appropriate pads (+ and -) on the Power Distribution Board and a connector to allow you to plug power into the flight controller. Make sure that you put the heat-shrink on before you solder the wires to the ESC and leave enough slack in the wires so that you can remove the board if required.</p><p id="cf73">If you have a servo or ESC tester then now is a good time to test that everything is working and the motors are spinning in the desired direction (Figure 6). Next up we will look at mounting and testing the flight controller.</p><figure id="622b"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/0*deynq1ixul0f5JdK.png"><figcaption><b>Figure 6. Testing the ESC’s and motor direction.</b></figcaption></figure><h2 id="ffb3">Flight Controller Firmware</h2><p id="988d">We have selected Betaflight as the flight controller firmware. It is open source and a fork of Baseflight and Cleanflight, focussed on flight performance. If required we could fork our own version or contribute to the Betaflight source code. Figure 7 illustrates a standard BetaFlight setup.</p><figure id="6241"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/0*p2Hcc-iE-63Pm393.png"><figcaption><b>Figure 7. Drone Technology Stack (<a href="https://github.com/betaflight/betaflight/issues/7112">credit</a>)</b></figcaption></figure><p id="3838">The flight controller firmware is the brains of the drone. The quality of this software and its tuning will determine how easy our drone is to fly. The Betaflight Configurator software (Windows, Mac or Linux) allows us to connect our PC to the flight controller hardware and upload the latest firmware version. It also allows us to configure, test and tune the software.</p><h2 id="2cd5">Flight Controller Hardware</h2><p id="ec82">As an interim Flight Controller we are using the CLRacingF7 MPU v2.1 MPU6000 (Figure 8). This flight controller is fully featured and uses a STM32 F7 MCU (i.e. heaps of grunt). The STM32 family of 32-bit microcontrollers are based on the Arm Cortex-M7 processor and are designed for high performance, real-time capabilities, digital signal processing, low-power / low-voltage operation, and lots of connectivity options.</p><figure id="e5f3"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/0*BC1__GgZi29AxWEW.png"><figcaption><b>Figure 8. Flight Controller Connections (bottom of board).</b></figcaption></figure><p id="ddea">The specifications of this board are impressive:</p><ul><li>MPU: STM32 F7 MCU</li><li>IMU (Gyro): MPU6000</li><li>Betaflight On Screen Display (OSD) capability</li><li>Input voltage 2S — 8S (36V)</li><li>BEC: 5V/3A and 3.3V/250mA</li><li>Serial: 6 Full UART’s</li><li>Supports FPV Camera Control (with necessary resistor and capacitor)</li><li>VBAT Polarity protection and battery monitoring</li><li>Built-in 32MB flash memory chip for Blackbox</li><li>4 Motor Control Outputs</li><li>Includes a 32MB Blackbox flash chip</li><li>Betaflight Target: CLRACINGF7, (comes preloaded with Betaflight)</li></ul><p id="1c93">The box from CLRACING also contains:</p><ul><li>6x rubber grommets for soft mounting (2 spares)</li><li>FC to 4in1 ESC ribbon cable (8-pin)</li><li>a couple of spare headers (9-pin and 8-pin)</li></ul><p id="808e">Before connecting the flight controller to the ESC’s, it is a good idea to check that it works with BetaFlight Configurator (Figure 9). You first need to download the configurator, and connect the flight controller to a computer USB port. Make sure that you use a USB cable which has the data pins connected, many of the charging cables don’t and you can waste a lot of time trying to diagnose this problem. We mark our cables to to assist with this issue.</p><figure id="76a4"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/0*wrolo2AxyaZcE0yB.png"><figcaption><b>Figure 9. CLRacingF7 Flight Controller connected to BetaFlight Configurator.</b></figcaption></figure><p id="ad03">Connections to the flight controller board (Figure 8) are straight forward apart from the 4 in 1 ESC port. At this point we only need to install two connections:</p><ol><li>The four wires to the radio control receiver (SBUS, telemetry, 5V and GND); and</li><li>The ESC Port (VBAT, GND, RX4, CURR, M4, M3, M2 and M1). Of course this is designed to match the corresponding port on a CLRACING 4 in 1 ESC and we are using the Racerstar which has different connections (GND, M4, M3, M2 and M1), so we will need to construct a wiring harness to suit. See Figure 10 for connection details.</li></ol><p id="c4af">The Racerstar Quad ESC comes with a couple of wiring harness which you can butcher or you can buy some JST 1.0 mm SH 6-Pin Connectors which match the ESC socket. Note that only 5 of these pins are used. Finding an 8 pin JST SH connector is much harder, so we will modify the cable that comes with the flight controller for the other end.</p><figure id="edbe"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/0*gJXumvu5jWjAal9Y.png"><figcaption><b>Figure 10. Flight Controller/ESC Wiring Harness Details.</b></figcaption></figure><p id="05d5">The completed harness is shown in Figure 11. In addition to the Flight Controller (FC) and ESC connections, we have drawn out a separate 2 pin JST connector which will provide VBAT (nominal 7.4V) voltage from the Power Distribution Board (PDB) and commoned up the GND connections. When designing the Nexgen PDB we will mount a 2 pins JST SH socket for this purpose. We may also add a Battery Elimination Circuit (BEC) if we don’t put this on the flight controller. The CLRacing FC provides a BEC which can provide 5V at 3A and 3.3V at 250mA but we wouldn’t want to pull 3A through the 1mm JST SH

Options

connection that is the only power connection for the FC. That connection will use a wire gauge size between 32 and 28 AWG, which shouldn’t be carrying more than 1A or things will get warm (<a href="https://en.wikipedia.org/wiki/JST_connector">reference</a>)!</p><figure id="26b9"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/0*g81USdcy9r3EmNgY.jpeg"><figcaption><b>Figure 11. Completed Flight Control Harness.</b></figcaption></figure><p id="ea3e">It is always a good idea to test before you do the final mounting. Figure 12 shows the flight controller connected to the ESC and powered by the battery using our new wiring harness. We will also connect up to BetaFlight Configurator again to make sure that the flight controller can talk to the ESC.</p><p id="b66b">Before doing anything else, back up your flight controller settings. When you connect to BetaFlight, in the Setup tab (Figure 9), click on Backup and save the resulting JSON file somewhere safe. This way you can always restore the factory configuration if you mess something up. Alternatively you can type “dump” in the Command Line Interface (CLI) and save the output to a text file.</p><figure id="7b23"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/0*jEKA3WmIlJ6m2s3d.jpeg"><figcaption><b>Figure 12. Flight Controller connected to ESC and powered by the battery.</b></figcaption></figure><p id="8163">In the Configuration tab of the configurator you can change motor direction if required and select the ESC protocol. The default is ONESHOT125 and we will leave that as is for now. The Motors tab allows us to test the motors either via the flight controller or using the remote control (Figure 13). You need to click on the button acknowledging that you understand the risks before you can use the motor slider controls.</p><figure id="b4b5"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/0*VmQhcYs2LGfmkP5E.png"><figcaption><b>Figure 13. Testing the motors via the Flight Controller using BetaFlight.</b></figcaption></figure><h2 id="689b">Power Distribution</h2><p id="1455">All of the drones power comes from our 2S 1300 mAh Lithium Polymer battery (Figure 14).</p><figure id="daf0"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/0*ayW6IrBLnMPkDsoQ.jpg"><figcaption><b>Figure 14. 2S 1300 mAh LiPo Battery</b></figcaption></figure><p id="feb3">The specifications for our battery are:</p><ul><li>Minimum Capacity: 1300mAh</li><li>Configuration: 2S1P / 7.4v / 2Cell</li><li>Constant Discharge: 20C</li><li>Peak Discharge (10sec): 30C</li><li>Pack Weight: 81g</li><li>Pack Size: 73 x 35 x 17mm</li><li>Charge Plug: JST-XH</li><li>Discharge plug: XT60</li></ul><p id="6b72">At 3.7V per cell our 2S battery will deliver a nominal 7.4V from the contacts on the power distribution board. The 2S indicates that we have two cells in series so the sum of the two cells voltage is the output voltage. As an aside, cells in parallel add to the batteries capacity (i.e. mAh) not voltage.</p><figure id="011f"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/0*G_taBFVsNpjzDm4c.png"><figcaption><b>Figure 15. Racerstar BLHeli_S 20A Quad Electronic Speed Control (ESC).</b></figcaption></figure><p id="2e7a">The CLRACINGF7 MPU V2.1 Flight Controller that we are using will provide 5V at 3A and 3.3V at 250mA. The modules we will need to power are:</p><ul><li>The CLRacingF7 MPU v2.1 MPU6000 Flight Controller.</li><li>The Racerstar BLHeli_S 20A Quad Electronic Speed Control — shown in Figure 15 (connects to the battery, receiver and the four motors). It doesn’t have a BEC (Battery Elimination Circuit) to provide a regulated supply. Supports the oneshot42, multishot, Dshot150 and Dshot300 ESC protocols.</li><li>The UBLOX Micro M8N GPS Compass Module — shown in Figure 16. This module expects a regulated 5V on VCC but control voltages are 3.3V (see Figure 17).</li><li>The FrSKY X8R 2.4Ghz SBUS Receiver. The receiver will also need to be connected to the regulated 5VDC bus.</li></ul><figure id="ca95"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/0*l-M3CthcRrSJlBot.jpg"><figcaption><b>Figure 16. UBLOX Micro M8N GPS Compass Module</b></figcaption></figure><figure id="899f"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/0*FW_v5_g7E3yIh3gC.png"><figcaption><b>Figure 17. GPS Module Connections.</b></figcaption></figure><p id="40cc">In <a href="https://reefwing.medium.com/designing-a-new-drone-part-2-62bab60dc5f4">Part 2</a> we will connect the remote control, pop on some propellers and see how she flies!</p><div id="9ca7" class="link-block"> <a href="https://reefwing.medium.com/designing-a-new-drone-part-2-62bab60dc5f4"> <div> <div> <h2>Designing a new Drone — Part 2</h2> <div><h3>3D Print the Drone Air Frame</h3></div> <div><p>reefwing.medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*fNECdNS7zHFTWdhq.jpeg)"></div> </div> </div> </a> </div><p id="5c4e"><i>If you enjoyed this article and would like to help support my writing, then please <a href="https://reefwing.medium.com/membership">subscribe to become a Medium Member</a>. I will get a portion of your subscription fee and you get access to every story on Medium. Alternatively, you can <a href="https://ko-fi.com/davidsuch">buy me a coffee</a>!</i></p><div id="c141" class="link-block"> <a href="https://reefwing.medium.com/membership"> <div> <div> <h2>Join Medium with my referral link - David Such</h2> <div><h3>Read every story from David Such (and thousands of other writers on Medium). Your membership fee directly supports…</h3></div> <div><p>reefwing.medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*fecO9jhpCa1JX8nf)"></div> </div> </div> </a> </div></article></body>

Designing a New Drone — Part 1

Code Name: Magpie DS2 — The Objective

The Reefwing team have decided to design their own drone! The idea is that it will eventually utilise open source hardware and software can be used for STEM training in schools.

Figure 1. The Drone Prototype — partially assembled.

With this in mind, we have come up with the following criteria for our drone:

  • The drone should be able to be constructed by students using a 3D printed airframe and a kit of parts provided.
  • The drone should be modular, open source hardware and software and include an API to allow mission control.
  • The design philosophy will be to provide the minimum functionality required to deliver the objectives.
  • A secondary objective is to use a crowdsourcing campaign to help fund development and market the concept.

We will build a prototype based on commercially available parts and then design our own airframe and flight controller, once we have a design that flies. We want a modular design that we can add optional functionality to (e.g. FPV camera or GPS). The initial design will have space for these features but as we want to get something up and running as quickly as possible, it will only include the minimum components to get a flyable drone (i.e. air frame, battery, power distribution, ESC, flight controller, receiver, motors and propellers).

As part of the educational process we will document our design journey and explain the engineering choices that we make along the way.

Air Frame & Construction

For the prototype we will use a Martian II 220 mm frame design. This design is mostly used for racing quads but it is a nice light compact design and will provide a good starting point for us to iterate on.

Frame construction is pretty straight forward. As shown in Figure 1, we labelled the front of the drone and motor number locations using electrical tape. This helps keep you oriented. Even though we won’t mount a GPS or FPV camera initially, we made sure that there was a spot at the front for it.

The first board attached to the frame is the Power Distribution Board. This makes it easy for us to distribute battery power to the ESC’s and flight controller. Regulated 5V and 3.3V supplies are available from the flight controller.

Figure 2. Drone Lower Deck Layout.

Once you have the arms attached to the bottom frame and the Power Distribution Board (PDB) mounted, you can add the quad 20A Electronic Speed Controller (ESC). The RacerStar ESC that I bought has mounting holes which line up nicely with the PDB. I assume that this isn’t a coincidence but I admit that I fluked it. Figure 2, provides an overview of what the bottom layer of the drone will look like when we are finished.

Figure 3. Partial Drone Elevation.

Using a stock Martian II frame, the available distance between the top and bottom layers is 30 mm and with the ESC in place we have already used 20 mm of that (Figure 3). Take this into account when you mount the Flight Controller board on top of the ESC.

Drones use an Inertial Measurement Unit (IMU) to determine the orientation of the air frame, these sensors may be a combination of accelerometers, gyroscopes, and magnetometers. When installing the flight controller board, make sure the arrow on the board points to the front of the drone. This ensures that the IMU is oriented correctly. You can tweak this in Betaflight configurator if you have to mount it in another orientation (YAW offset in the configuration tab, board sensor alignment — 90, 180, or 270 degrees usually).

When laying out the various modules on the air frame our aim is to keep the weight centred as much as possible. This makes level flight much easier to achieve for the flight controller.

Mounting the Motors

We need to mount the four brushless motors to work out the correct wire length to the ESC. My RacerStar motors came with two sets of M3 screws, 8mm and 6mm. The thickness of the frame arms is 4mm, so use the 6mm screws to ensure they don’t short out the motor coils. For now you can just do them up finger tight but eventually you will want to apply loctite to ensure that the motors don’t fall off mid flight (bad).

The RacerStar ESC can be programmed using the BLHeliSuite software on PC. With that we can reverse the motor direction but you need compatible Flight Controller software. For our purposes, it is probably simpler to just swap two wires if the motor is going in the wrong direction.

Figure 4. Drone Motor Orientation

Our motors indicate their default rotational direction (clockwise or anticlockwise) by arrows on the top of the motor and different coloured propeller nuts. The black nuts rotate clockwise and the red nuts anticlockwise. To minimise the amount of work, you should mount the motors in the configuration shown in Figure 4.

Figure 5. Quad ESC wired to the motors.

Once you have mounted the motors you can then wire them to the Quad ESC (Figure 5). While you are doing this, also solder the ESC battery connection to the appropriate pads (+ and -) on the Power Distribution Board and a connector to allow you to plug power into the flight controller. Make sure that you put the heat-shrink on before you solder the wires to the ESC and leave enough slack in the wires so that you can remove the board if required.

If you have a servo or ESC tester then now is a good time to test that everything is working and the motors are spinning in the desired direction (Figure 6). Next up we will look at mounting and testing the flight controller.

Figure 6. Testing the ESC’s and motor direction.

Flight Controller Firmware

We have selected Betaflight as the flight controller firmware. It is open source and a fork of Baseflight and Cleanflight, focussed on flight performance. If required we could fork our own version or contribute to the Betaflight source code. Figure 7 illustrates a standard BetaFlight setup.

Figure 7. Drone Technology Stack (credit)

The flight controller firmware is the brains of the drone. The quality of this software and its tuning will determine how easy our drone is to fly. The Betaflight Configurator software (Windows, Mac or Linux) allows us to connect our PC to the flight controller hardware and upload the latest firmware version. It also allows us to configure, test and tune the software.

Flight Controller Hardware

As an interim Flight Controller we are using the CLRacingF7 MPU v2.1 MPU6000 (Figure 8). This flight controller is fully featured and uses a STM32 F7 MCU (i.e. heaps of grunt). The STM32 family of 32-bit microcontrollers are based on the Arm Cortex-M7 processor and are designed for high performance, real-time capabilities, digital signal processing, low-power / low-voltage operation, and lots of connectivity options.

Figure 8. Flight Controller Connections (bottom of board).

The specifications of this board are impressive:

  • MPU: STM32 F7 MCU
  • IMU (Gyro): MPU6000
  • Betaflight On Screen Display (OSD) capability
  • Input voltage 2S — 8S (36V)
  • BEC: 5V/3A and 3.3V/250mA
  • Serial: 6 Full UART’s
  • Supports FPV Camera Control (with necessary resistor and capacitor)
  • VBAT Polarity protection and battery monitoring
  • Built-in 32MB flash memory chip for Blackbox
  • 4 Motor Control Outputs
  • Includes a 32MB Blackbox flash chip
  • Betaflight Target: CLRACINGF7, (comes preloaded with Betaflight)

The box from CLRACING also contains:

  • 6x rubber grommets for soft mounting (2 spares)
  • FC to 4in1 ESC ribbon cable (8-pin)
  • a couple of spare headers (9-pin and 8-pin)

Before connecting the flight controller to the ESC’s, it is a good idea to check that it works with BetaFlight Configurator (Figure 9). You first need to download the configurator, and connect the flight controller to a computer USB port. Make sure that you use a USB cable which has the data pins connected, many of the charging cables don’t and you can waste a lot of time trying to diagnose this problem. We mark our cables to to assist with this issue.

Figure 9. CLRacingF7 Flight Controller connected to BetaFlight Configurator.

Connections to the flight controller board (Figure 8) are straight forward apart from the 4 in 1 ESC port. At this point we only need to install two connections:

  1. The four wires to the radio control receiver (SBUS, telemetry, 5V and GND); and
  2. The ESC Port (VBAT, GND, RX4, CURR, M4, M3, M2 and M1). Of course this is designed to match the corresponding port on a CLRACING 4 in 1 ESC and we are using the Racerstar which has different connections (GND, M4, M3, M2 and M1), so we will need to construct a wiring harness to suit. See Figure 10 for connection details.

The Racerstar Quad ESC comes with a couple of wiring harness which you can butcher or you can buy some JST 1.0 mm SH 6-Pin Connectors which match the ESC socket. Note that only 5 of these pins are used. Finding an 8 pin JST SH connector is much harder, so we will modify the cable that comes with the flight controller for the other end.

Figure 10. Flight Controller/ESC Wiring Harness Details.

The completed harness is shown in Figure 11. In addition to the Flight Controller (FC) and ESC connections, we have drawn out a separate 2 pin JST connector which will provide VBAT (nominal 7.4V) voltage from the Power Distribution Board (PDB) and commoned up the GND connections. When designing the Nexgen PDB we will mount a 2 pins JST SH socket for this purpose. We may also add a Battery Elimination Circuit (BEC) if we don’t put this on the flight controller. The CLRacing FC provides a BEC which can provide 5V at 3A and 3.3V at 250mA but we wouldn’t want to pull 3A through the 1mm JST SH connection that is the only power connection for the FC. That connection will use a wire gauge size between 32 and 28 AWG, which shouldn’t be carrying more than 1A or things will get warm (reference)!

Figure 11. Completed Flight Control Harness.

It is always a good idea to test before you do the final mounting. Figure 12 shows the flight controller connected to the ESC and powered by the battery using our new wiring harness. We will also connect up to BetaFlight Configurator again to make sure that the flight controller can talk to the ESC.

Before doing anything else, back up your flight controller settings. When you connect to BetaFlight, in the Setup tab (Figure 9), click on Backup and save the resulting JSON file somewhere safe. This way you can always restore the factory configuration if you mess something up. Alternatively you can type “dump” in the Command Line Interface (CLI) and save the output to a text file.

Figure 12. Flight Controller connected to ESC and powered by the battery.

In the Configuration tab of the configurator you can change motor direction if required and select the ESC protocol. The default is ONESHOT125 and we will leave that as is for now. The Motors tab allows us to test the motors either via the flight controller or using the remote control (Figure 13). You need to click on the button acknowledging that you understand the risks before you can use the motor slider controls.

Figure 13. Testing the motors via the Flight Controller using BetaFlight.

Power Distribution

All of the drones power comes from our 2S 1300 mAh Lithium Polymer battery (Figure 14).

Figure 14. 2S 1300 mAh LiPo Battery

The specifications for our battery are:

  • Minimum Capacity: 1300mAh
  • Configuration: 2S1P / 7.4v / 2Cell
  • Constant Discharge: 20C
  • Peak Discharge (10sec): 30C
  • Pack Weight: 81g
  • Pack Size: 73 x 35 x 17mm
  • Charge Plug: JST-XH
  • Discharge plug: XT60

At 3.7V per cell our 2S battery will deliver a nominal 7.4V from the contacts on the power distribution board. The 2S indicates that we have two cells in series so the sum of the two cells voltage is the output voltage. As an aside, cells in parallel add to the batteries capacity (i.e. mAh) not voltage.

Figure 15. Racerstar BLHeli_S 20A Quad Electronic Speed Control (ESC).

The CLRACINGF7 MPU V2.1 Flight Controller that we are using will provide 5V at 3A and 3.3V at 250mA. The modules we will need to power are:

  • The CLRacingF7 MPU v2.1 MPU6000 Flight Controller.
  • The Racerstar BLHeli_S 20A Quad Electronic Speed Control — shown in Figure 15 (connects to the battery, receiver and the four motors). It doesn’t have a BEC (Battery Elimination Circuit) to provide a regulated supply. Supports the oneshot42, multishot, Dshot150 and Dshot300 ESC protocols.
  • The UBLOX Micro M8N GPS Compass Module — shown in Figure 16. This module expects a regulated 5V on VCC but control voltages are 3.3V (see Figure 17).
  • The FrSKY X8R 2.4Ghz SBUS Receiver. The receiver will also need to be connected to the regulated 5VDC bus.
Figure 16. UBLOX Micro M8N GPS Compass Module
Figure 17. GPS Module Connections.

In Part 2 we will connect the remote control, pop on some propellers and see how she flies!

If you enjoyed this article and would like to help support my writing, then please subscribe to become a Medium Member. I will get a portion of your subscription fee and you get access to every story on Medium. Alternatively, you can buy me a coffee!

Drones
Build
Tutorial
Betaflight
Recommended from ReadMedium