This project implements a PID-based process control system with anomaly detection, leveraging Python, Streamlit, and Scikit-learn. The system allows users to adjust PID parameters, visualize system behavior, and detect anomalies using Isolation Forest. It simulates a first-order system and provides real-time insights into control performance.
- Features
- Installation
- Usage
- How It Works
- Performance Metrics
- Anomaly Detection
- Future Enhancements
- Contributing
- License
- Connect With Me
β
PID Controller Implementation: Adjustable proportional, integral, and derivative gains.
β
First-Order System Simulation: Uses ODE integration for realistic process modeling.
β
Real-Time Performance Metrics: Computes rise time, settling time, overshoot, and IAE.
β
Anomaly Detection: Detects irregular behavior using Isolation Forest.
β
Interactive Visualization: Streamlit dashboard for intuitive tuning and monitoring.
β
Customizable Setpoint: Define your desired process control target.
git clone https://github.com/v1v3x/PIDetect.git
cd PIdetect
pip install -r requirements.txt
streamlit run app.py
- Open the Streamlit web interface.
- Adjust Kp, Ki, and Kd values in the sidebar.
- Set a desired process target (setpoint).
- Monitor real-time graphs of process behavior.
- View performance metrics to evaluate control efficiency.
- Detect anomalies and analyze control instability.
- PID Controller: Computes control outputs using error-based feedback.
- Process Model: Simulates a first-order system using ODE integration.
- Performance Metrics: Analyzes system response based on control theory principles.
- Anomaly Detection: Identifies system deviations with Isolation Forest.
- Interactive Visualization: Plots process variables and control signals in real time.
- The system follows a first-order process model with a time constant (Ο) of 10.
- PID tuning parameters (Kp, Ki, Kd) influence system behavior.
- The simulation runs for 200 seconds with a step size of 0.1 seconds.
Metric | Description |
---|---|
Rise Time | Time taken to reach 90% of the setpoint |
Settling Time | Time required for the system to stabilize within 5% of the setpoint |
Overshoot | Maximum deviation beyond the setpoint (%) |
IAE (Integral Absolute Error) | Accumulated error over time |
Anomalies in system behavior are detected using Isolation Forest:
- Outlier Detection: Identifies deviations in process variable and control signal.
- Visualization: Highlights anomalies as red markers in the graph.
- Threshold-Based Classification: 10% of data points are considered anomalies.
from sklearn.ensemble import IsolationForest
from sklearn.preprocessing import StandardScaler
def detect_anomalies(data):
scaler = StandardScaler()
data_scaled = scaler.fit_transform(data)
iso_forest = IsolationForest(contamination=0.1, random_state=42)
anomalies = iso_forest.fit_predict(data_scaled)
return anomalies == -1 # Returns True for anomalies
- β Adaptive PID tuning using machine learning.
- β Real-time cloud deployment with IoT integration.
- β Advanced anomaly detection with deep learning techniques.
- β Dynamic process modeling for different industries.
Contributions are welcome! Follow these steps:
- Fork the repository.
- Create a new branch (
feature-name
). - Commit your changes.
- Push to the branch.
- Open a pull request.
This project is licensed under the Apache 2.0 License.