Crates.io | foc-simple |
lib.rs | foc-simple |
version | 0.1.2 |
created_at | 2025-09-06 10:17:10.30291+00 |
updated_at | 2025-09-12 11:36:57.077903+00 |
description | A simple and easy to use implementation of the Field Oriented Control (foc) for brushless motors. |
homepage | https://github.com/smeenka/foc-simple |
repository | https://github.com/smeenka/foc-simple |
max_upload_size | |
id | 1826936 |
size | 339,324 |
Library for controlling blcd motors with Field Oriented Control (foc). With this library one can control blcd motors, with Embassy, or with RTIC 2.x.
Exclusively use fixed-point math for all FOC calculations, using the fixed crate.
Generic over angle sensors, current sensors, and PWM drivers.
No heap allocations anywhere.
Can be used with RTIC 2.0, or Embassy,
Application layer is fully decoupled from the control layer. In this way the library is easy to use. (No owning issues to solve)
Provides a basic serial command line terminal for controlling the motors
Multiple motors can be controlled
Able to do the startup calibration of the motor
reuse library foc v0.3.0 as much as possible
The library does provide interfaces for:
The user of this library should implement these interfaces. The user will have to solve all the nitty gritty details for controlling the hardware.
In this way the library can stay very generic.
This library provides:
This library does NOT provide:
current sensor implementation. Although current sense implementation can be done easy, as the library is already prepared for this. See the update function in FocPwm object.
The library does contain the following layers
Calibration should be done before each startup of the application. Calibration parameters (direction and electrical offset) can be discovered automatically. or set in the application, if known.
The discoverd values can be observed in the RTT channel.
The command menu has an entry to set the calibration offset. Use this function with care, only for test cases. If set incorrectly it can damage the motor.
To build this library feature "rtic" or "embassy" must be selected:
or