Getting started with BLDC motors – ODrive

The past Sumo contests we saw a lot of different robots in all shapes and sizes. Some used an Arduino Uno board others a went with a Raspberry Pi, detection was done using infrared or ultrasonic,…
Many different combinations and techniques. But one thing was missing. There was (almost) no one using BLDC motors. All the robots I saw used standard brushed DC-motors driven by an H-bridge.

After I saw this I started annoying Bruce by constantly asking why he wasn’t using BLDC motors for his next robot (Thierry). At the time I was experimenting with quadcopters and those use BLDC motors. The power those things have is incredible!
So after a while we agreed to try out BLDCs for the next robot if I would join the development. My nagging stopped and so here we are trying to figure if it is possible to use BLDC motors on the sumo robot.

ODrive BLDC motor controller

While exploring the options for BLDC motor control, we came across an interesting open source/hardware project, the ODrive:

This project aims to replace stepper motors with the much more powerfull BLDC motors. The people behind this project have put a lot of effort in making this amazing controller board that can control two BLDC motors simultaneously. All the hardware and software is fully open source!

For our robot they were very happy to provide us with one of their boards so we could start experimenting with it.

Picture of the ODrive from the official website.

The heart of the board is an STM32F405 micrcontroller. It is possible to communicate with it in many different ways (CAN, SPI, USB,…). To start we used the odrivetool which is written in Python and runs on the PC. It can be used to configure the ODrive through a command line.

Getting started

To get started with the ODrive just follow the Getting Started guide in the ODrive documentation:
It was very difficult in the beginning to get the ODrive working as it did not want to communicate with the PC and upgrading the firmware through the PC didn’t work either.
To get everything working we flashed the latest firmware in the STM32 using an STLink programmer. It is not very hard to do and is well documented here:
Once this firmware was flashed we confirmed that everything was working by doing a dfu through the PC. Once that was possible, the ODrive shows up in the odrivetool.

The ODrive shows up in the ODrivetool

Sensored brushless motor

The strength of the ODrive is that it has the option to use an encoder for feedback. This way the ODrive knows at what speed the motor is spinning and even at what position the motor shaft is exactly. So it is possible to use a brushless motor in applications like a 3D-printer when using the ODrive.

For the robot the only thing we are interested in is the motor velocity. By accurately controlling the velocity, the robot can push against heavy objects without the motors stalling suddenly (if the motor can deliver enough torque to move the object of course).

In order to implement feedback something is needed that measures what position the motor shaft is in. There are a lot of options to do this for example use a capacitive rotary encoder:

Example of an optical rotary encoder. Photo by Rrudzik. Picture relased under GNU Free documentation License and CC.

One interesting option that has already been explored ( is the use of hall sensors. There are brushless motors out there that have these built-in. Most of these motors are inrunner motors used in RC cars. For the robot we decided to use an outrunner BLDC motor and glue some hall sensors into the windings.

Mounting the hall sensors in the windings

On the market there are inrunner brushless motors that have hall sensors built in. However we decided to give outrunner brushless motors a try and mount the hall sensors ourself.

To mount the hall sensors onto an outrunner there are two options. The sensors can be placed very close to the outer rotating shell of the motor. In order for this to work the sensors need to be placed a certain amount of degrees spaced from eachother. It is not hard to calculate this distance, but mounting the sensors space e.g. 3.12deg from eachother is not that easy…
Also the sensors are not directly attached to the motor so when the motor starts vibrating this could easily introduce noise.

Hall sensors glued into the motor windings.

The second and in my opinion better option is to mount the sensors in between the motor windings. Above you can see our work of art with wires and a lot of hot glue…

Connecting the hall sensors

Connecting the hall sensors is pretty easy because the ODrive has onboard pull-up resistors. So the open drain outputs of the sensors can be directly connected to the A,B and Z inputs.

Directly connect the hall sensors to the ODrive.

The only thing that requires some attention is the supply voltage. For the SS41 to work correctly it needs at least 4,5V. So these sensors need to be connected to the 5V line of the ODrive. Connecting them to 3,3V will not work.
Because the sensors have an open drain output the supply voltage has no effect on the voltage levels seen on the GPIOs of the ODrive and thus no level shifters are necessary.

Setting up the hall sensors

Setting up the ODrive to use the hall sensors for feedback is pretty straight forward when looking at the hoverboard example. The only problem with the article is that in the latest firmware this command doesn’t work:

odrv0.axis0.encoder.config.mode = ENCODER_MODE_HALL

The command doesn’t work because the constant “ENCODER_MODE_HALL” doesn’t exist. When looking at the source code in “encoder.hpp” we can see that the encoder mode is an enumeration. The hall encoder mode gets assigned the integer number “1”. So we can tell the ODrive that we will hook up hall sensors by setting the encoder mode to “1”:

odrv0.axis0.encoder.config.mode = 1

Now if everything is Okay it is possible to see if the hall encoder is working by typing:


Try manually turning your motor and see the “hall_state” changing. Normally the “hall_state” should follow Table 1 on page 9 of this application note. If you don’t want to convert the binary values to decimal this is the states the encoder should follow:
3 -> 2 -> 6 -> 4 -> 5 -> 1

Shapeoko: threaded waste board

The start of a successful CNC machined part is reliable work-piece holding.
For this we made a threaded insert waste board so we don’t have to mess with double sided tape before we can machine something.

Installing all the threaded inserts
Installing the waste board with double sided tape
Doing a test run!

Shapeoko: ENDMILL adapter

When the Shapeoko 3 arrived we still had to order a makita or dewalt router to use with it. We went with the makita but then not all the provided endmills fit into the machine so we had to make an adapter.

Afther doing some research on forums we found out about the ER11 collet which can be used as an universal “adapter”.

You can find all the necessary parts to do this at the instructable:

Shapeoko: Sponsorship

Shapeoko is by far our biggest sponsor. What they provided is unreal. They send us a Shapeoko 3 XL, this is a makers dream coming true. It is a “Desktop” CNC router which can cut wood, plastic and even some metals. This machine and sponsorship are incredible.

For more information about machine, please check their site:

Innofill3D: Sponsorship

For our robot we’ll need to print a lot of prototypes to get things right the way we want for this we teamed up with Innofil3d and they and they send us 3 rolls of their ASA Natural filament. So now we’ll have enough filament to to prototype as much as we want and be able to print as much as possible of our 3d printed frame.

Be sure to check out their products:

BuildTak: Sponsorship

When you print exotic filaments the bed adhesion should be perfect otherwise you’ll risk that your prints start to warp. BuildTak is very popular for just this they provided us one of their BuildTak flexplate systems. So now we should be able to print these exotic filaments without any worries.
Thank you BuildTak for saving our prints from warping!

Make sure to check out their website:

The Olsson Ruby: sponsorship

As we got these great exotic filaments from our sponsor E3D we need a nozzle to print them. Because these filaments contain small carbon fiber particles which are abrasive to the 3D printing nozzle. To protect our nozzle from wearing out we contacted the people of the The Olsson Ruby nozzle, they were happy to provide us one of there high end nozzles so we could now print exotic filaments for our robot. Thank you Olsson Ruby for teaming up with us!

Make sure to check out their products at:

E3D: sponsorship

For our robot we’ll need some kind of reduction gears or pulleys that we’ll 3D print. These 3D printed parts will need to handle a lot of mechanical stress and be able to withstand higher temperatures. For these requirements E3D sells a few “exotic” filaments with carbon fiber mixed in which should be able to withstand the higher temperatures and mechanical stress. E3D wanted to support us for our competition by sending us 2 different rolls of carbon filament. One of them is COLORFABB_XT-CF20 and the other one is PA_CF low warp also from colorfabb. Thank you E3D to support us!

Make sure to check out their site: