Skip to main content

Delay Control System Simulation with PID Controller

Project description

ControlSim

A Python package for simulating delay control systems with PID controller implementation.

Overview

ControlSim provides tools to simulate control systems with input delays using state-space representations and transfer functions. It includes:

  • ProcessDefinition: Simulates a plant model with configurable delays
  • PIDController: Implements a PID controller with derivative filtering
  • Tuning Methods: IIMC (Indirect-IMC-PID) and IDA2 controller tuning algorithms

Features

  • Support for transfer function and state-space representations
  • Input delay simulation using circular buffer
  • PID controller with filtered derivative action
  • Gain and phase margin calculations
  • IIMC and IDA2 automatic controller tuning methods
  • Marginal stability checking

Installation

Install from PyPI:

pip install controlSim

Or install from source:

git clone https://github.com/vkbharatv/controlSim.git
cd controlSim
pip install -e .

Quick Start

import control as ctrl
from controlsim import ProcessDefinition, PIDController
import numpy as np

# Define a transfer function
s = ctrl.TransferFunction.s
G = 1 / ((s + 1) * (0.7 * s + 1))

# Create process with 2-second delay
process = ProcessDefinition(G, delay_time=2.0, dt=0.01)

# Create and tune PID controller
pid = PIDController(dt=0.01)
Kp, Ki, Kd = pid.IIMC_tuning(process, theta=2.0, l=0.5)

# Simulate for 100 seconds
setpoint = 1.0
for _ in range(10000):
    output = process.y[-1][0]
    control_signal = pid.compute(setpoint, output)
    process.step(control_signal)

# Analyze margins
gain_margin, phase_margin, wgc, wpc = process.gain_phase_margin()
print(f"Gain Margin: {gain_margin} dB")
print(f"Phase Margin: {phase_margin}°")

API Reference

ProcessDefinition

Represents a continuous-time process with input delay.

ProcessDefinition(tf, delay_time, dt=0.01, Total_time=10)

Parameters:

  • tf: Control system transfer function
  • delay_time: Input delay in seconds
  • dt: Simulation step size (default: 0.01)
  • Total_time: Total simulation time (default: 10)

Methods:

  • step(u): Advance simulation by one step with input u
  • reset(): Reset simulation state
  • marginal_stability(): Check if system is marginally stable
  • gain_phase_margin(omega): Calculate gain and phase margins

PIDController

Implements a discrete-time PID controller with derivative filtering.

PIDController(Kp=1.0, Ki=0.0, Kd=0.0, dt=0.01, N=100)

Parameters:

  • Kp: Proportional gain
  • Ki: Integral gain
  • Kd: Derivative gain
  • dt: Sampling time
  • N: Derivative filter coefficient

Methods:

  • compute(setpoint, measurement): Calculate control output
  • reset(): Reset integral and derivative states
  • update_gains(Kp, Ki, Kd): Update controller gains
  • IIMC_tuning(process, theta, l): IIMC-based automatic tuning
  • IDA2_tuning(rho): IDA2-based automatic tuning

Requirements

  • Python 3.8+
  • control >= 0.9.4
  • numpy >= 1.20.0
  • scipy >= 1.7.0
  • matplotlib >= 3.3.0

Citation

If you use this package in your research, please cite:

@software{controlsim2026,
  author = {Bharat Verma},
  title = {ControlSim: Delay Control System Simulation},
  year = {2026},
  url = {https://github.com/vkbharatv/controlSim},
  orcid = {0000-0001-7600-7872}
}

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Dr. Bharat Verma
The LNMIIT, Jaipur, India
ORCID: 0000-0001-7600-7872

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Disclaimer

This software is provided for educational and research purposes. The authors are not responsible for any damages or losses resulting from the use of this software.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

controlsim-0.1.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

controlsim-0.1.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file controlsim-0.1.0.tar.gz.

File metadata

  • Download URL: controlsim-0.1.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for controlsim-0.1.0.tar.gz
Algorithm Hash digest
SHA256 acd8058276a88cb8b74f85c38c3c08f0333a8c39178cce127ae7cd29137f78a0
MD5 45adec4af99ec97f47dde239b59905da
BLAKE2b-256 3fae3912148f4a6a45be97bd4bb28d6b654603269f39e9791276f37a57c8c6d3

See more details on using hashes here.

File details

Details for the file controlsim-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: controlsim-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for controlsim-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e7ba735b16e63efd7d944f35c8e729bdc028999a70ecd794b479b4116c3582e3
MD5 b0262484f2977aba55a786bc3567f0ad
BLAKE2b-256 a7cfb25e6e350ed9db98d7521692f652a882fbebf9c91512ff68e41f700aed6d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page