This project provides embedded code for Teensy microcontrollers to control BLDC motors using Trapezoidal and FOC (Field-Oriented Control) algorithms. It includes PID velocity control and is structured for easy integration with motor feedback systems.
- Trapezoidal Control: Simple, efficient control for basic BLDC operation.
- FOC Control: Smooth and precise field-oriented control.
- PID Velocity Control: Adjustable PID parameters for speed regulation.
- Logging Support: Motor and control data can be logged for analysis.
BldcFOC_teensy/
├── Bldc/ # Base motor control structures and helpers
├── Foc/ # FOC algorithm implementation
├── Trap/ # Trapezoidal control implementation
├── logs/ # Logging utilities
- Teensy microcontroller (compatible with Teensy 3.x or 4.x series)
- Arduino IDE or PlatformIO for building and uploading
- BLDC motor with Hall sensors or encoder for feedback
-
Clone the repository:
git clone https://github.com/Ineso1/bldcFOC_teensy.git cd bldcFOC_teensy -
Open the desired folder (
FocorTrap) in Arduino IDE or PlatformIO. -
Configure your PID parameters and motor setup in the main file.
-
Upload to your Teensy board.
-
Monitor the serial output for velocity and status logs.
Watch the following video to see the BLDC motor control in action:
- FOC provides smoother operation and higher efficiency at low and high speeds.
- Trapezoidal control is faster to deploy for simple applications.
- Logging helps tune PID gains and monitor motor behavior in real-time.
- Field-Oriented Control (FOC) principles
- Teensy microcontroller documentation
- BLDC motor datasheets
