The MiniBLDC is a brushless (BLDC) motor controller based on the TMC6200 motor controller and the ESP32S3 MCU. Some of the schematics and trace designs are inspired by the XESC project. This controller was developed at CMU's Rexlab.
The MiniBLDC project was designed to be used in a daisy chain configuration for projects that involve more than 10-1000s of motors to be easily controlable. As such the board needed to be small, affordable, and support communication protocols for daisy chaining.
The TMC6200 was chosen due to its affordability(~$5.5), easy configurability and fault monitoring over SPI, high stock availability, small footprint, support for inline current sense (for torque control with SimpleFOC), wide input voltage support, and high efficiency. This motor controller struck a great balance between powerful features and ease of use.
The ESP32 was picked for its affordability, dual-core support, and wide-peripheral support. The dual core support was extremely important to this application since SimpleFOC's motor loop runs best when it can run as fast as possible. By dedicating one entire core exclusively to the FOC loop and using the other core to handle communication, state machines, external peripherals/sensors, one can achieve great motor performance. The ESP32 also allows for reprogramable pin outputs using internal muxes which makes routing such a small, dense board much easier. Other internal peripherals such as CAN support for daisy-chaining boards, built-in WiFi/BT for wireless motor control, hardware quadrature encoder support for encoders etc were great features to have. Finally, the ESP32S3 has an inbuilt JTAG to USB interface which saves space and cost by not requiring an external serial peripheral, and also enables breakpoint/watchpoint style debugging!
The TMC6200 uses external Mosfets to control the actual switching of the 3 phases in a BLDC motor. This is achieved via 6 Mosfets where there are 2 per phase known as the high-side and low-side mosfet. This external/offboard mosfet design allows for one to pick an appropriate mosfet for their expected motor power output needs and appropriately save money by not getting overkill Mosfets.
SimpleFOC is an excellent open-source, and actively maintined library that helps simplify FOC motor control integration into one's embedded projects. Their firmware is extremely configurable, simple to use and actively growing. SimpleFOC also supports velocity control, position control, and most importantly torque control with both open-loop and closed-loop options using the in-line current sense electronics that this board has.
Note that the TMC6200 register communication codebase in the SimpleFOC Drivers (seperate repo to the regular SimpleFOC library) has been modified to work well with this board design. If one recreates this board and wants to use an updated version of the TMC6200 drivers, they would need to port over the appropriate modifications made in the TMC6200.cpp file.
Making your own board can be acomplished by either getting a fab-house such as MacroFab to build your PCB, and also populate the electronic components. This route is the easiest, but you have to pay a premium for the assembly service. Alternatively, you can order the PCB+Stencil for cheap from a supplier like OshPark, PCBWay etc, order the electronics from a supplier like Digikey/Mouser, and reflow the boards yourself. This approach requires a lot more skill with SMD reflowing and also requires specialized tools such as a reflow oven. I followed this approach since I had access to SMD reflowing equipment.
Once you've made your own board, you can power it via the XT30 connector using a power supply. Make sure to have this external power connected to the board when you conenct your USB-C Cable for testing as the TMC6200 requires the external higher-voltage power line to function.
To flash the firmware, one can simply plug in a USB cable from the board to your computer. The ESP32S3 contains an inbuilt JTAG debugger which allows for flashing and also debugging firmware using breakpoints! Using PlatformIO's board tab, one should see this JTag device pop up when the board is plugged into the computer.
If the board doesn't show up on your computer, try the following
- Make sure your USB-C cable supports data. Lots of cheap USB-C cables don't contain data pins
- Press the 'boot' button on the board and then power it up. Sometimes this forces the board to enter a flashable state.
The H1, H2, H3 pins on the board can connect to any sort of encoder such as Magnetic I2C encoders, analog encoders, Quadrature encoders with/without index signals, etc. These pins are directly connected to the ESP32 so any 3 pin or less digital or analog encoder should work as long as you can find an appropriate library or write your own drivers for it. SimpleFOC has great documentation on how to connect your encoder to the library in the firmware.
Note that the H1, H2, and H3 pins are 3.3v logic. If your encoder outputs a 5v signal, you will need a level-shifter.
The motor controller board is currently functional in performing torque, velocity, and position control. However, the in-line current sense based closed-loop torque control is only partially tested. Open-loop torque control works extremely well.
Future Hardware work involves:
- Upgrading the 2.54mm pitch peripheral connectors to higher quality locking connectors
- Adding an onboard magnetic encoder to enable the board to be mounted directly under a motor, eliminating additional encoder mounting challenges
- Switching onboard voltage dividers to a level-shifter IC to simplify BOM and ease manufacturing
- Dip-switch based encoder input voltage selector
- More affordable and reliable V_in - 3.3v voltage regulator
Future Firmware work involves:
- CAN firmware support and daisychain control bringup
- State Machine based arm-disarm and fault management
- Finish Inline Current sense support for closed-loop torque control