Closed purepani closed 2 weeks ago
I noticed a similar gap in the available libraries, which is why I created this library to begin with. You are correct that at the moment the basic FOC algorithms are implemented, but that there isn't much in the way of an all-in-one FOC controller that you can just drop in to your system.
I'm currently in the process of bringing up some hardware so that I can more actively work on this and test it, so there should be some more activity in this repo happening soon. Embedded-hal integration is definitely something I would like to implement at some point, however I anticipate some issues due to the traits that are available and their support in the hardware-specific crates. The interfaces that FOC would need are:
Encoder
trait) so that we don't have to put all the different encoder driver implementations in this crate.Given this, I'm not sure how feasible it would be to support embedded-hal. At least in the short term, I would be looking at keeping this crate to be more IO-agnostic. The API is going to look roughly like the Foc struct, which currently is just a prototype for me to plan around (you can't actually construct it). Based on that API, you get a single method that takes in your encoder reading, your current readings, and your desired torque, and then produces the PWM values you need to set on your PWM controller. This design would allow people to use it with minimal integration effort, while also allowing people to use it on any microcontroller they want.
there isn't much in the way of an all-in-one FOC controller that you can just drop in to your system.
I'm working on a rewrite of Simple FOCs arduino library. Still WIP stage, but I've gotten feedback that it's quite close to a PoC. An SFOC kit should arrive in the mail soon to get it to a stage where you can do basic voltage control with an esp32 based platform: https://github.com/Ben-PH/SimpleFOC-rs/tree/dev
My goal is to write something that is compatable and consistent with the simple foc project. My mental model is two-fold:
As for you points:
SetDutyCycle
for its pwm pins: https://github.com/Ben-PH/SimpleFOC-rs/blob/6662901a94a7c56de470cf3ca93138a851ab4d58/esp32-sfoc/src/main.rs#L275-L281embedded-time
crate.Hey @Ben-PH Here are the references I found for ADC stuff https://github.com/rust-embedded/embedded-hal/issues/377 https://github.com/rust-embedded/embedded-hal/pull/569
With 0.3.0 of this crate being released an overall FOC controller which wraps all of the underlying algorithms into a single controller is available, which addresses your original question of having something more than just the raw algorithms. For the embedded_hal
integration, I have created a tracking issue https://github.com/calebfletcher/foc/issues/3.
Title. I've been looking for FOC libraries in the rust ecosystem, and there don't seem to be any that are supported; I would consider rewriting my own, but I am not super experienced with motor control, so it would be better if this library could be further developed. Alternatively, I would like to ask what the current state of the library is. As far as I can tell, the FOC calculations are implemented, but there's little to no embedded-hal implementation. Is that accurate? If so, I'd feel more comfortable using this library as a base.