Linearise a non-linear simulink pendulum model to obtain


Model linearisation, controller design, closed- loop simulation, and controller implementation.

1. Objectives

• To linearise the non-linear open loop Simulink model created in Lab 2 & 3 using MATLAB and Simulink.

• To design a controller for the ROTPEN kit using the linearised pendulum model.

• To test the performance of the designed controller on hardware.

2. Tasks

• Linearise a non-linear Simulink pendulum model to obtain the matrices A, B, C, D which define the state-space system - see Eq. 1. All hardware gains are taken care of in the Labview program, hence they do not need to be considered in the modelling step.

• Calculate the vector of gains K using pole placement technique.

• Perform closed-loop simulations with the non-linear model using a full state feedback controller with gains K calculated in the previous step.

• Transfer the vector of gains K into Labview and hence implement the controller designed in Matlab/Simulink in Labview.

• Compare the simulation results from Matlab with empirical results obtained on the hardware (ROTPEN kit).

3. Introduction

In this laboratory session your task is to design a full state feedback controller for the ROTPEN kit and test the performance of the designed controller on hardwre. The schematic diagram of a closed loop system with full state feedback is shown in Figure 1. The controlled system is described with a linear time invariant (LTI) state-space relationship.

x = Ax + Bu

y = Cx + Du

1090_Closed loop system with full state feedback.png

Figure 1 Closed loop system with full state feedback

In case of inverted pendulum we have four states ( θ , α , θ? , α?

) which form a vector x in

Figure 1. In our system, all state variables are measured, i.e. the output vector y is equal

to the vector of states x. After the controller has been designed, i.e. we have calculated the vector of gains K , the nonlinear pendulum model in Simulink shall be simulated in closed loop with the new controller in place. If the simulation results are satisfactory, the calculated controller gains shall be input in Labview and the controller shall be tested on the ROTPEN kit. Finally the results obtained from hardware shall be compared with the closed loop simulation results from Matlab/Simulink. All tasks needed for completion of this laboratory session are described in the section below.

3.1. Procedure

a) Assign the parameters Mp (Mass of the pendulum assembly) and Lp (Mass centre of gravity) in the initialization file ‘ROTPEN_parameters.m'.

Open your finished model designed in Lab 2& 3 and linearise the model using the following Matlab command:

[A B C D]=linmod('your_model_name',[0;0;0;0],0);

Please note that when α=0 , it means that the pendulum is in the upwards position and when α=π , the pendulum is facing downwards. Use α=0 for linearisation as initial condition. Why are we linearising the model around the point α=0 ?

For more information about linmod command type: doc linmod or help linmod. In brief, linmod command creates a linear model from the non-linear model around the chosen operating point and returns the linearised state-space representation in form of matrices A, B, C & D. Note down or save the matrices in a .mat file so they can be further processed and included in the report.

b) Calculate the vector of gains K for the linearised model using a pole placement method. The poles we need to choose for this system have been calculated earlier with the lqr method which automatically designs a linear quadratic (LQR) controller More informatio about LQR controller can be found at https://en.wikipedia.org/wiki/Linear- quadratic_regulator. To find out more information about the lqr method in MATLAB please type doc lqr or help lqr in the command window. The computed poles for our system are: ­19.5615, ­6.2370+2.0742i,­6.2370­2.0742i and ­6.0937 (rad/s). The obtained values of poles result from the inherent dynamics of the system including limitations of the actuators, (DC motor).

Define the vector variable poles: poles=[­19.5615;­6.2370+2.0742i;­6.2370­2.0742i;­6.0937];
K= place(A,B,poles);

Once we know the desired closed loop poles we can calculate the required vector of gains such that the final closed loop poles are equal to the desired closed loop poles. We can do it either by hand or use the Matlab command place. For more information about the place command type: doc place or help place. You can now compare the intended poles with the poles of the closed loop system with the full state feedback controller with gains K.

poles_calc = eig(A­B*K);

Plot the desired and final poles in one figure. As an example and a starting point you can use the following sequence of commands, but feel free to modify the figure to suit your needs.

figure(); hold all;
plot(real(poles),imag(poles),'o') plot(real(poles_calc),imag(poles_calc),'d'); title('Pole Placement: specified and resulting poles') xlabel('Real (Hz)')
ylabel('Imaginary (Hz)')
legend('Specified poles','Calculated poles'); grid on;

c) Close the loop using in the Simulink model with the Gain block. Enter K under Gain in the block options and choose Matrix(K*u) as the method of multiplication.

Perform the following closed-loop simulations:

i. Stabilization of pendulum for an initial pendulum angle α of 0.07 radians
(assign this initial value in the Simulink model). Save the results from each simulation in a .mat file using the workspace block.

ii. Stabilization of pendulum with arm position θ subjected to a square wave input

signal with the amplitude of 0.2618 radians and the frequency of 0.05 Hz. To apply a square wave input to the arm, you need to subtract signal generator Simulink block with arm position θ as given in the Figure 2 below; Choose appropriate simulation time for each closed-loop simulation such that you can observe an entire model response. Record the arm angle θ , the pendulum position α and time vector, t in a separate .mat file.

190_Closed loop system with full state feedback1.png

Figure 2 - Simulink block diagram of a closed loop pendulum model

d) Apply the calculated controller gains in Labview in the model ‘QNET_ROTPENT_Swing_Up_Control.vi'.

i. Download and save ‘QNET_ROTPENT_Swing_Up_Control.vi‘ from Blackboard.

ii. Open ‘QNET_ROTPENT_Swing_Up_Control.vi'.

iii. Replace the default Balance Control parameters with the calculated gain vector K.

iv. Select the device name to match your NI ELVIS II device as shown in the NI Measurement & Automation Explorer in the Device control OR select ‘Dev 2' from the drop down menu as shown below.

v. Click on the white right facing arrow in the toolbar to run the Virtual Instrument (VI).

vi. . Slowly raise the pendulum to the upright position. When the pendulum is close to the vertical position the controller will activate and attempt to balance the pendulum. Immediately release the pendulum when you feel the controller engage. Do not attempt to lower the pendulum manually once the controller has engaged!

vii. Change the limits of the X axis on the plots to 0 and 100 sec, respectively. This can be performed by right clicking on the graph, selecting Properties and then Scales.

viii. Export the plotted values using the ‘Export' function by right clicking on each graph. The data will be exported to MS Excel format.

ix. Stop the the Virtual Instrument (VI) by clicking on the ‘Stop' button.

e) Apply the square wave signal.

i. Keep the ‘QNET_ROTPENT_Swing_Up_Control.vi' file open and leave the device selected.
ii. Change the Signal generator parameters to the parameters given below;
Amplitude: 15 deg Frequency : 0.05 Hz Offset: 0 deg

iii. Click on the white arrow from the toolbar to run the Virtual Instrument (VI).

iv. Slowly raise the pendulum to the upright position. When the pendulum is close to the vertical position, the controller will activate and attempt to balance the pendulum. Immediately release the pendulum when you feel the controller engage. Do not attempt to lower the pendulum manually once the controller has engaged!

v. Change the limits of the X axis on the plots to 0 and 100 sec, respectively. This can be performed by right clicking on the graph, selecting Properties and then Scales.

vi. Export the plotted values using the ‘Export' function by right clicking on each graph. The data will be exported to MS Excel format.

vii. Stop the Virtual Instrument (VI) by clicking on the ‘Stop' button.

4. Report

1. Introduction and aims of the experiment

2. Describe the linearisation process around the pendulum angle - both the theory and the procedure performed in Matlab

3. Describe the process of designing a full feedback controller.

4. Plot and analyse the simulation results. By now you should be having all the results saved in separate .mat files.

5. Plot the input and output data from the experiment (Labview) and simulation (Matlab/Simulink). Compare the behaviour of the model with the behaviour of the real pendulum.

6. How do the results of the real system compare with simulation? Formulate conclusions.

Solution Preview :

Prepared by a verified Expert
MATLAB Programming: Linearise a non-linear simulink pendulum model to obtain
Reference No:- TGS01223889

Now Priced at $195 (50% Discount)

Recommended (97%)

Rated (4.9/5)

A

Anonymous user

2/19/2016 12:24:06 AM

The following task is about to Model linearisation, controller design, closed- loop simulation, and controller implementation. 1. Objectives • To linearise the non-linear open loop Simulink model generated in Lab 2 & 3 using MATLAB and Simulink. • To design a controller for the ROTPEN kit using the linearised pendulum model. • To test the performance of the intended controller on hardware. 2. Tasks • Linearise a non-linear Simulink pendulum model to attain the matrices A, B, C, D that describe the state-space system - see Eq. 1. All hardware gains are taken care of in the Labview program, hence they don’t need to be considered in the modelling step. • Compute the vector of gains K using pole placement technique. • Execute closed-loop simulations through the non-linear model using a full state feedback controller with gains K computed in the previous step. • Shift the vector of gains K into Labview and therefore implement the controller intended in Matlab/Simulink in Labview.