Pre Lab

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 13

LAB OF AUTOMATIC CONTROL

VI Ciclo

Lab N° 05

Implementation of Real-Time PID Algorithms


Used Plants: [9] Qube with Nonlinear Load
[4] SRV02 Rotary servo base unit

REPORT

Team Members and Plant:

XXX
YYY

Professor: Arturo Rojas Moreno


Teaching Assistant: Gian Perez

Lab Sessions Dates: May 28, June 04


Lab report submission date: May 28, June 04

2019 – 1
Report

Introduction:

1. Read plants [4] and [9] manuals corresponding to the Qube and SRV02 devices
2. Read the Plant used in the paper “2DOF PID Control of the Angular Position of a Rotary
Torsion Plant”.

Objetives:

Implement Real-time PID control algorithms.

Hardware and Software:

1. Plants [4] and [9] in Lab 413


2. Quark (Real-time Matlab)

Safety:

Students must wear pants (no shorts) and shoes (no sneakers) to be admitted into the lab.

Pre Lab Work

1) Read documents listed in the introduction.


1. Using Simulink, design and simulate a PID speed control systems for plants [4] and [9].
You may use the known transfer function K/(T*s + 1) of the plant.( load disk)
Plant 9
PLANT 4:
2) Using Matlab into Simulink blocks, design a PID speed position control system for plants
[4] and [9], employing the discrete-time improved PID control algorithm. (load disk)
PLANTA 4
function u = speedqube(y,yp,e,ep,Dp,Ip)
%#codegen
Kp = 54.5; Ki = 550; Kd =12; Ti=Kp/Ki;Td=Kd/Kp;Nn =
100;
T=0.1;P=Kp*e;I=Ip+T*Kp*(e+ep)/(2*Ti);
D=(Td/(Nn*T+Td))*Dp - Kp*Td*Nn*(y-yp)/(Nn*T+Td);
u = P + I + D;yp=y; Dp=D;
end
PLANTA 9
function u = speedqube(y,yp,e,ep,Dp,Ip)
%#codegen
Kp = 0.699; Ki = 1.37; Kd =0.0791; Ti=Kp/Ki;Td=Kd/Kp;Nn
= 100;
T=0.1;P=Kp*e;I=Ip+T*Kp*(e+ep)/(2*Ti);
D=(Td/(Nn*T+Td))*Dp - Kp*Td*Nn*(y-yp)/(Nn*T+Td);
u = P + I + D;yp=y; Dp=D;
end

3) Using Matlab into Simulink blocks, design and simulate a speed control system for plants
[4] and [9], employing the discrete-time velocity PID control algorithm. (load disk)
% pidvelocity.m PID POSITION CONTROL OF THE ROBOT ARM OF
1DOF
clear all; close all; clc; s=tf('s');

Gp=178.4615/(s+7.6923); pidtune(Gp,'PID')
% SAMPLING TIME AND PID PARAMETERS
T = 0.01; Kp=0.936;Ki=67; Kd = 0;
a1=39.52569;b=60.4743;
% INITIAL CONDITIONS
e_1 = 0; x1 = 0; x1p=0; v=0;
% ******** CONTROL LOOP *********
Mm = 10000; T = 0.01; Nn = 10; ulow = -5; uhigh = 5; A=1;
for k = 1:Mm
if(k >= 0 && k <= Mm/4), r = A;
elseif(k >= Mm/4 && k <= Mm/2), r = 0.5*A;
elseif(k >= Mm/2 && k <= 3*Mm/4), r = 1*A;
elseif(k >= 3*Mm/4 && k <= Mm), r = 0.1*A;
end
R(k) = r; e = r - x1;
v = v + Kp*(e-e_1)+T*Ki*e+Kd*(e-2*e_1);
if(v < ulow), u = ulow; elseif( v > uhigh), u = uhigh; else
u = v;
end
U(k) = u;
% MODELO DE SEGUNDO ORDEN DEL PROCESO (DISCRETIZACI?ON
DIRECTA)
x1 = x1 + T*(a1*x1+b*u); Y(k) = x1;
e_1 = e;
end
% PLOTS
ejex = linspace(0,Mm*T,Mm); subplot(2,1,1)
plot(ejex,R,'b',ejex,Y,'r'); grid; ylabel('Posicion angular
(rad)')
subplot(2,1,2); plot(ejex,U); grid; ylabel('Se?al de
control u (V)')
xlabel('TIME [s]'); print -f -deps pidvelocity

Planta 4
PLANTA 9

4) Using Simulink, design and simulate a PID position control systems for plants [4] and [9].
You may use the known transfer function K/(T*s + 1) of the plant. (load disk)
Planta 9:
5) Using Matlab into Simulink blocks, design a PID position position control system for
plants [4] and [9], employing the discrete-time improved PID control algorithm. (load
disk)

% pidposfijo.m PID POSITION CONTROL OF THE ROBOT ARM OF


1DOF
clear all; close all; clc;s=tf('s');
Gp1=tf([1.53/0.0253],[1 1/0.0253 0]);
k=pidtune(Gp1,'PID')%Planta 4 Kp=0.936; Ki=67; Kd = 0;
Gp2=tf([23.2/0.13],[1 1/0.13 0]);
%pidtune(Gp2,'PID')%Planta 9
% SAMPLING TIME AND PID PARAMETERS
Kp=54.5; Ki =550; Kd = 1.2; Ti=Kp/Ki; Td=Kd/Kp;
% INITIAL CONDITIONS
ep = 0; x1 = 0; x1p=0; x2 = 0; Ip = 0; Dp=0;
% ******** CONTROL LOOP *********
Mm = 100000; T = 0.01; ulow = -5; uhigh = 5; A=1; Nn =
100;
for k = 1:Mm
if(k >= 0 && k <= Mm/4), r = A;
elseif(k >= Mm/4 && k <= Mm/2), r = 0.5*A;
elseif(k >= Mm/2 && k <= 3*Mm/4), r = 1*A;
elseif(k >= 3*Mm/4 && k <= Mm), r = 0.1*A;
end
R(k) = r; e = r - x1;
P = Kp*e; I = Ip + T*Kp*(e+ep)/(2*Ti);
D = (Td/(Nn*T + Td))*Dp - Kp*Td*Nn*(x1 - x1p)/(Nn*T +
Td);
v = P + I + D;
if(v < ulow), u = ulow; elseif( v > uhigh), u = uhigh;
else u = v;
end
U(k) = u;
% MODELO DE SEGUNDO ORDEN DEL PROCESO (DISCRETIZACI?N
DIRECTA)
x1=x1 + T*x2; Y(k) = x1;
x2=x2+T*(-x2*39.53+60.47*u);
ep = e; x1p=x1; Ip=I;
end
% PLOTS
ejex = linspace(0,Mm*T,Mm); subplot(2,1,1)
plot(ejex,R,ejex,Y); grid; ylabel('Posici?n angular
(rad)')
subplot(2,1,2); plot(ejex,U); grid; ylabel('Se?al de
control u (V)')
xlabel('TIME [s]'); print -f -deps pidposfijo

planta 4:

Planta 9:

6) Using Matlab into Simulink blocks, design and simulate a position control system for
plants [4] and [9], employing the discrete-time velocity PID control algorithm. (load disk)
Planta 4:

Planta 9:
Evaluation Rubric

Competencies: Be able to design and implement real-time PID algorithmms

Course: Automatic Control Semester: 6

Activity: Lab 3 Implementation of real-time PID algorithms Week: 8


Student (surnames and names) Period 2019-1

Workteam: Date: 23-30/05/2018 Instructors: A. Rojas, F. Salazar,


L. Pampamallco
Evaluation Documents
Laboratory: X Workshop Project: Work: Others

EVALUATION CRITERIA Very good Good Unaccep-


Fair
table
Test

Degree of knowledge of the subject and procedure 5 4- 3 2- 1 0


LAB SESSION
Using Simulink, implement a real-time speed control system for plant 2 1 0 0
either [4] or [9].
Using Matlab into Simulink blocks, implement a real-time speed control
system for plant either [4] or [9], employing the discrete-time improved 2 1 0 0
PID control algorithm.
Using Matlab into Simulink blocks, implement a real-time speed control
system for plant either [4] or [9], employing the discrete-time velocity 2 1 0 0
PID control algorithm.
Using Simulink, implement a real-time position control system for plant 2 1 0 0
either [4] or [9].
Using Matlab into Simulink blocks, implement a real-time position
control system for plant either [4] or [9], employing the discrete-time 2 1 0 0
improved PID control algorithm.
Using Matlab into Simulink blocks, implement a real-time position
control system for plant either [4] or [9], employing the discrete-time 2 1 0 0
velocity PID control algorithm.
Compare your results. Conclusions. 1 0 0 0
WORKTEAM REPORT
Complete the report on time and with good writing, orthography, 1 0 0 0
semantics, clear and concise ideas, images and suitable schemes.
CHALLANGE QUESTION
Challenge question: perform this Lab completely (if you are not able to
finish this Lab until 5 pm, ask the TAs another date to finish this Lab. 1 0 0 0
earn one point corresponding to the challenge question).
Total Grade

Comments on the student:

You might also like