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 functiondelay_time: Input delay in secondsdt: Simulation step size (default: 0.01)Total_time: Total simulation time (default: 10)
Methods:
step(u): Advance simulation by one step with input ureset(): Reset simulation statemarginal_stability(): Check if system is marginally stablegain_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 gainKi: Integral gainKd: Derivative gaindt: Sampling timeN: Derivative filter coefficient
Methods:
compute(setpoint, measurement): Calculate control outputreset(): Reset integral and derivative statesupdate_gains(Kp, Ki, Kd): Update controller gainsIIMC_tuning(process, theta, l): IIMC-based automatic tuningIDA2_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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
acd8058276a88cb8b74f85c38c3c08f0333a8c39178cce127ae7cd29137f78a0
|
|
| MD5 |
45adec4af99ec97f47dde239b59905da
|
|
| BLAKE2b-256 |
3fae3912148f4a6a45be97bd4bb28d6b654603269f39e9791276f37a57c8c6d3
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7ba735b16e63efd7d944f35c8e729bdc028999a70ecd794b479b4116c3582e3
|
|
| MD5 |
b0262484f2977aba55a786bc3567f0ad
|
|
| BLAKE2b-256 |
a7cfb25e6e350ed9db98d7521692f652a882fbebf9c91512ff68e41f700aed6d
|