You are on page 1of 4

2018 International Symposium on Computer, Consumer and Control (IS3C)

Control System Laboratory with Arduino


Jen-Hsing Li
Electrical Engineering Department, Kun Shan University
195 Kunda Road, YongKang District, Tainan City 710, Taiwan
LJH0906@mail.ksu.edu.tw

Abstract— This paper proposes an innovative control system C


R2
laboratory setup and a curriculum design. The Arduino tool is R1 R2
Vi1 +
utilized as a digital controller for the undergraduate control R
− R1

system course. The Arduino tool is an important tool for the R1

+ Vo1
maker group. Hence this control system laboratory curriculum +
R2
design can reinforce the student' hands-on experience for the
undergraduate engineering education. This paper provides two
Fig. 2 The first-order analog circuit
demonstrative examples for hands-on experiments, one is PID
control and the other is fuzzy control. From the experimental
results, the student can learn the related subjects. The education The resistors are R1 = R2 = R3 = 1KΩ and R4 = 5KΩ .
object is achieved. The resistor of integrator is R = 1KΩ . The capacitor of
integrator is C = 1mF . Hence, the product of RC is one.
Keywords— Control system, Laboratory, Engineering The transfer function of Fig.1 is given as follows,
Education, Arduino, Maker
Vo 2 5
= 2 (1)
I. INTRODUCTION Vi 2 s + s + 5
The control system course [1-2]ġ is a core course in The step response is shown in Fig.3 which is a photograph
engineering departments. It provides analysis and design of of a digital oscilloscope. The yellow line (CH1) is the 5Volts
control systems using transfer functions and state variable
step input and the blue curve (CH2) is the output Vo 2 of Fig.1
methods. Control system laboratory is a laboratory course
which can enhance the student' understanding of theory taught circuits.
in class and provide experience of controller synthesis. It can
also increase student' interest in the control system course.
The laboratory setup is case by case [3-7]. Recently, with
microprocessors becoming so fast, light, accurate and
economical, control laws can be implemented in digital form.
Special microprocessor designed for makers and known as
Arduino [8] is particularly well-suited for use as digital
controllers [9-10]. This paper provides fundamental control
laboratories based on Arduino. These hands-on laboratories
are useful materials for the engineering education.
The layout of this paper is as follows. Section II describes
the second-order analog circuit (SOAC) completely. Section
III presents Arduino control system. Section IV presents PID
(proportional integral differential) controller. Section V gives
the fuzzy logic controller. These algorithms are implemented Fig. 3 The step response of SOAC
by Arduino IDE. Section VI makes a conclusion.

II. SECOND-ORDER ANALOG CIRCUIT Considering sampled-data control [9-10] of a SOAC which
The second-order analog circuit (SOAC) is given in Fig.1. is given in Fig.4, the transfer function from the zero-order
Fig.1 is composed of first-order analog circuit which is shown hold to plant is given as follows,
in Fig.2. 1 − e−Ts 5
G( s) = ⋅ 2 (2)
C
s s +s+5
R3 R4
R2 The discrete-time model of (2) can be calculated using the
Vi 2 + R
Vi1 Vo1 − R1
− Vo 2
residue formula [9-10]:

ª 1 º
+
R3 +
G ( z ) = ¦ « residues of G (Ȝ) (3)
R4
at poles ¬ 1 − z −1eTȜ »¼
of G (Ȝ)
Fig. 1 The second-order analog circuit (SOAC)

978-1-5386-7036-1/18/$31.00 ©2018 IEEE 181


DOI 10.1109/IS3C.2018.00053
G (s ) ( Vo 2 ). It is implemented by operational amplifiers and it can
Controller
R(z ) E (z ) transfer voltage range [ − 10 , +10] into [0, 5] linearly. The
1 − e−Ts 5
Gc (z )
s s2 + s + 5
circuit of ADI is shown in Fig.6.
T

T Vo 2
Fig. 4 The block diagram of sampled-data control system

where T is the sampling period. The z transformation of


G (s ) is expressed as following discrete-time model,
­ ½
= (1 − z −1 ) ‫ ® ڹ‬2
5
G (z ) = ‫ڹ‬ {G(s )} ¾
¯ s(s + s + 5)¿ Fig. 6 The analog to digital input module (ADI)

N1 z + N 2
= 2
(4) The input-output relationship is described in (5).
z + D1 z + D2 § V 5· V
A0 = −¨ − o 2 − ¸ = o 2 + 2.5 (5)
§ 19 ·
T
− 19 1 © 4 2¹ 4
where N1 = 1 − e 2¨ cos
¨ T+ sin T ¸¸ ,
© 2 19 2 ¹ When input voltage is Vo 2 = 10V , the output voltage is

− §
T
1 19 19 · A0 = 5V . When input voltage is Vo 2 = −10V , the output
N 2 = e −T + e 2 ¨¨ sin T − cos T ¸¸ ,
19 2 2 voltage is A0 = 0V . Hence, the ADI module can transfer
© ¹
T
− 10V ~ +10V to 0V ~ 5V . The ADI module is the
− 19 interface between Arduino UNO and the SOAC.
D1 = −2e 2
cos T , and D2 = e−T . Because Arduino UNO does not involve digital to analog
2
(D/A) module, the DAO module is synthesized additionally.
‫ڹ‬ {•} is the operation of z transformation. The circuit of DAO is shown in Fig.7.
III. ARDUINO DIGITAL CONTROL SYSTEM
The controller is implemented by an Arduino UNO [8]. The V8
hands-on circuits are implemented by breadboarding as shown
Vi 2
in Fig.5. There are three parts in this breadboard. It includes
the SOAC, the analog to digital input module (ADI) and the
digital to analog output module (DAO).

Fig. 7 The digital to analog output module (DAO)

MCP4921 is 12-bit D/A converter with serial peripheral


interface (SPI). The resolution is 12-bit and output voltage
( V8 ) of pin 8 is from 0V to 5V. The input-output relationship
from V8 to Vi 2 is
Vi 2 = 4V8 − 10 (6)
When input voltage is V8 = 0V , the output voltage is
Vi 2 = −10V . When input voltage is V8 = 5V , the output
Fig. 5 The breadboard connections of the hands-on experiment voltage is Vi 2 = 10V . Hence, the output voltage range of
DAO is − 10 Volts to 10Volts.
Arduino is an open-source electronics platform based on easy- The DAO module is modelled as a sampler/zero-order hold
to-use hardware and software. The analog to digital (A/D) combination which is shown in Fig.4. The Arduino UNO is
input voltage range of Arduino UNO is 0 Volt to 5 Volts, so a
programmed and served as the digital controller Gc (z ) .
scaling circuit is implemented for ± 10Volt plant outputs

182
IV. PID CONTROL
The PID controller is a classical three-term controller which
is widely used in the industry. There are many advantages for
this compensator. For example, PD control improves damping
and reduces maximum overshoot. PI control can reduce or
eliminate the steady-state error. However, it is very simple
and easily implemented. The z-transfer function of digital PID
controller is given as follows [9-10],

Gc ( z ) =
U ( z)
E ( z)
= Kp +
Ki
1− z −1
(
+ K d 1 − z −1 ) (7)

where (K p , K i , K d ) are controller parameters, U (z ) is the


control input and E (z ) is the system error. The parameter Fig. 9 The response of PID control (Kp=1;Ki=0;Kd=1)
tuning of a PID controller can be accomplished by assigning
the three parameters K p , K i , and K d to enable the output
response Y (z ) to track reference input R(z ) .
There are many methods to tune the PID parameters [1-2].
In this section, the tuning method is the rule of thumb, i.e.
using the trial and error method. The experimental results are
presented in Fig. 8 to Fig.10 which are from a digital storage
oscilloscope.

Fig. 10 The response of PID control (Kp=1;Ki=1;Kd=1)

V. FUZZY LOGIC CONTROL


The fuzzy logic controller (FLC) [11] consists of four
modules, i.e., a fuzzification module, a fuzzy rule base, a
fuzzy inference engine and a defuzzification module. The
fuzzification module maps a measurement to fuzzy sets within
certain input universes of discourse. The fuzzy inference
engine infers fuzzy logic control actions from a rule base
Fig. 8 The response of PID control (Kp=1;Ki=0;Kd=0) based on expert experiences. The defuzzification module
yields a deterministic control input from an inferred control
Fig.8 shows the unity feedback control of Fig.4. In this case, action. The performance of FLC mainly depends on the If-
the I-parameter and D-parameter are both reset. From Fig.8, Then rules and membership functions. But there are no formal
we can observe a 50% steady state error and 80% max methods to construct the rule-base or define the membership
overshoot. In Fig.9, the D-control is added to the system by functions for FLCs.
assigning D-parameter of program. The D-parameter is one in The linguistic sets used in this paper are: positive big (PB),
this case. We can observe there is no overshoot in Fig.9. The positive middle (PM), positive small (PS), zero (ZE), negative
students can compare the Fig.8 with Fig.9. The PD control is small (NS), negative middle (NM) and negative big (NB). The
effective and obvious. membership functions are shown in Fig. 11. The knowledge
Finally, in Fig.10, all PID control parameters are set ones. pertaining to the control problem is formulated in terms of a
There are no steady state error and overshoot in Fig.10. set of fuzzy inference rules. The inference rule has the
Obviously, I-control can eliminate the steady state error. This following canonical form
is a good demonstrative example for PID control.
( )
If ηa e,ηb Δe is A× B , then u is C (8)
where ηa and ηb are normalized factors and
[A × B](ηa e,ηb Δe) = min[A(ηa e), B(ηb Δe)] . The total
number of possible non-conflicting fuzzy inference rules is 49.
They can conveniently be represented in Table I.

183
NB NM NS ZE PS PM PB The denormalized factor is set as ηc = 14 . Compare the
step response of Fig.12 with Fig.10, the settling time of PID
A control is about 2.5 seconds and FLC is about 5 seconds. The
−1 − 0.3 − 0.1 0 0.1 0.3 1 PID control is superior to FLC in this case. Hence, FLC must
be re-tuned for the optimal values. There are many factors
must be adjusted in FLC, so students can learn a lot for this
B
− 1 − 0.6 − 0.3 0 0.3 0.6 1 experiment.

VI. CONCLUSIONS
C In this paper, we proposed an innovative undergraduate
−1 − 0.3 − 0.1 0 0.1 0.3 1 control system laboratory curriculum of the engineering
Fig. 11 Membership functions education. At first, the SOAC system had experimented on the
breadboard. The step response of SOAC was exhibited on a
TABLE I digital oscilloscope. The rise time, delay time, maximum
FUZZY CONTROL RULES overshoot, peak time and settling time could be measured. The
digital controller was implemented with Arduino UNO. Then
the PID control and fuzzy control were programmed with
Arduino IDE. From experimental results, the student could
learn hands-on experience and the related control system
course subjects. From the assessment based on student
surveys, the students all satisfied with these hands-on
experiments and the education object is achieved.

ACKNOWLEDGMENT
The author would like to express sincere thanks to the
reviewers for their invaluable comments and suggestions. This
work was supported by the MOE Teaching Practice Research
Program and the MOST 107-2637-E-168-007.
The centroid defuzzification method calculates the weighted REFERENCES
average of fuzzy set as follows. [1] B. C. Kuo and F. Golnaraghi, Automatic Control Systems, 8th ed. John
49
Wiley & Sons, New York, USA, 2003.
¦ C ((u ) ) × (u )
n n
(9)
[2] G. F. Franklin, J. D. Powell and A. Emami-Naeini, Feedback Control
u = η c × n =1 49
of Dynamic Systems, 4th ed. New Jersey: Prentice Hall, 2002.
[3] J.-H. Li, “Hands-on dsp-based digital control laboratories for the
¦ C ((u ) ) n undergraduate curriculum”, The 12th Military Academy Basic
n =1 Academic ConferenceˈKaohsiung, Taiwan, pp.c-122-c-126, 2005.
where η c is the denormalized factor. The experimental result [4] J.-H. Li, “An undergraduate digital control project: a dsp-based
magnetic levitation system”, World Transactions on Engineering and
is shown in Fig.12. This is a step response of 5Volts. The Technology Education, vol.5, no.1, pp.207-210, 2006. Available:
http://www.wiete.com.au/journals/WTE&TE/Pages/TOC_V5N1.html
normalized factors are assigned ηa = 10 and ηb = 30 . [5] J.-H. Li and P.-T. Wang, “Hands-on control systems laboratories and
assessments for the undergraduate curriculum”, Journal of Kun Shan
University, no.7, pp.99-115, 2010.
[6] B. Catalbas and I. Uyanik, “A Low-cost Laboratory Experiment Setup
for Frequency Domain Analysis for a Feedback Control Systems
Course”, IFAC PapersOnLine vol.50-1, pp.15704–15709, 2017.
[7] I. Uyanik and B. Catalbas, “A low-cost feedback control systems
laboratory setup via Arduino–Simulink interface”, Computer
Applications in Engineering Education, vol.26, issue 3, pp.718-726,
2018.
[8] Arduino [online]. Available: https://www.arduino.cc/
[9] C. L. Phillips and H. T. Nagle, Digital Control System Analysis and
Design, 3rd ed. New Jersey: Prentice Hall, 1995.
[10] G. F. Franklin, J. D. Powell and M. Workman, Digital Control of
Dynamic Systems, 3rd ed. Menlo Park, CA: Addison Wesley, 1998.
[11] Wang, L.-X., A Course in Fuzzy Systems and Control, Prentice-Hall,
New Jersey (1997).

Fig. 12 The response of FLC (eta_a=10,eta_b=30,eta_C=14)

184

You might also like