Wound Up

You inherited a fixed-point field-oriented speed controller for a three-phase PMSM drive. Every 100 microseconds it reads the phase currents and the rotor's electrical sector, rotates the currents into the rotor frame, runs a cascaded current/speed control law, and rotates the commanded voltages back out to the three phase modulations. The outer speed loop produces a torque-current reference; the inner dq current loops drive the phase voltages toward it.

On the bench it holds a steady speed perfectly, and even a gentle speed ramp looks clean. But when the operator SLAMS the setpoint from full speed one way to full speed the other way — a hard reversal — the drive goes wild: the speed blows far past the new setpoint and takes a very long time to come back, and in the worst runs it never really re-settles at all before the test ends. Nothing is wrong with the steady-state tuning; it is only the hard reversal that misbehaves.

The commanded speed is delivered in an SRAM mailbox at 0x2000FF00 in milli-RPM (12,000,000 mRPM is 12,000 RPM) and is re-read every control tick, so the reversal is just a second write to that mailbox. The rotor's present electrical sector is reported in SECTOR (0 through 5) and the measured speed in SPEED (signed). The bring-up, the angle estimation, the transforms, and the reporting are all correct.

Find why a hard reversal makes the speed overshoot so far and refuse to re-settle, and fix it so the drive comes back to the new setpoint promptly with only modest overshoot.

Loading the interactive arena.