필터 지우기
필터 지우기

How can I set a reference value in PID in Matlab code/script?

조회 수: 6 (최근 30일)
SYED IMTIAZ ALI SHAH
SYED IMTIAZ ALI SHAH 2019년 4월 18일
답변: Raj 2019년 4월 19일
For example I have the following code which also include Transfer function. When I run this program, I want this program to tune my transfer function to a reference point of 0.1 however I have no clue how to do it.
clear all
clc
syms numerator denomenator Gp H Ts Gc Ka
numerator = [1];
denomenator = [1 0.3 0];
Gp = tf(numerator, denomenator)
H = [1];
Ts = feedback(Gp, H)
%%
Kp = 16;
Ki = 0;
Kd = 20;
Gc = pid(Kp, Ki, Kd)
Ka = 2;
Mc = feedback(Ka*Gc*Gp, H)
step(Mc)
hold on
grid on

답변 (1개)

Raj
Raj 2019년 4월 19일
Since you have put "step(Mc)" the closed loop system Mc is showing step response plot and tracking the value '1'.
Your requirement is for your closed loop system to track a reference of 0.1. Use this:
t = 0:0.1:10; %Simulation runs for 10 seconds with 0.1 sec sampling time
u_ref = 0.1*ones(size(t)); %Reference signal
u_input=zeros(size(t)); % input signal to the closed loop system
% now feed the difference of input and reference signal to your closed loop system and see the time response.
% The closed loop system will track and settle at the reference signal.
lsim(Mc,u_ref-u_input,t)
Hope this is what you are asking. If not please elaborate on your problem statement.

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by