Mechatronics laboratory Control of an inverted...

4

Click here to load reader

Transcript of Mechatronics laboratory Control of an inverted...

Page 1: Mechatronics laboratory Control of an inverted pendulumpeople.dti.supsi.ch/~smt/courses/labo_pendulum.pdf ·  · 2008-02-28Mechatronics laboratory, Control of an inverted ... Mechatronics

Scuola universitaria professionaledella Svizzera italiana

DipartimentoTecnologieInnovative

Mechatronics laboratory

Control of an inverted pendulum

��

��

-��

��

BB

BB

BBB

m, Θo BBBBBN

MF

r

Scope Modelling, identification and linearization of a non-linear system

and control using a state-feedback controller

Tasks - Modelling, identification and linearization of the model

- Design of the state-feedback controller

- Design of the full-state observer with measurement of position

and angle

- Design of the reduced-state observer with measurement of po-

sition and angle

- Design of the reduced-state observer with measurement of po-

sition only

Keywords Linearization, state-feedback control, observer

Prerequisites -

References -

Time 8 hours

Appendices -

Contact Silvano Balemi

Page 2: Mechatronics laboratory Control of an inverted pendulumpeople.dti.supsi.ch/~smt/courses/labo_pendulum.pdf ·  · 2008-02-28Mechatronics laboratory, Control of an inverted ... Mechatronics

Mechatronics laboratory, Control of an inverted pendulum SUPSI-DTI

1 Presentation

Consider the system in figure 1.1.

��

��

-��

��

BB

BB

BBB

m, Θo BBBBBN

MF

r

Figure 1.1: Inverted pendulum with cart and pole

The cart is moved by a force F (input to the mechanical system). The physicalvalues of the pendulm are denoted by M for the cart mass, m for the pole mass, Θo

for the pole inertia, r for the distance between the joint and pole center of mass andd for the viscous friction coefficient.

The objective is to control the pendulum in the upright position.

2 Set-up

2.1 Necessary material

Given are following items

• a mechanical system with a cart and a pole. The motor has a torque constantkt = 60.3 · 10−6Nm/mA. The pulley radius is 28.7mm. The system can beaddressed through the CAN bus at the speed of 500kB/s.

• a PC with linux RTAI, Matlab/Simulink, the PCAN library and the s functionsfor the pendulum.

• a PCAN dongle by peak-systems connected to the parallel port of the PC

• a termination connector (D-sub 9 male and female connectors with a 120Ohmresistor between pins 2 and 7) connected to the PCAN dongle

• a serial cable connecting the PCAN dongle with the 120Ohm terminator andthe mechanical system

2.2 Usage

When working on the system the following steps have to be taken.

1. Type the command loadrtai

2 Silvano Balemi November 2007

Page 3: Mechatronics laboratory Control of an inverted pendulumpeople.dti.supsi.ch/~smt/courses/labo_pendulum.pdf ·  · 2008-02-28Mechatronics laboratory, Control of an inverted ... Mechatronics

SUPSI-DTI Mechatronics laboratory, Control of an inverted pendulum

2. transfer your *.m and *.mdl files to the PC using ftp. The name of the differentPCs in the lab are rego1.dti.supsi.ch, . . . , rego7.dti.supsi.ch

3. Download the file www.dti.supsi.ch/~smt/courses/template_pendulum.mdlonto the PC (possibly with a different name)

4. Open Matlab with the command matlab -nojvm (which starts matlab withoutthe Java virtual machine)

5. Copy the content of your *.mdl file into the file template pendulum.mdl. Forinitialization reasons explained below, activate the controller only 10 secondsafter the start of the simulation/program (using an “enabled subsystem”)

6. Start from Matlab your *.m file configuring the controller

7. With the menu Tools/Real-Time Workshop/Build Model compile the modeltemplate pendulum.mdl

8. Switch on the mechanical system

9. From a shell, start the application with the command template pendulum -v.Note that the initial position and the angle are reset to the value 0 respectivelyπ at 1 second after the start of the program (thus, the pole must be kept inhanging position for gathering the correct position).

10. From a shell, start the monitoring program with the command xrtailab

11. From the menus of xrtailab connect to the application, monitor the signal

12. From the menus of xrtailab stop the application (do not kill the applicationtemplate pendulum from the shell: the system may not respond correctly anda reboot may be necessary)

13. Go back to step 6, modify the *.m and the template pendulum.mdl files andproceed with the new tests

14. Switch off the the mechanical system

3 Assignment tasks

1. Find the non-linear motion equations of the pendulum (the angle is positivecounter-clockwise) using Newton’s method. The input is the force applied tothe cart, the output are the position of the cart and the angle of the pole.

2. Find the non-linear motion equations of the pendulum using the Lagrangianmethod. The input is the force applied to the cart, the output are the positionof the cart and the angle of the pole.

November 2007 Silvano Balemi 3

Page 4: Mechatronics laboratory Control of an inverted pendulumpeople.dti.supsi.ch/~smt/courses/labo_pendulum.pdf ·  · 2008-02-28Mechatronics laboratory, Control of an inverted ... Mechatronics

Mechatronics laboratory, Control of an inverted pendulum SUPSI-DTI

3. Consider the presence of the motor driving the belt. Model the DC motor(assume it is ideal), the belt/pulley inertia and the gear (with ratio N = 13/3or N = 1 depending on the motor mounted on the pendulum). Note that theavailable measurements are the angle of the pole and the angle of the motorencoder.

4. Linearize symbolically the non-linear model found in point 3.

5. Identify the system

(a) Remove the pole from the cart and identify the remaining system. De-termine the equivalent cart mass Meq and the equivalent cart frictiondeq.

(b) Weigh the pole and calculate the distance r between the pole joint and thepoint center of mass. Then mount the pole and determine its oscillationperiod Tosc and from that the pole inertia Θ.

6. In Matlab linearize numerically the pendulum.

7. Simulate the behavior of the system with the erected pole in the followingcases:

(a) State-feedback controller with the linearized model of the inverted pen-dulum.

(b) State-feedback controller with the non-linear model of the inverted pen-dulum.

(c) State-feedback and complete observer with the linearized model. Themeasurements are the cart position and the pole angle.

(d) State-feedback and complete observer with the non-linear model. Themeasurements are the cart position and the pole angle.

(e) State-feedback and reduced observer with the linearized model. The mea-surements are the cart position and the pole angle.

(f) State-feedback and reduced observer with the non-linear model. Themeasurements are the cart position and the pole angle.

8. Simulate the behavior of the linearized model of the uprigth pendulum with astate-feedback controller obtained with the LQR method. Try with differentweights of the P and Q matrices (give more or less importance to a singlestate).

9. Implement the LQR controller on the real plant.

4 Silvano Balemi November 2007