Finally doing it myself
Making my own three phase motor controller is something I’ve been wanting to do for a long time. I would say this project is the culmination of my education as an EE at MIT.
Many of us have used brushless motors in our projects, and for good reason. They are very powerful, very efficient, and require minimal maintenence. What many of us have not done is make the leap and implement FOC (Field oriented control) ourselves. Doing my part in continuing this MITERS tradition has also been quite fulfilling.
In the interest in keeping the project scope simple, I wanted to minimize the most amount of things that could go wrong. I used a STM32 nucleo board along with a TI DRV830X dev kit. That let me focus on the firmware. I implemented FOC using the timers to control the switching and the adcs to sample the built in current amplification from the dev kit. An external incremental encoder in combination with a hardware timer to count the pulses resolves the position of the rotor. The system updates and switches at 16kHz. Switching a bit faster is possible, but I would really need to analyze the timing of ADC sampling to ensure that I have enough time to sample in the middle of the center of the waves at high duty cycles.
The setup
Here you can see a fixed voltage being applied while I simulate the rotor being spun, causing the three phases to change with time.
With this preliminary firmware, the rotor is started in a known position using some tape to align the rotor and stator since I do not have a calibration sequence, and the encoder I am using is an incremental encoder. If I were to make my own motor controller, adding support for a magnetic resolver would be the next obvious step.
The firmware can accept both voltage and current commands through a UART interface. Here I am using the arduino serial monitor to command 3000mA of q-axis current. The 3d printed plastic coupling is not the best, some offset is accumulated due to vibration of the system which leads to the change in top end speed.
Having this firmware is a great stepping stone, and I am now able to design my own power stage to control whatever size motor I want. This method of control scales to arbtrarily sized motors as long as the motor inductance is large enough.