Two matlab prgm
% Provide your student ID. Uncomment the followign line and assign your student number to the variable StudentID. %StudentID=1234567; % DC motor values La = 0.1; %Motor armature inductance Ra = 1.0; %Motor armature resistance Km = 0.4; %Gyrator (motor) co-efficient b = 0.2; %Damping co-efficient Jm = 0.1; %Moment of inertia TL = 0.0; %Load torque N = 7.0; %Gear ration N_2 / N_1 m = 5.0; %Mass of pendulum l = 1.0; %Length of pendulum arm g = 9.8; %Gravity % Matrices of the state-space model A = [-Ra/La -Km/Jm 0; Km/La -b/Jm -l*m*g/N^2 0 1/Jm 0]; B = [1; 0; 0]; C = [0 0 1/N]; D = [0]; % Define the transfer function G using the command "tf" %% PID tuning - Oscillation method % Use the Oscillation Method to obtain Ku and Pu. Define the variables here % Use the values of Ku and Pu to compute the PID gains Kp, Ti, Td and N. Define these variables here. % Fine tune the gains Kp, Ti and Td to satisfy the control requirements (rise time, overshoot, steady-state error), e.g. you can use Kp=0.9*Kp % Obtain the transfer function of the PID controller. Use the command "pidstd". % In the Matlab command window, you can type "help pidstd" to understand this command more. Matlab provides a comprehensive help documentation which explains every command in great details. % Obtain the closed-loop transfer function Tcl. Use the command "feedback" and save the result in the variable "Tcl" % Plot the step respose of the closed loop transfer function Tcl. Use the command "step". % Use the command "step" to save the the step response in the variables "y" and "t" (see the example in the problem description) % Use the command "stepinfo" to obtain the characteristics of the step response and save the result in the variable "assessStep" (see the example in the problem description) % Check that the control requirements are met % Compute the steady-state error and save it in the variable "ess" (see the example in the problem description) 18/10/2022, 14:19 MathWorks Learning Tool https://lms-grader.mathworks.com/launch 1/3 Script Problem 2: Reaction Curve Method My Solutions Description Consider a DC motor with a dynamic model , and is used to drive a cable reel with a dy controller using the Zielger Nichols Reaction Curve method. The closed loop system is shonw in the figure The PID controller should have the following parallel form, . Assessment The closed-loop step response should achieve the following objectives: Peak Time: Overshoot: Zero steady-state error Requirements The following requirements are for assessment purposes. Include the following MATLAB functions in your codes. tf; pidstd Store your closed-loop step response in y and t (time vector). The values in y will be used to evalua % Tcl is the closed-loop transfer function [y,t] = step(Tcl) % steady-state error ess = abs(1 - y(end)) % Peak time assessStep = stepinfo(y,t); % We will test if assessStep.PeakTime <= 0.5 g1(s) = 0.8s + 1.6 s2 + 4s + 7.2 cpid(s) = kp(1 + 1 tis + td τds + 1 ) tp ≤ 0.5 second p.o. ≤ 30% 18/10/2022, 14:19 mathworks learning tool https://lms-grader.mathworks.com/launch 2/3 reset matlab documentation (https://www.mathworks.com/help/) save % provide your student id. uncomment the followign line and assign your student nu %studentid=1234567; % dc motor transfer function g1 = % cable reel transfer function g2 = % system transfer fuction g=g1*g2 %% pid - reaction curve method % compute the step response of g and save it in [y2,t2] % compute the derivative of the step response % finds the inflection point [m,i] % time that the inflection point was observed % magnitude of the step reponse at the inflection point % gradient of the step reponse at the time of the inflection point % find the x and y intercepts % compute the parameters for zn pid tuning, i.e. "r" and "tau" % obtain the pid gains kp, ti, td and n using the zn tuning rules for the reaction % fine tune the gains kp, ti and td to satisfy the control requirements (peak time, % obtain the transfer function of the pid controller. use the command "pidstd". % in the matlab command window, you can type "help pidstd" to understand this comma % obtain the closed-loop transfer function tcl. use the command "feedback" and save % in the following line we use the command "step" to save the the step response in [y,t] = step(tcl); % use the command "stepinfo" to obtain the characteristics of the step response and % check that the control requirements are met 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 https://www.mathworks.com/help/ 18/10/2022, 14:19 mathworks learning tool https://lms-grader.mathworks.com/launch 3/3 assessment: run pretest submit run script © 2020 the mathworks, inc. % in the following line we compute the steady-state error and save it in the variab ess = abs(1 - y(end)) student id make sure the following matlab functions are included in your code. (pretest) check if g1 and g2 are defined correctly. (pretest) overshoot (pretest) peak time (pretest) steady-state error (pretest) 48 49 50 51 52 0.5="" g1(s)="0.8s" +="" 1.6="" s2="" +="" 4s="" +="" 7.2="" cpid(s)="Kp(1" +="" 1="" tis="" +="" td="" τds="" +="" 1="" )="" tp="" ≤="" 0.5="" second="" p.o.="" ≤="" 30%="" 18/10/2022,="" 14:19="" mathworks="" learning="" tool="" https://lms-grader.mathworks.com/launch="" 2/3="" ="" reset="" ="" matlab="" documentation="" (https://www.mathworks.com/help/)="" ="" save="" %="" provide="" your="" student="" id.="" uncomment="" the="" followign="" line="" and="" assign="" your="" student="" nu="" %studentid="1234567;" %="" dc="" motor="" transfer="" function="" g1="%" cable="" reel="" transfer="" function="" g2="%" system="" transfer="" fuction="" g="G1*G2" %%="" pid="" -="" reaction="" curve="" method="" %="" compute="" the="" step="" response="" of="" g="" and="" save="" it="" in="" [y2,t2]="" %="" compute="" the="" derivative="" of="" the="" step="" response="" %="" finds="" the="" inflection="" point="" [m,i]="" %="" time="" that="" the="" inflection="" point="" was="" observed="" %="" magnitude="" of="" the="" step="" reponse="" at="" the="" inflection="" point="" %="" gradient="" of="" the="" step="" reponse="" at="" the="" time="" of="" the="" inflection="" point="" %="" find="" the="" x="" and="" y="" intercepts="" %="" compute="" the="" parameters="" for="" zn="" pid="" tuning,="" i.e.="" "r"="" and="" "tau"="" %="" obtain="" the="" pid="" gains="" kp,="" ti,="" td="" and="" n="" using="" the="" zn="" tuning="" rules="" for="" the="" reaction="" %="" fine="" tune="" the="" gains="" kp,="" ti="" and="" td="" to="" satisfy="" the="" control="" requirements="" (peak="" time,="" %="" obtain="" the="" transfer="" function="" of="" the="" pid="" controller.="" use="" the="" command="" "pidstd".="" %="" in="" the="" matlab="" command="" window,="" you="" can="" type="" "help="" pidstd"="" to="" understand="" this="" comma="" %="" obtain="" the="" closed-loop="" transfer="" function="" tcl.="" use="" the="" command="" "feedback"="" and="" save="" %="" in="" the="" following="" line="" we="" use="" the="" command="" "step"="" to="" save="" the="" the="" step="" response="" in="" [y,t]="step(Tcl);" %="" use="" the="" command="" "stepinfo"="" to="" obtain="" the="" characteristics="" of="" the="" step="" response="" and="" %="" check="" that="" the="" control="" requirements="" are="" met="" 1="" 2="" 3="" 4="" 5="" 6="" 7="" 8="" 9="" 10="" 11="" 12="" 13="" 14="" 15="" 16="" 17="" 18="" 19="" 20="" 21="" 22="" 23="" 24="" 25="" 26="" 27="" 28="" 29="" 30="" 31="" 32="" 33="" 34="" 35="" 36="" 37="" 38="" 39="" 40="" 41="" 42="" 43="" 44="" 45="" 46="" 47="" 48="" https://www.mathworks.com/help/="" 18/10/2022,="" 14:19="" mathworks="" learning="" tool="" https://lms-grader.mathworks.com/launch="" 3/3="" assessment:="" run="" pretest="" ="" submit="" ="" ="" run="" script="" ="" ©="" 2020="" the="" mathworks,="" inc.="" %="" in="" the="" following="" line="" we="" compute="" the="" steady-state="" error="" and="" save="" it="" in="" the="" variab="" ess="abs(1" -="" y(end))="" student="" id="" make="" sure="" the="" following="" matlab="" functions="" are="" included="" in="" your="" code.="" (pretest)="" check="" if="" g1="" and="" g2="" are="" defined="" correctly.="" (pretest)="" overshoot="" (pretest)="" peak="" time="" (pretest)="" steady-state="" error="" (pretest)="" 48="" 49="" 50="" 51="">= 0.5 g1(s) = 0.8s + 1.6 s2 + 4s + 7.2 cpid(s) = kp(1 + 1 tis + td τds + 1 ) tp ≤ 0.5 second p.o. ≤ 30% 18/10/2022, 14:19 mathworks learning tool https://lms-grader.mathworks.com/launch 2/3 reset matlab documentation (https://www.mathworks.com/help/) save % provide your student id. uncomment the followign line and assign your student nu %studentid=1234567; % dc motor transfer function g1 = % cable reel transfer function g2 = % system transfer fuction g=g1*g2 %% pid - reaction curve method % compute the step response of g and save it in [y2,t2] % compute the derivative of the step response % finds the inflection point [m,i] % time that the inflection point was observed % magnitude of the step reponse at the inflection point % gradient of the step reponse at the time of the inflection point % find the x and y intercepts % compute the parameters for zn pid tuning, i.e. "r" and "tau" % obtain the pid gains kp, ti, td and n using the zn tuning rules for the reaction % fine tune the gains kp, ti and td to satisfy the control requirements (peak time, % obtain the transfer function of the pid controller. use the command "pidstd". % in the matlab command window, you can type "help pidstd" to understand this comma % obtain the closed-loop transfer function tcl. use the command "feedback" and save % in the following line we use the command "step" to save the the step response in [y,t] = step(tcl); % use the command "stepinfo" to obtain the characteristics of the step response and % check that the control requirements are met 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 https://www.mathworks.com/help/ 18/10/2022, 14:19 mathworks learning tool https://lms-grader.mathworks.com/launch 3/3 assessment: run pretest submit run script © 2020 the mathworks, inc. % in the following line we compute the steady-state error and save it in the variab ess = abs(1 - y(end)) student id make sure the following matlab functions are included in your code. (pretest) check if g1 and g2 are defined correctly. (pretest) overshoot (pretest) peak time (pretest) steady-state error (pretest) 48 49 50 51 52>