APPLICATION OF A NOVEL PID AUTO-TUNER
TO A LUNG FUNCTION TESTING DEVICE
Andres Hernandez, Robin De Keyser and Clara Ionescu
Department of Electrical energy, Systems and Automation, Ghent University
Technologiepark 913, B9052 Gent, Ghent, Belgium
Keywords: Respiratory impedance, Closed loop control, PID, Auto-tuner, Frequency response.
Abstract: The paper presents a closed loop approach for the lung function tests of forced oscillation technique. In this
method it is important to ensure that the desired excitation signal to be applied at the patient’s mouth will be
delivered by the lung function testing device, without introducing distortions and nonlinear effects. A novel
PID auto-tuner is applied in an initial phase of the investigation, without the patient, to verify whether the
closed loop control can be implemented. The results are promising, showing that the auto-tuner is able to
perform well and ensure the desired signal at the output of the device, within safety limits for the control
effort (air flow).
1 INTRODUCTION
Non-invasive lung function tests are broadly used
for assessing respiratory mechanics (Northrop, 2002;
Oostveen et al., 2003). Contrary to the forced
maneuvers from patient side and special training for
the technical medical staff necessary in spirometry
and in body plethysmography (Pellegrinno et al.,
2005; Miller et al., 2005), the technique of
superimposing air pressure oscillations is simple and
requires minimal cooperation from the patient,
during tidal breathing (Oostveen et al., 2003).
Among the air pressure oscillation techniques for
lung function testing, the most popular one is that of
Forced Oscillation Technique (FOT). FOT uses a
multisine signal to excite the respiratory mechanical
properties over a wide range of frequencies, usually
between 4-48Hz (Oostveen et al., 2003).
Using measurements of air pressure and air flow,
it is possible to extract information regarding the
human respiratory input impedance. However this is
a linear approximation of a nonlinear system, hence
the output will depend on the input’s amplitude and
frequency (Schoukens & Pintelon, 2001). It is
therefore important to ensure that the desired signal
to be applied at the patient’s mouth will be delivered
by the lung function testing device, without
introducing distortions and nonlinear effects. Hence,
a closed loop control system is necessary, to
continuously monitor and correct the errors between
the desired input signal and the one delivered by the
device at the patient’s mouth.
PID controllers can incorporate auto-tuning
capabilities (Åström & Hägglund, 1995). The auto-
tuners are equipped with a mechanism capable of
automatically computing a reasonable set of
parameters when the regulator is connected to the
process. Auto-tuning is a very desirable feature
because it does not require a-priori identification of
the system to be controlled. The auto-tuning features
provide easy-to-use controller tuning and have
proven to be well accepted among process engineers
(Leva et al. 2002).
The aim of this study is to apply a PID auto-tuner
to the FOT device and test whether the controller
can follow a multisine reference input. The objective
is that the nonlinear effects and distortions coming
from the FOT device itself are corrected by the
control action, such that the excitation signal of
interest is delivered to the patient. In this incipient
phase, the closed loop control will be designed for a
hypothetical patient: a respiratory tube and a rubber
balloon. The underlying reason is that we need to
ensure repeatability of our experiments, in order to
check the feasibility of implementing a closed loop
control strategy in the lung function device. The
final aim is to develop the closed loop control for the
case when the patient is breathing (i.e. in presence of
disturbance).
55
Hernandez A., De Keyser R. and Ionescu C..
APPLICATION OF A NOVEL PID AUTO-TUNER TO A LUNG FUNCTION TESTING DEVICE.
DOI: 10.5220/0003154500550061
In Proceedings of the International Conference on Biomedical Electronics and Devices (BIODEVICES-2011), pages 55-61
ISBN: 978-989-8425-37-9
Copyright
c
2011 SCITEPRESS (Science and Technology Publications, Lda.)
The paper is organized as follows: the device and
test setup are described in the next section. The
underlying principles of the auto-tuner algorithm
and the PID parameters are given in the third
section, followed by a section describing the
validation of the closed loop control for multisine
setpoint and comparison to open loop performance.
A conclusion section summarizes the main outcome
of this investigation and points towards further
developments.
2 IMPEDANCE MEASUREMENT
The impedance was measured using a modified FOT
setup, able to assess the respiratory mechanics from
4-50 Hz. The specifications of the device are: 11kg,
50x50x60 cm, 40 seconds measurement time,
European Directive 93/42 on Medical devices and
safety standards EN60601-1.
Figure 1: A schematic overview (A) and an electrical
analogy of the FOT setup (B).
Typically for lung function testing purposes, the
subject is connected to the setup from figure 1 via a
mouthpiece, suitably designed to avoid flow leakage
at the mouth and dental resistance artefact. The
oscillation pressure is generated by a loudspeaker
(LS) connected to a chamber. The LS is driven by a
power amplifier fed with the oscillating signal
generated by a computer. The movement of the LS
cone generates a pressure oscillation inside the
chamber, which is applied to the patient's respiratory
system by means of a tube connecting the LS
chamber and the bacterial filter (bf). A side opening
of the main tubing (BT) allows the patient to have
fresh air circulation. Ideally, this pipeline will have
high impedance at the excitation frequencies to
avoid the loss of power from the LS pressure
chamber. It is advisable that during the
measurements, the patient wears a nose clip and
keeps the cheeks firmly supported. Before starting
the measurements, the frequency response of the
pressure transducers (PT) and of the
pneumotachograph (PN) are calibrated. The PN is a
meter for measuring gas flow rates during breathing
by recording pressure differences across a device of
fixed-flow resistance that has known pressure and
flow characteristics. The measurements of air-
pressure P and air-flow Q during the FOT lung
function test are done at the mouth of the patient.
The FOT excitation signal was kept within a
range of a peak-to-peak range of 0.1-0.3 kPa, in
order to ensure patient comfort and linearity
(Oostveen et al., 2003). From these signals, the non-
parametric representation of the patient’s lung
impedance Z
r
is obtained assuming a linear
dependence between the breathing and
superimposed oscillations at the mouth of the patient
(Ionescu & De Keyser, 2008). The algorithm for
estimating Z
r
can be summarized from the electrical
analogue in figure 1-B:
(1)
where s denotes the Laplace operator. Since the
excitation signal is designed such that it is not
correlated with the breathing of the patient,
correlation analysis can be applied to the measured
signals. Therefore, one can estimate the respiratory
impedance as the ratio:
()
()
()
PU
r
QU
Sj
Zj
Sj
ω
ω
ω
=
(2)
whereas the P corresponds to pressure (its electrical
equivalent is voltage) and Q corresponds to air-flow
(its electrical equivalent is current), U the excitation
signal,
()
ij
Sj
ω
the cross-correlation spectra
between the various input-output signals, ω is the
angular frequency and
1/2
(1)j =−
, resulting in the
complex variable Z
r
. From the point of view of the
forced oscillatory experiment, the signal components
of respiratory origin (U
r
) have to be regarded as pure
noise for the identification task (Ljung, 1999). In
this application, the patient is replaced by a system
without disturbance U
r
=0 (i.e. a respiratory tube
with a rubber balloon attached at the end) in order to
ensure repeatability and test the feasibility of
implementing a closed loop control algorithm in the
FOT setup.
() () () ()
rr
Ps Z sQs U s=+
BIODEVICES 2011 - International Conference on Biomedical Electronics and Devices
56
3 UNDERLYING PRINCIPLES OF
KCR PID AUTO-TUNING
The development of this auto-tuning algorithm is
based on the prior art where two relay-based PID
auto-tuners have been presented: the Kaiser-Chiara
auto-tuner and the Kaiser-Rajka auto-tuner. Hence
the proposed algorithm is an extended combination
of the two: the Kaiser-Chiara-Rajka auto-tuner
algorithm (KCR) (De Keyser & Ionescu, 2010).
Notice that the development of the PID controller
does not require a-priori knowledge of the system.
The closed loop transfer function of a second
order system with complex conjugate poles, and
static gain one is given by:
2
22
()
2
n
nn
Ts
ss
ω
ζ
ωω
=
++
(3)
with
n
ω
the natural frequency and
ζ
the damping
factor. From (3) one has the relationship between the
closed loop percent overshoot (OS%) and the peak
magnitude M
p
in frequency domain (Nise, 2007):
2
/1
2
1
% 100 ,
21
p
OS e M
πζ
ζζ
−−
==
(4)
By specifying the allowed overshoot in the
closed loop, it follows that the closed loop transfer
function must fulfill the condition:
()
()
1()
Gj
Tj M
Gj
ω
ω
ω
==
+
(5)
with
()Gj
ω
the open loop transfer function of both
the process and controller. Re-writing (5) in its
complex form:
[]
() ()
()
1() ()
RjI
Tj
RjI
ωω
ω
ω
ω
+
=
++
(6)
with R the real part and I the imaginary part, and
taking
2
()Tj
ω
results that:
()
2
22
R
cIr++=
(7)
where
2
22
,
11
pp
pp
MM
cr
MM
==
−−
, which is nothing
else than the equation of a (Hall-)circle with radius r
and center in
{
}
,0c
(Nise, 2007). In order to have a
peak magnitude, only those circles with M>1 are of
interest. Intersection with the unit circle is achieved
by using (7) and the condition:
22
1
R
I+=, hence
solving for R and I yields:
2
2
12
0.5
p
p
M
R
M
=
and
2
2
0.25
p
p
M
I
M
=−
(8)
The phase margin is given by
tan
I
PM
R
=
thus:
2
1
2
0.25
tan
0.5
p
p
M
PM
M
=
(9)
We stated in (De Keyser & Ionescu, 2010) that
specifying PM does not suffice to guarantee a good
closed loop performance in all situations. Therefore,
the next step is to determine the cross-over
frequency; i.e. the frequency where the process and
controller crosses the 0 dB line (open loop).
If the settling time of the closed loop is specified,
then using
4/
sn
T
ω
ζ
=
and (4) we can obtain the
bandwidth frequency:
()
242
1442
BW n
ωω ζ ζζ
=
−+ +
(10)
From (De Keyser & Ionescu, 2010), we use that
1.5
BW c
ω
ω
and the generalization to higher order
systems which gives
2
cBW c
ω
ωω
. By having the
cross-over frequency
c
ω
, a sinusoid with period
2
c
c
T
ω
π
=
can be applied to the process and obtain
the output:
(
)
() cos sin
j
c
Gj Me M j
ϕ
ω
ϕϕ
== +
(11)
using the transfer function analyzer algorithm
(Ionescu et al, 2010). The task is now to find the
controller parameters such that the specification for
phase margin is fulfilled, by giving
%OS ,
s
T , M
and
ϕ
.
The controller is derived in its textbook form,
which for the critical frequency becomes:
21
() 1
2
cp d
c
i
c
Rj K jT
T
T
T
π
ω
π
⎛⎞
⎜⎟
⎜⎟
=+
⎜⎟
⎜⎟
⎝⎠
(12)
Starting from the controller frequency response
in (12), the loop frequency response is given by:
APPLICATION OF A NOVEL PID AUTO-TUNER TO A LUNG FUNCTION TESTING DEVICE
57
( 180 )
()()1
cos( 180 ) sin( 180 )
jPM
cc
Rj Gj e
P
Mj PM
ajb
ωω
−°+
=⋅
=−°+ +°+
=−
(13)
with cosaPM= and sinbPM
=
, schematically
shown in figure 2.
Figure 2: Schematic of the KCR tuning principle.
Based on (12), the controller is given by:
1
()1 (1 )
cdc p
ic
R
jjT Kj
T
ω
ωα
ω
⎡⎤
⎛⎞
=+ = +
⎢⎥
⎜⎟
⎝⎠
⎣⎦
(14)
Equivalence of (13) with (14) gives that
[]
(cos sin ) (sin cos )
(cos sin )
p
KM j
PM j PM
ϕ
αϕ ϕα ϕ
−++
=− +
(15)
From the real and imaginary parts of (15), we have
that:
tan tan
tan( )
1tan tan
1
dc
ic
PM
PM
PM
T
T
ϕ
α
ϕ
ϕ
ω
ω
==
+
=−
(16)
and using T
i
=4T
d
, (16) becomes:
1
tan( )
4
dc
dc
TPM
T
ω
ϕ
ω
−=
(17)
from where
sin( ) 1
cos( )
ic
PM
TT
PM
ϕ
π
ϕ
±
=
(18)
which gives only one positive result. From (15) and
(16) we have that
()
()
2
*1 1,
p
KM
α
+=
(19)
With
22
2
1
11tan( )
cos (
)
PM
PM
αϕ
ϕ
+=+ =
(20)
which gives the K
p
controller parameter:
cos( )
p
PM
K
M
ϕ
(21)
with only one positive result.
4 CONTROLLER VALIDATION
4.1 Open Loop Identification
In order to verify the performance of the controller,
we shall identify the open loop frequency response
of the system. We shall make use of the Chirp-TFA
(Chirp Transfer Function Analyzer) technique
proposed in (Ionescu et al., 2010). In short, the
frequency of such a sinusoidal test signal varies
from a minimum frequency (
0
f
) until a maximum
frequency (
1
f
) in a certain time (
1
t ), known as a
chirp signal. In the Chirp-TFA framework, the
sampling period varies such that a fixed number of
samples per period are ensured (
s
N ), independent of
the increasing frequency.
An example of a chirp signal with fixed number
of samples per period is given in figure 3. Notice
that the sampling period will be adjusted at every
sampling instant, because the frequency is varying
continuously. After the measurement is performed,
in order to process the data, the chirp signal is
divided into sections, such that sub-sequent sections
which have approximately the same frequency. Each
of these sections will be used to obtain one point for
gain and one point for the phase in the Bode diagram
of the system. The schematic flowchart of the Chirp-
TFA discrete-time implementation is depicted in
figure 4.
Figure 3:
Chirp signal from 1 to 10 Hz in 5 seconds, 20
samples per
p
erio
d.
c
ωω
=
-1
x
M=1
PM
-a
a
-b
b
1
c
ωω
=
-1
x
M=1
PM
-a
a
-b
b
1
0 1 2 3 4 5
-1
-0.5
0
0.5
1
Seconds
BIODEVICES 2011 - International Conference on Biomedical Electronics and Devices
58
Figure 4: Scheme of the Chirp-TFA discrete
implementation.
The form of the chirp signal is given by
sin(2 ) sin(2 ( ) ( ))
s
f
tftkTt
π
π
⋅⋅= . Hence, at
every time instant t, a variable sampling period
()
s
Tt
is calculated, such that one period contains
s
N
samples. The relation is given by
1
() ()
s
s
ft Tt
N
⋅=.
The
s
N samples are then given by
2
sin( )
s
k
N
π
, with
k=0, 1…
s
N -1. The sinusoidal output of a system in
terms of its magnitude, phase and noise, can be
written as:
() sin(2 / ) ()
s
yk b k N nk
π
ϕ
=++
(22)
where n is the noise, b is the amplitude, ω is the
angular frequency and φ is the phase shift. For
example, at the n
th
interval, we have that:
1
(1)
2
() ()sin( ) ()
s
s
Nn
ss
kN n
s
k
data n y k T k
N
π
=−
=
(23)
1
(1)
2
() ()cos( ) ()
s
s
Nn
cs
kN n
s
k
data n y k T k
N
π
=−
=
(24)
where
()
s
Tkrepresents the sampling period at the
k
th
sample in the data vector and:
1
()
()
s
s
Tk
Nfk
=
(25)
where
()
f
k denotes the frequency at the
k
th
sample. Considering that we obtain one point in a
Bode plot for each period on which we integrate, it
makes sense to increase the frequency exponentially
with time, in order to get the same resolution (points
per decade) for all frequency intervals in the plot.
Therefore, the frequency points are calculated from:
1
1
0
0
() ( )
t
t
f
ft f
f
=
(26)
which is then a function of the design parameters.
As the measurement time T
m
increases, (24) and (25)
can be reduced to the approximations:
() cos
2
sm m
b
data T T
ϕ
,
() sin
2
cm m
b
data T T
ϕ
(27)
from where it follows that
22
2
() ()
s
mcm
m
b data T data T
T
=+
(28)
()
arctan
()
cm
s
m
data T
data T
ϕ
=
(29)
Plotting the b/a and
ϕ
values for a range of
frequencies provides the Bode diagram for the
observed system.
4.2 Real-time Implementation
In practice, in order to send a sinusoidal signal of 50
Hz, is necessary to have a sample rate for about 500
Hz, which means about 10 samples per sinusoid
period. The sampling time obtained was 0.002
seconds. In this particular example, it is not possible
to work with Matlab, because the delay for
calculations in the closed loop is about 14ms, much
higher than the desired sample rate. A solution to
overcome this limitation consists in using Real Time
Windows Target (RTWT) Toolbox in Matlab. This
toolbox assigns some resources of the system
exclusively for this task, ensuring the desired
sampling time. A corresponding Simulink model
was developed in order to send and receive signals
to/from the real FOT system, as depicted in figure 5.
Next, the Simulink model is automatically compiled
in C-language, making in this way a direct
communication using the National Instruments
DAQCard 6024E (which is recognized by Matlab
and supported for real time applications).
Figure 5: Real Time Simulink model used in closed loop.
APPLICATION OF A NOVEL PID AUTO-TUNER TO A LUNG FUNCTION TESTING DEVICE
59
4.3 Open Loop versus Closed Loop
Performance
The open loop and closed loop identification using
the Chirp-TFA algorithm is given by means of Bode
plots in figure 6. It can be observed that the
bandwidth (frequency at -3dB) of the system is
about 45Hz.
Figure 6: Bode characteristic of the open and closed loop.
For this preliminary study an OS%=20 and
Ts=0.041 seconds are defined as design
specifications. The KCR experiment is based on
obtaining the magnitude and phase of the system for
ω
c
(crossover frequency), or represented in time as
T
c
. This value is obtained from the settling time as
T
s
<T
c
<2*T
s;
it follows that T
c
=0.082 seconds, with
ω
c
=76.62 rad/s or 12.19 Hz. A sinusoidal signal to
this frequency ω
c
was applied to the system, from
where the magnitude (M) and phase (φ) were 10.48
dB, and 11.21° respectively.
Once the values for OS%, T
s
are defined and M
and φ are experimentally obtained, then by using
(4,9, 18, 21) as presented on the KCR algorithm in
section 3, it follows that the PID parameters are:
K
p
=0.4775; T
i
=0.0141; T
d
=0.0035 (30)
The designed PID controller (30), was tested by
applying a multisine setpoint with frequencies of
3Hz and 20Hz. The response is presented in figure 7.
In order to be able to follow a reference signal in
a closed loop is necessary that the magnitude of the
closed loop remains in 0dB and the phase in 0º into
the frequencies of interest. From the Bode plot in
figure 6 for the closed loop, we can observe that the
results are in agreement with the expected
bandwidth, and that the controller performs
satisfactorily. This result is also visible when a
comparison in time domain between open loop and
Figure 7: Comparison test between Open loop and PID
controller performance for a multisine setpoint at 3 Hz and
20 Hz.
closed loop is done. The controller avoids distortions
and nonlinear effects at the output of the lung
function device; the desired signal will be
successfully delivered at the patient’s mouth as
depicted in figure 7.
5 CONCLUSIONS
In this paper, the problem of closed loop control of a
medical device for lung function testing was
initiated. Preliminary results show that a proposed
PID autotuner can be applied and developed with
desired closed loop performance specifications for
settling time and overshoot. The next step is to
develop the method in the presence of noise, i.e.
interference with the breathing signal coming from
the patient.
REFERENCES
Åström, K. J., & Hägglund, T., 1995. PID Controllers:
Theory, Design and Tuning. Instrument Society of
America, Research Triangle Park, NC, USA,
De Keyser R., Ionescu C., 2010. “A generally valid
algorithm for PID auto-tuners”, accepted for
presentation at the Int Conf of Mathematical Methods
in Engineering, Coimbra, Portugal, to be held 21-24
October.
De Keyser R., Ionescu C., 2006. “FRtool: a frequency
response tool for CACSD in MatLab”, IEEE Conf on
Computer Aided Control Systems Design (CACSD-
CCA-ISIC), Munchen, Germany, pp. 2276-2280
0 5 10 15 20 25 30 35 40 45 50
-15
-10
-5
0
5
10
Bode characteristic Closed and Open loop
Magnitude [dB]
Open loop
Closed loop
0 5 10 15 20 25 30 35 40 45 50
-100
-50
0
50
100
150
Phase [Degree]
Frequency [Hz]
Wc
Wc
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-2
-1
0
1
2
Time [sec]
Voltage [V]
Reference
Out openloop
Out closedloop
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-2
-1
0
1
2
Time [sec]
Voltage [V]
Ctrl effort
BIODEVICES 2011 - International Conference on Biomedical Electronics and Devices
60
Ionescu, C. & De Keyser, R., 2008. Parametric models for
characterizing the respiratory input impedance.
Journal of Medical Engineering & Technology, Taylor
& Francis, 32(4), pp. 315-324
Ionescu C., Robayo F., De Keyser R., Naumovic M.,
2010. “The frequency response analysis revisited”, in
Proc. the IEEE 18
th
Mediterranean Conference on
Control and Automation, 23-25 June, Marrakesh,
Marocco, pp. 1441-1446
Leva, A., Cox C. & Ruano A., 2002. “Hands-on Pid
autotuning: a guide to better utilisation”. IFAC
Professional Brief
Ljung, L., 1999, System Identification, NJ: Prentice Hall
Northrop R., 2002. Non-invasive measurements and
devices for diagnosis, CRC Press
Miller, M., Hankinson, J., Brusasco, V., Burgos, F.,
Casaburi, R., Coates, A., Crapo, R., Enright, P., van
der Grinten, C., Gustafsson, P., Jensen, R., Johnson,
D., MacIntyre, N., McKay, R., Navajas, D., Pedersen,
O., Pellegrino, R., Viegi, G., Wanger, J., 2005,
Standardization of spirometry, Eur Resp J, 26, 319-
338
Nise, N. S, 2007. Control systems engineering, Wiley
India Pvt. Ltd., 4th edition
Oostveen, E., Macleod, D., Lorino, H., Farré, R., Hantos,
Z., Desager, K., Marchal, F, 2003, The forced
oscillation technique in clinical practice: methodology,
recommendations and future developments, Eur
Respir J, 22, 1026-1041
Pellegrino, R., Viegi, G., Brusasco, V., Crapo, R., Burgos,
F., Casaburi, R., Coates, A., van der Grinten, C. P. M.,
Gustafsson, P., Hankinson, J., Jensen, R., Johnson, D.
C., McKay, R., Miller, M. R., Navajas, D., Pedersen,
O. F., Wanger, J., 2005, Interpretative Strategies for
Lung Function Tests. European Respiratory Journal,
26: 948-968
Schoukens J., and Pintelon, R., System Identification, a
frequency-domain approach, (IEEE Press, 2001)
APPLICATION OF A NOVEL PID AUTO-TUNER TO A LUNG FUNCTION TESTING DEVICE
61