Phase current sensing: measuring in step with PWM
The differences between low-side shunts, in-line shunts and Hall sensors, and why the ADC is triggered at a fixed instant of the PWM period.
Sensing methods
| Method | Advantage | Disadvantage |
|---|---|---|
| Single low-side shunt (DC link) | Cheap | Reconstructing phase currents is complex; limited measurement window |
| Three low-side shunts | Standard, accurate | Can measure only while the low switch is on |
| In-line shunt (phase output) | Measures at any time | Common-mode voltage swings widely; needs a high-performance amplifier |
| Hall current sensor | Isolated, high current | Expensive, offset drift |
When to measure
With low-side shunts, phase current flows through the shunt only while the low MOSFET is on. With centre-aligned PWM, the instant the counter is near 0 (when all low switches are on) is the quietest and the one where measurement is possible.
On STM32, the timer update (or CH4 compare) event triggers an ADC injected conversion. Adjust the sampling instant and sampling time to avoid the ringing just after switching.
3D labRun what you have read so far→Two phases are enough
In a balanced three-phase system ia + ib + ic = 0, so you can measure two phases and calculate the third. When a very large duty narrows one phase's measurement window, calculate it from the other two.
Calibration
At start-up, with PWM off, read each channel a few hundred times to find the offset, and check the gain with a known current. If the current values are wrong, the whole FOC goes wrong.