EasyDIY-ESC icon indicating copy to clipboard operation
EasyDIY-ESC copied to clipboard

Two motors with one STM32 microcontroller?

Open happytm opened this issue 3 years ago • 6 comments

Is it possible to run 2 motors with one STM32 micro controller by adding 6 more mosfets? Are there enough pin available?

Thanks.

happytm avatar Feb 01 '22 01:02 happytm

Yes, it is possible!

  • If you want 2 x 6-PWM control you need a model with two advanced control timers, normally TIM1 and TIM8.
  • It has to be a fairly fast MCU to run 2 times the SimpleFOC loop
  • if you want current sensing, you will need 6 ADC pins also
  • and you need 2 sensor inputs, for ABI you would ideally use 2 more timers and our STM32HardwareEncoder or use SPI, maybe with two separate SPI buses...

I think most of the STM32G4 series would be suitable.

Here is an example design I made, with 2x 6-PWM, 2x current sensing and 2x SPI bus for sensors: https://github.com/rosmo-robot/Rosmo_ESC

runger1101001 avatar Feb 01 '22 08:02 runger1101001

(but it is not possible using a BluePill or BlackPill MCU board - not enough pins; but I guess one of the big Nucleo boards could do it...)

runger1101001 avatar Feb 01 '22 08:02 runger1101001

Thank you @runger1101001 for your insight.

happytm avatar Feb 03 '22 20:02 happytm

@runger1101001 How about using ESP32 ? Does it have enough pins to run 2 motors?

Thanks.

happytm avatar Feb 08 '22 19:02 happytm

Pins are always in short supply on the ESP32! It only has relatively few to begin with compared to other MCUs, and then they are so complicated to use... some are input only, some can't be used at the same time as WiFi, and some are only "pretend" pins since they're actually connected to the flash memory and you can't use them at all...

So the answer is: it depends. A DevKit type MCU-board: not really, I don't think so. A ESP32 module or chip with 2x 3-PWM driver: I think it is possible. A ESP32 module or chip with 2x 6-PWM driver and 2x current sense: not sure, but probably.

runger1101001 avatar Feb 08 '22 20:02 runger1101001

I think the middle option (A ESP32 module or chip with 2x 3-PWM driver: I think it is possible) seems attractive option for low cost motor controller. I wanted a low cost controller to control 2 250 watts hoverboard motors for my project using SimpleFoc.

Your https://github.com/rosmo-robot/Rosmo_ESC project looks promising if it can use ESP32 and at least 10A drivers and Mosfets.

Thanks.

happytm avatar Feb 09 '22 02:02 happytm