필터 지우기
필터 지우기

how to get PID output?

조회 수: 6 (최근 30일)
mohamed El Hamzawy
mohamed El Hamzawy 2014년 7월 3일
답변: mamal 2022년 9월 4일
hello i am currently doin my bachelor thesis ,, the project is ball on beam. i am using PID function for matlab to control a servo motor . the code is as follows:
s = tf('s');
P_ball = 0.48/s^2;
Kp =2;
Kd =1;
Ki=.75;
C = pid(Kp,Ki,Kd);
sys_cl=feedback(P_ball,1);
t=0:0.01:5;
step(0.25*sys_cl)
disp(sys_cl);
The problem is extracting the output value from the PID function. the output of PID function is supposed to be the angle of the servo motor,, now i dont know how to get this angle in order to give it to the servo motor continuously. can anyone help?

답변 (4개)

Arkadiy Turevskiy
Arkadiy Turevskiy 2014년 7월 7일
Your code, as written does not make much sense. You define controller C, but then do not use it, and instead just use unity gain when computing closed-loop response. I am also not sure why you are mutiplying sys_cl by 0.25 when computing the step reponse.
The more meaningful code would be:
s = tf('s');
P_ball = 0.48/s^2;
Kp =2;
Kd =1;
Ki=.75;
C = pid(Kp,Ki,Kd);
sys_cl=feedback(C*P_ball,1);
t=0:0.01:5;
step(sys_cl)
what you see then is the angle of the motor (the variable you control). The output of the PID would be something like a voltage request to the motor. Another issue is that typically a motor transfer function is not a double integrator, like your plant transfer function, but that's for you to figure out.
  댓글 수: 2
mohamed El Hamzawy
mohamed El Hamzawy 2014년 7월 8일
편집: mohamed El Hamzawy 2014년 7월 8일
First of all thanks for answering.
Second of all, in the code C controller is used in the feed back function "sys_cl=feedback(C*P_ball,1);". The transfer function is not for the motor too, it is for the system of ball on beam. its is a relation between the output which is the position of the ball, and the input which is the angle of the servo. The problem is i am using arduino connections with matlab to control the servo motor as follows:
" a.servoAttach(9);
a.servoWrite(9,Outputpid); "
the Problem is i am trying to get the output of pid function as an integer for each time the pid calculates a new output.
parag patil
parag patil 2020년 10월 23일
Hello,
I had the same question. Sorry for being too late, but did you manage to get the answer?

댓글을 달려면 로그인하십시오.


Komal Damodara
Komal Damodara 2019년 4월 4일
s = tf('s');
P_ball = 0.48/s^2;
Kp =2;
Kd =1;
Ki=.75;
C = pid(Kp,Ki,Kd);
sys_cl=feedback(C*P_ball,1);
t=0:0.01:5;
step(sys_cl)

Komal Damodara
Komal Damodara 2019년 4월 4일
s = tf('s');
P_ball = 0.48/s^2;
Kp =2;
Kd =1;
Ki=.75;
C = pid(Kp,Ki,Kd);
sys_cl=feedback(C*P_ball,1);
t=0:0.01:5;
step(sys_cl)

mamal
mamal 2022년 9월 4일
How do you solve this problem?

카테고리

Help CenterFile Exchange에서 PID Controller Tuning에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by