Question

Design a feedback control compensator in MatLab/Simulink to keep the pendulum vertical. (a feedback compensator to...

Design a feedback control compensator in MatLab/Simulink to keep the pendulum vertical. (a feedback compensator to stabilise and control the dynamics of a rotating inverted pendulum, as described in Microchip Application Note AN964, “Software PID Control of an Inverted Pendulum Using the PIC16F684” by Charais and Lourens)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

%--------------------------------------------------------------------------------------------
% trans_func_ip_comp.m
% Design and Development of Closed Loop Control for INVERTED PENDULUM
% Closed Loop Compensated Transfer Function of the Inverted Pendulum System
%--------------------------------------------------------------------------------------------
%
% E(s) U(s)
% Vpot --->O---[ C(s) ]--->[ G2(s) ]--->[ G1(s) ]---+---> Theta (s)
% - ^ |   
% | | Theta = SYS * E
% +----------------[ H(s) ]<---------------+
% V viper

% func_ip_uc is a MAT File (MATLAB specific binary file),
% with variables G, GH, Gc, H, Th_U, U_E, num_G, den_G
load func_ip_uc

% C(s) = ( Kd * s^2 + Kp * s + Ki ) / s
% PID Controller to reshape the root locus.
Kp = 20;
Ki = 100;
Kd = 1;
Kc = 30;
num_PID = Kc * [Kd Kp Ki];
den_PID = [1 0];
disp ('The transfer function of the PID Controller is:')
PID = tf (num_PID, den_PID)

% G_comp(s) = PID(s) * G(s)
% Overall Forward Transfer Function.
num_Gcomp = conv (num_PID, num_G);
den_Gcomp = conv (den_PID, den_G);
G_comp = series (PID, G);

% Open Loop Transfer Function of the Compensated System
% G_comp_H(s) = G_comp(s) * H(s)
G_comp_H = series (G_comp, H);

% Closed-Loop Transfer Function of the Compensated System
% Gc_comp
disp 'Closed Loop Transfer Function of the Compensated Inverted Pendulum System is:'
Gc_comp = feedback (G_comp, H)

% DC Gain
disp ('The DC Gain of the Closed Loop Compensated Inverted Pendulum System is:')
disp (dcgain (Gc_comp))
%

% func_ip is a MAT File (MATLAB specific binary file),
% with variables G, GH, H, Th_U, U_E
load func_ip_uc

% Locations of Poles and Zeroes of Open-Loop Transfer Function in Complex Plane
figure
pzmap (G)
title ('Pole-Zero Map of Open-Loop Uncompensated Inverted Pendulum System')

% Impulse Response
figure
impulse (G)
title ('Impulse Response of Open Loop Uncompensated Inverted Pendulum System')

% Step Response
figure
step (G)
title ('Step Response of Open Loop Uncompensated Inverted Pendulum System')

% Locations of Poles and Zeroes of Closed-Loop Transfer Function in Complex Plane
figure
pzmap (feedback (G, H))
title ('Unity Feedback Closed-Loop Uncompensated Inverted Pendulum System')

% Root Locus Plot of Uncompensated System
figure
rlocus (GH)
title ('Root Locus of Uncompensated Inverted Pendulum System')
% Experimental Data of the Inverted Pendulum System
%------------------------------------------------------------------------

% expdata is a MAT File (MATLAB specific binary file),
% with variables exp_data & tout
load expdata

plot (tout,exp_data);
xLabel ('Time (Seconds)');
yLabel('Pendulum Position From Vertical (Degrees)');
Title('Experimental Data');
axis ([0 0.15 -40 40]);
Grid;
% Closed Loop Compensated Transfer Function of the Inverted Pendulum System
%--------------------------------------------------------------------------------------------
%
% E(s) U(s)
% Vpot --->O---[ C(s) ]--->[ G2(s) ]--->[ G1(s) ]---+---> Theta (s)
% - ^ |   
% | | Theta = SYS * E
% +----------------[ H(s) ]<---------------+
% V viper

% func_ip_uc is a MAT File (MATLAB specific binary file),
% with variables G, GH, Gc, H, Th_U, U_E, num_G, den_G
load func_ip_uc

% C(s) = ( Kd * s^2 + Kp * s + Ki ) / s
% PID Controller to reshape the root locus.
Kp = 20;
Ki = 100;
Kd = 1;
Kc = 30;
num_PID = Kc * [Kd Kp Ki];
den_PID = [1 0];
disp ('The transfer function of the PID Controller is:')
PID = tf (num_PID, den_PID)

% G_comp(s) = PID(s) * G(s)
% Overall Forward Transfer Function.
num_Gcomp = conv (num_PID, num_G);
den_Gcomp = conv (den_PID, den_G);
G_comp = series (PID, G);

% Open Loop Transfer Function of the Compensated System
% G_comp_H(s) = G_comp(s) * H(s)
G_comp_H = series (G_comp, H);

% Closed-Loop Transfer Function of the Compensated System
% Gc_comp
disp 'Closed Loop Transfer Function of the Compensated Inverted Pendulum System is:'
Gc_comp = feedback (G_comp, H)

% DC Gain
disp ('The DC Gain of the Closed Loop Compensated Inverted Pendulum System is:')
disp (dcgain (Gc_comp))
% Open Loop & Closed Loop (Uncompensated) Transfer Function of the Inverted Pendulum System
%--------------------------------------------------------------------------------------------
%
% E(s) U(s)
% Vpot --->O--->[ G2(s) ]--->[ G1(s) ]---+---> Theta (s)
% - ^ |   
% | | Theta = SYS * E
% +----------[ H(s) ]<----------+
% V viper

% ip_data is a MAT File (MATLAB specific binary file),
% with variables I, Kf, Km, Lp, M, b, g, l, m, r, tau  
load ip_data

Kp = 1 / ((M + m) * g);
K = Kf * Kp * Km * r * (M + m);
Ap = sqrt ((M + m) * m * g * l / ((M + m)*(I + (m * (l ^ 2)))- ((m * l)^2)));

% G1(s) = Theta(s) / U(s)
% represents a small angle from the vertical upward direction,
% u represents the input (impulse) force on the cart by pulley chain mechanism.
num_Th_U = [0 0 Kp];
den_Th_U = [Ap^(-2) 0 -1];
Th_U = tf (num_Th_U, den_Th_U);

% G2(s) = U(s) / E(s)
% u represents the input force on the cart by the pulley chain mechanism,
% e represents the input to the motor driving pulley-chain mechanism.
num_U_E = [((Km * (M + m))*r) 0];
den_U_E = [tau 1];
U_E = tf (num_U_E, den_U_E);

disp ' '
% G(s) = Theta(s) / E(s)
% Forward Transfer Function (Open Loop Without Feedback)
num_G = conv (num_U_E, num_Th_U);
den_G = conv (den_U_E, den_Th_U);
disp 'Forward Path Transfer Function of Inverted Pendulum System is:'
G = series (U_E, Th_U)

% H(s) (Feedback)
num_H = Kf;
den_H = 1;
H = tf (num_H, den_H);

% Closed Loop Transfer Function of Uncompensated System
% Gc(s) = G(s) / (1 + G(s) * H(s))
disp 'Closed Loop Transfer Function of Inverted Pendulum System is:'
Gc = feedback (G, H)

% GH(s)
% Open Loop Transfer Function
GH = series (G, H);

Add a comment
Know the answer?
Add Answer to:
Design a feedback control compensator in MatLab/Simulink to keep the pendulum vertical. (a feedback compensator to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please show all work and write neatly so that I can understand. All information is given Problem 4 The state-space equations for the simple pendulum is 0 1 25 02 T2 C2 a) Design a state feedback con...

    Please show all work and write neatly so that I can understand. All information is given Problem 4 The state-space equations for the simple pendulum is 0 1 25 02 T2 C2 a) Design a state feedback controller such that the roots of the closed-loop characteristic equation arc at s-41 4j b) Design an estimator that reconstructs the state of the pendulum. Pick the estimator roots to be at s--10 ± 10, (Make sure to provide the dynamics equation of...

  • Problem 2: Given the plant G,le)+2( +3) design a PI compensator Gc(s)-K Ш such the closed-loop...

    Problem 2: Given the plant G,le)+2( +3) design a PI compensator Gc(s)-K Ш such the closed-loop unity feedback system has two dominant poles at s1.2 =-1 ±j. Using Matlab ritool (or simulink), simulate your closed loop system to show that the unit-step response of the system has PO ~ 4.3%, tr 2.35 sec, and 4 ะ 4.15 sec. Compute the closed-loop poles and zeros.

  • Matlab control

    The open-loop system dynamics model for the NASA eight-axis Advanced Research Manipulator II (ARM II) electromechanical shoulder joint/link, actuated by an armature-controlled dc servomotor is shown in Figure P1.The ARM II shoulder joint constant parameters areKa= 12, L=0.006 H, R= 1.4 Ω, Kb= 0.00867, n=200, Km= 4.375, J=Jm+ JL /n2, D=Dm+DL /n2, JL= 1, DL= 0.5, Jm= 0.00844, and Dm= 0.00013.FIGURE P1 Open-loop model for ARM ll(Due to 29/8/2020)a. Obtain the equivalent open-loop transfer function, ?(?) (with a unity feedback...

  • Questions 14-17: For the control system shown below Design the compensator so that the unit-step response...

    Questions 14-17: For the control system shown below Design the compensator so that the unit-step response has a settling-time ofless then twe seconds, rise-time of less th 025seconds, and overshoot ofless than 29%1, adion maximum value ofthe actuator signal ) must be kept under five14) Indicate the allowable region of the complex plane for the closed-loop poles 15) Deterine K and a, the answers are nos unique). 16.) Use Matlab to plot the step-response of the control system using your...

  • PLEASE DO IN MATLAB Problem 8 (PID feedback control). This problem is about Proportional-Integral-Derivative feedback control...

    PLEASE DO IN MATLAB Problem 8 (PID feedback control). This problem is about Proportional-Integral-Derivative feedback control systems. The general setup of the system we are going to look at is given below: e(t) u(t) |C(s) y(t) P(s) r(t) Here the various signals are: signal/system r(t) y(t) e(t) P(s) C(s) и(t) meaning desired output signal actual output signal error signal r(t) y(t) Laplace transform of the (unstable) plant controller to be designed control signal Our goal is to design a controller...

  • Problem 2. (40p) Consider the fooling feedback control system: Y(s) Where 10s 1 S(s+0.5) (s 1)...

    Problem 2. (40p) Consider the fooling feedback control system: Y(s) Where 10s 1 S(s+0.5) (s 1) -12-. That is, design C(s) to Using MATLAB rltool interface design the compensator C(s) have no zeros, two complex poles at $1,2 1t j and gain = 0.12 (i.e. C(s) Please submit screenshots from the rltool interface (include your root locus plots, step response plots, and compensator editor screen) 0.12

  • Matlab needs to be done by matlab Create a root locus plot to determine design a...

    Matlab needs to be done by matlab Create a root locus plot to determine design a control system for the following system which has a standard negative unity feedback system. G(s) = K (s2 - 4s +20)/[(s+2)(s+4)] Damping ratio goal for the control system gain K is to maintain a 45% damping ratio, or zeta = 0.45. Select the gain, K, using the root locus software. O 0.211 O 0.417 0.987 O 1.97 At what gain K does the system...

  • System dynamics and control course. Use only “MATLAB “to solve this. Need a pro to help Let a system have plant transfer function (00.2) s3 +22s 156s+232 Design a PID controller such that the cl...

    System dynamics and control course. Use only “MATLAB “to solve this. Need a pro to help Let a system have plant transfer function (00.2) s3 +22s 156s+232 Design a PID controller such that the closed-loop rise time is less than 0.5 seconds, the overshoot is less than 10%, and the steady-state error is zero for a step command. Let a system have plant transfer function (00.2) s3 +22s 156s+232 Design a PID controller such that the closed-loop rise time is...

  • Design by Synthesis: It is possible to design the PID so that the overshoot of the feedback syste...

    If anyone has Matlab, help me with problem e and f. Thank you. Design by Synthesis: It is possible to design the PID so that the overshoot of the feedback system would be zero, furthermore, the feedback system would behave as a first order system. This is done by noting the PID transfer function: 3. PID Controller Plant Gp (s) R(s) C(s) s2+s+1 Note in the above KPK and Ki/Kp may be chosen so that the numerator of the PID...

  • ' 1. Review Question a) Name three applications for feedback control systems. b) Functionally, ho...

    ' 1. Review Question a) Name three applications for feedback control systems. b) Functionally, how do closed-loop systems differ from open-loop systems? c) Name the three major design criteria for control systems. d) Name the performance specification for first-order systems. e) Briefly describe how the zeros of the open-loop system affect the root locus and the transient response. What does the Routh-Hurwitz criterion tell us? f) 2. Given the electric network shown in Figure. a) Write the differential equation for...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT