Simple foc algorithm to fpga

interesting project. I am software engineer playing with robotics. Was thinking about how advanced control for robotics price points could be driven down and found this project.

The robot I am thinking about making is a 4 bldc hub wheeled rover with a 6 dof stepper motor arm + other sensors.

Had the idea of porting simple foc algorithm to a fpga that has an open source toolchain. High level control would be done by raspi or arduino board, low level control by the fpga and then a minimal motor driver board for each motor. motor driver boards could have a few flavors depending on the voltage/current needs of the motors.

Most FPGA are not available now due to the shortage but the chinese clones are and some are supported by yosys open toolchain because they are “similar” to other supported boards. A 20k lut fpga board could control many motors and cost less then 10 usd for bom.

Maybe what you want already exists, it’s just a bit hard to get information on it :
https://forum.digikey.com/t/application-note-for-allegro-a89301-bldc-driver/6946/15

Yes, there exist IC that implement motor control. Also the trinamic TMC4671 looks good. The pricing is not bad for these but currently there are availability issues. You are limited to configuring the algorithm and if you design with them at some point they go obsolete.

FPGA vendors also have IDE that makes it easier to implement motor control but it is limited to their own products and over time these toolkits go obsolete.

Similar to simplefoc in software, it only needs to be done once and can be used until end of time.

In theory, yes. But I’ve learned the hard way that open-source software is not immune to dependencies and lack of maintainers.

On the other hand : brushles motors are not going to go away any time soon, so demand for IC’s controlling them will follow. At worst you are going to need to redesign your board.

Hi @mshamber , and welcome to SimpleFOC!

I think several people have found SimpleFOC while on this journey, mine is similar!

That sounds very cool, and I look forward to seeing your prototypes!

That would be very cool, sounds difficult to me (not knowing much about FPGAs). Aside from the fact that the algorithm is loop-based rather than structured as a pipeline the way I guess you’d want it for a FPGA, it uses lost of floating point math including sin() and cos()… but I guess maybe if you know about FPGAs it’s not as hard as it seems?

One option might be to implement the PWM, ADC for low side current sensing (and maybe back-EMF) all in the FPGA x N, so you wind up with a complete hardware driver for N motors… then you could run the FOC on top of that on an integrated ARM core, or something like that.

Fascinating. My ignorance about FPGAs is nearly complete.

What are the advantages of FPGA compared to a low cost, high-performance MCU like NXP iMXRT1062 at 1GHz? SimpleFOC (and any other C code for that matter) runs just fine on this, with plenty of reserve for any extra I/O and C&C activities. Or, any of the single or dual-core STM H-series.

That seems like a really complex setup to achieve MCU compiled code functionality.

Hope my questions are not too stupid.

That would be very cool, sounds difficult to me

I’ve found a small team implementing an open source code though they seem to have given up because of the chip shortage and not been active for a few months. I am trying to push them to get started again and will join in. They have so far controlled 4 stepper motors using Space vector pulse width modulation (SVPWM) with 5 usd fpga.

That sounds very cool, and I look forward to seeing your prototypes!

v1 is an AR3 6DOF kit from annin robotics that I am almost done assembling. The rover will be a bldc hub wheeled electric skateboard in an aluminum box frame.

In v2 I am going to try to integrate the control + make it easier to assemble.

What are the advantages of FPGA compared to a low cost, high-performance MCU

“The processing power of microcontrollers is time-limited and based on its processor cycling power. FPGAs are space limited; you need to create more logic circuits to achieve your desired coding scale.”
ref.

FPGA boards have a lot of IO pins compared to MCU boards

That seems like a really complex setup to achieve MCU compiled code functionality.

I’m looking for horizontal scalability of motors and sensors for the robot at lowest cost. The additional FPGA board might be what is needed to achieve that for use cases of 4+ motors.

If I could control 10 motors and sensors with a MCU that would be fine for me though I haven’t seen anyone able to do that. Maybe it would take 3 MCU to control 10 motors and sensors? Then it becomes complex to have those talk together.

Now I understand. Thank you.

I may be ignorant about FPGA but real-time /industrial bus control I’m very familiar with. Fieldbus implementations such as modbus, profibus, interbus, high-speed can, as well as all ethernet implementations of the above, as well as “modern” ones such as ether-cat, have been around for ages. For example, 100mbps ether-cat can control 100 servos in real-time with absolutely no problem, and if you go for 1gbps fiber-optic ether-cat, you need to win the lotto to buy the fiber and number of servos you could control over 20 km in real-time.

If real-time centralized motor control is your problem, I could tell you FPGA is the wrong solution, as little as I know about FPGAs.

This is a very mature area of the RTC industry.

Sounds about right, and I’d say that’s with optimized driver boards - more usual is one driver per motor.

But you have to consider the complete solution. Even for a spatially quite close system like a robot arm, each motor needs a sensor, and all those sensors need to be connected to the FPGA.
But (cheap) sensors speak SPI, ABI, PWM or I2C - all somewhat “unreliable” protocols for routing across wires. So comparing a 1 driver per motor scenario, connected via CAN or RS485, compared to the FPGA with 1 sensor per motor, connected with something less reliable, I’m not sure…

Also consider the power stage - 10 motors at 5A per motor is 50A on the input to the PCB which have to be routed around the board to 60 mosfets (or 10 driver ICs). There would be 30 high-current outputs for the motor phases, and 10 sensor connectors with at least 4 lines each. Or would the power stage be modular? Either way it sounds like a pretty mighty PCB. It won’t be cheap.

On the other side of the coin, having a ready to use FOC-block for FPGAs, that users could combine with their designs, that really would be pretty cool - who knows how people would use it? Maybe 10-BLDC drivers are just the beginning!

I don’t understand most of this thread, I just stumbled ob this that may be relevant custom bldc motor board using fpga | Hackaday.io

I did find a good starting point with an open source FOC implementation on FPGA. I need to compare the implemented algorithms. GitHub - WangXuan95/FpOC: FPGA-based Field Oriented Control (FOC) for driving BLDC/PMSM motor.

I want to implement canbus through the system so looking into those chips. The asics for controller and receiver are few euro each. Other factory automation types are not going to hit those price points.

Simplefoc from a microcontroller or foc from an FPGA need the same motor driver board.

The 8302 motor driver board is good but costs 50 usd from china with 30 days shipping. I also want to run my robot at 48v but 8302 only reaches 45v. What I really want is a 20 euro single axis board that I can click on in amazon and have show up in 2 days.

So now to sidetrack and build a single axis high power motor driver board with target price 20 euro and get it stocked at amazon.

I did find some gate driver chips from trinamic interesting. TMC6100 and TMC6200 with open evaluation boards. So far I have checked the chips and 60v mosfets are available or have shipments arriving at a distributor in the next month.

plan would be to check simplefoc on the evaluation boards. If that is ok then use jlcpcb with smt to put on the small resistors and capacitors for a small test run. Then put on the TMC chip and mosfets myself.

1 Like