Configuring an ESC with BLHeli firmware using an Arduino Uno

The Importance of Motor Direction

In order to stop our drone spinning like a top, it is important that the four motors turn in a particular direction. As shown in figure 1, we want the motors to alternate spinning clock wise and counter clockwise. This arrangement causes the torque from the spinning motors to cancel out and the quad only yaws when we want it to.

We wired up all our motors to the RacerStar Quad ESC in the same way as we assumed that the default arrangement would give us the correct spin direction. It doesn’t. Two diagonally opposed motors are spinning in the wrong direction (M1 and M3). We could fix this by swapping any two wires from the ESC to the motor but it is easier to do this in software.

ESC Firmware

In the beginning, ESC’s came with firmware from the manufacturers, and they were rubbish. So 3rd party firmware came to be. The two originals were SimonK and BLHeli. SimonK is no longer supported so BLHeli has become the defacto (Open Source?) standard.

BLHeli has continue to evolve and now comes in BLHeli_S and BLHeli_32 flavours. As you can guess, BLHeli_32 is targeted at 32 bit ESC hardware and performs better than its predecessors.

The RacerStar ESC (Figure 2) we are using is not 32 bit compatible and comes standard with BLHeli_S.

The majority of multirotor ESC’s on the market use processors (MCU’s) from ATMEL, Silabs and ARM. The different MCU’s have different specifications and features, and are supported by different firmware:

  • ATMEL 8-bit MCU’s are compatible with both SimonK and BLHeli ESC firmware;
  • SILABS 8-bit MCU’s are supported by BLHeli or BLHeli_S only; and
  • ARM Cortex 32-bit MCU’s (e.g. STM32 F0, F3, L4, F4) can run BLHeli_32.

Arduino Pass through Sketch

In order to communicate with our ESC we need some middleware, as the only way to communicate with the RacerStar Quad ESC is via the motor control lines. A lot of commercial flight controllers include a pass through mode which allows you to communicate with the ESC using BetaFlight/CleanFlight. Ours doesn’t have this, but you can use a standard Arduino UNO or Nano to do the same thing.

In order to load the Arduino Interface code we need to know which port the Arduino is connected to. The easiest way to work this out is using the Arduino IDE. Connect the Arduino to your PC via USB and then open up the IDE. In tools, select the Arduino model (Uno in our case) and then the port should be indicated as shown in Figure 3. Make a note of this port and then shut down the IDE. You can’t have two serial connections to the board at the same time.

As ESC’s are built with a variety of MCU’s there are a variety of methods to communicate with them. Interface methods include:

  • SiLabs C2 Interface (3 wires);
  • Atmel ISP Interface (6 wires); and
  • USB/UART 1-Wire bridge (2 wires).

The RacerStar quad ESC’s use SiLabs hardware but they don’t expose a C2 interface so we will be using the 1-Wire approach. In order to upload the BLHeli bootloader to our Arduino, we need BLHeli Suite.

BLHeli Suite

BLHeli Suite is a Windows program for flashing, setting up and configuring your BLHeli or BLHeli_S ESCs.

You can use it to:

  • Reverse the rotation direction of the motors;
  • Upgrade the BLHeli firmware on your ESC; and
  • Change the BLHeli ESC parameters (see Figure 4).

We are particularly interested in the first dot point but the others are useful as well.

BLHeli Suite is an application for setting up BLHeli and BLHeli_S ESC’s. It is still maintained and being updated. BLHeli Suite only runs on Windows. BLHeli_32 Suite is available for Windows, Linux and MacOS X platforms, but we don’t have 32 bit ESC’s so that doesn’t help us.

There is another program called BLHeli Configurator. This is a simplified more user friendly version of BLHeli Suite and looks similar to BetaFlight Configurator. There is also a chrome app of the same name but this is no longer maintained, so don’t use that. In order to flash the Arduino we need BLHeli Suite. Downloads for the various packages may be found at the following links:

  1. BLHeli Suite and BLHeli_32 Suite
  2. BLHeli Configurator

Uploading the Arduino Bootloader

Once you have downloaded BLHeli Suite from the above link, open up the app and you should see a screen similar to Figure 4. Click on the Make interfaces tab to get to the screen shown in Figure 6. To the far right you will see “Make Arduino Interface Boards.” This is what we need.

Connect the Arduino to your Windows laptop. If you haven’t already, determine which COM port the board is connected to (use the Arduino IDE) and make a note of this. Select the correct COM port in the drop down box at the bottom of the screen. In Figure 6you can see that we selected COM7 Arduino Uno.

Select the Arduino board that you are using in the “Arduino Board” drop down box. Leave the baud rate at 115,200. Finally, click on the “Arduino BLHeli Bootloader” button and BLHeli Suite will attempt to upload the bootloader to the Arduino. If you are successful, you will see Figure 7.

Hardware Considerations

In order to simplify the required connections, it helps if you have set up the connections to your flight controller in a particular way.

On our flight controller power distribution board (PDB), we have a male XT-60 plug for connection to the battery and a female side mount XT-60 socket which passes this battery voltage to the ESC. The LiPo battery has a female XT-60 socket, this is normally plugged into the PDB but when using BLHeli Suite we can plug the LiPo battery directly into the ESC (Figure 8).

The RacerStar Quad ESC (Figure 3) has a 6 pin JST-SH male plug for motor control and GND. One of the pins isn’t used. We made up a cable with a matching female 6 pin JST-SH socket and standard 2.54 mm (0.1 inch) DuPont male headers at the other end (Figure 9). We normally have a cable from the flight controller plugged into the JST-SH so this needs to be removed before connecting the UNO. In subsequent PDB designs we will look at adding a pass through connection so that the PDB cable doesn’t have to be removed during the ESC setup process. The actual connections are very simple.

  • Connect the ESC power to your battery.
  • Connect the GND control pin on the ESC to one of the GND pins on the UNO.
  • Connect M1 control to UNO pin D11.

Theoretically multiple ESC’s (up to 8) can be controlled through the one pin but that didn’t work for us. We had to connect each ESC control pin in turn to D11 in order to configure them.

Once you have successfully connected to the ESC, you can read the setup (Figure 5) and then change the motor direction. To change direction, click on the scroll bar below the Motor Direction item. You want number 2 (reversed), see Figure 10. Don’t forget to save the configuration change (Write Setup) before you disconnect.

We repeated this process for Motor 3 (i.e. ESC 3). We had to power cycle the Uno to get it to recognise the new ESC when we changed the motor control pin connection. They all come up as ESC# 1 in BLHeli Suite.

Motor Testing

The last step was to use Nexgen Configurator (Figure 11) to test that the changes in motor direction were saved correctly.

Reefwing Software · iOS & Android Development · Robotics · #followback #iOS #Android #developer #indiedev #robotics #startup #arduino #raspberrypi

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store