Hi @Nabeel21 , welcome to SimpleFOC!
The BGC3.1 controller is quite old now. It’s possible to get it working, but I really would not recommend it, especially in combination with I2C sensors and 2 motors, the ATMega chip is really not powerful enough, nor does it have enough RAM.
Doing this project (cool project!) will require you to tune several PID controllers and run many trials. It will be much easier for you using a up-to-date 32bit MCU.
Regarding the hardware: I think you can consider 2 types of setup:
-
like BGC3.1 and Remy’s project, try to run 2 motors, 2 sensors and the control code on one MCU. This will place high demands on the MCU and you will have to code the solution carefully to keep the loops running quickly while at the same time producing telemetry and accepting control inputs.
-
Run each motor on a separate MCU board, where the MCU does only motor control, and coordinate both motors from a central MCU which runs the control and balancing loop.
This will be simpler in terms of the hardware resources and the code, but might have higher latencies in the control loop due to the extra communication between the MCUs.
It’s hard to say for sure which architecture is the better one…
For 1) you should choose a very fast MCU, perhaps an ESP32-S3 with 2 cores or a fast STM32G4 like a Nucleo64-G474 board. ESP32 could be tricky because they don’t have so many pins to use.
For 2) you could use 3 smaller MCUs, for example a Nano33 Sense or IoT (with integrated IMU on the board) as the controller MCU and two cheaper SAMD21 (like a Feather M0, Seeed XIAO), Nucleo32 or RPi Pico as the motor MCUs.
If you can connect the MCUs via I2C we have a I2CCommander class you could use to easily control the motors from the main MCU.
In either setup I would strongly recommend using SPI type sensors (AS5048A, various others) or ABZ type encoders and not to use I2C, which is really too slow for the sensor connection.
For the driver, you could use 2x SimpleFOC Mini drivers. I think it will be simpler to find two separate drivers than one dual one, but it doesn’t really matter. Look for drivers that allow you to use 3-PWM control, as this will be simpler to interface (less pins needed).
As long as you use relatively high resistance, gimbal type motors, you don’t really need current sensing I don’t think.
Let us know how it goes! We would love to see some pictures of your project!