Another attempt at building a motor controller

Electric Motors and Controllers
thorlancaster328   100 W

100 W
Posts: 159
Joined: May 25 2018 3:20pm
Contact:

Re: Another attempt at building a motor controller

Post by thorlancaster328 » Mar 18 2021 12:04am

I finally got around to replacing the gate resistors.
@mxlemming you were correct about the gate resistors being too low, switched 4.8r to 8.2r and there was only 4v of ringing at 20v, 6v at 40v. Ringing is still almost completely independent of phase current at above 20 amps. Total switching times (Id increase and Vds decrease) are around 150 nanoseconds, which is a bit longer than ideal but the FETs still run pretty cool.
High- and Low-side gate drive waveforms are nearly identical.
webcam-toy-photo8.jpg
Phone died, had to use crappy laptop webcam
webcam-toy-photo8.jpg (63.2 KiB) Viewed 82 times
webcam-toy-photo7.jpg
webcam-toy-photo7.jpg (63.56 KiB) Viewed 82 times
There is a bit of bouncing (~2 volts) when the gate drive to the FETs crosses the threshold voltage, but it only increases slightly with voltage and very slightly with phase current.

I can't do any high-power motor tests because Vector sent me the wrong motor and I can't clamp it in my frame. When the correct motor arrives (1-2 weeks), I'll put the scope on it again and see how it switches at higher voltages and currents.

If all goes well with that test, the next version of this controller (using 36 TO-220 FETs) will go off to JLCPCB to get produced. Fingers crossed that the next controller can switch faster.
Find weakest component, upgrade it, repeat until satisfied. Rome was not built in a day.
When in doubt, get bigger MOSFETs / Batteries / Motors / Etc.

thorlancaster328   100 W

100 W
Posts: 159
Joined: May 25 2018 3:20pm
Contact:

Re: Another attempt at building a motor controller

Post by thorlancaster328 » Apr 07 2021 2:22am

3 weeks later and I finally had enough of a break from other projects and classes to work on the controller again. Accurate angle tracking was a pain with the trapezoidal. The BEMF looks something like this
BEMF.png
BEMF.png (20.96 KiB) Viewed 34 times
and passing the waveform through the DQZ (Park + Clarke) transformation yielded an angle measurement that had quite a few bumps in it, due to the non-sinusoidal BEMF.
AngleMeas.png
AngleMeas.png (14.12 KiB) Viewed 34 times
Getting that smoothed out was challenging, as I had to build a PLL. For the sake of learning, I decided to write it from scratch, using a PID-style control to control the virtual speed. Dealing with radians being a circular number system was the hardest part, the constrain() function was much more complicated than the C++ one-liner, with 4 different cases.
After debugging (took over an hour), the PLL completely eliminated the ripples in the position measurement at all but the lowest speeds. Which doesn't matter because I'll be doing saliency at those speeds anyway :)
Code for the PLL:
FOCSnippet.cpp
(1.22 KiB) Downloaded 6 times
(Not sure if terminology is correct but it works)

Even though the position detection was buttery smooth, the phase currents were all over the place due to the extremely non-sinusoidal BEMF of the motor. The PID control I'm using is too slow to respond to changes in current. If I try to stiffen it, the system oscillates and the motor emits a terrible whine.

The future motor control algorithm will model the motor as a (roughly) known inductance with an unknown voltage on the other end. With each iteration, it will adjust the output voltage so that the error gets halved on each PWM cycle. This algorithm will also yield a good real-time estimation of each phase's inductance at higher speeds, so I will have two separate sources of rotor position. Won't be too hard to design, either, as voltage is the only unknown.
Find weakest component, upgrade it, repeat until satisfied. Rome was not built in a day.
When in doubt, get bigger MOSFETs / Batteries / Motors / Etc.

Post Reply