TinFOC/README.md

44 lines
1.6 KiB
Markdown

# TinFOC: a Rust-y Field-Oriented Control crate for STM32 MCUs
A crate that provides an
[FOC](https://www.st.com/en/applications/industrial-motor-control/3-phase-field-oriented-control-foc.html)
motor controller using STM32 Cortex microcontrollers.
Or rather, it *would* if it were done, but it is not. It's currently my embedded programming
playground project, but I do intend on making it useful and good. I'll let you know when that's the
case, but until then, it's going to be a work in progress.
## Dependencies
The MCU I'm using is the
[STM32F302R8](https://www.st.com/en/microcontrollers-microprocessors/stm32f302r8.html), and I'm
using the [X-Nucleo IHM07M1](https://www.st.com/en/ecosystems/x-nucleo-ihm07m1.html) BLDC motor
controller shield board that provides the actual power to the motor.
This requires the `thumbv7em-none-eabihf` Rust target:
``` console
rustup target add thumbv7em-none-eabihf
```
In order to connect to the microcontroller with a debugger (say, to load the program) on Ubuntu
linux, you'll need to:
``` console
sudo apt install openocd gdb-multiarch
```
[probe-rs](https://probe.rs/) is a convenient tool for interacting with your dev board.
## Running on hardware
Assuming you've plugged your board into your computer via USB:
1. build TinFOC with `cargo build`
2. load it onto the board and run it with:
- `probe-rs run --chip=STM32F302R8Tx target/thumbv7em-none-eabihf/debug/tinfoc`
If all went well, and your IHM07M1 motor controller board is attached to the Nucleo dev board, the
red LED on the IHM07M1 should start to blink, and you can turn the potentiometer to adjust the
blinking rate.