Important

This documentation was last updated 08 Jul 2025, so it may not be up to date with the repository.

The project is still a work in progress, i.e., things are still changing frequently, not everything works, or works as expected.

Brushless Motor Controller

A Python Controller for the DFRobot Brushless DC Motor with Encoder 12V 159RPM (FIT0441)

Welcome!

In 2025 DFRobot released the Brushless DC Motor with Encoder 12V 159RPM (FIT0441), a small (24mm diameter, 40mm length), relatively inexpensive 12V DC brushless motor with its own internal controller, suitable for integration with the rest of the Python-based robot OS (KROS).

The motor is controlled by three pins: a pulse-width-modulated (PWM) pin, a direction pin, and an FG pin providing feedback from its internal motor encoder, permitting closed-loop control. Note that the encoder pin does not provide direction information, only an indication of movement.

Also note that the motor’s PWM is inverted: 100% is stopped, 0% is full speed.

The GitHub repository for this project may be found at: brushless_motor_controller

References

Features

The project operates in one of five hardware modes:

  1. using a software PWM from the Raspberry Pi to the motors: does provide a stable frequency

  2. using a hardware PWM from the Raspberry Pi to the motors: there are only two hardware PWM pins available on the Raspberry Pi

  3. using an external PWM controller such as the TI TLC59711 PWM controller (supplied by an Adafruit board [*], see below): requires an additional SPI device but is both stable and there are 12 PWM channels available

  4. connecting via UART to either an RP2040 or STM32 microcontroller: the microcontroller reliably handles the PWM to the motors, but may be limited by the performance of the UART

Note

While the fourth option describes a Raspberry Pi master connected to a microcontroller slave, strictly speaking the Raspberry Pi is not necessary if control of the MotorController were fleshed out with a higher-level robot controller on the microcontroller itself (though that is beyond the scope of this project). I.e., a robot based solely on a microcontroller could use this project’s MotorController without a Raspberry Pi at all.

The motor controller itself includes support for open- or closed-loop control, stall-and-recovery, deadband control, and control by target RPM when operating in closed-loop mode. Provided a wheel diameter this also provides for odometric distance and speed measurements.

This uses a YAML configuration file for the application itself, and another on the microcontroller for the motor pin configuration, specifically when using the UART in the MicroPython environent.

Support & Liability

This project comes with no promise of support or acceptance of liability. Use at your own risk.