Hi @Brandon
The PID tuner can only tune single-input, single-output (SISO) linear time-invariant (LTI) dynamical system objects. In the continuous-time domain, LTI systems are described using ordinary differential equations (ODEs) with constant coefficients, but they are often expressed in the form of state-space representation (using matrices). In the frequency domain, SISO LTI systems are described as transfer functions after performing a Laplace transform on the ODEs.
However, the data in the attached .csv file is merely a sequence of measured currents over successive intervals of time. Can we generally derive a complete mathematical model from the raw measured output signal alone? The answer is no! Modeling dynamical systems using a data-driven approach requires knowledge of both input and output signals, as well as the system's structure and parameters.
Measured current signal:
T = readtable('Controlled Current test.csv', VariableNamingRule="preserve");
x = T{:,1};
y = T{:,2};
plot(x, y), grid on
ylim([0, 200])
title('Controlled Current test')
xlabel('Time (s)');
ylabel('Current (amp)');
If you have both input and output signals, you can use the ssest() command from the System Identification Toolbox to estimate a state-space model using time-domain or frequency-domain data.
Example:
% load input/output data
load sdata1 tt1
% estimated number of states
nx = 4;
% estimate a 4th-order state-space model
sys = ssest(tt1, nx, 'DisturbanceModel', 'none')
% compare the simulated model response with the measured output
compare(tt1, sys)
% plot zero initial condition response of the estimated system
figure
step(sys, 5), grid on
% PID controller design
opt = pidtuneOptions('PhaseMargin', 60, 'DesignFocus', 'reference-tracking');
[C, info] = pidtune(sys, 'PIDF', opt)
% closed-loop system
Gcl = minreal(tf(feedback(C*sys, 1)))
% plot the simulated response of compensated system (not the actual measured signal)
figure
step(Gcl, 5), grid on
stepinfo(Gcl)