Using the PID Tuner to read excel data
16 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am trying to use the PID tuner for this excel sheet to automatically tune this values for less than 20% overshoot I am struggling to find a code to be able to read the imported values from this time series data to tune my controller. Is there anyone that can help provide a code that was used to read the values from this excel sheet for the PID tuner to use?
0 commentaires
Réponses (1)
Sam Chak
le 4 Sep 2025 à 6:08
Modifié(e) : Sam Chak
le 4 Sep 2025 à 10:17
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)
0 commentaires
Voir également
Catégories
En savoir plus sur PID Controller Tuning dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!