Measured-Nonideality Simulation for Harmonic-Injection Motor Controllers

Electric motor drives cancel unwanted vibration with a technique called active harmonic injection. The drive measures distortions in the motor current at specific multiples of the rotation frequency, and then adds small "anti-harmonic" voltages that cancel them. These controllers are designed and tuned in simulation, and simulation flatters them badly. In one recent permanent-magnet motor study, the injection controller produced about 1.5 N·m of torque ripple in simulation but 3 N·m on the real test bench. A plain proportional-integral (PI) controller showed the same pattern: about 6 N·m in simulation versus 11 N·m on hardware (Harmonic Injection Control of Permanent Magnet Synchronous Motor Based on Fading Memory Kalman Filtering). The simulator therefore misses roughly half of the real ripple. That missing half is a simulation-to-hardware gap, and the people who build these controllers rarely measure it or explain it.

Computer-systems researchers have shown how to close gaps like this. Air Learning recorded the actual execution-latency distribution of a drone's onboard computer and replayed it inside the training simulator. That one step cut the gap in flight time between simulation and hardware from 37.73% to 0.5%. We propose to apply the same discipline to harmonic-injection controllers. We would measure each non-ideal behavior of the real drive and put it back into the simulator: interrupt timing jitter on the microcontroller, inverter dead time (the short forced pause when switching between transistors), and temperature-driven drift in winding resistance. We would then find out which of these explains the missing ripple. Finally, we would tune the injection controller, including the four-harmonic cancellation pattern that so far exists only offline, in the calibrated simulator rather than the idealized one.

Core Claim

Our claim is that most of the gap between simulated and measured torque ripple in harmonic-injection drives comes from a small number of non-idealities that can be measured on the bench. Replaying their measured distributions in simulation should do two things:

  1. It should predict hardware ripple to within a small fraction of the current error.
  2. It should yield injection settings that achieve lower ripple on hardware than settings tuned in an idealized simulator.

Two simpler fixes compete with this approach. Folding in a fixed delay plus a standard dead-time model is the classical power-electronics remedy. Randomizing motor parameters is the standard robotics remedy. We expect our approach to beat both.

The new contribution is the attribution and calibration loop itself, which none of the cited works builds. Du et al. report the gap but do not decompose it. Their Kalman filter also uses fixed motor parameters even though the authors note that resistance and inductance drift with temperature and saturation. Influence of harmonic voltage coupling on torque ripple of permanent magnet synchronous motor found that injecting the 5th, 7th, 11th and 13th harmonics together can cancel ripple: at 16% amplitude, ripple fell back to about the 6% baseline, whereas the 7th alone pushed it to 11.7%. That result, however, comes from finite-element simulation that assumes constant material properties, plus open-loop tests. It also reports a "positive synergy" pairing (5th with 11th) that makes ripple worse. This is the reason transfer matters. A cancelling combination tuned in an idealized model could become an amplifying one on a warm, delayed, real drive.

Research Program

Testbed. We will build a PMSM drive bench comparable to Du et al.'s, consisting of an inverter controlled by space-vector pulse-width modulation, a dynamometer, and a torque transducer. It will run three controllers: PI, conventional harmonic injection, and the fading-memory Kalman filter scheme (FMKF-HI). We will not have Du et al.'s hardware. Their numbers will therefore serve as reference points for the size of the gap, not as targets our rig must reproduce. On our own rig we will measure the simulated-versus-hardware gap $G = (R_{hw} - R_{sim})/R_{hw}$, where $R$ is peak-to-peak torque ripple. From Du et al.'s reported figures, $G$ is about 50% for FMKF-HI, 45% for PI, and 30% for conventional injection.

Profiling the hardware. We will measure three non-idealities directly on the drive.

  • Timing. A GPIO pin toggles at the start and end of every control interrupt, and a logic analyzer captures the result. This gives the full distribution of sampling-to-update delay, including the variable cost of the Kalman filter, across speeds and loads. It is the Air Learning recipe moved from a Raspberry Pi to a motor microcontroller.
  • Inverter behavior. We will measure dead-time and device voltage-drop distortion as a function of current.
  • Thermal drift. We will log winding resistance and back-EMF constant against stator temperature during sustained multi-harmonic injection. This targets the drift that Geng et al.'s constant-property simulation leaves out.

Each measured quantity becomes a module that can be switched on or off in the Simulink model. The point of the switches is that each source can be added alone or in combination.

Attributing the gap. We will add each module separately, then in combination, and record how much of $G$ each one removes for each controller. This shows which physics actually matters, for example whether timing jitter matters at all once the mean delay is modeled.

Calibrated design. Using the calibrated simulator, we will search the amplitudes and phases of the 5th, 7th, 11th and 13th injection vectors, and the Kalman fading factor. The goal is to turn Geng et al.'s offline cancellation finding into a closed-loop controller, extending Du et al.'s 5th/7th-only scheme. We will deploy settings found in the ideal simulator and settings found in the calibrated simulator, and compare their hardware ripple.

Second testbed (if time allows). We will replicate the attribution study on a two-stage single-phase DC-AC converter of the kind used by A Hybrid Second Harmonic Current Mitigation Strategy for Two-Stage Single-Phase DC–AC Converters. That work already attributes a small miss (5.2% achieved versus a 5.0% design target for virtual impedance alone) to digital delay and parasitics.

Baselines

Naive reference. The do-nothing reference is the idealized Simulink model with zero delay and an ideal inverter, used both to predict ripple and to tune the controllers. Its prediction error defines the gap we are trying to close.

Classical delay compensation. The strongest competitor is what an experienced drive engineer already does. They model a fixed delay of about 1.5 sampling periods, apply a textbook dead-time compensation, and add phase lead at each injected harmonic. This competitor is strong because, at 5th–13th harmonic frequencies with typical switching rates, a constant delay may account for nearly all of the phase error. We will run it on the identical rig, with the same controllers and the same tuning budget, meaning the same number of simulator evaluations in the search.

Parameter randomization. The robotics-style competitor tunes for robustness across uniformly randomized resistance, inductance and flux linkage, without measurement.

Ablations. Three ablations isolate the key ingredient. The first replaces the measured timing distribution with its mean. The second drops thermal drift. The third uses measured parameters at a single temperature.

Hardware reference. For the hardware outcome, the strongest reported result is FMKF-HI at 3 N·m torque ripple, versus 5 N·m for conventional injection, with a simulated THD of 2.83% (Du et al.). There is no reported closed-loop result for coupled four-harmonic injection; Geng et al.'s near-baseline ~6% ripple is open-loop.

What counts as success. The proposal wins if two conditions both hold. First, the calibrated simulator cuts $G$ by at least half relative to classical delay compensation. Second, settings tuned in the calibrated simulator lower measured hardware ripple, beyond run-to-run variation, compared with settings from both the classical and the randomized simulator.

Why not just…?

Why not just add a fixed delay and dead-time compensation? This is the real threat, and it may well be enough. If the attribution study shows that mean delay plus dead time removes nearly all of $G$, the honest conclusion is that timing jitter does not matter for this class of drive. We would report that as the finding and shift the emphasis to thermal drift. The mean-delay ablation exists specifically to settle this question. The case for doing the work anyway is that nobody has measured it: Du et al.'s 2× gap persists despite a real hardware platform, and Zhao et al. name delay without quantifying it.

Why not just tune directly on the hardware, or rely on adaptive control? Online adaptation such as repetitive control (used for wind-farm distortion in Study on Grid-Connected Power Quality Improvement of Wind Farms Based on Repetitive Controller) does correct steady errors. Its stability, however, still depends on loop delay. Searching the joint amplitude and phase space of four coupled harmonics on a 20 kW-class bench is also slow and risky, because some combinations amplify ripple, as Geng et al.'s 5th+11th case shows. We will compare against a hardware-only search with a matched number of bench trials, and report how many trials each approach needs to reach a given ripple.

Why not just randomize parameters in simulation? Air Learning found that randomization alone left a 37.73% flight-time gap when the missing physics was timing. In addition, randomizing hides the deterministic phase relationships that harmonic cancellation depends on. The randomized-tuning baseline tests this directly on our rig.

Proposed Experiments

Experiment 1: decompose the gap. We sweep three operating points (low, mid and rated load) at several speeds. At each point we measure hardware ripple and THD for PI, conventional injection and FMKF-HI, and compute $G$ under each combination of simulator modules. The output is a gap-attribution chart per controller.

Experiment 2: transfer test. Four-harmonic injection settings are tuned in the ideal, classical, randomized and calibrated simulators and then deployed on hardware. We report measured ripple, average torque (Geng et al. found coupling shifted it by at most 0.13 N·m, so any larger shift signals a modeling error), and stator temperature rise.

Experiment 3: thermal stress. We run sustained injection at 16% harmonic amplitude until the stator reaches thermal steady state, and check whether a combination that cancels ripple when cold turns into an amplifying one when hot. We also check whether the temperature-aware calibrated simulator predicts that flip.

Falsification conditions. The core claim fails in either of two cases. If the classical baseline matches the calibrated simulator on both prediction error and deployed ripple, the measurement step adds nothing. If calibrated tuning does not improve deployed ripple even though prediction improves, then better prediction did not translate into better control.