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
Product page: Brushless DC Motor with Encoder 12V 159RPM FIT0441
Documentation: FIT0441 Brushless DC Motor with Encoder 12V 159RPM
Features
The project operates in one of five hardware modes:
using a software PWM from the Raspberry Pi to the motors: does provide a stable frequency
using a hardware PWM from the Raspberry Pi to the motors: there are only two hardware PWM pins available on the Raspberry Pi
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
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.
Copyright & License
All contents (including software, documentation and images) Copyright 2020-2025 by Ichiro Furusato. All rights reserved.
Software and documentation are distributed under the MIT License, see the LICENSE file included with the project.
Features
- Overview
- Pinout
- Modules
Component
ComponentRegistry
ConfigurationError
IllegalStateError
MissingComponentError
ConfigLoader
Level
Logger
Util
BrushlessMotor
ControllerChannel
DigitalPotentiometer
Payload
HardwarePWMController
PWMController
SoftwarePWMController
PWMControllerImpl
RotaryEncoder
SlewLimiter
STM32PWMController
TLC59711
TLC59711PWMController
DigitalPotSpeedProvider
RotaryEncoderCommandProvider
ValueProvider
AsyncUARTManager
Payload
SyncUARTManager
UARTMaster