Electronics > Microcontrollers

BLDC control FOC: Questions answered

(1/4) > >>

eTobey:
Hi,

i had some research into BLDC FOC, and i am a bit confused. zerovectors as i understand are used, to limit the voltage magnitude.

These  zerovectors are shorting the phases of the motor to either GND or Vcc. But i know that shorting the phases of a motor will make it brake. That sounds like stepping on the gaspedal and the brakepedal over and over again. Wouldnt it be much better to just slightly push the gaspedal?

Siwastaja:
I have implemented BLDC FOC numerous times but never heard the term "zerovector".

"Shorting" the phases is normal operation in all operating modes, FOC or otherwise, with any setpoint. Maybe what you are missing is how the motor inductance acts as a triangular ramp generator; you always either apply full DC input voltage, or full short alternatively and the current ripples around your desired current. No problem here.

But such shorting only happens for a short time and not 100% duty cycle*. During this shorting, due to the back-EMF the rotating motor generates, current in motor windings is increasing. Once you remove the short, the inductance then pushes the inductance-stored energy into the DC link / battery if there is one. Motor will brake, and kinetic energy flows into the inverter supply side.

*) except when the motor is at standstill

If you apply the short infinitely, you are just increasing the current towards infinity, saturating the motor iron, and dissipating all kinetic energy in motor winding resistance, instead of pushing it into DC link (and either into battery, or into an external resistor bank). Current and torque is uncontrolled and too much. There is usually no reason to ever do this on purpose. With FOC, the idea is to measure the current and PI feedback the duty cycle such that current is whatever value you wish. If you want to brake hard, you can choose pretty high current, but aiming for "infinite" makes no sense.

Siwastaja:
If you are familiar with the synchronous buck converter topology, it helps to understand motor control is basically that. Output voltage, which is smaller than input voltage, represents the RPM. Output capacitance represents the mechanical inertia. The buck inductor is motor inductance.

Let's say Vin=10V, rated RPM = 1000 rpm @ 10V. Then at 20% duty cycle, in steady state conditions assuming 100% efficiency, assuming enough load to operate in Continuous Conduction Mode, output voltage would be 2V and motor would run at 200 rpm. Apply mechanical force trying to speed up the motor, and now the ideal motor would be generating infinite current, boosting it from 2V to 10V (Vin). Or, add mechanical force slowing down the motor, and now it's trying to hog infinite current from Vin. This infinite current would generate infinite torque and quickly overcome the mechanical force and find the equilibrium again.

In real motors, say for example a simple brushed motor, this can be seen as high inrush currents: connect a large DC motor directly to a 12V battery and it takes massive so-called "stall" current which then diminishes once it reaches full rated RPM. This is not a good way to control motors; motor iron saturates (there is a limit how much torque it can actually generate; current keeps increasing only limited by resistance), so efficiency plummets. Too much torque and cause mechanical damage.

While RPM is trivial to control by adjusting duty cycle, it clearly isn't the only thing we want to control; we want to control torque, at very least limit it to reduce the rate of motor reaching the speed equilibrium, to prevent things breaking up, to limit electrical current. So add current limit; for this you need to sense current and feedback the duty cycle. This is easier than it initially sounds because motors have a lot of inductance; current changes slowly. You can apply full input voltage, or zero voltage (short) and current rises or lowers. You have many microseconds to measure and react, easy peasy for most current sense amplifiers, microcontroller peripherals etc.

Now instead of controlling duty cycle to control RPM and adding a current limit on top, the idea of FOC (and many other control strategies) is to make the current (~ torque) the only primary control parameter, so that RPM is not controlled at all by this scheme, but by an optional outer feedback loop (which controls the FOC input, current, capped to some limit).

Now all that FOC really is, over a simple single-phase synchronous buck DC/DC, is a way of decoupling the rotational movement of a three-phase machine, from the current measurement -> duty cycle PI feedback loop. It is much easier to think about the basic concepts in the realm of a simple brushed DC motor, or synchronous buck DC/DC.

I hope I can be of help here. I remember the struggles trying to understand motor control, especially FOC; from initial attempts of learning the thing, it took several years until I felt I really grok it (didn't happen until fully implementing it from scratch). Terminology and explanations often seem confusing, even if you are a seasoned player on some other field.

eTobey:

--- Quote from: Siwastaja on December 01, 2023, 06:01:00 pm ---If you are familiar with the synchronous buck converter topology, it helps to understand motor control is basically that.

--- End quote ---

This information is all it took, to understand how it is working.

I can feel your pain you had learning this, as i am right now. It is very hard to find specific information for certain aspects of FOC. I am at the point of 3rd harmonic injection, but cant find information that would help me to create the rigt curves. I also came across a sine wave and a triangular wave to use. Now what is right?

Here i got the zero vector from:
https://www.switchcraft.org/learning/2017/3/15/space-vector-pwm-intro

Siwastaja:
There were two things specifically which confused the hell out of me when trying to learn this stuff: the Space Vector Modulation thing, and for AC induction motors, the magical "flux estimator" black box. For BLDC, luckily, the latter does not exist.

In all BLDC implementations I have done, I just always skipped the space vector modulation thing. None of the microcontrollers I use came with Space Vector Modulator peripheral, but they all come with classic three-phase center-aligned PWM modules (e.g., in STM32, "advanced control timer"; it can even synchronize ADC and look at analog comparator for overcurrent signal, saving MOSFETs when your PI loop is wrongly tuned). The claimed use case for Space Vector Modulator is that you don't have to perform inverse Clarke transform (from 2-phase duty cycles to 3-phase duty cycles) but could drive the modulator "directly" with the 2 phases, but OTOH, inverse Clarke is a few multiplications and additions, two lines of code and maybe 10-15 CPU instructions cycles so I don't see what's the big deal - then you can just use bog standard PWM timers.

I used third harmonic injection once, and just generated the waveform in Matlab by gut feeling. The idea is that it should resemble a "softly clipped sine wave", pretty close to what you get by just multiplying and clipping a sine, but softer - no higher harmonics. What you gain is better utilization of DC link voltage especially in the case you have mismatched DC link voltage and motor nominal rating, i.e., can't go for higher voltage but want a tad more output power. I don't think there are any other advantages, maybe a tiny reduction in switching losses when running at absolute maximum output voltage. I did that only in an experimental EV conversion project where we had designed the motor windings for 300V or so but only had 96V of batteries.

Re sinusoidal vs. triangular current waveform: there is a lot of confusion and probably no authoritative answer, but what is true that when a BLDC motor is driven from hall sensors directly i.e. just applying input voltage to the windings in square wave, emulating how actual brushes work, then naturally the motor current after the motor inductance will be integral of that, triangle wave. Some people miss the important point that this is just a consequence of simplistic low-cost drive, not some kind of ideal design target. To muddy the waters, those BLDC motors that are primarily designed to be driven this stupidly, maybe possibly perhaps have different physical construction which kinda sorta evens out the rotation of the magnetic field even when driven with triangular current, and some further think that the distinctive factor is the "name": BLDC is trapezoidal, AC PMSM is sinusoidal. I don't know - but if such mechanical compensation really exists and is performed perfectly ideally, then it indeed would be ideal to use triangle wave in FOC (thus, use triangle function in Park / Inverse Park calculation). I have always used just sine wave even with cheapest of BLDC motors and with accurately interpolated angle, they run really smooth, much smoother than when driven "BLDC way" with square waves, where +/- 30deg torque ripple is easily observable. If the physical construction tries to compensate for the triangle wave, Chinese do it poorly. For a sine to perform worse than triangular, this mechanical compensation should need to work to at least 50% perfection.

In essence, BLDC motor control is:
* Apply a magnetic field, direction of which is 90 degrees advanced from the measured electrical position

Then for the current (torque) control:
For a motor which turns very very slowly, you could just use three PI loops which measure current of each phase and output a duty cycle for that phase, then make the three current setpoints change sinusoidally and make the motor rotate that way. It works; the only problem is the delay in the feedback loop: optimal 90 degrees starts being less than 90 when speed increases, and worst, the delay isn't exactly constant per speed but depends on motor resistance which depends on temperature, so...

All FOC does is, it makes the generation of sine waves a separate issue from the PI regulators; their setpoints and outputs will be constants over a short time, and sine waves applied before and after the PI loops. (Setpoints change when you desire different torque; outputs change slowly as for example temperature differences changes motor resistance.)

In essence, FOC achieves this by:
* measure current of two phases
* calculate the third by knowing the sum of the three is zero
* convert the 3-phase (120deg separated) current measurement vectors into 2-phase (90deg separated) vectors, i.e. copy the (simple) Clarke formula from Wikipedia.
* rotate this 2D vector by the measured electrical angle of the rotor, so that it's rotated always to same stationary position (simple 2D vector rotation, the formula you see in computer graphics etc., for some weird reason called "Park transform" in this context; again, copy from Wikipedia). THIS is where the sine wave is introduced.
* Use two PI loops, one for each component of the 2D vector
* One of the component you want to usually regulate at zero - this is Id, the part which generates magnetic field into the current (or opposite) direction of the rotor. It tries to keep the rotor standstill, or if negated, fight against the magnets to weaken them.
* Other one, Iq, creates magnetic field 90 degrees (or -90, if negative) from the current rotor position - this is what drives the motor forward/backward at optimum efficiency. Set at +/- desired current (torque).
* Output of the two PI loops is again a stationary 2D vector, you can call it "voltage" or "duty cycle" command.
* Follow the input steps in reverse and inverse order:
* Opposite 2D rotation
* Conversion from 2-phase to 3-phase (inverse clarke)
* Write to PWM control registers of the timer peripheral and enjoy.

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod