Skip to content
cccskills
FreePublished on GitHub

imc-tuning-rules

Calculate PI controller gains for a first-order process from its gain and time constant using Internal Model Control (IMC). Choose a response speed setting and get proportional and integral gains for control work.

OriginalShow the original description

Calculate PI/PID controller gains using Internal Model Control (IMC) tuning rules for first-order systems.

benchflow-ai/skillsbench1,872 stars(GitHub 1,872 + cccskills 0)
Works withAWS

Run score Not tested

See how to install

Good for

  • Tuning a PI controller for a first-order process
  • Choosing a response speed for a control loop
  • Adjusting gains when a process model is noisy or uncertain

Files included (1)

  • SKILL.md3.5 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

IMC Tuning Rules for PI/PID Controllers

Overview

Internal Model Control (IMC) is a systematic method for tuning PI/PID controllers based on a process model. Once you've identified system parameters (K and tau), IMC provides controller gains.

Why IMC?

  • Model-based: Uses identified process parameters directly
  • Single tuning parameter: Just choose the closed-loop speed (lambda)
  • Guaranteed stability: For first-order systems, always stable if model is accurate
  • Predictable response: Closed-loop time constant equals lambda

IMC Tuning for First-Order Systems

For a first-order process with gain K and time constant tau:

Process: G(s) = K / (tau*s + 1)

The IMC-tuned PI controller gains are:

Kp = tau / (K * lambda)
Ki = Kp / tau = 1 / (K * lambda)
Kd = 0  (derivative not needed for first-order systems)

Where:

  • Kp = Proportional gain
  • Ki = Integral gain (units: 1/time)
  • Kd = Derivative gain (zero for first-order)
  • lambda = Desired closed-loop time constant (tuning parameter)

Choosing Lambda (λ)

Lambda controls the trade-off between speed and robustness:

LambdaBehavior
lambda = 0.1 * tauVery aggressive, fast but sensitive to model error
lambda = 0.5 * tauAggressive, good for accurate models
lambda = 1.0 * tauModerate, balanced speed and robustness
lambda = 2.0 * tauConservative, robust to model uncertainty

Default recommendation: Start with lambda = tau

For noisy systems or uncertain models, use larger lambda. For precise models and fast response needs, use smaller lambda.

Implementation

def calculate_imc_gains(K, tau, lambda_factor=1.0):
    """
    Calculate IMC-tuned PI gains for a first-order system.

    Args:
        K: Process gain
        tau: Time constant
        lambda_factor: Multiplier for lambda (default 1.0 = lambda equals tau)

    Returns:
        dict with Kp, Ki, Kd, lambda
    """
    lambda_cl = lambda_factor * tau

    Kp = tau / (K * lambda_cl)
    Ki = Kp / tau
    Kd = 0.0

    return {
        "Kp": Kp,
        "Ki": Ki,
        "Kd": Kd,
        "lambda": lambda_cl
    }

PI Controller Implementation

class PIController:
    def __init__(self, Kp, Ki, setpoint):
        self.Kp = Kp
        self.Ki = Ki
        self.setpoint = setpoint
        self.integral = 0.0

    def compute(self, measurement, dt):
        """Compute control output."""
        error = self.setpoint - measurement

        # Integral term
        self.integral += error * dt

        # PI control law
        output = self.Kp * error + self.Ki * self.integral

        # Clamp to valid range
        output = max(output_min, min(output_max, output))

        return output

Expected Closed-Loop Behavior

With IMC tuning, the closed-loop response is approximately:

y(t) = y_setpoint * (1 - exp(-t / lambda))

Key properties:

  • Rise time: ~2.2 * lambda to reach 90% of setpoint
  • Settling time: ~4 * lambda to reach 98% of setpoint
  • Overshoot: Minimal for first-order systems
  • Steady-state error: Zero (integral action eliminates offset)

Tips

  1. Start conservative: Use lambda = tau initially
  2. Decrease lambda carefully: Smaller lambda = larger Kp = faster but riskier
  3. Watch for oscillation: If output oscillates, increase lambda
  4. Anti-windup: Prevent integral wind-up when output saturates

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

13f-analyzer

FreeSummary

Analyze SEC 13F filings to summarize a fund’s holdings and assets under management for a quarter, compare holdings across two quarters, and rank funds by the reported value of a stock position.

  • Summarizing a fund’s holdings for one quarter
  • Comparing a fund’s reported positions across quarters
  • Finding funds with the largest reported position in a stock
benchflow-ai/skillsbench1.9KUpdated Oct 24, 2026

Compute active and reactive power flows at both ends of an AC power line, accounting for transformer tap ratios and phase shifts. The skill also covers apparent power, bus balance aggregation, MVA limit checks, and branch loading calculations.

  • Calculate power flow in both directions across a transmission line
  • Check branch apparent power against its MVA rating
  • Calculate and report the most heavily loaded branches
benchflow-ai/skillsbench1.9KUpdated Oct 24, 2026

Prepare academic PDFs for blind review by removing matching identifying details before the References section. The skill focuses redaction on specific text matches, preserves references and self-citations, and checks that the saved document retains its pages and most of its text.

  • Anonymizing an academic paper for blind review
  • Removing author names and affiliations from a PDF
  • Checking a redacted paper for text loss
benchflow-ai/skillsbench1.9KUpdated Oct 24, 2026

Check bathroom floor plans against simplified ADA-derived geometric rules for turning space, door width and swing, toilet placement, grab bars, and lavatory knee or toe clearance. It reports rule-specific violations and suggests local, traceable layout repairs.

  • Check turning space in a bathroom plan
  • Review door width and swing clearances
  • Verify toilet and grab bar placement
benchflow-ai/skillsbench1.9KUpdated Oct 24, 2026

analyze-ci

FreeSummary

Reviews failed GitHub Actions job logs for a pull request or specific job URLs. It returns a concise summary of the likely root cause, error messages, test names, and relevant log excerpts, so you can see what needs attention.

  • Summarizing failed CI jobs for a pull request
  • Investigating an individual GitHub Actions job
  • Finding the error and related test in logs
benchflow-ai/skillsbench1.9KUpdated Oct 24, 2026

Extract plan-view geometry from architectural DXF files by interpreting CAD layers and geometric entities. Normalize rooms, doors, fixtures, clearances, and grab bars into consistent, machine-checkable JSON, and describe repaired geometry in a new DXF when needed.

  • Turning an architectural DXF plan into structured JSON
  • Checking room and door geometry for accessibility
  • Extracting fixture bounds and grab bar details
benchflow-ai/skillsbench1.9KUpdated Oct 24, 2026

See all skills by benchflow-ai

Report a problem with this skill