Three motors on single controller, is it viable?

I’m looking into controlling three BLDC motors with either hall sensors or magnetic encoders as feedback from 1 MCU. The main reason for this is to simplify the coding, as each motor needs to run in sync. Doing this all from 1 MCU is much simpler than programming 3 MCUs that need to communicate to each other in real-time.

Currently using an STM32G4 for controlling two motors, and this seems to work fine. Maximum RPM is around 4000, currently using trapezoidal commutation. Is it viable to do control 3 motors with 1 MCU? Any recommendations are much appreciated!

Good news: yes. Bad news: There is only one such STM32 with three motor timers.

You will need a custom board designed with STM32G474 on a 100pin or higher footprint.


1 Like

Great, thanks! I’m open to other manufacturers such as ESP32. Or is the STM32G4 the only one on the market that’s supported by simplefoc?

What is the difference between general purpose and dedicated motor control PWM timers?

I think I saw someone in the discord designing a triple motor controller with STM32F446- I’m not sure how far the project got.

You need to use advanced timers when using multiple motors because you need the complementary PWM outputs. Otherwise you end up needing way more timers and channels and the firmware starts to get very messy.

edit: The STM32F303 and the G474 seem to be the only two with 3x advanced motor control timers.

the ESP32 only has two MCPWM timers so maybe not great for triple motor use.

There are 4 timers on many esp32, am I wrong?
except on the C3 …

Would it be possible to use the rp2040 state machines to act like complementary outputs?
If so, we’d have a dual MCU core and 8 state machines (dual core use hasn’t been tested yet)


It’s possible to run 3 BLDCs, yes, but you will need a fast MCU and to pay careful attention to the pin assignments and peripherals used.

The advanced control timers on STM32 are only needed for 6-PWM control, for 3-PWM you can also use the general purpose timers. When using 3 motors I’d go for 3 PWM is possible, to make your life easier in the routing and also to make it easier to find a suitable MCU.

RP2040, I doubt it’s fast enough, and it probably won’t have enough pins.
ESP32 will almost certainly not have enough pins for 3 motors. Keep in mind you need a sensor for each motor, too. Perhaps the upcoming ESP32-P4 will change the game here.

STM32 is a solid choice for this, but of course the high pin count, fast STM32s aren’t cheap.

1 Like

I had not seen the espressif news on ESP32-P4
looks promising :slight_smile:

1 Like

I was actually just looking at doing a 4x motor driver with the 2040’s dual core functionality. Using two AS5600 sensors with 7pp gimbal motors and SFOC mini boards I was able to successfully run with a loop speed of ~~2000Hz and acceptable motor performance. I’m not sure how the hardware behind the scenes would scale with using another core, but it’s at least fast enough to run two motors while only using one core.

I’m going to avoid expanding testing to 4 motors for now since I’d have to mix and match I2C & SPI sensors as well as two different types of driver boards to be able to use what I have on hand, but it’s on my bucket list.

Because of what I have on hand, I looked at how feasible using a pico is with serial1, 1 SPI bus, & two I2c busses for four motors using 3PWM. This leaves a grand total of… 2 free pins :yum:

That’s definitely cutting it close to using all the pico’s pins (assuming nothing breaks when trying to use everything all at once). Replacing the SPI sensors with A/B/I sensors with no index pin would give another two pins too, so maybe it can be done… at this point I’m half tempted to hack it together just to see if it can work


I’ve used the storm32 bgc before with simplefoc, stm32f1 i think. I only used 2 if the 3 motors controllers. It’s original purpose is to control 3axis gimbals so it’s not that powerful but could be useful for experimentation.
There are some schematics discussions from a few years back on this forum

Not bad!

Were you reading both I2C sensors in closed loop mode? 2k iterations per second is enough if you don’t need high performance.

The problem I see is for reliable operation you also have a fault line and three enable lines for each motor, as well as a sleep and a reset line… So that would be another 24 pins you need. If you combine them all so that you don’t know which driver sent the fault, don’t use sleep or reset, and you can only disable all phases of all motors alltogether, then it would still need your last 2 pins…


My point being that this doesn’t seem enough to make a fully featured board. Typically I also need extra pins for:

  • User buttons (e.g. emergency off)
  • Status indication LEDs
  • ADC channel for bus voltage sensing
  • Digital inputs for I2C or CAN address setting
  • Thermistor inputs for temperature monitoring (you could use I2C here, but it would compete with the sensors for bandwidth)
1 Like

There is a chance to use SPI sensors. They only need one extra CS pin for 2nd and 3rd motor. The ESP32 has 21 GPIO pins, only 15 are required…I think it’s worth a try.

Maybe it’s a bit slow, but it depend on the waveform too. Using one core for Comms and trapezoidal FOC plus two motors on the other core might work.

Blockquote When using 3 motors I’d go for 3 PWM is possible

I haven’t been able to test 6 PWM control with the motors yet, mostly because the DRV8313 on the SimpleFOC mini doesn’t support it. Is there any other off-the-shelf driver that can be used to quickly test 6x PWM with SimpleFOC?

Sure, off the shelf you could use

  • ST Micro X-Nucleo boards like the X-NUCLEO-IHM08M1, or other BLDC boards, have to check the details of which control scheme they are using.
  • Same for Texas Instruments, something like a BOOSTXL-DRV8323 would work.
  • On AliExpress you’ll find driver boards based on the DRV8320 and DRV8312
  • ODrive (also clones) and VESC (also clones) hardware should work although it might require more effort

Perhaps some others will have more suggestions.

1 Like