Control loop for CLUPI - repositorio.poli.ufrj.br

67
CONTROL LOOP FOR CLUPI Eduardo Miranda M. D. Casseres Projeto de Gradua¸ c˜ao apresentado ao Corpo Docente do Departamento de Engenharia El´ etrica da Escola Polit´ ecnica da Universidade Federal do Rio de Janeiro, como parte dos requisitos necess´ arios`aobten¸c˜ ao do t´ ıtulo de Engenheiro Eletricista. Orientador: Oumar Diene Rio de Janeiro Mar¸co de 2016

Transcript of Control loop for CLUPI - repositorio.poli.ufrj.br

Page 1: Control loop for CLUPI - repositorio.poli.ufrj.br

CONTROL LOOP FOR CLUPI

Eduardo Miranda M. D. Casseres

Projeto de Graduacao apresentado ao Corpo

Docente do Departamento de Engenharia

Eletrica da Escola Politecnica da Universidade

Federal do Rio de Janeiro, como parte dos

requisitos necessarios a obtencao do tıtulo de

Engenheiro Eletricista.

Orientador: Oumar Diene

Rio de Janeiro

Marco de 2016

Page 2: Control loop for CLUPI - repositorio.poli.ufrj.br

CONTROL LOOP FOR CLUPI

Eduardo Miranda M. D. Casseres

PROJETO DE GRADUACAO SUBMETIDO AO CORPO DOCENTE

DO DEPARTAMENTO DE ENGENHARIA ELETRICA DA ESCOLA

POLITECNICA DA UNIVERSIDADE FEDERAL DO RIO DE JANEIRO

COMO PARTE DOS REQUISITOS NECESSARIOS PARA A OBTENCAO DO

GRAU DE ENGENHEIRO ELETRICISTA.

Examinado por:

Prof. Oumar Diene, D.Sc.

Prof. Luis Guilherme Barbosa Rolim, Dr.-Ing.

Prof. Sergio Sami Hazan, Ph.D.

RIO DE JANEIRO, RJ – BRASIL

MARCO DE 2016

Page 3: Control loop for CLUPI - repositorio.poli.ufrj.br

Miranda M. D. Casseres, Eduardo

Control loop for CLUPI / Eduardo Miranda M. D.

Casseres. – Rio de Janeiro: UFRJ/Escola Politecnica,

2016.

XIV, 53 p.: il.; 29, 7cm.

Orientador: Oumar Diene

Projeto de Graduacao – UFRJ/Escola Politecnica/

Departamento de Engenharia Eletrica, 2016.

Bibliography: p. ?? – ??.

1. Control systems. 2. PID control. 3. Simulink.

4. Stateflow. I. Diene, Oumar. II. Universidade Federal

do Rio de Janeiro, Escola Politecnica, Departamento de

Engenharia Eletrica. III. Control loop for CLUPI.

iii

Page 4: Control loop for CLUPI - repositorio.poli.ufrj.br

Para Maria Jose (in memoriam)

iv

Page 5: Control loop for CLUPI - repositorio.poli.ufrj.br

Acknowledgments

Firstly, I would like to thank Jean-Luc Josset for believing in my enthusiasm con-

cerning the aerospace sector and for accepting my application to work as an intern

at the Space Exploration Institute, which was a unique experience in my career.

I also take this opportunity to express a deep sense of gratitude to Marie Josset

for her helpfulness and efforts on my integration at the institute and, more generally,

on my establishment in Switzerland.

I would like to very sincerely thank Audrey Souchon, Antoine Verhaeghe and

Tor Viscor for their reception, friendship and for helping me with the most various

problems. I was very lucky to work in such a pleasant environment during these six

months.

I would like to specially thank Mitko Tanevski, who has been a patient supervisor,

an exceptional teacher, a gentle advisor and a generous friend.

Finally and most importantly, I would like to thank Silvana, Antonio and Lıvia

for their constant and inconditional love.

v

Page 6: Control loop for CLUPI - repositorio.poli.ufrj.br

Resumo do Projeto de Graduacao apresentado a Escola Politecnica/UFRJ como

parte dos requisitos necessarios para a obtencao do grau de Engenheiro Eletricista

CONTROL LOOP FOR CLUPI

Eduardo Miranda M. D. Casseres

Marco/2016

Orientador: Oumar Diene

Departamento: Engenharia Eletrica

Neste projeto de graduacao, procura-se descrever as atividades ligadas ao desen-

volvimento de um controlador para o mecanismo de focagem do instrumento CLUPI,

uma smart camera que estara a bordo do rover planetario da missao ExoMars 2018.

O projeto tem por objetivo modelar, simular, controlar e testar uma planta

constituıda por um mecanismo de focagem com duas partes fixas e uma parte movel.

O controle deve ser implementado de maneira a garantir o bom funcionamento da

lente movel, garantindo alta precisao e rapidez de resposta para, assim, o bom

funcionamento do empilhamento de distancias focais, tecnologia de combinacao de

imagens que permite obtencao de uma imagem final com profundidade de campo

elevada.

Em suma, o objetivo foi o desenvolvimento de um controlador que permitisse

a camera mudar sua distancia focal automaticamente. O projeto divide-se em tres

etapas:

1. A elaboracao de um modelo para o sistema em questao.

2. O estudo e implementacao de um controlador. Inicialmente, optou-se por

um controlador PID e, num segundo momento, pela ferramenta Stateflow do

MATLAB. Esta ultima foi escolhida como ferramenta definitiva para o projeto

do controlador.

3. Realizacao de testes em tempo real para validacao do controlador projetado.

vi

Page 7: Control loop for CLUPI - repositorio.poli.ufrj.br

Abstract of Graduation Project presented to POLI/UFRJ as a partial fulfillment of

the requirements for the degree of Electrical Engineer

CONTROL LOOP FOR CLUPI

Eduardo Miranda M. D. Casseres

March/2016

Advisor: Oumar Diene

Department: Electrical Engineering

This report aims to describe the progress and the results of my Course Comple-

tion Internship (Projet de Fin d’Etudes), which was effected at the Space Explo-

ration Institute, in Neuchatel, Switzerland.

During this six-month project, I worked within one of the institute’s main

projects, namely the development of CLUPI, a smart camera that will integrate

a Mars exploration rover as part of the international ExoMars mission, led by the

European Space Agency (ESA).

The goal of the project was to design a control loop for CLUPI’s focus mechanism

so that the camera can automatically change its optical working distance.

The progress of this internship can be divided in three steps:

1. The design of a numerical model of the system to be controlled.

2. The addition of a controller to this model and the implementation of a control

logic.

3. Finally, real-time tests using a target machine.

vii

Page 8: Control loop for CLUPI - repositorio.poli.ufrj.br

Contents

List of Figures x

List of Tables xiii

1 Introduction 1

1.1 ExoMars Mission . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

1.2 The CLUPI Instrument . . . . . . . . . . . . . . . . . . . . . . . . . . 3

1.3 Presentation of the problem . . . . . . . . . . . . . . . . . . . . . . . 5

2 Theoretical background 7

2.1 Linear Time-invariant Systems . . . . . . . . . . . . . . . . . . . . . . 7

2.2 Transfer functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

2.3 First and second order systems . . . . . . . . . . . . . . . . . . . . . 7

2.3.1 First order systems . . . . . . . . . . . . . . . . . . . . . . . . 7

2.3.2 Second order systems . . . . . . . . . . . . . . . . . . . . . . . 9

2.4 Control systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

3 First part: model design 12

3.1 Real system presentation . . . . . . . . . . . . . . . . . . . . . . . . . 12

3.2 Hypotheses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

3.2.1 Focus Mechanism . . . . . . . . . . . . . . . . . . . . . . . . . 13

3.2.2 Flexure stages . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

3.2.3 Voice-coil . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

3.2.4 Other hypotheses . . . . . . . . . . . . . . . . . . . . . . . . . 14

3.2.5 Resulting model . . . . . . . . . . . . . . . . . . . . . . . . . . 14

3.3 Analysis using the control theory . . . . . . . . . . . . . . . . . . . . 15

3.3.1 Transfer function . . . . . . . . . . . . . . . . . . . . . . . . . 15

3.3.2 Bode diagram and root locus . . . . . . . . . . . . . . . . . . 16

3.4 Simulink model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

4 Second part: addition of a control loop 20

4.1 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

viii

Page 9: Control loop for CLUPI - repositorio.poli.ufrj.br

4.2 Controller options and choice . . . . . . . . . . . . . . . . . . . . . . 20

4.3 Simulations using a PID controller . . . . . . . . . . . . . . . . . . . 21

4.3.1 Inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

4.3.2 Simulations using the tuning tool . . . . . . . . . . . . . . . . 22

4.3.3 A short study on PID controllers theory . . . . . . . . . . . . 24

4.3.4 Simulations using the direct method . . . . . . . . . . . . . . 27

4.3.5 Conclusions about the PID controller . . . . . . . . . . . . . . 31

4.4 Simulations using the Stateflow environment . . . . . . . . . . . . . . 32

4.4.1 Stateflow presentation . . . . . . . . . . . . . . . . . . . . . . 32

4.4.2 Operating principle . . . . . . . . . . . . . . . . . . . . . . . . 32

4.4.3 First attempts . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

4.4.4 Conservation of the energy . . . . . . . . . . . . . . . . . . . . 34

4.4.5 Addition of the gravity effect . . . . . . . . . . . . . . . . . . 38

4.4.6 Damping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

4.4.7 Adapting the controller to any kind of displacement . . . . . . 43

5 Third part: real-time control 45

5.1 Speedgoat presentation . . . . . . . . . . . . . . . . . . . . . . . . . . 45

5.2 Loop-back test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

5.2.1 Addition of the operational amplifier . . . . . . . . . . . . . . 47

5.2.2 Next steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

6 Conclusion 51

A LVDT and Speedgoat data 53

A.1 LVDT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

A.2 Speedgoat (IO101 module) . . . . . . . . . . . . . . . . . . . . . . . . 53

ix

Page 10: Control loop for CLUPI - repositorio.poli.ufrj.br

List of Figures

1.1 Space Exploration Institute expertise and activities (Space Explo-

ration Institute) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

1.2 ESA’s artistic concept of the 2018 ExoMars rover (European Space

Agency) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

1.3 CLUPI computer-aided design model (Space Exploration Institute) . . 4

1.4 CLUPI computer-aided design model mounted on the drill, piercing

the Martian surface (Space Exploration Institute) . . . . . . . . . . . 4

1.5 CLUPI computer-aided design model mounted on the rover drill, in

stowed position (Space Exploration Institute) . . . . . . . . . . . . . . 5

1.6 CLUPI’s optical components: a mobile lens is placed between the

rear optics and the front optics . . . . . . . . . . . . . . . . . . . . . 6

1.7 Schematic representation of CLUPI’s focus mechanism control loop. . 6

2.1 Typical step response of a first order system . . . . . . . . . . . . . . 8

2.2 Typical step response of a second order system . . . . . . . . . . . . . 9

2.3 Closed loop control system . . . . . . . . . . . . . . . . . . . . . . . . 10

3.1 CLUPI main components (Space Exploration Institute) . . . . . . . . 13

3.2 Force diagram of the focus mechanism after hypothesis definition. . . 14

3.3 Bode diagram of the system (gain and phase) . . . . . . . . . . . . . 17

3.4 Root locus plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

3.5 Simulink model including the focus mechanism, the voice-coil and the

spring. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

3.6 Simulink model of the focus mechanism block. . . . . . . . . . . . . . 19

4.1 Control loop after addition of the PID controller. . . . . . . . . . . . 21

4.2 Two distinct set points: xsp = 1 mm and xsp = 5 mm. . . . . . . . . 22

4.3 x (meters)×t (seconds) -Tuning tool PID controller - system response

with a 1 mm set point . . . . . . . . . . . . . . . . . . . . . . . . . . 23

4.4 x (meters)×t (seconds) - Tuning tool PID controller - system response

with a 5 mm set point . . . . . . . . . . . . . . . . . . . . . . . . . . 24

4.5 Diagram of a PID controlled system. . . . . . . . . . . . . . . . . . . 24

x

Page 11: Control loop for CLUPI - repositorio.poli.ufrj.br

4.6 The structure of a PID controller block. . . . . . . . . . . . . . . . . 25

4.7 x (meters) × t (seconds) - Increasing the proportional gain - system

response with a 1 mm set point . . . . . . . . . . . . . . . . . . . . . 27

4.8 x (meters) × t (seconds) - Increasing the proportional gain - system

response with a 5 mm set point . . . . . . . . . . . . . . . . . . . . . 28

4.9 x (meters) × t (seconds) - Increasing the integral gain - system re-

sponse with a 1 mm set point . . . . . . . . . . . . . . . . . . . . . . 29

4.10 x (meters) × t (seconds) - Increasing the integral gain - system re-

sponse with a 5 mm set point . . . . . . . . . . . . . . . . . . . . . . 29

4.11 x (meters)× t (seconds) - Optimal Td - system response with a 1 mm

set point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

4.12 x (meters)× t (seconds) - Optimal Td - system response with a 5 mm

set point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

4.13 An example of a Stateflow chart - Two different states and one tran-

sition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

4.14 Interpolation between maximal acceleration and stability position. . . 33

4.15 Energy analysis. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

4.16 Stateflow chart - conservation of the energy . . . . . . . . . . . . . . 35

4.17 Complete model with the Stateflow chart acting as a controller . . . . 36

4.18 x (meters) × t (seconds) - system response with xsp = 2 mm . . . . 37

4.19 x (meters) × t (seconds) - system response with xsp = 5 mm . . . . 37

4.20 x (meters) × t (seconds) - system response with xsp = −3 mm . . . 37

4.21 Acceleration sub-state after addition of the gravity effect . . . . . . . 39

4.22 System response after the robustness enhancement - xsp = 2 mm . . . 40

4.23 System response after the robustness enhancement - xsp = 5 mm . . . 40

4.24 System response after robustness enhancement - xsp = −3 mm . . . . 41

4.25 Implementation of a new state in order to remove the small oscillations. 42

4.26 Zoomed displacement output - x (meters)× t (seconds) - xsp = 5 mm

- No damping. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

4.27 Zoomed displacement output - x (meters)× t (seconds) - xsp = 5 mm

- Damping. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

4.28 Closed loop after insertion of a new transition. . . . . . . . . . . . . . 43

4.29 The limitation of our closed control loop. . . . . . . . . . . . . . . . . 44

4.30 The focus mechanism displacement tracks the reference square wave. 44

5.1 Speedgoat performance real-time target machine. . . . . . . . . . . . 45

5.2 IO101 68-pin terminal board. . . . . . . . . . . . . . . . . . . . . . . 46

5.3 Loop-back test configuration. . . . . . . . . . . . . . . . . . . . . . . 47

5.4 The CLUPI set at the Space Exploration Institute. . . . . . . . . . . 48

xi

Page 12: Control loop for CLUPI - repositorio.poli.ufrj.br

5.5 LVDT and voice-coil attached to CLUPI’s focus mechanism . . . . . 49

5.6 Overall diagram of the control system . . . . . . . . . . . . . . . . . 49

5.7 Optical sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

xii

Page 13: Control loop for CLUPI - repositorio.poli.ufrj.br

List of Tables

4.1 Time, precision and energy results achieved with the Stateflow con-

troller based on the conservation of energy. . . . . . . . . . . . . . . . 38

5.1 Loop-back characteristics . . . . . . . . . . . . . . . . . . . . . . . . . 46

5.2 Global loop characteristics . . . . . . . . . . . . . . . . . . . . . . . . 47

5.3 Operational amplifier characteristics . . . . . . . . . . . . . . . . . . . 47

xiii

Page 14: Control loop for CLUPI - repositorio.poli.ufrj.br

List of Abbreviations

• CCD - Charge-coupled device

• CLUPI - Close-Up Imager

• EDM - ExoMars entry, descent and landing demonstration module

• ESA - European Space Agency

• LVDT - Linear Variable Differential Transformer

xiv

Page 15: Control loop for CLUPI - repositorio.poli.ufrj.br

Chapter 1

Introduction

The purpose of this report is to describe the design and implementation of a control

loop for the CLUPI instrument, a smart camera which is part of ExoMars 2018, a

scientific mission led by the European Space Agency (ESA).

1.1 ExoMars Mission

This project was developed by the Space Exploration Institute, one among many

institutions involved in ESA’s mission.

SPACE-X, short for Space Exploration Institute, is a non-profit research insti-

tute situated in Neuchatel, western Switzerland. The institute aims at developing

space exploration activities, in particular research activities linked to planetary space

exploration. Its goals are (figure 1.1):

• to develop research activities related to the Moon, Mars, Mercury, Europa and

other celestial objects, including studies of ice deposits and past or present

traces of life;

• to propose and develop scientific instruments linked to its research activities,

for planetary exploration missions;

• to operate these instruments, process and analyze their scientific data;

• to promote space science to the general public, schools, universities, etc.

Two missions are foreseen by ESA within the ExoMars programme (both will

be carried out in cooperation with Roscosmos).

• the first one consists of an orbiter and an EDM, to be launched in 2016;

• the second, featuring a rover, will be launched in 2018.

1

Page 16: Control loop for CLUPI - repositorio.poli.ufrj.br

Figure 1.1: Space Exploration Institute expertise and activities (Space ExplorationInstitute)

The 2018 mission of the ExoMars programme will deliver an European rover

(figure 1.2) and a Russian surface platform to the surface of Mars. A Proton rocket

will be used to launch the mission, which will arrive to Mars after a nine-month

journey.

The ExoMars rover will travel across the Martian surface to search for signs

of life. It will collect samples with a drill and analyze them with next-generation

instruments. ExoMars will be the first mission to combine the capability to move

across the surface and to study Mars at depth.

2

Page 17: Control loop for CLUPI - repositorio.poli.ufrj.br

Figure 1.2: ESA’s artistic concept of the 2018 ExoMars rover (European SpaceAgency)

1.2 The CLUPI Instrument

CLUPI or CLose-UP Imager (figure 1.3) is one of the instruments that will be carried

by the ExoMars rover.

The device, as the name suggests, is a high-performance colour close-up imager,

an interplanetary equivalent of the hand lens used by geologists when undertaking

field work.

It is a small smart camera that will acquire color close-up images of rocks and

surface materials as well as images of core drill samples from two-meter depth.

CLUPI will return the first images of a sample extracted two meters under the

surface of Mars.

3

Page 18: Control loop for CLUPI - repositorio.poli.ufrj.br

Figure 1.3: CLUPI computer-aided design model (Space Exploration Institute)

CLUPI will be implemented on the drill of the rover (figure 1.4), allowing a

certain freedom of movement to the camera. Different observation configurations

will thus be exploited.

Figure 1.4: CLUPI computer-aided design model mounted on the drill, piercing theMartian surface (Space Exploration Institute)

In figure 1.5, the computer-aided design model of the rover carrying the device

(circled in yellow) is shown.

4

Page 19: Control loop for CLUPI - repositorio.poli.ufrj.br

Figure 1.5: CLUPI computer-aided design model mounted on the rover drill, instowed position (Space Exploration Institute)

1.3 Presentation of the problem

CLUPI is designed so that it can take pictures from different optical working dis-

tances. Actually, the images that will be taken from different distances will be used

to perform a z-stacking (or focus stacking), a digital image processing technique

which combines multiple images taken at different focus distances to give a result-

ing image with a greater depth of field than any of the individual source images.

In order to work with these different working distances, CLUPI’s optical system’s

design includes a mobile part, enabling the lens to change their position one with

respect to another (figure 1.6).

5

Page 20: Control loop for CLUPI - repositorio.poli.ufrj.br

Figure 1.6: CLUPI’s optical components: a mobile lens is placed between the rearoptics and the front optics

According to the z-stacking needs, the focus mechanism will be able to move

along a 10 mm range (−5 mm to 5 mm), changing the depth of field from 10 cm to

infinite.

In order to do so, a control loop must be implemented. This control loop, which

will use a LVDT as sensor and a voice-coil as actuator, aims to ensure a precise

and rapid adjustment of the focus mechanism position. Figure 1.7 illustrates the

operation of this control system.

Figure 1.7: Schematic representation of CLUPI’s focus mechanism control loop.

6

Page 21: Control loop for CLUPI - repositorio.poli.ufrj.br

Chapter 2

Theoretical background

2.1 Linear Time-invariant Systems

Linear time-invariant systems 1 are systems in which

• the equations relating the input and output variables are linear,

• the equation coefficients do not change over time,

2.2 Transfer functions

The transfer function [1] of a linear time-invariant system is defined as the rela-

tion between output Laplace transform and input Laplace transform, considering

zero every initial value. Let us consider the linear system defined by the following

equation:

a0y(n) +a1y

(n−1) + · · ·+an−1y′+any = b0x

(m) + b1x(m−1) + · · ·+ bm−1x

′+ bmx, (2.1)

in which x is the input and y is the output. The system’s transfer function is given

by

G(s) =Y (s)

X(s)=b0s

m + b1sm−1 + · · ·+ bm−1s+ bm

a0sn + a1sn−1 + · · ·+ an−1s+ an(2.2)

2.3 First and second order systems

2.3.1 First order systems

The transfer function of a first order system has the form

1The theory presented here considers SISO (single input, single output) systems.

7

Page 22: Control loop for CLUPI - repositorio.poli.ufrj.br

G1(s) =K

τ + s, (2.3)

in which K is the gain,

τ is the time constant.(2.4)

The step response of a first order system is illustrated in figure 2.1.

Figure 2.1: Typical step response of a first order system

8

Page 23: Control loop for CLUPI - repositorio.poli.ufrj.br

2.3.2 Second order systems

The transfer function of a second order system has the form

G2(s) =Kω2

n

s2 + ξωns+ ω2n

, (2.5)

in which K is the gain,

ωn is the natural frequency

ξ is the damping ratio

(2.6)

The step response of a second order system is illustrated in figure 2.2.

Figure 2.2: Typical step response of a second order system

Based on figure 2.2, we can define some characteristics of the transient response

of a system:

• delay time, td, the time that the system takes to reach, for the first time, half

of its final value,

• rise time, tr, the time that the system takes between 10 % and 90 % of its

final value,

• peak time, tp, the time that the system takes to reach, for the first time, its

maximum value,

9

Page 24: Control loop for CLUPI - repositorio.poli.ufrj.br

• the percentage overshoot Mp, which is the maximum value minus the step

value divided by the step value,

• settling time, the time taken for a measuring or control instrument to get

within 5 % or 2 % of its final value.

2.4 Control systems

The objective of a control system [2] is to regulate the behaviour of a given plant.

There are two classes of control systems,

• open loop control systems

• closed loop control systems

In open loop control systems, the control is exclusively determinated based on

the input. Most often, industrial and research applications use closed loop control

systems, in which there is a negative feedback loop that modifies the behaviour of

the the output. A closed loop control system is shown in figure 2.3.

The function of the negative feedback is to be compared to the reference in

order to provide the error, which will be taken into account by the controller.

It is basically composed by the plant, i.e., the system to be controlled, and the

controller or compensator, which is responsible for transforming the global system

into a stable system.

Figure 2.3: Closed loop control system

The closed loop transfer can be calculated through

Y (s) = (C(s)P (s)) (R(s)− Y (s)) (2.7)

10

Page 25: Control loop for CLUPI - repositorio.poli.ufrj.br

Y (s) = C(s)P (s)R(s)− C(s)P (s)Y (s) (2.8)

C(s)P (s)Y (s) + Y (s) = C(s)P (s)R(s) (2.9)

(C(s)P (s) + 1) Y (s) = C(s)P (s)R(s) (2.10)

Thus, the closed loop transfer function is

H(s) =Y (s)

R(s)=

C(s)P (s)

1 + C(s)P (s)(2.11)

11

Page 26: Control loop for CLUPI - repositorio.poli.ufrj.br

Chapter 3

First part: model design

3.1 Real system presentation

As explained, the system to be controlled is the movable part of a lens assembly.

The figure 3.1 shows the principal components of the control system:

1. The focus mechanism, which can move along a 10 mm range.

2. Three identical flexure stages mounted symmetrically around the optical

axis. This mechanical set brings the focus mechanism back to the stability

position (x = 0) if the actuator is not delivering a force.

3. The voice-coil, an actuator based on a linear ratio between current and force.

It is actually a simple linear motor, which consists of two separte parts: the

magnetic housing and the coil.

4. The LVDT or Linear Variable Differential Transformer, which is a three-coil

transformer used as position sensor.

12

Page 27: Control loop for CLUPI - repositorio.poli.ufrj.br

Figure 3.1: CLUPI main components (Space Exploration Institute)

3.2 Hypotheses

Before designing a numerical model representing the system, we have to posit our

hypotheses for its different components.

3.2.1 Focus Mechanism

We assume that the focus mechanism is subjected to two forces in its direction of

movement (at first, we consider the device to be operating in horizontal position) :

• the force produced by the actuator (voice-coil);

• the force produced by the flexure-stages (which will be considered as a spring,

as explained ahead);

This means we neglect the friction forces, which should be a reasonable hypothesis

once that the voice-coil slides without any mechanical contact.

Furthermore, we consider the movable part of the system to have a mass1 of

m = 38, 27 g.

1During the first simulations, we did not have the precise value of the mass of the movable part.Therefore, we have used 30 g as an estimated value. Once determined the precise value of 38, 27 gby Antoine Verhaeghe, we have instantly performed the alteration.

13

Page 28: Control loop for CLUPI - repositorio.poli.ufrj.br

3.2.2 Flexure stages

As the flexure stages have a linear characteristic, in order to simplify our model, we

represent them by a spring, which allows us to use Hooke’s law (~F = −k~x). The

stiffness k is calculated2 to be 160 N/m.

3.2.3 Voice-coil

At nominal conditions, voice-coil’s resistance is 3, 3 Ω. This resistance corresponds

to the coil windings. Its force constant is K = 0, 77 N/A. As made explicit by the

units, this constant represents the linear relation between current and force.

3.2.4 Other hypotheses

We consider the system to be operating at 25oC. A change in temperature does not

have an important impact on the voice-coil’s operation, but it can affect the spring’s

stiffness.

The step time used for the simulations is fixed at 1 µs.

3.2.5 Resulting model

Once all these assumptions are posed, we get the force diagram that is represented

in figure 3.2.

Figure 3.2: Force diagram of the focus mechanism after hypothesis definition.

2Calculation based on FEM static gravity load analysis performed by Antoine Verhaeghe.

14

Page 29: Control loop for CLUPI - repositorio.poli.ufrj.br

In the diagram, a particular case is illustrated: the focus mechanism is moving

along the horizontal direction, thus the gravity does not influence the system. Ac-

tually, as we will see ahead, the gravity factor is one of the major difficulties in the

implementation of a control loop.

3.3 Analysis using the control theory

3.3.1 Transfer function

Considering the resulting model as the plant to be controlled, the transfer function

can be calculated from the equation of motion:

~F = m~a (3.1)

F = md2x(t)

dt2(3.2)

Fvc + Fm = md2x(t)

dt2(3.3)

Ki(t)− kx(t) = md2x(t)

dt2(3.4)

KI(s)− kX(s) = m

s2X(s)− sx(0)︸ ︷︷ ︸0

−x′(0)︸︷︷︸0

(3.5)

KI(s) = ms2X(s) + kX(s) (3.6)

KI(s) = X(s)(ms2 + k

)(3.7)

X(s)

I(s)=

K

ms2 + k=

Km

s2 + km

(3.8)

By comparing the equation 3.8 with the second order transfer function equation,

G(s) =KP ω2

n

s2 + 2ξωns+ ω2n

, (3.9)

in which ωn = 2πfn. Thus, we conclude that

ωn =

√k

m(3.10)

15

Page 30: Control loop for CLUPI - repositorio.poli.ufrj.br

ξ = 0 (3.11)

KP =K

k(3.12)

The numerical values are:

ωn = 64, 659 rad/s, (3.13)

fn = 10, 291 Hz, (3.14)

KP = 4, 813 mm/A. (3.15)

The corresponding transfer function is

G(s) =(4, 813)(10−3)(4180, 82)

s2 + 4180, 82=

20, 12

s2 + 4180, 82(3.16)

3.3.2 Bode diagram and root locus

The bode diagram of the system is shown in figure 3.3. The root locus plot of the

system is shown in figure 3.4.

16

Page 31: Control loop for CLUPI - repositorio.poli.ufrj.br

Figure 3.3: Bode diagram of the system (gain and phase)

Figure 3.4: Root locus plot

17

Page 32: Control loop for CLUPI - repositorio.poli.ufrj.br

3.4 Simulink model

The design of a model for the studied system is based on the connection of the

devices that were previously presented3: the focus mechanism, the voice-coil and

the spring4.

The focus mechanism displacement x is the variable to be controlled. Hence,

this is the system output. The focus mechanism has also two inputs5, namely

the actuator force and the spring force, each of which has one input (current and

displacement, respectively).

Thus, we can represent the set as it follows (figure 3.5).

Figure 3.5: Simulink model including the focus mechanism, the voice-coil and thespring.

Let us present now the structure of each of the blocks.

The voice-coil block structure consists of a multiplication of the input current

by the motor constant K = 0, 77 N/A.

The same applies to the spring block. The input displacement is multiplied by

the stiffness k = 160 N/m in order to get the elastic force.

Differently from the two other blocks, in the case of the focus mechanism, the

relation input/output is not direct. The inputs of this block are forces while the

output is the displacement.

3The LVDT was omitted here because, as it is a sensor, its only function is to deliver a posi-tion measurement as an input. Thus, we consider that the feedback itself represents the LVDT.Afterwards, the influence of LVDT’s sample time will be analyzed.

4From now on, we refer to the flexure stages as spring.5We are still considering the particular case of figure 3.2, in which the gravity does not affect

the system behavior.

18

Page 33: Control loop for CLUPI - repositorio.poli.ufrj.br

In order to establish a link between these quantities, we use Newton’s second

law followed by two integrator blocks. The structure of the focus mechanism block

is shown in figure 3.6.

Figure 3.6: Simulink model of the focus mechanism block.

Aiming to ensure that the maximum voice-coil current6 to 1, 5 A and to limit

the displacement range to 10 mm, we add two saturation blocks to the model .

6This limit comes from the electronical components that are used.

19

Page 34: Control loop for CLUPI - repositorio.poli.ufrj.br

Chapter 4

Second part: addition of a control

loop

4.1 Objectives

Before designing a controller, it is important to set up the goals concerning the

system output.

In our case, we aim to provide as fast as possible displacements for the focus

mechanism until a given position, while keeping a given accuracy. More precisely,

we want our controller to be able to:

1. Achieve the target position with an accuracy of at least 10 µm.

2. Achieve the goal of point 1 as quickly as possible - we set ourselves a target of

100 ms.

3. Avoid or minimize the overshoot.

It is important to emphasize that the accuracy is of utmost importance. A correct

positioning of the focus mechanism allows CLUPI to function with the proper optical

working distance, which is essential to the z-stacking processing.

4.2 Controller options and choice

As we use MATLAB and Simulink within this project, several options for the im-

plementation of a controller are available, among which:

• writing a MATLAB code containing a control logic;

• using the Stateflow tool. Stateflow is a Simulink environment for modelling and

simulating combinatorial and sequential decision logic based on state machines

and flow charts.

20

Page 35: Control loop for CLUPI - repositorio.poli.ufrj.br

• inserting a PID block, which is available in Simulink library.

Choosing the PID controller seemed a good option for several reasons:

• its implementation in Simulink is rapid and practic;

• the PID controller is widely used in the industry and there is a large bibliog-

raphy available on this topic.

• we can easily tune the PID parameters according to our goals and priorities

through the Tuning tool, a feature of the PID block.

4.3 Simulations using a PID controller

After the addition of a PID controller, we have the model that is shown in figure

4.1.

Figure 4.1: Control loop after addition of the PID controller.

4.3.1 Inputs

In figure 4.1, we can see that there is a step block that is being used as a source.

In the framework of this analysis, we consider two different types of input1: a

short displacement and a larger one. (figure 4.2).

By considering a 1 mm displacement and 5 mm one, a more demanding case in

terms of energy, we are able to analyze the system reaction in completely different

situations.

1Here, we dot not refer to the voice-coil input, but to the global system input, i.e., to the desiredposition or set point.

21

Page 36: Control loop for CLUPI - repositorio.poli.ufrj.br

Figure 4.2: Two distinct set points: xsp = 1 mm and xsp = 5 mm.

4.3.2 Simulations using the tuning tool

The PID block has two input modes:

• a direct one, in which the parameters P, I, D and N directly entered by the

user;

• an indirect one, the Tuning tool, in which we adjust two parameters:

– response time (tr) - it is the time lagged between the initial moment

and the first moment in which the output reaches 50 % of its final value;

– transient behavior coefficient (Ktb) - it is a coefficient that allows us

to change the robustness of the system. The higher this coefficient is,

the more stable will be the output. However, increasing this value means

slowing down the system.

Then, based on our choice, the block automatically calculates the four afore-

mentioned parameters.

In a first stage, we choose to use the Tuning tool. Subsequently, we will perform

a fine tuning using the direct method in order to enhance the controller performance

according to our initial goals.

Having tested several response time/transient behavior coefficient pairs, the best

controller that we have obtained has the following characteristics:tr = 0, 8 ms

Ktb = 0, 6(4.1)

22

Page 37: Control loop for CLUPI - repositorio.poli.ufrj.br

This configuration corresponds to:

P = 2501, 9

I = 16522, 2

D = 34, 4

N = 1783, 1

(4.2)

The results are shown in figures 4.3 and 4.4. In both cases, there is a large

overshoot (≈ 10%), followed by a slow recovery.

Figure 4.3: x (meters)× t (seconds) -Tuning tool PID controller - system responsewith a 1 mm set point

A 90 µm error is observed at 100 ms (10 µm was the goal that was set in

section 4.1) in the case of a 5 mm. In the case of a 1 mm displacement, there is an

apparently precise value, but by observing the graph, we can notice that this result

is not valid because the steady-state has not been reached yet. Even though the

controller works, we are still far from the desired rapidity.

It is clear that, despite the usefulness of the Tuning tool for establishing a first

set of parameters, the results that are obtained with this feature are very limited.

23

Page 38: Control loop for CLUPI - repositorio.poli.ufrj.br

Figure 4.4: x (meters)× t (seconds) - Tuning tool PID controller - system responsewith a 5 mm set point

4.3.3 A short study on PID controllers theory

In order to enhance the PID controller by directly changing its fundamental pa-

rameters, it is necessary to understand how they work, which is not trivial. A

PID controller actually performs three separate actions (proportional, integral and

derivative), which have distinct effects (rapidity increase, robustness increase, etc.).

Therefore, before going into the direct method, we have performed a brief theo-

retical study on PID control theory.

Introduction

A proportional-integral-derivative controller is a control loop feedback mechanism

that calculates an error value as the difference between a measured process variable

and a desired set point. The controller attempts to minimize the error in outputs

by adjusting the process control inputs (figure 4.5).

Figure 4.5: Diagram of a PID controlled system.

24

Page 39: Control loop for CLUPI - repositorio.poli.ufrj.br

The PID block details are shown in figure 4.6.

Figure 4.6: The structure of a PID controller block.

Therefore, the equation which describes the operation of a PID controller is:

u(t) = K

(e(t) +

1

Ti

∫ t

0

e(τ)dτ + Tdde(t)

dt

), (4.3)

in which:

• e(t) is the control error, given by the subtraction ysp(t)− y(t);

• K is the proportional gain;

• Ti is the integral time;

• Td is the derivative time.

In a PID, three separate actions are performed:

• the integral part can be interpreted as a control action based on the past;

• the proportional part can be interpreted as a control action based on the

present;

• the derivative part can be interpreted as a control action based on the predicted

future.

25

Page 40: Control loop for CLUPI - repositorio.poli.ufrj.br

Effects of proportional, integral and derivative actions

Proportional action

• The controller action will be proportional to the present value of the error.

• A proportional controller will have the effect of reducing the rise time.

• The steady-state error can be reduced (with increasing gain) but it will

never disappear.

• As the gain increases, the tendency towards oscillation will also increase.

Integral action

• The strength of integral action increases with decreasing of Ti.

• Rapid rise, but a long time for steady-state establishment.

• The action of a integral controller may eliminate the steady-state error.

• Increasing the integral action also implies a growth of the oscillation ten-

dency.

Derivative action

• Damping increases with increasing derivative time, but decreases again when

derivative time becomes too large.

• Derivative action does not help if the prediction time Td is too large.

• The period of oscillation increases when derivative time is increased.

Filtering Differentiation is always sensitive to noise. Without noise, we would

have:

D(s) = L(Tdde(t)

dt

)= sTdE(s) (4.4)

In a practical controller with derivative action it is therefore necessary to limit

the high frequency gain of the derivative term. This can be done by implementing

the derivative term as

D(s) =sKTd

1 + sTd

N

E(s) (4.5)

The equation 4.5 actually represents a derivative term such as the ideal one

(equation 4.4) but filtered by a first-order filter with the time constant Td

N.

26

Page 41: Control loop for CLUPI - repositorio.poli.ufrj.br

Thus, the transfer function of the PID controller becomes:

U (s)

E(s)= K

(1 +

1

sTi+

sTd

1 + sTd

N

)(4.6)

4.3.4 Simulations using the direct method

The most evident problem with the precedent controller is its rise time. We would

like to have a faster system so that the desired accuracy is reached before t = 100 ms.

As explained in section 4.3.3, increasing the proportional gain could be the so-

lution to this. Let us observe the effect of doubling the proportional gain while

keeping constants the other ones.

This change provides indeed a faster controller, in particular in the case of the

5 mm displacement. The new accuracy values at 100 ms are:

• 12 µm (∆x = 1 mm)

• 3 µm (∆x = 5 mm)

This measure allowed us to sharply reduce the error in the 5 mm. However, we

can notice that the 1 mm has lightly raised. This is probably due to the increase of

the oscillatory tendencies arising from the high proportional gain.

Figure 4.7: x (meters) × t (seconds) - Increasing the proportional gain - systemresponse with a 1 mm set point

27

Page 42: Control loop for CLUPI - repositorio.poli.ufrj.br

Figure 4.8: x (meters) × t (seconds) - Increasing the proportional gain - systemresponse with a 5 mm set point

In order to try to continue to provide a fast rise without creating the problem

of the previous controller, we try to manipulate the integral action. The integral

action contributes to a rapid rise.

The results at t = 100 ms are:

• 2 µm (∆x = 1 mm)

• 70 µm (∆x = 5 mm)

with I = 17000 and

• 9 µm (∆x = 1 mm)

• 16 µm (∆x = 5 mm)

with I = 18000, which is the best result so far (figures 4.9 and 4.10). However, we

can not unlimitedly increase the I parameter once that we will reach the steady-state

slower.

28

Page 43: Control loop for CLUPI - repositorio.poli.ufrj.br

Figure 4.9: x (meters)× t (seconds) - Increasing the integral gain - system responsewith a 1 mm set point

Figure 4.10: x (meters)× t (seconds) - Increasing the integral gain - system responsewith a 5 mm set point

29

Page 44: Control loop for CLUPI - repositorio.poli.ufrj.br

As last improvement, we try to optimize the derivative action. Increasing Td a

stability enhancement until an optimal point, from which it brusquely drops.

Indeed, in our PID controller, we are able to detect the presence of an optimal

point, but this parameters is almost equal to the previous D parameter (figures 4.11

and 4.12).

Figure 4.11: x (meters)× t (seconds) - Optimal Td - system response with a 1 mmset point

30

Page 45: Control loop for CLUPI - repositorio.poli.ufrj.br

Figure 4.12: x (meters)× t (seconds) - Optimal Td - system response with a 5 mmset point

4.3.5 Conclusions about the PID controller

Implementing a PID controller in Simulink is not a complicated task. By inserting

the PID block, we can immediately design a feedback control loop of the studied

system.

However, the choice of the P , I and D parameters is not that simple. As we have

“three independent controllers” acting simultaneously, the perfect tuning requires

delicate changes. Moreover, in the case of CLUPI ’s focus mechanism, we have rigid

and precise objectives - accuracy and speed. In order to properly respond to these

exigencies, it was necessary to understand the actions of each part of the PID.

The results were not satisfying. Although some good accuracy results were

obtained, we were not able to ensure a rapid response to any displacement.

The PID controller is commonly used in industrial applications in which the plant

has a complex mathematical description and in which there are many variables to

be controlled. This is not the case of our focus mechanism, which is a well-defined

system with a precise theoretical description.

Therefore, it is possible that the PID is not the most appropriate controller

for this project because it adds complexity to our system, leading to impredictable

results, such as what happened after we increased the proportional gain: the error

at 100 ms was higher in the 1 mm case than in the 5 mm case.

This issue led us to decide to implement a controller in which the logic is defined

by ourselves, returning thereby to the list presented in section 4.2.

31

Page 46: Control loop for CLUPI - repositorio.poli.ufrj.br

4.4 Simulations using the Stateflow environment

4.4.1 Stateflow presentation

Stateflow [3][4] is an environment for modeling and simulating combinatorial and

sequential decision logic based on state machines and flow charts. Stateflow lets us

combine graphical and tabular representations, including state transition diagrams,

flow charts, state transition tables, and truth tables, to model how our system reacts

to events, time-based conditions, and external input signals.

As an example of the Stateflow logic, we show in figure 4.13 one of the first

models that we used as an attempt to control the plant. The chart is composed by

two states, each one with its voice-coil current value. The transition between them

is based on speed criteria: when the focus mechanism speed drops below a certain

value, the transition takes place. The variable named “cycle” works as a trigger.

This is a illustrative basic model and we will not go into its details.

Figure 4.13: An example of a Stateflow chart - Two different states and one transi-tion.

4.4.2 Operating principle

Basic models such as the one that was presented in figure 4.13 do not use all the

power that can be provided by the voice-coil. These models, which are based on

applying the stabilty current 2 (the current needed to keep the voice-coil at a certain

position) have as major drawback the poor performance regarding the speed.

In order to design a controller that is able to satisfy the 100 ms criteria for any

displacement range, it is important to use the voice-coil’s maximum power. This

can be done in accordance with the following logic:

2The stability current at a given position is given by Istab = kxK .

32

Page 47: Control loop for CLUPI - repositorio.poli.ufrj.br

1. In a first moment, we supply a 1, 5 A3 current to the voice-coil, which will

thereafter output a maximal force.

2. As the focus mechanism moves in response to this current, we constantly

calculate xf , which is the position where would the focus mechanism returns

to a v = 0 condition if we stopped to accelerate and started applying a −1, 5 A4

braking current.

3. As we want the focus mechanism to stop at the set point, we apply this braking

current when xf = x.

4. We keep the brake effect until the moment in which the focus mechanism has

a very low speed, when we finally apply the stability current.

4.4.3 First attempts

The first idea that comes to mind when we want to implement this logic is the use

of the classical equations of motion. By setting ~F = m~a, we generate a differential

equation relating x(t) to i(t), which allows us to know, for example, the behavior

of x when we apply 1, 5 A. From this relation, what we try to do is to link the two

known parts of the output by an interpolated function (figure 4.14).

Figure 4.14: Interpolation between maximal acceleration and stability position.

The corresponding model in Stateflow has a considerable amount of incertitude.

The position in which we start braking is arbitrary, as well as the interpolated

function.

3In the case of a negative set point, −1, 5 A.4In the case of a negative set point, 1, 5 A

33

Page 48: Control loop for CLUPI - repositorio.poli.ufrj.br

The use of ~F = m~a does not enable us to design a direct and precise Stateflow

controller and therefore it is not a satisfactory solution5.

4.4.4 Conservation of the energy

Another way to put the control logic that was explained in section 4.4.2 into practice

is by using conservation of energy. In this sense, let us consider the diagram of figure

4.15.

Figure 4.15: Energy analysis: at xi, we start braking with maximal power. At theset point, zero speed.

The initial position xi is actually the position in which we stop providing Imax =

1, 5 A and we start providing −Imax = −1, 5 A so that the focus mechanism slows

down.

The final position xf corresponds to the set point. We want the braking effect

to act so that the focus mechanism stops exactly here (v ≈ 0).

This is not a conservative system because the voice-coil force acts like an external

agent, removing energy from the system. Hence, we can say that6 7 8:

Ef = Ei −Wvc, (4.7)

5Indeed, the resulting graphics evidence large oscillations around the set point6Ef is the final energy.7Ei is the initial energy.8Wvc is voice-coil’s work.

34

Page 49: Control loop for CLUPI - repositorio.poli.ufrj.br

in which Wvc is the absolute value of the work done by the voice-coil during the

braking period. As E = Ekinetic + Epotential, we can rewrite the equation 4.7 as it

follows:

1

2kx2f =

1

2kx2i +

1

2mv2i −Wvc (4.8)

or

kx2f = kx2i +mv2i − 2Fvc (xf − xi) (4.9)

By rearranging the terms of 4.9 and replacing Fvc by KImax, we obtain the following

quadratic equation9:

x2f︸︷︷︸a=1

+

(2KImax

k

)︸ ︷︷ ︸

b

xf +

[−(x2i +

mv2ik

+2KImaxxi

k

)]︸ ︷︷ ︸

c

= 0. (4.10)

Bhaskara’s formula gives:

xf =−b±

√b2 − 4ac

2a. (4.11)

These equations are represented in Stateflow by three states (figure 4.16): a

initial state of acceleration (which has two sub-states, each one for positive or neg-

ative case), an intermediate state of braking, in which the system enters once that

xf = xsp and finally, a stability state (v ≈ 0).

Figure 4.16: Stateflow chart - conservation of the energy

The complete control system is shown in figure 4.17. In figures 4.18, 4.19 and

4.20, we are able to see, for three different set points, the result of the Stateflow

9For the negative points, we invert the signs of b and of the last term of c.

35

Page 50: Control loop for CLUPI - repositorio.poli.ufrj.br

control based on the conservation of energy. Detailed results are shown in table 4.1,

in which δss is the steady-state accuracy and “criteria” is our 100 ms criteria.

Figure 4.17: Complete model with the Stateflow chart acting as a controller

36

Page 51: Control loop for CLUPI - repositorio.poli.ufrj.br

Figure 4.18: x (meters) × t (seconds) - system response with xsp = 2 mm

Figure 4.19: x (meters) × t (seconds) - system response with xsp = 5 mm

Figure 4.20: x (meters) × t (seconds) - system response with xsp = −3 mm

37

Page 52: Control loop for CLUPI - repositorio.poli.ufrj.br

Table 4.1: Time, precision and energy results achieved with the Stateflow controllerbased on the conservation of energy.

xsp (mm) t10%−90%(ms) tss(ms) |v|max(µm/ms) Erise(mJ) δss(µm) Criteria

±5, 0 13, 0 22, 0 40 158 9, 5 OK±4, 0 12, 0 20, 0 35 143 9, 5 OK±3, 0 10, 5 18, 0 31 130 9, 5 OK±2, 0 08, 0 15, 0 25 110 9, 5 OK±1, 0 06, 5 06, 5 17 080 9, 5 OK±0, 5 06, 0 08, 0 12 056 9, 5 OK

This controller gave us the best results so far. A satisfactory accuracy was

obtained (9, 5 µm for all the movements) within a very short time interval. The

longest settle time, t = 22 ms, is approximately 15

of our initial goal, 100 ms.

4.4.5 Addition of the gravity effect

By using the conservation of energy, we have obtained a controller that works very

well for a wide range of situations. Instead of treating differential equations as in

the previous attempts, we have managed to design a chart that deals only with

quadratic equations.

However, this new controller is for now limited to an operation in horizontal

position because the gravitiy was not taken into account. Generally, we can say

that our controller is very sensitive to light changes (the conservation of energy

including the gravity becomes much less precise).

In order to increase the system’s robustness, we try to design a controller in

which:

• the gravitational force is not a known input;

• other types of perturbation are also neutralized.

In order to deal with these new requirements, we have to perform some modifi-

cations on the original chart (figure 4.16).

We do not know CLUPI ’s angle regarding the ground. Thus, we are unable to

determine the intensity of the component of the gravitational force that acts along

the displacement axis. Therefore, we need the controller to continuosly calculate

this force.

One way of doing this is by calculating the difference between the measured

acceleration and the expected acceleration (ideal case). If there were no disturbing

38

Page 53: Control loop for CLUPI - repositorio.poli.ufrj.br

forces10 at all, the acceleration would be equal to:

aideal =Ki− kx

m(4.12)

By comparing this acceleration with the real one we are able to determine the

magnitude of the gravitational force:

∆a = a− ai (4.13)

Fg =∆a

m(4.14)

We add this new calculation to our Stateflow controller 11. In figure 4.21, we are

able to see the modifications that were made on one of the acceleration sub-states

according to the equations 4.13 and 4.14.

Figure 4.21: Acceleration sub-state after addition of the gravity effect

There are no changes concerning the braking state. On the other hand, we do

not keep the stability state as in the previous controller. This state takes also into

account the potential perturbations (Istab = Isp − Fg

K).

10in which we include the gravity11Later, in order to ensure a correct robustness, instead of taking only the last gravity value into

account, we have implemented an algorithm that calculates an average using the last ten values.By doing this, we aimed to prevent an incorrect measure from spoiling the controller’s logic.

39

Page 54: Control loop for CLUPI - repositorio.poli.ufrj.br

The resulting outputs, very similar to the ones shown in section 4.4.4, are shown

in figures 4.22, 4.23 and 4.24. The accuracy is even better (3 µm).

Figure 4.22: System response after the robustness enhancement - xsp = 2 mm

Figure 4.23: System response after the robustness enhancement - xsp = 5 mm

40

Page 55: Control loop for CLUPI - repositorio.poli.ufrj.br

Figure 4.24: System response after robustness enhancement - xsp = −3 mm

4.4.6 Damping

Even after the modifications and improvements on accuracy, there is still a problem

that the controller was not able to solve: as the focus mechanism keeps a residual

momentum when it reaches the steady state position, small amplitude oscillations

can be observed around the set point.

We would normally count on drag to damp the output, but the martian atmo-

sphere is very light, which implies a negligible drag force. One way to express this

is by means of the drag equation:

FD =1

2ρv2CDA, (4.15)

in which FD is the drag force, ρ is the density of the fluid, v is the speed of the object

relative to the fluid, A is the cross-sectional area and CD is the drag coefficient.

In our case, ρ = 0, 02 kg/m3 (air), CD = 0, 82 (using an approximation that

considers the mobile part of the system to be a cylinder) and A = πR2 with R =

38 mm. From these values, we get drag forces varying between 10−15 N and 10−14 N.

This means that a very soft damping is performed by the air. We can not use

the air drag to stabilize the focus mechanism. A forced damping is necessary and

we can create this by implementing a new state in Stateflow.

Let us suppose that IC is the current which keeps the focus mechanism oscillating

around the set point (not necessarily equal to Isp because there may be the gravity

effect or another perturbation).

In order to create a state which provides the desired damping, we can establish:

i(t) = IC + ∆i(t) . (4.16)

As IC is a constant, we must perform this action by changing ∆i. As in the case

41

Page 56: Control loop for CLUPI - repositorio.poli.ufrj.br

of a aerodynamic drag, we can use the speed to reach the stability. Therefore, let

us impose

∆i = −Bv . (4.17)

The figure 4.25 shows how did we implement this logic in Stateflow.

Figure 4.25: Implementation of a new state in order to remove the small oscillations.

By comparing figures 4.26 and 4.27, we can notice the effectiveness of the damp-

ing effect for the case in which xsp = 5 mm.

Figure 4.26: Zoomed displacement output - x (meters)× t (seconds) - xsp = 5 mm- No damping.

Figure 4.27: Zoomed displacement output - x (meters)× t (seconds) - xsp = 5 mm- Damping.

42

Page 57: Control loop for CLUPI - repositorio.poli.ufrj.br

4.4.7 Adapting the controller to any kind of displacement

Since the beginning of this study, we have analyzed one single case, in which the

focus mechanism is initially at the position x = 0. Afterwards, we apply to the

system a certain current in order to bring it to a desired position, the set point.

In order to generalize this model so that our controller is capable of bringing the

focus mechanism from any position to any position, we need to add a new transition

in our Stateflow chart.

Figure 4.28: Closed loop after insertion of a new transition.

One way of doing this is by imposing a new displacement condition: we ask

the system to re-enter the accelerate state if and only if the new set point moves

away from the current position by a certain distance δ. As shown in figure 4.29,

this method has a precision limit. The controller will track the set point only if the

distance between the old and the new set point is higher than δ. We have chosen

δ = 0, 1 mm.

43

Page 58: Control loop for CLUPI - repositorio.poli.ufrj.br

Figure 4.29: The limitation of our closed control loop. The logic works for the greencase, but not for the orange one.

In order to test this global model, we use a 5 mm-amplitude square wave with

a frequency of 5 Hz so that the set point changes at every 100 ms. The result is

shown in figure4.30.

Figure 4.30: The focus mechanism displacement tracks the reference square wave.

44

Page 59: Control loop for CLUPI - repositorio.poli.ufrj.br

Chapter 5

Third part: real-time control

5.1 Speedgoat presentation

In the framework of the development of the real control loop, we use a real-time

target machine (figure 5.1).

Figure 5.1: Speedgoat performance real-time target machine.

When connected to a host computer, this machine is able to act as a real-time

controller. This will allow us to test the controllers that were developed within

MATLAB and Simulink using our real system. The interface host computer/target

machine is done by means of a IO101 module, whose terminal board is shown in

figure 5.2.

The IO101 module is a precision, single size PMC module with the capability to

45

Page 60: Control loop for CLUPI - repositorio.poli.ufrj.br

monitor 16 differential or 32 single-ended analog input channels to 16-bit resolution.

In addition, eight 16-bit analog output voltage channels and 16 digital input/output

channels are provided.

Figure 5.2: IO101 68-pin terminal board.

5.2 Loop-back test

Our final objective is to use Speedgoat as a controller in order to validate our

previous work (MATLAB and Simulink models). However, before implementing the

whole control loop, we perform some tests.

In order to know how the target machine influences the data acquisition, we per-

form a loop-back test. A loop-back test consists in getting a signal that is generated

by the machine itself. In other words, we connect the analog output directly to the

analog input so that we can compare the acquired signal to the original one, as in

the diagram which is shown in figure 5.3 1.

The results of the loop-back test are shown in table 5.1.

Table 5.1: Loop-back characteristics

Offset [mV] Gain error coefficient (Kg)0, 673 0, 0667

1We connect all the analog inputs to the ground to prevent them from floating.

46

Page 61: Control loop for CLUPI - repositorio.poli.ufrj.br

Figure 5.3: Loop-back test configuration.

5.2.1 Addition of the operational amplifier

Speedgoat is not able to deliver a 1, 5 A current. In order to provide more power, we

place at IO101’s output a operational amplifier. Its function is precisely to deliver

the proper current values to the system.

However, by adding this new element, we add also a new gain and a new offset.

However, in this case, the loop-back error and the amplifier error are mingled, which

gives us a global error (table 5.2). As we know the loop-back error from the previous

section, we are able to calculate the amplifier parameters (5.3).

Table 5.2: Global loop characteristics

Offset [mV] Gain error coefficient (Kg)1, 302 0, 167

Table 5.3: Operational amplifier characteristics

Offset [mV] Gain error coefficient (Kg)0, 629 2, 502

47

Page 62: Control loop for CLUPI - repositorio.poli.ufrj.br

5.2.2 Next steps

Having characterized the real-time target machine as well as the operational ampli-

fier, we still have to:

• implement the LVDT sensor and couple it to the control loop;

• test the global control loop;

• test our final Stateflow controller linking it to the real system through Speed-

goat.

An overall diagram of the control system is shown in figura 5.6. In order to

validate the effectiveness of the control loop, we use the optical sensor which is

shown in figura 5.7. It allows us to measure the displacement with a precision of 5

µm.

Figure 5.4: The CLUPI set at the Space Exploration Institute.

48

Page 63: Control loop for CLUPI - repositorio.poli.ufrj.br

Figure 5.5: LVDT and voice-coil attached to CLUPI’s focus mechanism

Figure 5.6: Overall diagram of the control system

49

Page 64: Control loop for CLUPI - repositorio.poli.ufrj.br

Figure 5.7: Optical sensor

50

Page 65: Control loop for CLUPI - repositorio.poli.ufrj.br

Chapter 6

Conclusion

Our initial goals were:

1. To create a numerical model to the system.

2. To develop a control logic able to control the system.

3. To implement this control logic on the real system in a real-time condition.

Concerning the item 1, which was a requirement to the other ones, we can say

that the task was entirely accomplished. Actually, this was a initial step to the

development of the item 2.

The second part of this mission, in which I have passed most of the time, was

a harder task. Starting from scratch, we had to design a controller capable of

responding to a certain number of needs. The PID controller, our first option, was

left behind. Our accuracy criteria was of utmost importance and we could not be

satisfied by average results.

Our choice to change the type of the controller was a true success. We achieved

a much more precise and mainly a much more rapid controller with Stateflow. The

controller’s logic is accurated, mathematically simple and easily adaptable to dif-

ferent situations. Indeed, it is possible to adapt the controller for other operating

conditions, such as temperature, for example.

Recently, we have started to implement the item 3, the real-time control loop,

final step of this mission. Having performed several tests with each isolated device,

we are now ready to assemble the entire system. Then, we will use Speedgoat to

test and validate the work that had been done in Simulink and MATLAB.

We have initiated the real-time tests, which were coherent with the previous

simulations. Unfortunately, I did not have enough time within the institute to

accomplish these tests and to formalize their results. This assignment was left to

my co-workers.

51

Page 66: Control loop for CLUPI - repositorio.poli.ufrj.br

Bibliography

[ 1 ] OGATA, K. Engenharia de Controle Moderno. Editora Prentice Hall, Rio

de Janeiro, RJ. 1982

[ 2 ] FRANKLIN, G. F., POWELL, J. D., EMAMI-NAENI, A. Feedback

Control of Dynamic Systems. Pearson, 7th edition. 2015

[ 3 ] PINTO, J. Stateflow Hands-on Tutorial. Faculdade de Engenharia do

Porto, Porto. 2010

[ 4 ] Stateflow User’s Guide. MathWorks, Inc. 2009

52

Page 67: Control loop for CLUPI - repositorio.poli.ufrj.br

Appendix A

LVDT and Speedgoat data

A.1 LVDT

This micro-miniature LVDT is designed for high resolution position measurement in

tight places. It is layer wound on metal coil-form provides excellent stability, while

ferromagnetic housing takes care of the electromagnetic and electrostatic shielding

Several options are available for signal conditioning: digital or analog EL-35 sig-

nal conditioners, CB-100 line powered control box, and USB-10 digital controller.

Different versions of this LVDT can be manufactured by request.

• SM Series LVDT 2,3 mm diameter

• Input voltage: 2,3 Vrms max

• Input frequency: 5 kHz

• Operating temperature range −20o C to 70o C

• Housing material: Nickel-Iron Alloy

A.2 Speedgoat (IO101 module)

• 32 single-ended or 16 differential channels, multiplexor, all channels share one

A/D converter

• 16 bit resolution

• 8 single-ended channels, dedicated D/A converter per channel

• 16 bit resolution

• 16 TLL channels, direction configurable in 2 banks of 8 channels.

53