Can I use SimpleFOC for my project?

Hi all, first post here, I’m new to the forum! I am an engineering student and for my senior project, I am designing a motor controller for a 7kW (150Vdc) BLDC motor. My group and I are designing custom hardware based on existing requirements (setpoints fed in via the CAN bus, lots of temperature sensing, etc.). The hardware is based around the STM32F446. I am wondering if we can use SimpleFOC for our firmware architecture? If not, does anyone have any recommendations for other frameworks/libraries to use? I have been looking into STM’s native motor control library but I am finding it quite difficult to use and find good resources for. Any help is greatly appreciated! Thanks in advance!!

Edit: Some other tidbits of info:

  • The motor does not have an encoder but does have hall sensors
  • We are operating in the 0-2000RPM range, ~150V, ~100A peak
1 Like

Hey @Alex_Ezzat,

Awesome project, please make sure to share with us the final product!

I’m sure SimpleFOC will work nicely. @Owen_Williams did the hall sensor implementation, I’m sure he can tell us if this type of sensor would work best for your application.

Hi @David_Gonzalez Thanks so much for the quick response! This is great news, I am really liking how straight forward the SimpleFOC library is (hence the great name!). As a quick follow-up, would this forum be the best place to basically spam questions? Just looking into the library a bit, I one question I have off the bat is the following:

It seems like the library only includes a single PID controller for velocity. I may be getting concepts mixed up here, but my system simulations use two independent controllers for the Id and Iq axes. Is there a way to consolidate these two control schemes?

Thanks again! And again, feel free yo redirect me if there is a better place for stuff like this - I wasn’t sure if it was worth making a new forum thread for small questions like this but I will likely have more as I continue development! :slight_smile:

Hey @Alex_Ezzat!
Sorry for not responding to your email.

Simplefoc library is a type of a base code which is intended to be suitable for many different mcu+driver+sensor+motor combinations. Due to a large spectrum of hardware some trade ofs have been made. And the idea is really to use it in a way to adapt it to what you actually need. :slight_smile:

You will be able to control low and high side of mosfets for your application in the off the shelf library release. And run the motor with many different sensors.

Now in terms of current control. At the moment we don’t have it implemeted in the release v2.0 but this is certainly the step we are concentrating the most on for the next release.

In the current release we consider I’d=0 and we consider that:

I_q ~ voltage_q

And we use voltage_q for all the motion control purposes.
This works more or less well for small motors but not in you case :smiley:

You can see one example code for torque control in the topic

This code works for inline current shunt resistors. The code will have to change a bit for low-side measurement.

And this is the perfect place for the questions, don’t hesitate to ask, I’m sure there is many more people who are interested as well!

Some big motors you have there! The biggest I’ve tried are hoverboard motors which can theoretically do about 400W but i’ve only taken them to 50W. They have hall sensors on them. I’ve also recently used halls with a skateboard motor.

Explainer vid here:

If you have any hall questions then hopefully i can help. @Marc_O also has experience with halls. We are trying to make the code generalise so that it works on new setups and not just our setups!

1 Like

@Antun_Skuric @Owen_Williams Thank you both very much for the responses! For some project context, the motor is being used on a solar-powered race car (if you are interested, our team website is here). Based on Antun’s response about voltage vs current control, sounds like our best bet may be to start with speed control just to get it working. It would be nice to at least be able to test our hardware before developing more complex firmware. I’ll keep you posted!

1 Like

That sounds awesome! Some quick googling suggests a 7kW motor might be able to do 75km/h!
We generally suggest starting even simpler than velocity control. Start with openloop (no halls) then move to voltage control (halls but no pid loop) then move to velocity (PI loop).

Do you have any hardware to play with? If you don’t it might be worth your software team picking up some low voltage/power hardware and start playing with smaller motors until the high voltage hardware is ready. The drone controller i used is £20 quid and has a stm32g4 chip that supports hall. The g431 on the drone and your f446 aren’t that dissimilar (e.g. both are roughly 180mhz).

Yeah the cars are pretty awesome. We focus a ton on aerodynamics so we’re actually able to reach closer to 100km/h at something like 4kW just from the raw efficiency. Thanks for the tips on workflow, sounds like a good plan to me! And yes, we’re definitely planning to start with a much smaller scale, something in the 12V/50W range. We just wanted to make sure we’re starting with an architecture that we will be able to easily port over to higher power once we get the basics working!

2 posts were split to a new topic: CAN Bus Support