Question

In: Electrical Engineering

Develop a detailed model the inverted pendulum system in MatLab/Simulink (a feedback compensator to stabilise and...

Develop a detailed model the inverted pendulum system in MatLab/Simulink (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. T)

Solutions

Expert Solution

%--------------------------------------------------------------------------------------------
% 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);


Related Solutions

How to model an inverted pendulum in matlab and simulink?
How to model an inverted pendulum in matlab and simulink?
write a matlab code to simulate fiber optics communication system on matlab simulink
write a matlab code to simulate fiber optics communication system on matlab simulink
Explain the inverted pendulum for modeling human gait. Then explain why can't this model be a...
Explain the inverted pendulum for modeling human gait. Then explain why can't this model be a good choice for human running?
Create matlab simulink model for dc-dc buck converter with screenshot. Note: provide matlab code for the...
Create matlab simulink model for dc-dc buck converter with screenshot. Note: provide matlab code for the output of dc-dc buck converter if possible.
2- Develop a simulink model for natural PWM inverter connected to a dc source of 100...
2- Develop a simulink model for natural PWM inverter connected to a dc source of 100 V and an output frequency of 60 Hz. The load is a series RL load with R = 10 Ohm and L = 25 mH. Use the simulation to Determine (a) The frequency Ratio to eliminate the 11th harmonic . (b) The fundamental output Voltage V1 (first term of Fourier series) (c) The fundamental output current I1 (d) If the load requires a fundamental...
Simulate the Spring Mass Damper System shown in Fig. Using MATLAB/Simulink, m being the mass of...
Simulate the Spring Mass Damper System shown in Fig. Using MATLAB/Simulink, m being the mass of Vibrating System in Kg. c Being the coefficient of damping in N-sec/m, K being spring stiffness in N/m. For the values m=15kg C=100 N-sec/m k=200 N/m mx''+cx'+kx=f0sinwt
SUBJECT: CONTROL SYSTEM DESIGN (Simulink Model) • What does the ‘Bias’ block do to the input...
SUBJECT: CONTROL SYSTEM DESIGN (Simulink Model) • What does the ‘Bias’ block do to the input sine wave? Describe it. • What is a ‘Subsystem’ and why is it useful when developing a model? • What does the ‘Gain’ block do? What does a gain value of 255/5 mean? • What does the '1023' value do in the Arduino I/O subsystem? • What does the gain value of ‘5/1023’? What is its relationship to an 8-bit digital wave? PLEASE TYPE...
give a detailed matlab code to implement unscented KF on arbitrary first order nonlinear system
give a detailed matlab code to implement unscented KF on arbitrary first order nonlinear system
Develop a construction to show that a system implementing the Chinese Wall model can support the...
Develop a construction to show that a system implementing the Chinese Wall model can support the Bell-LaPadula Model.
cryogenic engineering subject research question. Develop a mathematical model of Claude system driving pulse tube refrigerator...
cryogenic engineering subject research question. Develop a mathematical model of Claude system driving pulse tube refrigerator using R507 refrigerant Nd discuss its impact on system.....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT