To identify an open-loop model between the controller output (CO) and process value (PV) from closed-loop data, given PID values and the PID algorithm, you can follow a systematic approach. The goal is to estimate the open-loop process model using the data collected while the process is under closed-loop control.
Here's a step-by-step guide to achieve this:
-
Understand the PID Algorithm and Values:
- First, understand the PID (Proportional, Integral, Derivative) algorithm used. The standard form is (CO = K_p e(t) + K_i \int e(t) dt + K_d \frac{de(t)}{dt}), where (e(t) = SP - PV), and (K_p), (K_i), (K_d) are the PID gains.
- Note down the PID values ((K_p), (K_i), (K_d), and any filter coefficients if used).
-
Collect Closed-Loop Data:
- Collect time-series data of (CO), (PV), and (SP) (SetPoint) while the system is operating in closed loop. The data should be collected at a sufficient sampling rate.
-
Preprocess the Data:
- Check the data for any anomalies or missing values and preprocess it if necessary.
- You might need to filter the data to remove noise.
-
Estimate the Open-Loop Model:
- To estimate the open-loop model, you can use the method of "direct identification" or other closed-loop identification techniques. One common method is to use the "Prediction Error Method" or other subspace methods available in system identification toolboxes.
Here's a simplified example using MATLAB, assuming you have the System Identification Toolbox. This example assumes you're dealing with a SISO (Single Input Single Output) system.
% Assuming you have the data in vectors CO, PV, and time vector t
% and you know the PID gains Kp, Ki, Kd.
% Step 1: Create an iddata object
Ts = t(2) - t(1); % Sampling time
data = iddata(PV, CO, Ts);
% Step 2: Use a suitable model structure (e.g., state-space or transfer function)
% For simplicity, let's use a simple transfer function model
% You might need to adjust the number of poles and zeros based on your system
np = 2; % Number of poles
nz = 1; % Number of zeros
sys = tfest(data, np, nz);
% Step 3: Compare the model output with the measured output
compare(data, sys);
% To validate, you can simulate the open-loop response
% First, create a step or any input signal you used during identification
u = ones(100,1); % Example step input
t_sim = (0:length(u)-1)'*Ts;
y_sim = lsim(sys, u, t_sim);
plot(t_sim, y_sim);
For Python, you can use libraries like scipy for system identification and control library for control systems analysis.
import numpy as np
from scipy import signal
import matplotlib.pyplot as plt
from control import tf
# Assuming CO and PV are numpy arrays and Ts is the sampling time
Ts = t[1] - t[0]
# Create a simple transfer function model (example)
# You need to estimate the coefficients based on your data
# For a real system, you'd use a system identification technique
num = [1] # numerator coefficients
den = [1, 2, 1] # denominator coefficients (example for a 2nd order system)
sys = signal.TransferFunction(num, den, dt=Ts)
# To simulate
t_sim = np.arange(0, 10, Ts)
u = np.ones_like(t_sim)
t_out, y_out = signal.dlsim(sys, u, t=t_sim)
plt.plot(t_out, y_out)
plt.show()
# For system identification, you might use libraries like SIPPY or PySystemIdentification
# They offer functionalities to identify systems from data.
- Validate the Model:
- Validate the identified model by comparing its output with the actual (PV) for a different set of (CO) data (not used during identification).
- You can also check the model's response to a step input or other standard test signals.
This is a simplified overview. Real-world systems might require more complex models (e.g., MIMO, nonlinear systems) and more sophisticated identification techniques. Always refer to the documentation of the specific tools or libraries you are using for detailed instructions and examples.