ƒ

Lead-Lag

Continuous
Run the live example Free · no sign-up · runs in your browser

Implements a first-order continuous dynamic lead-lag compensator. Parameterized by a lead time constant τ1\tau_1 and a lag time constant τ2\tau_2. When τ1>τ2\tau_1 > \tau_2, the block operates as a Phase Lead Compensator, introducing positive phase lead (up to +90∘+90^\circ) to increase phase margin, extend closed-loop bandwidth, and damp resonant overshoot. When τ1<τ2\tau_1 < \tau_2, it operates as a Phase Lag Compensator, boosting low-frequency loop gain to eliminate steady-state tracking errors while attenuating high-frequency noise.

Mathematical Model

In the Laplace domain (ss), the continuous transfer function is defined as:

G(s)=Y(s)U(s)=τ1s+1τ2s+1G(s) = \frac{Y(s)}{U(s)} = \frac{\tau_1 s + 1}{\tau_2 s + 1}

where τ1\tau_1 represents leadTime and τ2\tau_2 represents lagTime (τ2>0\tau_2 > 0).

Evaluating the frequency response along the imaginary axis (s=jωs = j\omega) yields:

∣G(jω)∣=1+(ωτ1)21+(ωτ2)2,∠G(jω)=arctan⁡(ωτ1)−arctan⁡(ωτ2)|G(j\omega)| = \sqrt{\frac{1 + (\omega \tau_1)^2}{1 + (\omega \tau_2)^2}}, \quad \angle G(j\omega) = \arctan(\omega \tau_1) - \arctan(\omega \tau_2)

The peak phase shift ϕm\phi_m occurs at the geometric center frequency ωm\omega_m:

ωm=1τ1τ2,sin⁡(ϕm)=τ1−τ2τ1+τ2\omega_m = \frac{1}{\sqrt{\tau_1 \tau_2}}, \quad \sin(\phi_m) = \frac{\tau_1 - \tau_2}{\tau_1 + \tau_2}
  • Lead Network (τ1>τ2\tau_1 > \tau_2): Contributes positive phase advance (ϕm>0\phi_m > 0), improving stability margin and transient settling.
  • Lag Network (τ1<τ2\tau_1 < \tau_2): Contributes phase retard (ϕm<0\phi_m < 0) while providing high DC gain to eliminate steady-state error.
  • Unity Neutral (τ1=τ2\tau_1 = \tau_2): Zero and pole cancel identically, yielding transparent unity passthrough (G(s)=1G(s) = 1).

Inputs & Outputs

Direction ID Label Type Status
→ In in In number Required
← Out out Out number Output

Parameters

Parameters Label Type Default Description
leadTime Lead Time Constant (τ₁) number 1
lagTime Lag Time Constant (τ₂) number 0.1

Usage Examples

Example 1: Phase Lead Compensation for Servomotor Resonant Damping

In an underdamped optical tracking gimbal with an inadequate phase margin of only 25∘25^\circ, step inputs provoke severe oscillatory ringing. Designing a LeadLag block with leadTime = 0.1 s and lagTime = 0.02 s (α=5\alpha = 5) aligns peak phase advance (ϕm≈42∘\phi_m \approx 42^\circ) at ωm=1/0.1⋅0.02≈22.36 rad/s\omega_m = 1/\sqrt{0.1 \cdot 0.02} \approx 22.36\text{ rad/s}. Cascading this block into the forward loop raises phase margin to 55∘55^\circ, suppressing transient overshoot without adding derivative noise.

Example 2: Phase Lag Compensation for Steady-State Error Reduction

In robotic conveyor speed regulation, load friction introduces undesirable steady-state velocity droop. Configuring a LeadLag block with leadTime = 0.4 s and lagTime = 4.0 s provides a tenfold (+20 dB+20\text{ dB}) DC gain amplification below ω=0.25 rad/s\omega = 0.25\text{ rad/s} to eliminate tracking offset, while returning to unity gain (0 dB0\text{ dB}) at high frequencies to preserve existing high-frequency gain margins.

Remarks & Best Practices

  • Center Frequency Placement: To extract maximum phase compensation, always size τ1\tau_1 and τ2\tau_2 such that the geometric center frequency ωm=1/τ1τ2\omega_m = 1/\sqrt{\tau_1 \tau_2} coincides exactly with the open-loop gain crossover frequency (ωgc\omega_{\text{gc}}).
  • Pure Low-Pass Filtering: Setting leadTime = 0.0 converts the block into an ideal first-order low-pass filter with cutoff frequency ωc=1/τ2\omega_c = 1/\tau_2 and −20 dB/decade-20\text{ dB/decade} high-frequency roll-off.
  • Continuous ODE State Integration: Formulated as a continuous-state dynamic system in the WASM simulation engine, ensuring smooth integration across RK4, RK45, and TR-BDF2 solvers.
  • Cascaded Topologies: Multiple LeadLag blocks can be cascaded in series to synthesize complex multi-stage lead-lag compensators (e.g. lead-lead-lag networks for flexible structures).

Frequently Asked Questions (FAQ)

Q: When should I design a Lead Compensator vs a Lag Compensator?

Use Phase Lead (z<pz < p, zero before pole) to improve phase margin and speed up transient settling time. Maximum phase lead ϕm=arcsin⁡(p−zp+z)\phi_m = \arcsin(\frac{p - z}{p + z}) is placed at geometric mean ωm=z⋅p\omega_m = \sqrt{z \cdot p} near the gain crossover frequency. Use Phase Lag (p<zp < z, pole before zero) to boost DC gain by factor Kdc=z/p>1K_{dc} = z/p > 1 without destabilizing the loop, driving steady-state tracking error to near zero while placing its phase attenuation far below gain crossover.

Related Components

  • TransferFunction: General continuous-time transfer function in polynomial fraction form B(s)/A(s)B(s)/A(s).
  • PIDController: Packaged three-term controller with configurable proportional, integral, and derivative gains.
  • Integrator: Continuous 1/s1/s dynamic state accumulator.
  • Derivative: First-order filtered differentiator (Ns/(s+N)N s / (s + N)).