0% found this document useful (0 votes)
22 views12 pages

Practicals Labs

Uploaded by

Amos Korir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views12 pages

Practicals Labs

Uploaded by

Amos Korir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

EEE 2507 CONTROL ENGINEERING IV

JOMO KENYATTA UNIVERSITY OF AGRICULTURE AND TECHNOLOGY


BSC IN EEE AND ECE 5TH YEAR SECOND SEMESTER

EEE 2507 CONTROL ENGINEERING IV LABORATORY EXERCISES


ISSUED: 9/10/2024 DUE: 30/11/2024

INSTRUCTIONS
1. In carrying out the following laboratory exercises, you can form groups of 8 to 10 students
each that must be maintained across all the exercises. Use the same groups as in the
assignments.
2. Write lab reports in the constituted groups (but show workload distribution).
3. Use MATLAB & SIMULINK Software.
4. Submit softcopy reports IN WORD FORMAT to laloo@jkuat.ac.ke for the lab exercises.
5. Also, be ready to present if called upon to do so.
6. The labs shall be due for submission on or before 30/11/2024.

1
EEE 2507 CONTROL ENGINEERING IV

Laboratory Experiment 1
TITLE: CONTINUOUS TIME PID CONTROLLER
Figure 1 shows the elements of a closed-loop temperature control system.

Fig. 1.Temperature Control Systems


The walls of the oven have a thermal resistance 𝑅𝑇 and the oven has a thermal capacitance 𝐶𝑇 and
operates at temperature 𝜃0 (𝑡). The heat transfer equation for the oven may be written as
1 𝑑
𝑄𝑖 (𝑡) − 𝜃0(𝑡) = 𝐶𝑇 𝜃0 (𝑡)
𝑅𝑇 𝑑𝑡
The system parameters are 𝐾1 = 5, 𝐾2 = 1.5 𝐽/𝑉, 𝐾3 = 1 𝑉/𝐾, 𝑅𝑇 =2 K/J, 𝐶𝑇 = 22 𝐽𝑠/𝑊.
Required
1. Obtain the systems transfer function and simulate it in MATLAB/SIMULINK for a unit
step input.
2. With the proportional controller, obtain the closed loop time constant, settling time and
steady state error.
3. Increase the proportional gain to 10 and repeat procedure 2 above. Discuss the result
4. Determine the optimal gain and repeat procedure 2 above. Discuss the result
5. Change the controller to a PI with 𝐾𝑃 = 5 and 𝐾𝐼 = 10 controller. Discuss the effects of
the PI controller in the system.
6. Repeat 5 above with 𝐾𝐼 = 2 and discuss the result
7. Repeat 5 above with 𝐾𝑃 = 10 and 𝐾𝐼 = 2 and discuss the results
8. Tune the PI controller to obtain the optimal gains and comment on the results obtained
9. Change the controller to a PD with 𝐾𝑃 = 5 and 𝐾𝐷 = 4 controller. Discuss the effects of
the PI controller in the system.
10. Repeat 9 above with 𝐾𝐼 = 1 and discuss the result
11. Repeat 9 above with 𝐾𝑃 = 20 and 𝐾𝐼 = 1 discuss the results

2
EEE 2507 CONTROL ENGINEERING IV

12. Tune the PD controller to obtain the optimal gains and comment on the results obtained
13. Change the controller to a PID with 𝐾𝑃 = 10, 𝐾𝐼 = 10 and 𝐾𝐷 = 4 controller. Discuss
the effects of the PID controller in the system.
14. Tune the PID controller to obtain the optimal gains and comment on the results obtained
15. Based on the results obtained throughout the procedures, choose the best controller for
this system.
16. Recommend on some of the techniques that can be used to improve on the performance
of the closed-loop temperature control system undertaken in this lab.

Laboratory Experiment 2
DISCRETE CONTROLLER DESIGN IN MATLAB

1. Design a discrete PID controller for the following plants using MATLAB & SIMULINK.

a) G ( s )  Y ( s )  663
Ri ( s ) s  101.71s 2  171s  663
3

b) Y ( s) 97.43
G ( s)  
Ri ( s ) s 3  81.68s 2  481.63s  97.43

1
c) 𝐺(𝑠) = (𝑠+1)(𝑠+2)(𝑠+5)

2. Fig. 2 shows a simplified model of a digital antenna position control system using
servomechanism. Using MATLAB & SIMULINK,
a) Draw a SIMULINK simulation block diagram of the system.
b) Using MATLAB code, find the closed-loop digital transfer function for this system and
determine if the system is stable for 𝐾 = 20 and 𝐾 = 65 with a sampling interval of
𝑇 = 0.2 second.
c) Plot a curve to show variations in output position with time for 𝐾 = 20 and 𝐾 = 60.

Motor-gear-load
Sample Hold Amplifier system
10 Output position
Position + 1 − 𝑒 −𝑇𝑠
_ 𝐾
command 𝑠 𝑠(𝑠 + 10)

Sample

Fig. 2

3
EEE 2507 CONTROL ENGINEERING IV

Laboratory Experiment 3: Non –linear Control


PART 1: Simulating Common Non-linearities in MATLAB
Objective: To simulate common nonlinearities using MATLAB
1. Using MATLAB, simulate the nonlinearities shown in Fig. 3 and Fig.4 and obtain the resultant
output.

Output

K[M-A]

-M -A A M Input

-K[M-A]

Fig. 3

Output
K

-M -A A M

Fig.4

4
EEE 2507 CONTROL ENGINEERING IV

PART 2: Stability Analysis using Lyapunov Methods in MATLAB&SIMULINK


Objective:
To analyze the stability of a nonlinear system using Lyapunov functions and test if the system is
stable, asymptotically stable, or unstable.
Equipment/Software Required:
o MATLAB/Simulink
o Knowledge of Differential Equations
o Basic understanding of nonlinear control systems
Introduction/Theory

See lecture notes

Methodology/Procedure

Here, you are required to choose your own second-order and third systems to run through the steps
that have been highlighted using the second-order nonlinear pendulum system.

1. System Definition:

 Choose a simple nonlinear system, for example, a second-order nonlinear system like a
pendulum:

where 𝒙𝟏 represents the angle, and 𝒙𝟐 the angular velocity.

2. Selection of Lyapunov Function:

 Select a candidate Lyapunov function. For the pendulum system, a suitable Lyapunov
function is:

This function is chosen based on the energy of the system (kinetic and potential energy).

̇
3. Deriving the Time Derivative 𝑉(𝑥):

5
EEE 2507 CONTROL ENGINEERING IV

Compute the time derivative of the Lyapunov function:

Using the system equations, this simplifies to:

4. MATLAB Implementation:
Step 1: Define the Nonlinear System
Create a MATLAB script or function to define the system:
function dxdt = pendulum_system(t, x)
k = 0.5; % Damping coefficient
dxdt = [x(2); -sin(x(1)) - k*x(2)];
end

Step 2: Define and Compute Lyapunov Function

Define the Lyapunov function and compute its derivative:

function V = lyapunov_function(x)
V = 0.5 * x(2)^2 + (1 - cos(x(1))); % Lyapunov function
end

function dVdt = lyapunov_derivative(x)


k = 0.5; % Damping coefficient
dVdt = -k * x(2)^2; % Derivative of Lyapunov function
end

Step 3: Simulate the System

Use MATLAB's ODE solver to simulate the system's response over time:

tspan = [0, 10];


x0 = [pi/4; 0]; % Initial conditions (angle, angular velocity)
[t, x] = ode45(@pendulum_system, tspan, x0);

6
EEE 2507 CONTROL ENGINEERING IV

% Plot the results


plot(t, x(:,1), 'r', t, x(:,2), 'b');
xlabel('Time (s)');
ylabel('States');
legend('x1 (angle)', 'x2 (angular velocity)');
title('System States over Time');

Step 4: Evaluate Stability

Plot the Lyapunov function over time to verify stability:

V_values = arrayfun(@(idx) lyapunov_function(x(idx, :)), 1:length(t));

plot(t, V_values);
xlabel('Time (s)');
ylabel('Lyapunov Function V(x)');
title('Lyapunov Function over Time');

5. Analysis of Results

 The plot of 𝑉(𝑥) should show that the Lyapunov function decreases over time, confirming
that the system is asymptotically stable.
 The plot of 𝑉(𝑥) ̇ should show negative values, confirming that the system’s energy is
dissipating over time.
6. Discussion:
 If the Lyapunov function remains positive and its derivative is negative definite, the system
is asymptotically stable.
 If V˙(x) is negative semi-definite, the system is stable but not necessarily asymptotically
stable.
 If no valid Lyapunov function can be found or V˙(x) is positive for some states, the system
is unstable.

Results and Discussions

Provide a detailed presentation and analysis of the results obtained from your two selected non-
linear systems.

Conclusion
Provide your conclusions here.

References
Provide your references here.

7
EEE 2507 CONTROL ENGINEERING IV

Laboratory Experiment 4: Optimal Control


Part 1: Linear Quadratic Regulator Control Method

1.Given a second order system

𝑥̇ 1 (𝑡) 0 5 𝑥1 (𝑡) 0
[ ]=[ ][ ] + [ ] 𝑢(𝑡)
𝑥̇ 2 (𝑡) 0 0 𝑥2 (𝑡) 1
The system is to be controlled using LQR method to minimize the performance index
1 2
𝐽(𝑥1 , 𝑥2 , 𝑢) = ∫ 𝑢2 (𝑡) 𝑑𝑡
2 0
with boundary conditions

𝑥1 (0) 1 𝑥 (2) 2
[ ] = [ ] and [ 1 ] = [ ]
𝑥2 (0) 1 𝑥2 (2) 1
a) Draw a SIMULINK simulation diagram required to implement the Optimal Tracking
System
b) Design an LQR controller by finding the optimal control law and optimal states, in
MATLAB.
c) Plot variations of the states 𝑥1 (𝑡) and 𝑥2 (𝑡)with time.

PART 2: Lab Title: Optimal Trajectory Planning using MATLAB’s fmincon

Objective:
This lab aims to solve an optimal control problem involving trajectory planning with constraints
using MATLAB's 'fmincon' function. The focus is on optimizing a trajectory while respecting the
given constraints on control inputs, states, and final conditions.

Theory Overview:
In optimal trajectory planning, the objective is to find the best possible path for a system to follow,
minimizing a given performance criterion such as energy consumption or time, while satisfying
system dynamics and constraints on the states and controls.

8
EEE 2507 CONTROL ENGINEERING IV

'fmincon' is a MATLAB function that finds the minimum of a constrained nonlinear multivariable
function. It is widely used for optimization problems with bounds, linear constraints, and nonlinear
constraints.

Problem Definition:
Consider a system described by simple kinematic equations, where the goal is to move an object
from an initial position to a target position in minimum time while satisfying velocity and
acceleration constraints.
The optimization problem is to minimize the objective function representing time, subject to the
constraints on control (acceleration) and state (velocity and position).

9
EEE 2507 CONTROL ENGINEERING IV

Methodology/Procedure
First use the system presented next and then choose your own system to demonstrate the
application of MATLAB's 'fmincon' for solving optimal control problems with constraints. By
using 'fmincon', optimize the trajectory of the selected system while adhering to the given state
and control limits. You may consider real-world applications like robotics, autonomous vehicles,
and aerospace systems.
1. Define the System Dynamics:
The dynamics of a simple point mass system can be defined as:
dx/dt = v (velocity)
dv/dt = u (acceleration, control input)
The state variables are position (x) and velocity (v), and the control input is acceleration (u).

2. Define the Optimization Problem:


The optimization objective is to minimize the total time taken to reach the target position. The
objective function can be expressed as:
J = integral (1, t_f)

where t_f is the final time.


Constraints:

 Dynamics: dx/dt = v, dv/dt = u

3. Implement in MATLAB using fmincon:


To implement the problem in MATLAB, use 'fmincon' to solve the optimization problem.
Follow the steps below to set up the optimization:
a) Define the state vector and control variables.
b) Define the objective function (minimize time).
c) Specify the dynamic constraints and boundary conditions.
d) Implement control and state constraints using nonlinear constraints in 'fmincon'.

For instance, in MATLAB, we will solve the optimal control problem using fmincon. The
fmincon function minimizes a nonlinear objective function with constraints. The function syntax
is:

10
EEE 2507 CONTROL ENGINEERING IV

matlab
Copy code
x_opt = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon)

Step 1: Define System Dynamics

Define the system dynamics in a separate function. This function will represent the evolution of
the state:

matlab
Copy code
function dxdt = system_dynamics(t, x, u)
dxdt = [x(2); u];
end

Step 2: Define the Cost Function

We want to minimize the final time tft_ftf:

matlab
Copy code
function J = cost_function(tf)
J = tf;
end

Step 3: Define Nonlinear Constraints

Include the constraints for velocity and acceleration in a nonlinear constraint function:

matlab
Copy code
function [c, ceq] = nonlin_constraints(x, u, tf, x0, xf)
% Dynamics constraints
ceq = system_dynamics(0, x0, u) - x; % Initial conditions
% Control and state constraints
c = [abs(u) - u_max; abs(x(2)) - v_max];
end

Step 4: Call fmincon

matlab
Copy code
% Initial guess for control input and final time
u0 = zeros(N,1); % Initial guess for control input
tf_guess = 10; % Initial guess for final time

% Bounds on control input


u_max = 2;
lb = -u_max * ones(N,1); % Lower bound on control
ub = u_max * ones(N,1); % Upper bound on control

11
EEE 2507 CONTROL ENGINEERING IV

% Bounds on state variables


v_max = 1.5;
% No direct bounds on the state, managed in nonlin_constraints

% Solve the optimization problem


u_opt = fmincon(@cost_function, u0, [], [], [], [], lb, ub,
@nonlin_constraints);

5. Results and Discussions

After solving the optimization problem, plot the results to visualize the optimal trajectory, control
inputs (acceleration), and the time taken to reach the target position. Verify that the solution
satisfies all the constraints and analyze the behavior of the system.

Once the fmincon function converges, analyze the optimal trajectory and control input. You can
use MATLAB to visualize the position, velocity, and control input as a function of time.

matlab
Copy code
% Simulate the system with the optimal control input
[t, x] = ode45(@(t,x) system_dynamics(t, x, u_opt), [0, tf_guess], x0);

% Plot results
figure;
subplot(3,1,1);
plot(t, x(:,1)); xlabel('Time (s)'); ylabel('Position (m)');
title('Optimal Position vs Time');

subplot(3,1,2);
plot(t, x(:,2)); xlabel('Time (s)'); ylabel('Velocity (m/s)');
title('Optimal Velocity vs Time');

subplot(3,1,3);
plot(t, u_opt); xlabel('Time (s)'); ylabel('Acceleration (m/s^2)');
title('Optimal Control Input (Acceleration) vs Time');

Conclusion
Provide your conclusions.
References
Provide your references here.

END OF LAB PRACTICALS

12

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy