• No results found

Introduction to the control of an inverted pendulum setup

N/A
N/A
Protected

Academic year: 2021

Share "Introduction to the control of an inverted pendulum setup"

Copied!
59
0
0

Bezig met laden.... (Bekijk nu de volledige tekst)

Hele tekst

(1)

Introduction to the control of an inverted pendulum setup

Citation for published version (APA):

van den Berg, H. W. J. (2003). Introduction to the control of an inverted pendulum setup. (DCT rapporten; Vol. 2003.056). Technische Universiteit Eindhoven.

Document status and date: Published: 01/01/2003

Document Version:

Publisher’s PDF, also known as Version of Record (includes final page, issue and volume numbers)

Please check the document version of this publication:

• A submitted manuscript is the version of the article upon submission and before peer-review. There can be important differences between the submitted version and the official published version of record. People interested in the research are advised to contact the author for the final version of the publication, or visit the DOI to the publisher's website.

• The final author version and the galley proof are versions of the publication after peer review.

• The final published version features the final layout of the paper including the volume, issue and page numbers.

Link to publication

General rights

Copyright and moral rights for the publications made accessible in the public portal are retained by the authors and/or other copyright owners and it is a condition of accessing publications that users recognise and abide by the legal requirements associated with these rights. • Users may download and print one copy of any publication from the public portal for the purpose of private study or research. • You may not further distribute the material or use it for any profit-making activity or commercial gain

• You may freely distribute the URL identifying the publication in the public portal.

If the publication is distributed under the terms of Article 25fa of the Dutch Copyright Act, indicated by the “Taverne” license above, please follow below link for the End User Agreement:

www.tue.nl/taverne

Take down policy

If you believe that this document breaches copyright please contact us at:

openaccess@tue.nl

providing details and we will investigate your claim.

(2)

TU/e

technische universiteit eindhoven

Introduction to the control of an

inverted pendulum setup

H.W.J.van den Berg

July 2003

Report nr. 2003.56

TU/e

-

traineeship

Coaching:

Prof. I.Mareels

Prof.dr. H.Nijmeijer

University o f Melbourne

Department o f Electrical

&

Electronic Engineering

Eindhoven University of technology

Department o f Mechanical Engineering

Section Dynamics

&

Control

(3)
(4)

Contents

1 Introduction 1

2 The inverted pendulum model 3

. . .

2.1 Setup introduction 3

. . .

2.2 Derivation of the model 4

3 Parameter Estimation 9

. . .

3.1 System calibration 9

. . .

3.1.1 The servo potentiometer 9

3.1.2 The optical encoder . . . 10

. . .

3.1.3 The motor dead zone 12

. . .

3.2 Parameter estimation experiments 12

. . .

3.2.1 Directly measured parameters 13

3.2.2 Parameters from pendulum experiment . . . 13 3.2.3 Parameters from total setup experiment

. . .

14

4 Controller suggestions 17 . . . 4.1 Swing up controller 17 . . . 4.2 Balancing controller 20 . . . 4.3 Switching strategy 22

. . .

4.4 Simulations 23

(5)

contents

5 Conclusions & recommendations 25

5.1 Conclusion

. . . .

.

. . . . .

. . . .

. .

. .

.

. . . . 25

5.2 Recommendations

.

. . .

. . . . . . . . .

.

.

. . . .

. .

25

Bibliography 27 A Calibration of the servo potentiometer 29 B Calibration of the optical encoder 35 C Motor dead zone-experiment results 37 D Total results parameter estimation 39 D . l Results parameter estimation part 1

. .

. . . .

. . . . . . . .

. . .

.

. . 39

D.2 Results parameter estimation part 2

. . . . . . .

. . .

. . . . . .

39

E Sirnulink model 43 F Manual for controlling the KRi Inverted Pendulum PP-300 45 F.l Running an existing program, with no output

. .

. . .

. . . . . .

45

F.2 Running an existing program, providing output

. . . .

. . .

.

. . .

. . .

48

F.3 Write a new program .

. . .

. . . . .

. . . . . . .

. .

. . . . . . . . .

49

(6)

List

of

Figures

. . .

2.1 The Inverted Pendulum setup 4

. . .

2.2 Schematic drawing of the setup 5

. . .

2.3 Motor electrical model 6

. . .

2.4 Dry friction in rotation of the arm 7

. . .

3.1 Measuring range potentiometer 10

. . .

3.2 'Crossing-over noise' 10

. . .

3.3 'Behaviour of armpos and armposabs' 11

. . .

3.4 Error in sine input signal 15

. . .

4.1 Geometric illustration of the swing-up strategy 19

. . .

4.2 Control scheme 1 21 . . . 4.3 Control scheme 2 22

. . .

4.4 System response 24

. . .

A.l The servo potentiometer

. . .

A.2 Explanation measurement points Program 4

. . .

B . l Calibration experiment 36

. . .

F . l Reset target system 46

. . .

F.2 Program ready for communication 46

. . .

F.3 Program running 47

. . .

(7)

LIST OF FIGURES

F.5 Program running. producing output

. . .

48

. . .

F.6 Stop Program. no direct response 49

F.7 Compiling terminated successfully

. . .

50 F.8 Linker executing in MatLab command window

. . .

51

(8)

Chapter

1

Introduction

The inverted pendulum setup is very popular for educational purposes and forms a typical example of an underactuated system. A study with this purpose was executed for an internship, which is part of the study Mechanical Engineering a t the Technical University Eindhoven.

The goal of this project is to build a controller which is capable of performing the balancing act with the available setup, preferable with minimum motion of the setup. To accomplish this several steps are passed through. First a model for the available Kri Inverted Pendulum pp-300 setup will be designed. Since the setup hasn't been used before, next a calibration of the integrated instruments is made. For the project two identical setups are available, so all experiments will be executed in duplicate. Next a parameter estimation is performed. After this the actual design of the controller can start. Since the setup isn't supplied with a suitable manual it is necessary t o start with gaining some experience how to run the setup a t all first. At the end the obtained results can be compared with the predicted simulation.

The practical part of this internship was performed a t the Melbourne University, Aus- tralia, a t the Department of Electrical and Electronic Engineering, under the supervision of prof. Iven Mareels. The final report was written in the Netherlands again, under the supervision of prof. Henk Nijmeijer.

(9)
(10)

Chapter

2

The

inverted pendulum model

2.1

Setup introduction

Before we can start with composing a model, it must be clear what kind of setup is involved. A picture of the total setup is shown in figure 2.1. The setup has two degrees of freedom: the rotation of the arm, and the rotation of the pendulum rod. The rotation of the arm is powered by a motor and measured with a optical encoder; the rotation of the pendulum rod is free and measured with a servo potentiometer. The calibration of these instruments is mentioned in section 3.1.

The setup is connected to a P C via the COM-port. The software used runs in a DOS- environment and can only be used off-line. It is written in the program-language C. The program to run the setup has to be loaded into the local controller board, after which it can be started. Afterwards measured data can be loaded back into the PC. The amount of data is limited by the controller board memory to 4100 data points. Since this is the total of data points that can be stored, the time that can be measured decreases when more than one variable has to be stored. The program loaded contains a control function, which is executed every 0.01 second. Therefore the maximum measurement frequency is 100 Hz. Because of the limitations of flops that can be executed within this 0.01 second the complexity of the control function will be bounded. With the experiments executed for this project this boundary was never reached. The signal from the servo potentiometer is transfered to the base structure by a copper on copper wiper. This wiper also introduces a non-constant friction. This can be overcome partly by always running a warming up program before measurements are started. Still this makes the system time-dependent, and so once in a while some parameters of the system have t o be estimated again.

(11)

Chapter 2. The inverted pendulum model

Figure 2.1: The Inverted Pendulum setup

2.2

Derivation of the model

The derivation of the model will start with the Lagrange equations of motion. These will be derived step by step now. First we choose a set of generalized coordinates:

Here a is the rotation of the arm, and ,O is the rotation of the pendulum rod. The direction of positive movement is clarified in figure 2.2.

The first step is t o derive the kinetic energy of the system. To do so the position of the considered mass m l , located a t the center of mass of the pendulum rod, must be expressed in the generalized coordinates. This leads to:

locosa - Llsinasin,O 10sina

+

11cosasinp

-I1 cos

p

Taking the time-derivative of this expression, we obtain the speed of mass m l : - d o sin a - 1511 sin a sin ,8

+

,811 sin a cos ,L?

. . .

I =

(

do cos a

-

dl sin a sin ,O

+

,bll cos a cos

0

(12)

2.2. Derivation of the model

Figure 2.2: Schematic drawing of the setup

The total kinetic energy of the system becomes:

When we combine (2.3) and (2.4), we obtain after some simplifying :

1 2 2 1 2 2 2 1 2 . 2 1 1

T = -ml& lo

+

- m l b 1, sin

P

+

-mlllP

+

m l c i b ~ o ~ ~ cosp

+

-

J,,b2

+

- JZ0b2 (2.5)

2 2 2 2 2

Here lo and 11 are the lengths as shown in figure 2.2, while Jzo and J,, stand for the inertias of the arm and the pendulum rod, respectively. Next, the potential energy of the system is expressed in terms of the generalized coordinates:

To bring the viscous damping into account, now the virtual work will be implemented. First we take the work from the virtual displacement bqT - = [&a, 01:

6W = -[Cob]6a

+

r,,ba = &,ha (2.7) Next we apply hqT - = [O, bP], which leads to:

bW = -[~l,b]b/3 = QpbP This leads to the nonconservative generalized forces:

Cob

+

-r,

Qnc =

[

-

-clb

(13)

Chapter 2. The inverted pendulum model

Figure 2.3: Motor electrical model

Now we can apply Lagrange's equations of motions, which are defined as:

Resulting in the equation of motion:

In standard notation:

Co

+

$rnll$sin2p $rnll:&sin2@ - mlloLl s i n ~ j

rnl&lf cos

p

c1

I[;]+

(2.12)

With this equation of motion we have a start for the model we want. The next step is t o define T,, since the input given to the setup is not a real torque. The input given is a real

number (positive or negative) with no unit. The scheme for the motor is shown in figure 2.3. The input given in the computer will be called u, and now a relationship between

u and rm will be derived. The voltage Vm is a result from conversing and amplifying

the input u with a factor Ku, which we will call the gain of the PWM Amplifier:

(14)

2.2. Derivation of the model

Figure 2.4: Dry friction in rotation of the arm

I, armature coil current

Ra armature coil resistance La armature coil inductance

Eb motor's back EMF

The motor's back EMF, Eb, is proportional to the rate of change of magnetic flux and

hence proportional to the angular velocity of the motor:

For a constant field current, the torque T exerted by the motor is proportional to the

armature current. This leads to:

When we assume that the coil inductance has a a negligible influence, the torque exerted by the motor becomes:

The last thing not implemented yet is the dry friction present in the setup. The friction present in the rotation of ,B is considered to be totally modelled by the viscous damping term in the model. The friction present in the rotation of a proves to have a dry friction component, by its behaviour: when the input u increases, starting from zero the motor won't start moving until a dead zone is overcome. Next, when the input decreases, the arm stops before zero input is reached, but a t a smaller input as when the arm started moving. The friction behaviour is visualized in figure 2.4.

In equation-form a split has to be made between & = 0 and &

#

0. For &

#

0 the friction

(15)

8 Chapter 2. The inverted pendulum model

with

Kf

the friction coefficient. For & = 0 the friction can take any value between -Mf,maz and Mf,maz, and will be implemented as M s f , the moment resulting from the

static friction. Since mostly a moving setup is considered, the friction for dL

#

0 will be implemented in the model.

When (2.12), (2.17) and (2.18) are combined, this leads to the total model for the inverted pendulum setup:

J,,

+

mil;

+

mllf sin2

p

mlloll cosP mlloll cos

p

J,,

+

mil;

]

[;I+

K t K b

+

imlltbsin2/3 ~ r n l l ~ & s i n

20

- mlloll s i n p b

mid;

cos

p

Cl

] [ ]

+

(2.19)

(16)

Chapter

-

3

Parameter

Estimation

3.1 System calibration

To be sure that the data loaded from the system is interpreted the right way, a calibra- tion will precede the parameter estimation. Since there are two setups present for this project, there will be two results per calibration.

3.1.1 The servo potentiometer

For the calibration of the servo potentiometer no input signal is given, while the pen- dulum rod is moved manually and only the movement of ,Ll is recorded. The separate results of these measurements are given in Appendix A. The resulting signal varies be- tween 0 and 1023 (counts). At the start in all used C-programs the downward position is set to 0, so the position can also get negative values. For setup 2, the measure area covers 337', and the remaining 23' is a blind zone. This blind zone is located between

0

= 230.4' and

p

= 253.2'. For setup 1, the blind zone is not present, and the values from 0 t o 1023 are equally spaced over the 360'. The crossover point is located a t

p

= 107.7' (crossover point: point where signal jumps from 1023 to 0 or vice versa). This is illustrated in figure 3.1. The specifications mention a blind zone of 20°, and an accuracy of 15% for the resistance of the potentiometer. This resistance is not measured since the software already transforms this into counts. For setup 1 the distribution leads to 256 counts per 90°, e.g. 1 count stands for 0.351'. For setup 2 it leads to 273 counts per 90°, e.g. 1 count stands for 0.330'.

Unfortunately the servo potentiometer also gives an output while jumping from 0 to 1023 or back; in this area the potentiometer returns a random value. This can be seen as a systematic form of noise. Especially when building a controller this effect should not be neglected, but while performing normal measurements it can easily be seen which data points are a result of this effect. It is illustrated in figure 3.2. This measurement was

(17)

Chapter 3. Parameter Estimation

Setup

1

Setup

2

Figure 3.1: Measuring range potentiometer

Pendulum position (counts)

800 1 I 3

-400 I I

0 5 10 15 20

time (s)

Figure 3.2: 'Crossing-over noise'

performed with a measurement frequency of 100 Hz, while the pendulum rod continues crosses the 'crossover' point, backwards and forwards from ,6 = 180° and ,6 = 270°. The normalizing option was active this time (set ,6 = 0' to counts = 0).

3.1.2 The optical encoder

For the calibration of the optical encoder the same method is used as with the servo potentiometer: manual movement of the arm while the encoder signal is recorded.

(18)

3.1. System calibration

x

l o 4

armpos

-5

1

I , I I I I I I I

i

0 1 2 3 4 5 6 7 8 9 10

l o 4

armposabs

Figure 3.3: 'Behaviour of armpos and armposabs'

In contrast to the potentiometer, the optical encoder records movement instead of a position. This means no information can be gathered about the absolute position of the arm a (generalized coordinate, see chapter 2.2), or a t least no more then relative t o the starting point. Since a is not explicitly present in the model this doesn't matter. The program that controls the setup can record armvelo, armpos and armposabs, which suggests that we can get a velocity and a position from the arm. armvelo turns out t o be just the difference in position from every measurement, and armpos and armposabs are both the sum of all previous armvelo-values. Unfortunately armposabs is set to zero every time a certain value is reached, as well in positive direction as in negative direction. armpos is bounded and every time the value crosses the boundary it jumps to the other boundary and continues. The problem with this is that the exact location of the boundaries can not be extracted from the software, and the measurements show variation in this boundary. The behaviour of both armpos and armposabs is illustrated in figure 3.3.

To overcome this problem a new function is added to the software, which works as armpos, but now has known boundaries. These boundaries are set to 0 and 6528 for setup 1, and 0 and 6544 for setup 2. These boundaries are coupled to a = O0 and

a = 360°. Since a has now absolute meaning, this is just every time the starting point of a measurement. The counts registered per rotation is determined by turning the arm round as much times as possible without crossing the boundary set in the software. This way we get an average of 52228 counts per 8 rotations for setup 1, and 52355 counts per

(19)

12 Chapter 3. Parameter Estimation

8 rotations for setup 2. All the results from these measurements are shown in Appendix B. It results in 18.1 counts per degree for setup 1, and 18.2 counts per degree for setup 2. I t is tried to integrate this conversion already in the .c-file so the output would be a position in degrees instead of counts, but for an unknown reason this doesn't work properly.

3.1.3

The

motor dead zone

As mentioned before the input of the motor has to exceed a certain value before the arm will start moving, due to static friction in the arms suspension and motor. To be able to design experiments which do not endure the effect of switching between static and dynamic friction these bounderies have to be known. Two types of experiments have been performed to measure the transition from static to dynamic friction (for which input does the arm start moving); the first type increases the input step by step, the second type does the same, but jumps back to zero input in between every time. Next, an experiment has been performed to measure the boundery for the transition from dynamic friction to static friction (for which input does the arm stop moving). Unfortunately no data records are available from this experiment. Every experiment has been performed for clockwise motion as well as counterclockwise motion. The average of the results are listed in table 3.1. The total results are listed in appendix C.

Table 3.1: Average results motor dead zone -. .- - "

I t can be concluded from these results that for parameter estimation experiments the absolute input should stay above 65 for setup 1, and above 30 for setup 2. It is clear that it makes a difference whether an input value is given a t once or is approached from a lower value. This can prove t o be important when designing a controller. Furthermore the dry friction in setup 1 proves to be large: when the arm finally starts moving this instantly results in a high rotation speed. Though no exact results can be showed from the dynamic friction lower boundery, this boundery showed to be significantly lower in relation to the presented values for the static friction boundery for setup 1. For setup 2 the difference was nihil.

Setup 1

Setiln 2

3.2

Parameter est irnat ion experiments

Positive input, shockwise

The parameters to be determined can be divided in 3 groups: parameters that can be

measured directly, parameters that can be estimated with an experiment considering Positive input Negative input -67.4 -29.2 Negative input, shockwise -48.6 -26.6 63.0 -29.8 54.8 25.8

(20)

3.2. Parameter estimation experiments

only the pendulum rod and parameters that can only be estimated from an experiment considering the total setup. Which parameters have to be determined and t o which category they belong is shown in table 3.2.

Table 3.2: Classification ~ a r a m e t e r s

I

Directly measured

11

m ~ , 10, 11

It shows 12 parameters that have to be estimated. This can be reduced to 10 parameters, since the 4 parameters from the motor only arise in the model in combination with each

Kt K",

other

(v

and

x).

Experiment i n v d v i ~ g penduhm re:! Experiment involving total setup

3.2.1 Directly measured parameters

A,,

Ci

JZO, CO, Kt,

&,

K W R a ,

Kf

As said, the lengths lo, I1 and the mass m l can be measured directly. The results:

3.2.2 Parameters from pendulum experiment

The first experiment executed considered only the movement of the pendulum rot Comment Measured directly Measured by manufacturer Measured bv manufacturer Parameter 10 11 ml

input is given, a and its derivatives are zero, and the free vibration of the pendulum is

recorded. For this experiment the model (2.19) reduces to: Result

151.7 mm 145 mm 27.4 gram

mlloll cos

,D

-mlloll s i n p p Jz,

+

mil;

] m +

[

c1

Remark that in the first equation the term M s f is present again, since we consider the

situation of d! = 0 (see section 2.2). The first equation will only provide the magnitude of M s f , which is of no interest here. Therefore this equation will not be used in this part of the parameter estimation.

Only the second equation contains not yet estimated parameters, and can be recognized as the standard equation for the pendulum. The first term, (J,,

+milt),

is the moment of inertia concerning the rotating point of the pendulum, constructed in relation t o the normal moment of inertia with Steiner's law. From now on this term will be referred to as J,, . For setup 1 6 experiments have been performed, for setup 2 4 experiments.

(21)

Chapter 3. Parameter Estimation

The data is filtered with a first order filter, having a cut-off frequency of 1.67 Hz a t the sample frequency of 100 Hz. The MatLab-function f iltf ilt is used for this filter. This function first filters the data in forward direction, and next the filtered sequence is reversed and run back through the filter; the result has zero phase-disturbance this way. The transfer function of the filter is:

The derivatives are calculated using the central difference method. Next, the parameters are fit using the least square method. The total results of these fits can be found in Appendix D.1. The average values that result are:

3.2.3 Parameters from total setup experiment

J,, ( k g . m 2 )

For the last part of the parameter estimation several experiments have been performed. Every time an input signal is given and both the signal from the servo potentiometer and the optical encoder are recorded. Since every experiment is performed a t the maximum of 100 Hz, the time limit to record information is 10 seconds. The input signals chosen are a sine with a frequency of 2 Hz and one of 10 Hz. Both the sinusoids are superpositioned to a constant signal, so the movement of the arm is in one direction during a whole experiment. This way the difficult and non-linear friction that occurs when crossing c i = 0 will not disturb the experiment. Because of the discrete input for the setup, several points of the sine have to be defined in the .c-file. For the 10Hz sine these are 10 points per period, for the 2 Hz sine these are 50 points per period. Since the input can only be a real number, the actual input is not a real sinusoid. The kind of input signal that results is illustrated in figure 3.4. This will introduce high-frequency terms in theory, but since the motor is a relative slow mechanic object, this influence will likely be negligible. Since all data is filtered before the parameter fit is executed, this effect is not retraceable in the measured data.

Setup I Setup 2 0.7870 0.7882

For the sine signals of 2 and 10 Hz, a different filter has to be used. For the measurement of the 2 Hz signal, a filter with a cut off frequency of 3.24 Hz is chosen. Its transfer function is:

The results are passed through the filter twice, to obtain a second order filter. For the measurement of the 10 Hz signal, a filter with a cut off frequency of 16 Hz is chosen. Its transfer function is:

(22)

3.2. Parameter estimation experiments

Detail of input signal 2 Hz

Figure 3.4: Error in sine input signal

To fit the unknown parameters, these first have to be isolated in the model equation. This becomes:

2 . 2

mllg

+

mill

sin ,B mlloll cosp

mlloll cos

0

J ~ l

]

[;I+

~ m l l ~ b s i n 2 , B kmll?&sin2,B - mlloll sin,Bb

mlct.L? cos

,D

~1

]

[:]+[mgil('sino] =

It shows the second equation has no influence on the remaining unknown parameters, so this time only the upper equation will be used. Since it is impossible to distinguish the contribution of Co and separately, these will be estimated together as one parameter. This reduces the number of parameters still to be estimated to 4. The total results for the fit can be found in Appendix D.2.

The total listing of the results shows that still an error is present, since the scatter of the results is more then acceptable. The table also shows that for some fits a negative

(23)

Chapter 3. Parameter Estimation

value results for a parameter, while this is physical impossible. Only the results from setup 1 with the experiment a t 2 Hz look acceptable. Since no explanation for this can be given, the reliability of these results can be questioned as well. Taking the average value of the results, the next parameters result; see table 3.3.

Table 3.3: Average result parameter estimation sine 2 Hz

I

Setuz, i

Since no satisfactory results are obtained, the method of a extended Kalman filter is recommended t o apply for this estimation. Unfortunately the time available for this project did not allow to do so already.

Another option to solve this problem is to alter the model used for the parameter estimation. Such a model evaluation was not possible within the limited time either.

(24)

Chapter

4

Controller

suggest

ions

The time for this project didn't allow to design and test a controller, but still some suggestions can be given about what kind of controller could be able to perform the balancing act. Since the goal of this project was model-based control, no attention will be given to fuzzy controllers.

After studying some literature it shows many already existing controllers consist of two parts: a swing up controller and a stabilizing controller. The first part brings the pendulum near the upright position, and when this is done the second controller takes over and tries to keep the pendulum in this upright position. Such controller will be the objective of this design.

4.1

Swing

up

controller

The swingup of the pendulum can be realized with two different types of controllers: a minimum time controller and an energy based controller. The last one was first presented by Furuta and Astriim

[Aoo]

in July 1996 and is focussed purely on the acceleration of the pivot. It will also be the focus for this section.

When we consider only the pendulum itself and the acceleration of the pivot, and neglect all friction effects the second part of the equation of motion (2.19) reduces to:

The first part of the equation of motions describes the dynamics of the rotary arm, which is out of scope here. The term up will be the input for the isolated pendulum, being the acceleration of the pivot. For the total system up is equal t o lo&. lo& cannot

be controlled directly, since this term depends on the dynamics of the rotary arm. That part will deliberately be neglected temporary, for clarity of the intended strategy.

(25)

Chapter 4. Controller suggestions

Taking the state variables as ,8 and

b,

this state space system has two equilibria:

P

=

0,

p

= 0 and

p

= T,

,b

= 0. The energy of the uncontrolled pendulum (& = 0) is: 1

E = - J,,

b2

+

mlgZ1 (- cos ,LI - 1)

2 (4.2)

By defining it this way the energy of the pendulum is zero for the pendulum in upright position. Now the number of parameters present in (4.1) will be reduced. Introduce the normalized variables wo =

@,

7 = = wot and v =

*.

Inserting these

9

in (4.1) the equation of motion 'becomes:

This system is characterized by two parameters only, namely the natural frequency for small oscillations wo and the normalized maximum acceleration of the pivot which we define as n = v,,, = up,,,,/g. This means the maximum acceleration of the pivot is scaled to the acceleration of gravity. This n will prove to be very important for swingup control. The idea of this energy based method is to increase the energy of the pendulum from -2mlgll to zero, to balance the pendulum upright. The rate of change of the energy is limited by n. This will be illustrated by the following example. Consider the situation as illustrated in figure 4.1. The pendulum is located a t point A, having zero velocity. Now let the pivot accelerate with the maximum acceleration ng = up,,,, to the right. This way the gravity field seen from an observer fixed t o the pivot gets the direction OB, with angle

Po

= arctann and magnitude

gJm.

The pendulum will now swing symmetrically around OB, and will thus reach zero velocity at point C, located a t the angle cp

+

2Po. Now the pendulum has increased its swing by 2Po and will do so again for each reversal of the acceleration of the pivot. By this strategy energy can simply be pumped into the system, and as shown the energy added per swing is proportional to 2,LIo = 2 arctan n.

After pumping energy in the system we want to catch the pendulum in upright position. The energy of the uncontrolled pendulum was given in (4.2). To perform energy control it is necessary t o understand how the energy is influenced by the acceleration of the pivot. Taking the derivative of this energy with respect to time and combining it with (4.1) Ieads to:

dE

- =

J,,bp

+

mlgllbsin /? = -mlupllb cos

0

dt (4.4)

Since up is our direct input for the isolated pendulum it is easy to control the energy. This also means that controllability is lost when = 0 or when ,LI = f ~ / 2 , since a t these points the derivative of the energy becomes zero, regardless of the chosen input up . Physically this happens when the pendulum is horizontal or when it reverses its

(26)

4.1. Swing up controller

Figure 4.1: Geometric illustration of the swing-up strategy

velocity. It shows this system is simply an integrator with varying gain. To increase energy the acceleration of the pivot up should be positive when the quantity

b

cos

P

is negative. A control strategy is easily obtained by the Lyapunov method. With the the Lyapunov function V = (E - ~ 0 ) ~ / 2 and the "control law"

we find that

d'i

= -rnlllk((E -

Eo)b

cos ,l?)2

dt (4.6)

As said before this method only considers the acceleration of the pivot, and therefore

ti

will be considered as an directly controlled input here, with no regards to the dynamics of the arm. The Lyapunov function decreases as long as

,b'

= 0 and coso

#

0 . Since

the positions

p

= + ~ / 2 (for which coso = 0) are not maintainable as stable positions strategy (4.5) drives the energy to the desired value E o . There are many other strategies which do so as well. To change the energy as fast as possible the magnitude of the control signal should be as large as possible. The control law

achieves this. This control law may result in chattering when used for the total control of the pendulum, instead of being part of a hybrid controller. In such case a n identical law which saturates a t ng would be better. Both (4.5) and (4.7) give no input signal when the swing up is started with the pendulum in downward position a t rest. This will restrain the pendulum from moving.

(27)

Chapter 4. Controller suggestions

Depending on the size of n , a swing-up behaviour results that is rather simple for large n, and becoming more complex for smaller n. For large n (n

2

$) the pendulum can be brought upright with one swing. For smaller n it might take the controller several swings to increase the energy enough and bring the pendulum upright. Several examples of this swing-up behaviour are discussed in [Aoo].

The size of n is also expected to determine the advantage of energy control above minimum time strategy control; the last one is very sensitive for large n. Beca-cise

the minimum time strategy always uses the maximum acceleration of the pivot, this results in an overshoot of inserted energy. This energy has to be dissipated again when the pendulum approaches the upright position. This overshoot is 50% for n = 2 and increases rapidly, being 200% already for n = 5.

When the pendulum is brought to its upright position the hybrid controller can switch to the balancing part to keep it upright.

4.2

Balancing controller

The simplest way of balancing the pendulum is with a controller based on the linearized model around the equilibrium point. This has the disadvantage of a limited attraction region, but with a clever switching strategy towards the swing up controller it should be capable of giving satisfying results. Other controllers which are based on the non-linear model still have the limit of being only globally stable. The focus of this section will be a controller based on the linearized model.

At first the linearisation of the model (2.19) has to be derived. The state of the system

z ( t ) is chosen [ a: &

/?

p

I T .

Linearizing a t & = 0, a: = 0,

B

= 0,

/?

= .ir and neglecting the coulomb friction the linear model becomes:

For clarity the following variables will be introduced:

a = J,,

+

mlli b = mlloll c = Jrl d = Co

+

9

e = mlgll

f

= E 2 L R a

(28)

4.2. Balancing controller

Now t h a t we have the standard from of x = Ax(t)

+

Bu(t) the controllability of the

system is checked. To do this the controllability matrix P is calculated:

with

The rank of this matrix is 4, as is necessary for the system to be completely controllable. Implementing a standard state feedback control gives the following system.

Figure 4.2: Control scheme 1

With r being the desired position of the pendulum and u the input of the system the

controlled state of the system becomes: x = ( A - B K ) x

+

B r . The Matlab function 'acker' can calculate the values for the feedback gain matrix K, given the A and B matrices, when the poles of the controller are chosen. The C matrix can is chosen

[

1 1 1 1

1.

Simulations have only been performed using arbitrary values for the parameters, so no useful poles can be given here. The poles resulting from the chosen parameter values are included with the simulations.

A second suggestion for the balancing controller also includes an integral action. The scheme is as follows:

(29)

Chapter 4. Controller suggestions

Figure 4.3: Control scheme 2

This leads to the controlled state space model:

( A - B K - KpBC) B

[

:

]

=

[

-&C 0

Again the feedback gain matrix K can easily be calculated with the function 'acker'. Next the values for K p and Ki can be designed. Finally the location of the poles are

checked with K p and Ki included, which is done by checking the eigenvalues of the

'new' A-matrix from (4.11).

4.3

Switching strategy

To keep the pendulum straight up, and to get maximum profit from each of the separate controllers a well chosen switch strategy has to be implemented. Because of the limited validity of the linearized model, it will only be used in the area for ,b' = [160°, 200'1. Furthermore the energy based controller is expected to be more efficient in dissipating energy. Therefore, the linearized controller will only take over for limited

8.

To preserve the controller from chattering, it could be designed in such a way, that the linear controller takes over a t the bounderies ,L? = 165" and ,b' = 195", but restrains from switching back to the energy based controller until ,L? = 160" or is /3 = 200" is passed. The maximum velocity of the pendulum for which the linear controller still takes over should be experimentally determined.

(30)

4.4. Simulations

4.4

Simulations

To found the controller suggestions given above, simulations have been performed in MatLab Simulink. The exact Simulink model, based on the first mentioned linear controller, is shown in appendix E. Because not all parameters were satisfactorily estimated, some have been given arbitrary values. Only the simulation with the linear conti-oiler was performed successf.;!, so r,o cmc!nsi~ns car, be take= fer the eff;-ciency of the energy based controller. This also means the switching strategy couldn't be tested. The poles are chosen to be -0.4, -0.9, -0.45+0.2i and -0.45-0.2i. This gives a satisfactory result for the balancing of the pendulum, as is illustrated in figure 4.4. The simulation is ran for several initial values (each time within the restrictions given by the switching strategy for the linear controller) and all give similar results.

Since the influence of the motor dead zone is hard to quantify, as well as the noise present in the setup, this result cannot guarantee a good result when balancing the controller in real time.

(31)

Chapter 4. Controller suggestions

Simulation Results

10 20 30 40 time 0.05 - 0 -

-

-0.05 . I a

$

-0.1 - -0.1 5 - -0.2 - -0.25 0 10 20 30 40 time

(32)

Chapter

5

Conclusions

&

recommendations

5.1 Conclusion

During this project much experience is gained with the provided setup. A model has been presented which was derived by Lagrange equations method. Next a parameter es- timation was performed. Unfortunately no suitable results have been obtained with this estimation. Due to a lack of time no alternative method for the parameter estimation could be implemented.

For the control of the pendulum balancing act the suggestion is given to implement a hybrid controller, with an energy based controller to get the pendulum upright, and a choice of two standard controllers to keep it upright. A brief idea of what kind of switching strategy should be used is given as well, though practical experience with this control is necessary to give numerical values for the switching boundery. The linear controller has been simulated in Simulink, and from this simulation a suggestion for the pole locations is given. Because not all disturbing effects in the setup will be implemented correct in this model, no conclusion can be given about the performance of this controller in real time.

The gained experience with the setup was sufficient to be able to write a basic manual of how to control the setup. It is included in this report in Appendix F.

5.2

Recommendat ions

For following projects with this setup it is recommended to apply an extended Kalman filter for the parameter estimation. Furthermore it might be possible to develop a com- munication program which runs in a Windows-environment, this to avert the limitations the current included software brings along. The controller design is still a t the initial phase, so this can be expanded in following projects.

(33)

Chapter 5. Conclusions & recommendations

For safety it would be desired to implement a safety program, which prevents the setup of uncontrolled and unstable movement. Unstable motion of the pendulum setup was experienced once during this project, and caused the setup to break down.

(34)

[A001 Astriim. K.J.,Furuta, K. Swinging up a pendulum by energy control. Auto- m a t i c ~ , vol. 36:pp. 287-295, 2000.

[Chy99] Chye, T.K. and Sang, T.C. Rotary inverted pendulum. Technical report, School of Electrical and Electronic Engineering, Nanyang Technological Uni- versity, 1999.

[Kwa72] Kwakernaak, H.,Sivan, R. Linear optimal control systems. Wiley: New York, 1972.

(35)
(36)

Appendix

A

Calibration

of

the

servo

potentiometer

For the calibration of the servo potentiometer 8 experiments are performed per setup. Each time a prescribed motion of the pendulum rod is executed manually, while the output of the potentiometer is recorded. Here 4 different movements programs are executed, and each program is performed twice. The first 3 pro-

grams are recorded with a sample frequency of 10 Hz, the last one a t 100 Hz. It must be

said here that with the movement of the pen- Figure A.l: The servo potentiometer dulum rod to a certain value of

P,

this position

is determined with the naked eye.

Program 1: The pendulum rod is moved from /3 = O0 to ,B = 180" in counterclockwise direction, and back again. This is repeated 5 times. While doing this, it can be seen that the count-vaIue jumps from a negative value to a high positive value. More information about this will be gathered in a separate measurement. In table A.l the results for the count-values a t ,O = O0 and

p

= 180' are presented.

Program 2: The pendulum rod is moved from ,B = O0 to

/3

= 180' in clockwise direction, and back again. This is repeated 5 times. Again the results for the count-values a t

p

= O0 and = 180' are presented. See table A.2.

Program 3: The pendulum rod is moved from ,B = O0 t o /3 = 270° (counterclockwise), back t o

P

= OO(clockwise), then to

P

= 90°(clockwise) and back to ,Ll = O0 (counterclock- wise) again. This is repeated 5 times. The results for the count-values a t

P

= 270° and ,O = 90° are presented in table A.3.

(37)

Appendix A. Calibration of the servo potentiometer

Table A.1: Results movement program 1

Setup 1 Setup 2 Experiment Exp. 1 Exp.1 Movement Mov.1 Mov.2 Exp. 1 Exp. 1 Exp. 1 Exp. 2 Exp. 2 Exp. 2

Table A.2: Results movement program 2

Exp. 1 Exp. 2 Exp. 2 Exp. 2 Exp.2 Exu.2 Experiment Exp.1 Setup 2 Mov. 5 Mov.1 Mov.2 Mov.3 Mov.4 Mov.5 Movement Mov. 1 Count-value

p

= 180° 544 Setup 1 Count-value

p

=

oO

0 Count-value

p

= 180° 507 506 505 505 504 505 505 Count-value

p

= 0" 1 1 0 0 0 0 0 546 543 545 545 541 542 1 -1 0 -1 - 1 - 1

(38)

Table A.3: Results movement program 3 Setup 1

Experiment Exw.1

then t o

fl

= 180°(counterclockwise), and back t o

P

= 270'(clock~i~e) again. This last movement is repeated 10 times. Because of the limited data set that can be recorded on the local pc-board, not all ten movements are recorded. With both experiments a t least 5 movements were recorded, so only these will be presented. This experiment is executed a t with a sample frequency of 100 Hz, as mentioned before. This means no outputs will be missed, but also that the measurement time is limited to 20 seconds. The goal of this experiment is to get more information near the 'crossover' point. For every movement the exit- and entrance-value will be given. c stand for clockwise crossing, and cc for counterclockwise crossing of the crossover point. The meaning/position of these points is illustrated in figure A.2. The results are presented in table A.4

Setup 2 Exp.1 Exp.1 Exp.1 Exp. 2 Exp. 2 Exp. 2 Exp. 2 Exp.2

Result setup 1: From test 3 it can be seen that the count-values for

/3

= 270' and

f l

= 90' lie around the perfect -256 and 256, which involves that the distribution for setup 1 is equally distributed over the total 360'. Tests 1 and 2 show that the count-value for

p

= 180° has an average of 506 instead of the perfect 512. This can be caused by a non- linear distribution in the potentiometer, but also by a systematic error in the prescribed position. Assuming an equal distribution each count would stand for 360°/1024 = 0.35', so the difference in angle would have been 6 . 0.35' = 2.11°, which is a reasonable error with a naked eye positioning. Therefor a total linear and equal distribution of the output signal is assumed for setup 1. From test 4 it can now be calculated that the boundary points of the potentiometer lie a t -306. 0.35' = -107.6' = 252.4O and 717. 0.35' = 252.1°. The gap of 1 count (0.3') will be neglected, since it will have no significant influence.

Movement Mov. 1

Last thing to be noticed from the result of test 4, occurs when the crossover point is crossed in counterclockwise direction. Often the count-value directly after the crossing

Mov.3 Mov.4 Mov.5 Mov.1 Mov.2 Mov.3 Mov.4 Mov.5 Count-value

/3

= 270' -256 -255 -257 -256 -255 -257 -254 -253 -256 Count-value

0

= 270' -278 Count-value ,8 = 90' 257 Count-value ,8 = 90' 2 72 254 256 253 257 253 253 256 258 -274 -275 -274 -276 -274 -274 -272 - -277 276 275 276 274 275 276 276 275

(39)

Appendix A. Calibration of the servo potentiometer

entrance point cc

/

,exif point cc

/

/~endulurn position (counts)

10

time (s)

\

,

,'

entrance point c

exit po~nt cc

Figure A.2: Explanation measurement points Program 4

is 640 instead of the augmented 717. It looks like the potentiometer 'sticks' to the -306 value, preceding the crossover point, and then suddenly slips t o the next point which has the count-value 640 (with corresponding resistance). This would mean a direction- dependent blind zone is present of (717 - 640) .0.35' = 27.0'. Since this effect was not present with all experiments, it will not be implemented with the calibration.

Result setup 2: When test 3 is evaluated, it shows the servo potentiometer is not as perfect as the one from setup 1. The average values for

P

= 270' and

P

= 90' are -275 and 275, resp. The average difference for ,b' = 0' and

P

= 180' is 544 counts. This leads to a distribution of 273 counts per 90°, that is each count stands for 0.33'. When the boundaries are calculated from test 4, this leads to a placement of the start point a t -324

-

0.33' = -106.8' = 253.2' and the end point a t 699.0.33' = 230.4'. This means there is a blind zone of 23'. Setup 2 has no direction-depended behaviour near the crossover point.

(40)

Table A.4: Results movement program 4 Exp. 1 Mov.1 -306 640 717 -306 p--ppp Exp. 1 Mov.2 -306 640 717 -306 Experiment

I

Setup 2 Movement Exp. 2 Exa. 2

Count-value Count-value Count-value Count-value Experiment Movement

exit cc entrance cc exit c entrance c Count-value exit cc Mov.2 Mov.3 Exp.1 Exp. 1 Exp. 1 E x D . ~ Count-value entrance cc -306 -306 Exp. 2 Exp.2 Exp. 2 Exp. 2 Mov.2 Mov.3 Mov.4 Mov.5 Count-value exit c 663 640 Mov.1 Mov.2 Mov.3 Mov.4 Count-value entrance c -324 -324 -324 -324 717 71 7 -324 -324 -324 -324 -306 -306 699 699 699 699 699 699 699 699 699 699 699 699 -324 -324 -324 -324 699 699 699 699 - - -324 -324 -324 -324

(41)
(42)

A p ~ e n d i x

I

B

Calibration

of

the optical

encoder

The optical encoder is also calibrated by exerting a known movement to the arm, while recording the output of the optical encoder. As mentioned in section 3.1.2, there are several ways to record this output, with their own disadvantages. The choice is made for a self-written recording function, for which the reset-value has yet to be obtained. This value is obtained by determining the counts per total revolution. Two movement programs are executed to obtain the counts recorded per revolution: the arm is turned 4 times round in one direction, next 8 times round in the other direction, and next 4 times back in the first direction again. The difference between the two programs is that program 1 starts with a counterclockwise direction, and program 2 with a clockwise direction. Each program is performed 3 times. With this movement the maximum successive rotations without crossing the reset-boundary is executed. The total counts recorded in 8 rotations will be obtained from this data, and is presented in table B.1. Furthermore the difference for a! = 0' at the start and a t the end of the experiment is

presented. The purpose of this experiment is also illustrated in figure B.1. Table B.l: Results encoder-calibration

I

Counts for 8 rotations

I

Start-end error a! = O0

I

Experiment Exp.1

Results: With these values the average value of counts per rotation can be calculated. For setup 1 the average of 8 rotation comes to 52227.6 counts, which leads t o 6528

Exp. 3 Exp.4 Exp.5 EXD. 6 Program 1 1 2 2 2 Setup 1 52356 52274 52012 52350 52288 Setup 2 52264 Setup 1 304 Setup 2 92 52318 52470 52366 52332 76 20 126 138 134 344 4 54

(43)

Appendix B. Calibration of the optical encoder x

l o 4

armpos 3 -5.2301

bj

count: . . . : (8 rotations) . . .

I

1 .

" 0 10 20 30 40 50 Time (s)

Figure B.l: Calibration experiment

counts per rotation. For setup 2 the average of 8 rotation comes to 52355.6 counts, which leads to 6544 counts per rotation. When converted to counts per degree, this becomes 6528/360=18.1 counts per degree for setup 1 and 6544/360=18.2 counts per degree for setup 2. The mismatch for the count value for a = 0 a t the start and the end show a limited accuracy for the position of the arm. It has not been investigation which effect this inaccuracy has on the precision of the speed of the arm.

(44)

Appendix

A

C

Motor

dead zoneexperiment

results

For the determination of the dead zone 2 experiments are performed, and each experi- ment is repeated 5 times per setup. Because of the different in static friction between the 2 setups, the range of inputs differs for each setup. For setup 1 the input vzries from 40 to 70, and for setup 2 from 20 to 45. The input is increased by 1 every 2 seconds for first type of experiments (type A); the second type gives an input for 1,5 seconds, but drops to zero for 0,5 seconds before increasing the input again (type B). The total results are listed in table C.1. Again, c stands for clockwise and cc stands for counterclockwise movement of the arm.

Table C.l: Results measurements motor dead zone Exp. 1 -70 Setup 1 Exp. 2 -61 Experiment type A - c c Exp. 5 -66 Exp. 3

<

-70 Average -67.4 Exp. 4

<

-70

(45)
(46)

Total

results parameter

est irnat

ion

D.l

Results parameter estimation part 1

The total results of the parameter estimation of J,, and C1 are presented in table(D.l): Table D.l: Total results J,. and CI

Experiment Exp.1 E x n 2

D.2

Results parameter estimation part 2

First the results of the parameter estimation obtained with the input signal of a 2 Hz sine are presented in table D.2. The amplitude of the sine was programmed 15 for all measurements, the balance point differs per 5 measurements. The magnitude of the input is substantial lower for setup 2, because the dry friction is less with this setup.

Exp.3 Exp.4 Exp.5 Exp.6 Average Setup 1 0.0762 0.0809 0.0796 0.0776 0.0781 Setup 2 J,, (lop3) 0.7868 0.7870 - Jv, 0.7883 0.7882 C1 0.0774 0.0771 0.7882 0.7882 0.7882 0.7869 0.7873 0.7872 0.7870 0.7870 CI (lop3) 0.0643 0.0661 0.0673 0.0639 0.0654

(47)

Appendix D. Total results parameter estimation

Table D.2: Results parameter estimation sine 2 Hz

I

Setun 1 Sine

1

balance

1

point 45 -1.0201 . 1 0 - ~ Sine Kt Ku balance 7 Jzo point 35 -4.9643

.

1.2136. 35 -9.3749. l o W 5 -1.4646.

loW4

35 1.2533.

loW4

-2.6089.

loW4

35 -3.9337.

loW4

4.5893.

loW5

35 -1.4832.

loW5

-2.0149.

loW4

The results still have significant variation and are not satisfying. Next, the results for the sine of 10 Hz are presented in table D.3. With this sine the amplitude is also programmed 15 each time, while the balance point is varying. For an unknown reason this amplitude is not present in the recorded data. This shouldn't disturb the results, since now a different input signal as augmented is controlling the setup, but it still is a real input signal.

(48)

0.2. Results parameter estimation part 2

Table D.3: Results parameter estimation sine 10 Hz

I

Setuw 1 Sine balance point 45 5.8969. l o W 6 1.4479. l o W 4 9.4457.

loW4

1.2032.

loW2

-45 -45 Sine balance Setuw 2 -8.7478. -5.7984.

9

point 30 -9.3999.

loW5

-7.6507.

loW4

-3.9046.

loW7

6.8420. loW4 1.5989

.

l o W 4 -1.7687.

loW4

- -2.8815

.

loW2

-2.3021

.

loW2

1.6642.

loW6

7.7527.

loW5

(49)
(50)

Appendix

E

Simulink model

Below the used Simulink model and the connected m-file are shown. The m-file is ran every time before the simulation is started.

(51)
(52)

Appendix

- -

F

Manual

for controlling t h e

KRi

Inverted Pendulum PP-300

During this project experience was gained about how t o run the setup, using the included software. As mentioned in chapter 2.1, the setup is ran using the included software, operating in a DOS-environme~t. Because of the lack of 2 s&isfactcry manual with

the setup, a brief manual is given here, t o precipitate any following project with this setup. For clarity, lots of print-screens from the program are included. In this manual

3 situations are clarified:

1. Running an existing program, which gives no output 2. Running an existing program, which provides output

3. Write a new program in C

Finally, some limitations and points of attention will be highlighted. Commands that have to be executed are surrounded by quotes and have a different font, for example: 'execute t h i s ' .

F.l

Running an existing program, with no output

-Log on to the P C that is connected to the pc. -Open a command window.

-Go to the directory where you've stored your program. -Switch on the power for the inverted pendulum.

-Run the control program by typing 'ecm96 - p o l l -coml'. When the setup is connected to another com-port, change the last term of this command. When the program you want t o run is not located in the same directory as the file ecm96.exe, make sure your command line points all the way to the ecm96-file. Example: your program is located in the directory c : \invpend\test\expl\

. .

and the ecm96-file in the directory c : \invpend\

. .

. Your command line should now be

'

.

.

\.

.

\ecm96 - p o l l -coml'. Sometimes the program opens and starts with the message 'reset target system', see

(53)

Appendix F. Manual for controlling the KRi Inverted Pendulum PP-300

figure F.1. This means the connection has to be reset. Type 'y' and the program will proceed.

Figure F.l: Reset target system

Now the program is ready to communicate with the setup. The window should look like figure F.2.

Figure F.2: Program ready for communication

-Load the program you want t o run into the local board by typing 'load filename. out', filename being the name of the program you want to run.

-Tell the processor where it can find the start of the program by setting the pointer: 'pc=2080h'. Now the program is ready to run, it just needs your signal before it starts. -Type 'go' to really start the program.

(54)

F. 1. Running an existing program, with no output

The program should now be running on the local board. On the PC this is by a blinking cursor, behind a

>.

See figure F.3.

indicated

Figure F.3: Program running

The other possibility is that an error occurs again. The program mentions a time-out occurred, and asks to reset the system. Type 'y' to proceed. Now sometimes the same error might appear again, see figure F.4

.

This indicates the local board has to be reset as well. Do this by turning of the power switch of the inverted pendulum setup, and wait till the LED-indicator on the local board has faded before you switch it on again. After switching the power on again, type 'y'. Now the board is ready for communication again, and we proceed as we did before: load the program, set the pointer and start the program.

(55)

48 Appendix F. Manual for controlling the KRi Inverted Pendulum PP-300

When the program is finished, you have to stop it by typing 'halt'. The blinking cursor now appears behind the asterix, showing the program is ready to execute commands again. To run the same program another time, the program has no need to be loaded again. Just set the pointer and it is ready to go. When the total experiment is finished, exit the ECM96-program by typing 'quit'. Always make sure you stop the program from running, before you exit the ECM96-program!! This way you won't get surprised by unexpected movements from the pendulum, which might cause damage or injury.

F.

2

Running a n existing program, providing output

This is mostly the same as running a program with no output, but some other errors can occur. Start the same way as before:

-Log on your pc, open a command window, and start the ECM96-program as described before.

-Load the program that will produce output, set the pointer and start running the program.

When the program is started now, instead of a blinking cursor, the window should be scrolling down, printing one

'>'

per line. This is shown in figure F.5.

Figure F.5: Program running, producing output

In the right upper corner you should see the text t a r g e t s t a t u s .

.

,

and behind this alternately running and stopped.

-To stop the program, type ' h a l t ' again. The program might stop im- mediately, but often it also happens the scrolling continues. The text Cannot execute: t a r g e t not running will follow directly after your command. When this happens, just try typing ' h a l t ' again, till you succeed in stopping the pro- gram, see figure F.6.

(56)

F.3. Write a new program

Figure F.6: Stop Program, no direct response

Now the data produced during the experiment can be loaded back into the pc again. -Type 'save 7f c0 t o Sf f f i n filename .raw'. This will save all the data stored on a specific place on in the local processor to the file filenamexaw. Both numbers are hexadecimal pointers, the first lying near the start of the measurement, and the second being the maximum the program accepts.

Now the data is stored on the computer, it has t o be converted t o something you can read and understand.

-Either open a second command-window and go to the same directory as before or exit the ECM96 program. Type 'raw2mat filename .raw filename

.

dat'. This will convert the imported .raw-file to a .dat-file, which can be opened in MatLab, notepad or some other program. Again be sure your command line points to the place where the file raw2mat.exe is located. For an unknown reason it often occurs that after running this command once, a n empty .dat-file is created. Therefor always run the command twice t o be sure the data is converted correctly.

F.3

Write a new program

To write a new program a basic understanding of the program language C is necessary. The easiest way t o write a new functionality/program is by editing a standard one. The following parts can be recognized in the included programs:

Header: this is the first part of the program file. It includes the links to all the files that are used to run the setup. The several global variables are declared here. If you want t o use more variables then already included, add the declaration in this part of the file.

(57)

50 Appendix F. Manual for controlling the KRi Inverted Pendulum PP-300

several variables their initial value. Further more the current configuration of the setup is set to zero.

0 Absolute: This is just a local function, that will be called from the void Control. This

part can mostly be left unedited.

o Control: This is the main program, which is called every 0.01 seconds. The new control signal has to be defined here, as well as the storage of data.

0 More local functions: some program files include some more local functions a t the end of the file. If new functions are needed, include them in this part.

When a satisfactory program is written, it has to be compiled in order to use it with the setup.

-Open a command-window, go to the directory where your .C-program file is stored and type 'c96 filename

.

c'. Again make sure this program line points to the location of c96.exe, as mentioned before with the ecm96.exe file. This will produce the file filename.lst, and when successfully compiled, also the file filename.obj. The message

0 warnings, 0 e r r o r s should appear, see figure F.7.

Figure F.7: Compiling terminated successfully

When 1 or more errors occur, no .obj-file will be produced. Evaluating the .lst-file now mostly gives a good insight of what went wrong. The C-language is very sensitive for forgetting for example the characters ';' and

')',

so this often will cause the error. Correct the .C-file and compile it again, till all errors are solved, and the .obj-file is created.

Now the produced .obj-file has t o be linked to several other files, since this one file does not contain all programming necessary to run the setup. This is done with the linker program r196.exe.

-Use the command window again and type r196 main. ob j , addr

.

obj , uc96. l i b ,

filename.obj,c96.lib,fpal96.lib t o filename.out R0(2000H-7FFFH)RA(80OOH-OEFFH).

Referenties

GERELATEERDE DOCUMENTEN

On 7 May 2012 a Decree by the President ‘On measures to implement the foreign policy of the Russian Federation,’ outlined as one of the priorities of the executive offices of

The purpose of this study was to get insight into the reactions of consumers toward a retailer loyalty program withdrawal, by taking into account the level of progress the consumer

Bovendien zijn er in elk van die gevallen precies twee keerpunten die elkaars spiegelbeeld bij spiegelen in een van de coördinaatassen. We illustreren elk van de 16 gevallen van

This applies to a wide range of political stimuli, such as politicians (Study 1), groups associated with different ideologies (Study 2), or newspapers (Study 3), and also applies

When it is not we check if #1 is present in the list of files to be processed. If not we add it and initialize list of output files for that input and list of output files that

rapport3.cls report compatible, design 3 book.cls book compatible, design 1 ntg10.clo 10 point option for all styles ntg11.clo 11 point option for all styles ntg12.clo 12 point

The conceptual model sketches the main research question which is aimed at finding out the influences of resistors and enablers on collaborative behaviours, and how

The researcher is of the opinion that qualitative case study methodology best serves the goal of this research; that is, to access the survivors’ voice and their trauma and