Digital control loop specialist for discrete-time power electronics simulators in C++. Covers Z-domain design and discretization (ZOH, Tustin, matched pole-zero), computational delay modeling, PID and type-II/III compensators, anti-windup, and digital PWM generation. Use when implementing or debugging voltage-mode or current-mode control loops in simulation. Trigger for terms like "digital control", "Z-domain", "ZOH", "Tustin", "bilinear", "PID", "compensator", "computational delay", "anti-windup", "voltage mode", "current mode", "duty cycle update", "discrete-time controller", or "control loop stability".
Use this skill when implementing, debugging, or analyzing control loops in a discrete-time power electronics simulator. The simulator advances in discrete time steps — the controller runs at the switching frequency (or a sub-harmonic) and updates duty cycle once per period.
Key difference from continuous-time analysis: a digital controller introduces computational delay (one sample period between measurement and duty cycle update), which adds a phase lag of e^(−sT_s). This phase lag must be accounted for in stability analysis and compensator design.
Default stance:
Design in continuous time, then discretize.
references/pid-and-compensators.md for compensator forms and design equations.Discretize the compensator.
references/digital-control.md for discretization formulas and Z-transform pairs.Model computational delay.
Implement the discrete-time control law in C++.
references/digital-control.md for the difference equation implementation pattern.Verify digital PWM generation.
Validate loop stability.
references/average-state-space.md for plant model discretization.| Topic | Reference | Load when |
|---|---|---|
| Digital control and discretization | references/digital-control.md | Z-domain design, ZOH/Tustin formulas, difference equation implementation |
| PID and compensators | references/pid-and-compensators.md | Type-I/II/III compensator design, anti-windup, current-mode control |
| Averaged state-space plant models | references/average-state-space.md | Discretizing the power stage model for Z-domain loop gain analysis |
| Script | Purpose | Usage |
|---|---|---|
scripts/run_stability_analysis.py | Evaluate open-loop gain T(z) = C(z)·P(z)·z⁻ᵈ on the unit circle; compute phase margin, gain margin, and crossover frequencies from z-domain polynomial coefficients | python skills/control-loop/scripts/run_stability_analysis.py --plant-num "1" --plant-den "1 -0.8" --comp-num "2" --comp-den "1" --Ts 2e-5 |
For control loop tasks, provide: