Bode Plot Gain and Phase Margin Calculator
Find the gain margin, phase margin, and crossover frequencies of a classic single-integrator, two-real-pole open-loop system, with magnitude and phase Bode plots.
📊 What are Gain Margin and Phase Margin?
A Bode plot shows how a system's open-loop magnitude and phase change with frequency, and its gain margin and phase margin are the two classic numbers engineers read off that plot to judge how close a feedback system sits to instability. Phase margin is how much extra phase lag the loop could tolerate at the frequency where its gain is exactly 1 (0 dB) before the system becomes unstable. Gain margin is how much extra gain the loop could tolerate at the frequency where its phase is exactly -180 degrees before the same thing happens. Both numbers being comfortably positive is the standard, quick way to confirm a feedback loop is stable with reasonable safety margin.
Control engineers use gain and phase margin constantly when tuning feedback loops, from a motor speed controller to a power supply's voltage regulation loop to an aircraft's autopilot. A designer increasing a controller's gain to make the system respond faster checks the phase margin after every change, since gain and phase margin trade off directly against response speed: push the gain crossover frequency higher for a faster response, and the margins typically shrink. An engineer troubleshooting a loop that oscillates or overshoots excessively often finds the phase margin is too small, well under the commonly cited 30 to 60 degree comfort zone.
A common misconception is that a system with a positive gain margin and a positive phase margin is automatically "very stable" regardless of the actual margin size. In reality, a phase margin of just a few degrees is still technically stable but practically fragile, small changes in the plant (temperature drift, aging components, an unmodeled delay) can easily push such a system into instability. The margin size, not just its sign, is what tells you how much real-world headroom a design has.
This calculator takes the DC gain K and two pole time constants T1, T2 of a classic single-integrator, two-real-pole open-loop transfer function, numerically finds the gain and phase crossover frequencies, computes both margins, gives a clear stability verdict, and plots the full magnitude and phase Bode plots with each crossover frequency marked.
📐 Formula
📖 How to Use This Calculator
Steps
💡 Example Calculations
Example 1 — Marginally Stable Default Case
K = 10, T1 = 0.5 s, T2 = 0.1 s
Example 2 — Unstable, High Gain
K = 50, T1 = 0.5 s, T2 = 0.1 s (same poles, higher gain)
Example 3 — Comfortably Stable, Low Gain
K = 2, T1 = 1 s, T2 = 0.2 s
❓ Frequently Asked Questions
🔗 Related Calculators
What is the difference between gain margin and phase margin?
Phase margin is how much additional phase lag it would take to push the system to instability, measured at the gain crossover frequency where the loop gain is exactly 1 (0 dB). Gain margin is how much additional gain it would take to push the system to instability, measured at the phase crossover frequency where the phase is exactly -180 degrees. Both must be positive for a stable closed loop.
How do you find the gain crossover frequency?
The gain crossover frequency wgc is the frequency where the open-loop magnitude |G(jw)| equals 1 (0 dB). For a system with no closed-form solution, this is found by numeric root search, since |G(jw)| decreases monotonically for a Type-1 system with real poles, a simple bisection search converges quickly.
How do you find the phase crossover frequency?
The phase crossover frequency wpc is the frequency where the open-loop phase equals -180 degrees. Like the gain crossover, this is found by numeric root search rather than an algebraic formula for anything beyond a simple two-pole system.
What is a good phase margin for a stable control system?
A phase margin between 30 and 60 degrees is the commonly cited target range for practical control loops, giving a reasonable balance between fast response and acceptable overshoot. Margins near or below 0 degrees mean the system is marginally stable or unstable.
What happens if the phase margin is negative?
A negative phase margin means the open-loop phase has already dropped below -180 degrees by the time the gain crosses 0 dB, which means the closed-loop system (with unity negative feedback) is unstable, its response grows without bound rather than settling.
Why does the phase start near -90 degrees instead of 0 degrees?
The single integrator term (1/s) in the transfer function contributes a constant -90 degree phase shift at every frequency. At very low frequencies, before either real pole's phase lag becomes significant, the total phase sits close to this -90 degree integrator contribution.
What does the DC gain K represent in this transfer function?
K is the overall gain multiplier of the open-loop transfer function G(s) = K / (s(1+sT1)(1+sT2)). It shifts the entire magnitude curve up or down on the Bode plot (in dB, by 20*log10(K)) without changing the phase curve, since a real positive constant contributes zero phase shift.
Can I use this calculator for a system without an integrator?
No, not directly. This calculator is scoped to the specific structure K/(s(1+sT1)(1+sT2)), which always includes exactly one integrator and two real poles. A system without the integrator term would need a different transfer function structure and a separate tool.
What is the relationship between a Bode plot and a Nyquist plot?
A Bode plot shows magnitude and phase separately as two curves versus frequency, which is what this calculator plots. A Nyquist plot instead traces the same frequency response as a single curve in the complex plane, and its encirclements of the point -1+0j give an equivalent, sometimes more general, stability criterion covering cases a simple gain/phase margin reading can miss.
Why does increasing K reduce the phase margin?
Raising K shifts the magnitude curve upward on the Bode plot without moving the phase curve, which pushes the gain crossover frequency to a higher value. Since phase keeps decreasing (becoming more negative) as frequency increases for this system, a higher gain crossover frequency means a more negative phase there, and therefore a smaller phase margin.