ScienceDirect ScienceDirect

12 downloads 2836 Views 571KB Size Report
2015, IFAC (International Federation of Automatic Control) Hosting by Elsevier Ltd. All rights reserved. ... hardware devices, simulation, communications, etc.
3rd IFAC Workshop on Internet Based Control Education 3rd IFAC Workshop Internet Based Control Education November 4-6, 2015.on Brescia, Italy 3rd IFAC IFAC Workshop on Internet Based Control Control Education Education 3rd Internet Based NovemberWorkshop 4-6, 2015.on Brescia, Italy November November 4-6, 4-6, 2015. 2015. Brescia, Brescia, Italy Italy Available online at www.sciencedirect.com

ScienceDirect IFAC-PapersOnLine 48-29 (2015) 099–104

Teaching Control Engineering Concepts Teaching Control Engineering Concepts Teaching Control Engineering Concepts Teaching Control Engineering ConceptsPi using Open Source tools on a Raspberry using Open Source tools on a Raspberry Pi using Open Source tools on a Raspberry using Open Sourceboard toolson a Raspberry Pi Pi  board  board board ´ Angeles ´ Angeles ´ Angeles ´ Angeles

Hoyo ∗∗ Hoyo ∗ Hoyo Hoyo ∗

Jos´ e Luis Guzm´ an ∗∗ Jos´ e Carlos Moreno ∗∗ Jos´ e Luis Guzm´ a n Jos´ e Carlos Moreno ∗∗ ∗ ∗ Jos´ e a Manuel Berenguel ∗ e Jos´ e Luis Luis Guzm´ Guzm´ an n ∗ Jos´ Jos´ e Carlos Carlos Moreno Moreno Manuel Berenguel ∗ ∗ Manuel Berenguel Berenguel Manuel ∗ ıa, 04120 Almer´ıa, Spain. ∗ Dep. of Informatics, University of Almer´ Dep. of Informatics, University of Almer´ ıa, 04120 Almer´ ıa, Spain. ∗ ∗ Dep. (Tel: of University of Almer´ ıa, +34 950 214133; e-mail:[email protected]; Dep. (Tel: of Informatics, Informatics, University of Almer´ ıa, 04120 04120 Almer´ Almer´ıa, ıa, Spain. Spain. +34 950 214133; e-mail:[email protected]; (Tel: +34 950 214133; e-mail:[email protected]; [email protected]; [email protected]; [email protected]) (Tel: +34 950 214133; e-mail:[email protected]; [email protected]; [email protected]; [email protected]) [email protected]; [email protected]; [email protected]; [email protected]; [email protected]) [email protected]) Abstract: This paper presents the idea about how to combine a set of software and hardware Abstract: This presents idea about how to aa set of and Abstract:available This paper paper presents the the ideaused about how to combine combine set of software softwareeducation. and hardware hardware resources in literature to be as how support to control engineering The Abstract: This paper presents the idea about to combine a set of software and hardware resources available in literature to be used as support to control engineering education. The resources available be used as support to control engineering education. The available tools allowin toliterature mix topicsto related to programming, communications, operating systems, resources available in literature to be used as support to control engineering education. The available tools allow to mix topics related to programming, communications, operating systems, available tools allow to mix topics related to programming, communications, operating systems, and control theory. The well-known Raspberry Pi board is used as platform to exploit the available tools allow to mix topics related to programming, communications, operating systems, and control theory. The well-known Raspberry Pi board is used as platform to exploit the and control theory. The well-known Raspberry Pi board is used as platform to exploit different proposed concepts. SciPy, Matplotlib, and NumPy libraries, which are Python-based and control theory.concepts. The well-known Raspberryand Pi NumPy board islibraries, used as which platform to exploit the the different proposed SciPy, Matplotlib, are Python-based different proposed proposed concepts. SciPy,computing Matplotlib, and NumPyrepresentation, libraries, which which are Python-based open-source libraries for scientific andand graphical areare used to perform different concepts. SciPy, Matplotlib, NumPy libraries, Python-based open-source libraries for scientific computing and graphical representation, are used to perform open-source libraries scientific computing and used to Matlab-like simulations to implement controlrepresentation, loops. On the are other hand, virtual open-source libraries for for and scientific computingclassical and graphical graphical representation, are used to perform perform Matlab-like simulations and to implement classical control loops. On the other hand, virtual Matlab-like simulations and to implement classical control loops. On the other hand, virtual processes developed in Easy Java Simulations are adapted to be controlled through the network Matlab-like simulations and Java to implement classical control loops. On thethrough other hand, virtual processes developed in Easy Simulations are adapted to be controlled the network processes developed in Simulations are adapted to through network from a controller implemented on the Raspberry with Python. This option is verythe useful from processes developed in Easy Easy Java Java Simulations arePi adapted to be be controlled controlled through the network from a controller implemented on the Raspberry Pi with Python. This option is very useful from from a controller controller implemented on the Raspberry Raspberry Pi with with Python. Python. This option optioncontrol is very very useful useful from afrom teaching point of view since on time-based, networked-based, or event-based approaches a implemented the Pi This is from a teaching point of view since time-based, networked-based, or event-based control approaches a teaching point of view since time-based, or event-based control approaches can be easily introduced on this proposed networked-based, architecture. Furthermore, once students know how a teaching point of view since time-based, networked-based, or event-based control approaches can be easily introduced on this proposed architecture. Furthermore, once students know how can be on this proposed architecture. Furthermore, once students know to implement control loops Raspberry Pi using Python, external processes canhow be can be easily easily introduced introduced on on thisthe proposed architecture. Furthermore, oncereal students know how to implement control loops on the Raspberry Pi using Python, external real processes can be to implement control loops on the Raspberry Pi using Python, external real processes can easily controlled by using the GPIO interface available in the this electronic board. Then, to implement control loopsthe on GPIO the Raspberry Pi using Python, external real processes can be bea easily controlled by using interface available in the this electronic board. Then, easily controlled controlled by using theand GPIO interface available inpresented the this this in electronic board. Then, aaa project based on by these tools ideas is motivated andin this paper to control easily using the GPIO interface available the electronic board. Then, project based on these tools and ideas is motivated and presented in this paper to control aa project based these and is motivated ctools two-tank level on process  Copyright IFAC 2015. project based on these and ideas ideas is 2015. motivated and and presented presented in in this this paper paper to to control control a cctools two-tank level process Copyright IFAC two-tank level process  Copyright IFAC 2015. c two-tank level process  Copyright IFAC 2015. © 2015, IFAC (International Federation of Automatic Control) Hosting by Elsevier Ltd. All rights reserved. Keywords: Programming, control, communications, Raspberry Pi, Python. Keywords: Keywords: Programming, Programming, control, control, communications, communications, Raspberry Raspberry Pi, Pi, Python. Python. Keywords: Programming, control, communications, Raspberry Pi, Python. 1. INTRODUCTION It is really clear that control theory is the core of control 1. It clear that theory core of 1. INTRODUCTION INTRODUCTION It is is really really but clearcurrently, that control control theory is is the the core of control control education, communication and implementa1. INTRODUCTION It is really clear that control theory is the core of control education, but currently, communication and implementaeducation, but currently, communication and are gaining importance in the training ofimplementacontrol enControl engineering is a scientific discipline that relies on tion education, but currently, communication and implementation are gaining importance in the training of control enControl engineering is scientific discipline that relies tion are gaining importance in training of control enthe industry demand about knowlControl engineering is a scientificfields. discipline thatengineers relies on on gineers knowledge from many different Control tion arebecause gaining of importance in the the training of this control enControl engineering is aadifferent scientific discipline that relies on gineers because of the industry demand about this knowlknowledge from many fields. Control engineers gineers because of the industry demand about this knowledge. This aspect is mainly due to the dramatic growth knowledge from many different fields. Control engineers should acquire and manage concepts related to mathematgineers because of the industry demand about this knowlknowledge from many different fields. Control engineers edge. This aspect is mainly due to the dramatic growth should acquire and related to edge. This aspect aspectcapabilities is mainly mainly that due to to the dramatic dramatic growth in technological require a tight integrashould acquire and manage manage concepts concepts related to mathematmathematics, physics, programming, operatingrelated systems (OS), I/O edge. This is due the growth should acquire and manage concepts to mathematin technological capabilities that require a tight integraics, physics, programming, operating systems I/O in technological capabilities require tight integraof control with computerthat science and aacommunication ics, physics, programming, operating systems (OS), (OS), I/O tion hardware devices, simulation, communications, etc. Usuin technological capabilities that require tight integraics, physics, programming, operating systems (OS), I/O tion of control with computer science and communication hardware devices, simulation, communications, etc. Usution with omcontrol and Murray, 2008). science hardware devices, simulation, communications, etc. Usually, control engineering students attend lessons etc. about all (Astr¨ tion of of control with computer computer science and and communication communication hardware devices, simulation, communications, Usu(Astr¨ o m and Murray, 2008). ally, control engineering students attend lessons about all (Astr¨ o m and Murray, 2008). ally, control engineering students attend lessons about all these topics along their degrees, but seldom all this knowl(Astr¨ o m and Murray, 2008). ally, control engineering students attend lessons about all The main reason of why many control courses are still these topics along their but all knowlmain reason of why many control courses are still these topics along their degrees, degrees, but seldom seldom all this thislessons. knowl- The edge istopics used along and combined in control engineering these their degrees, but seldom all this knowlThe main reason of why many control courses are still focused only on theoretical aspects is because of the edge is used and combined in control engineering lessons. The main reason of why many control courses are lack still only on theoretical aspects is because of the lack edge iscontrol used and and combinedcourses in control control engineering lessons. Most is engineering are engineering focused mainly on focused edge used combined in lessons. focused only resources on theoretical theoretical aspects is because because of the lack of practical and/or lack of time in of thethe course Most control engineering courses are focused mainly on focused only on aspects is lack of practical resources and/or lack of time in the course Most control engineering courses are focused mainly on theoretical aspects and simulations, but implementation Most control engineering courses arebut focused mainly on of practical resources and/or lack of time the schedule. Nowadays, gap can thanks to the theoretical aspects and practical resourcesthis and/or lackbe ofsolved time in in the course course schedule. Nowadays, this gap can be solved thanks to the theoretical aspectsissues and simulations, simulations, but implementation implementation and programming are rarely included. This issue is of theoretical aspects and simulations, but implementation schedule. Nowadays, this gap can be solved thanks to the amazing availability of low-cost hardware devices as and programming issues are rarely included. This issue is schedule. Nowadays, this gap can be solved thanks towell the amazing availability of low-cost hardware devices as well and programming issues are rarely included. This issue is a real problem from an education point of view, because and programming issues are rarely point included. This because issue is as amazing availability of low-cost hardware devices as well open-source software tools, that can allow to include aa real problem from an education of view, amazing availability of low-cost hardware devices as well as open-source software tools, that can allow to include real problem fromconnections an education educationbetween point of oftheoretical view, because because it real can problem lead to loss and practical a from an point view, as open-source open-source software tools,courses that can can allow to include activities in control in aallow very to cheap and it can to connections between theoretical and software tools, that include practical activities in control courses in aa very cheap and it can lead lead to loss lossThis connections between theoretical and as practical aspects. gap between theory and practice it can lead to loss connections between theoretical and practical control courses very cheap and easy way.activities Arduino in and Raspberry Piin are becoming the practical aspects. This gap between theory and practice practical activities in control courses in a very cheap and easy way. Arduino and Raspberry Pi are becoming the practical aspects. This gap between theory and practice has an strong relationship with the holistic view interpractical aspects. This gap between theory and practice easy way. Arduino and Raspberry Pi are becoming the most popular low-cost electronic boards with impressive has an strong relationship with the holistic view intereasy way. Arduino andelectronic Raspberryboards Pi arewith becoming the most popular low-cost impressive has an strong relationship with the holistic view interpretation of theory and applications described in (Astr¨ o m has an strong relationship with thedescribed holistic view intermost popular low-cost electronic boards with impressive capabilities for education and with many open source pretation of theory and applications in (Astr¨ o m most popular low-cost electronic boards with impressive capabilities for education and with many open source pretation of theory theory and applications applications described in (Astr¨ (Astr¨ m projects and Kumar, 2014). Traditionally, practice and theory have pretation of and described in oom capabilities for education education and with withand many open source source (Sobota et al., 2013),(Sarik Kymissis, 2010), and Kumar, 2014). Traditionally, practice and theory theory have capabilities for and many open projects (Sobota et al., 2013),(Sarik and Kymissis, 2010), and Kumar, 2014). Traditionally, practice and have beenKumar, separated somehow in the control engineering field, and 2014). Traditionally, practice and theory have projects (Sobota al., 2013),(Sarik and Kymissis, 2010), (Sundaram et al.,et 2013). On the other hand, many free been separated somehow in the control engineering field, projects (Sobota et al., 2013),(Sarik and Kymissis, 2010), (Sundaram et al., 2013). On the other hand, many free been separated somehow in the control engineering field, with periods with strong relevance for applications and been separated somehow in the control engineering field, (Sundaram et al., 2013). On the other hand, many free and/or open-source programming and simulation tools are with periods with strong relevance for applications and (Sundaram et al., 2013). On the and other hand, many free and/or open-source programming simulation tools are with periods with strong relevance for applications and others with strong importance for theory. However, nowawith periods with importance strong relevance for applications and also and/or open-source programming and simulation tools available in literature, such as Easy Java Simulations others with strong for theory. However, nowaand/or open-source programming and simulation tools are are available in literature, such as Easy Java Simulations others with strong strong importance for theory. theory. However, nowa- also days, theory and practice must run togetherHowever, to successfully others with importance for nowaalso available available 2014), in literature, literature, such(Piguet, as Easy Easy 2013), Java Simulations Simulations (Esquembre, Sysquake or Octave days, theory and practice must run together to successfully successfully also in such as Java (Esquembre, 2014), Sysquake (Piguet, 2013), or Octave days, theory and practice must run together to face the demanding control engineering problems from days, theory and practice must run togetherproblems to successfully (Eaton (Esquembre, 2013), or Octave et al.,2014), 2013),Sysquake which are(Piguet, very well known conface the 2014), Sysquake (Piguet, 2013), or in Octave (Eaton et al., 2013), which are very well known in conface the demanding demanding control control engineering engineering problems problems from from (Esquembre, Industry. face the demanding control engineering from (Eaton et al., 2013), which are very well known in control education. These computer-based tools can be easily Industry. (Eaton et al., 2013), which are very well known ineasily control education. These computer-based tools can be Industry. Industry. trol education. These computer-based tools can be easily combined with Arduino or Raspberry Pi and to be used  This work has been partially funded by the following projects: trol education. These computer-based tools cantobe easily combined with Arduino or Raspberry Pi and be used  This work has been partially funded by the following projects: combined with Arduino or Raspberry Raspberry Pi and and to toabove be used used to overcome all Arduino the different concepts described for  combined with or Pi be DPI201455932-C2-1-R and DPI2014-56364-C2-1-R (financed by the This has funded projects:  to overcome all the different concepts described above for This work work has been been partially partially funded by by the the following following projects: DPI201455932-C2-1-R and DPI2014-56364-C2-1-R (financed by the to overcome all the different described above for the control engineer training.concepts However, in this paper, we to overcome all the different concepts described above for Spanish Ministry of Science and Innovation and EUERDF funds) DPI201455932-C2-1-R and DPI2014-56364-C2-1-R (financed by the the control engineer training. However, in this paper, we DPI201455932-C2-1-R and DPI2014-56364-C2-1-R (financed by the Spanish Ministry of Science and Innovation and EU- ERDF funds) the control engineer training. However, in this paper, the control engineer training. However, in this paper, we we Spanish Spanish Ministry Ministry of of Science Science and and Innovation Innovation and and EUEU- ERDF ERDF funds) funds) Copyright © 2015, 2015 IFAC 99 Hosting by Elsevier Ltd. All rights reserved. 2405-8963 © IFAC (International Federation of Automatic Control) Copyright © 2015 IFAC 99 Copyright © 2015 IFAC 99 Peer review under responsibility of International Federation of Automatic Copyright © 2015 IFAC 99 Control. 10.1016/j.ifacol.2015.11.220

IFAC IBCE 2015 100 November 4-6, 2015. Brescia, Italy

Ángeles Hoyo et al. / IFAC-PapersOnLine 48-29 (2015) 099–104

would like to introduce some other open-source software tools existing in literature that can be run directly on a Raspberry Pi, and where the Raspberry Pi is the only hardware necessary to be used, without requiring a computer (Upton and Halfacree, 2012). Furthermore, working only with the Raspberry Pi as computer, it is also very valuable from a teaching point of view since it allows to cover some extra concepts, such as operating systems, lowlevel programming and low- and high-level communications. So, NumPy, Matplotlib and SciPy, three open-source software packages for scientific computing and graphical representation based on Python (Scott, 2014), (Tosi, 2009), are described and used as support to control education concepts on a Raspberry Pi. These software packages allow to perform simulations in a Matlab-like manner and to easily implement control loops. Furthermore, by using these libraries on the Raspberry Pi, students learn also about Python programming, which is an open and very powerful programming language. Notice that Python control system library (Developers, 2014) could have been used in this paper, but for this first approach, the original NumPy, Matplotlib, and SciPy packages were selected. These libraries can be also installed in any computer, but again, we think that it is very interesting and valuable that students can perform all their simulation and control education activities on the same platform, Raspberry Pi in this case. Moreover, thanks to the I/O capabilities of the Raspberry Pi, students can work in simulation or with real processes just by using the same computer (otherwise, a computer with additional I/O boards would be needed). Therefore, this paper presents and describes how to use a Raspberry Pi as low-cost hardware device and its combination with open-source software tools to learn concepts about implementation, communication, and control engineering topics. First, the main capabilities and features for education purposes of the Raspberry Pi and the Pythonbased libraries are described. Afterwards, examples and ideas of the different educational concepts that can be introduced with these resources for control engineers are presented. Then, a project developed at the University of Almer´ıa (Spain) where all these tools have been combined for control education is described. This project is based on a two-tank level control problem, where the virtual and remote labs developed in Easy Java Simulations have been modified to perform remote control from a Raspberry Pi. So, a teaching methodology based on several activities is proposed to show how to exploit basic knowledge on control theory, programming, operating systems, simulation, and communications. Although the proposed softwarehardware architecture is focused on basic concepts at this first stage, it can be easily extended to deal with some other interesting topics such as networked-based or eventbased control approaches. 2. HARDWARE AND SOFTWARE This section briefly describes the main features of the hardware and software resources used in this paper. 2.1 Raspberry Pi Raspberry Pi is a low-cost single board computer which works with open source software (see Figure 1). There are 100

Fig. 1. Raspberry Pi. Low-cost hardware device used in this paper (Upton and Halfacree, 2012) many software that can be used on it, for example the one called Raspbian - operating system (OS) which we are going to work with- which is based on Debian. For this paper the Raspberry Pi model B+ was used. Its principal hardware characteristics are 512 Mb of RAM memory, four USB 2.0 ports, HDMI, 3.5mm audio jack, and a MicroSD slot for the card that will store the software (Upton and Halfacree, 2012). Raspberry Pi was mainly created with the aim of introducing students on computer programming as well as letting them have a better understanding on how computers work. Hence, they will be able to use this device wherever they need owing to its small size. Looking at the engineering perspective via the scholar application, many benefits may be obtained from it. For example, students are taught to program in Python as will be shown in this paper to learn discrete control and use it as the main controller in a feedback control system. Examples about how to use Raspberry Pi for control purposes can be found in (Sobota et al., 2013). Thanks to the packages created for control like SciPy and the graphic field owned by Raspbian, simulations and different systems can be seen in a graphical manner, such as shown in the following sections of this paper. 2.2 Python, SciPy, Matlplotlib and NumPy Python is used in this paper as the main open source programming language. It is widely used due to its simple syntax and versatility, making it an useful tool in developing programs. Another great advantage is that is widely used in electronic devices, such as Arduino or Raspberry Pi. In fact, Python is the most frequently used language programming on Raspberry Pi projects running on Raspbian. Due to the wide range of libraries that Python includes, it is commonly used for different scientific areas, as control engineering (Developers, 2014). In this paper, students are required to use Python to simulate discrete control loops and to implement networked-based control loops. One of the most important libraries in control is SciPy, an open source Python library which has very useful tools to

IFAC IBCE 2015 November 4-6, 2015. Brescia, Italy

Ángeles Hoyo et al. / IFAC-PapersOnLine 48-29 (2015) 099–104

be applied in this field, such as mathematics algorithms and signal processing applications. This library provides the possibility to work with control simulations in the similar way that is done using Matlab (Scott, 2014). In order to work with data and graphical representations, apart from SciPy, two more Python libraries called Matplotlib and NumPy are used (Scott, 2014). The first one allows to draw graphics from vectors in the same way as with Matlab. The second one provides high-level mathematical functions that let us the possibility to work with vectors easily. In this paper, these libraries and Python as programming language will be used to show that Raspberry Pi can be used to introduce control education concepts and also as a controller in a full feedback control system.

101

τ = 10. This simulation can be easily done in Matlab by using the following code: K=1; tau =10; P=t f ( [K ] , [ tau , 1 ] ) ; [ t , y ] = s t e p (P) ; plot ( t , y )

The same result can be obtained using the Python-based libraries commented above as follows: #/ u s r / b i n / p y th o n from s c i p y import s i g n a l import m a t p l o t l i b . p y p l o t a s p l t K=1 tau =10

3. CONCEPTS AND TEACHING ACTIVITIES This section describes how the different software and hardware resources commented above can be used for control education purposes, where students can go through all the concepts motivated above, starting for operating system knowledge and finishing with the implementation of a control loop. The idea is that students are able to cover concepts related to mathematics, physics, programming, operating systems, I/O hardware devices, simulation, and communications (Astr¨ om and Murray, 2008). 3.1 Installing an operating system Although nowadays most students are familiar with computers, not all of them know how to configure and install an operating system. So, a first and trivial teaching activity can be to start working with an empty Raspberry Pi and to install and configure the operating system. This task is specially interesting when a Linux-based operating system is installed, what requires that students learn how to use a command-line OS. In this paper, we recommend to use Raspbian as commented above, which is a free operating system based on Debian optimized for the Raspberry Pi hardware (Upton and Halfacree, 2012). When the OS is installed, students will be required to download and to install the SciPy, Matplotlib and NumPy libraries, following the command-line instructions given in their documentation (Scott, 2014). Notice that these installation activities can seem very trivial for computer science engineers, but most of control engineers never learn about them during their academic training.

P=s i g n a l . l t i ( [K ] , [ tau , 1 ] ) t , y = s i g n a l . s t e p 2 (P) plt . plot (t , y) p l t . show ( )

As observed, a very similar structure is used in both packages. On other hand, notice that, while students are learning about how to use SciPy, Matplotlib and NumPy libraries, they are also learning about Python and programming concepts, which are very useful for implementation capabilities. SciPy allows to perform classical time- and frequencydomain analysis, as well as discrete-time simulations. So, this package can be used to teach and learn a wide range of automatic control concepts, such as usually done with Matlab. Notice that these simulation activities can also be done in a computer using Matlab, Sysquake or Octave, without the requirement of using the Raspberry Pi for that purpose. However, as Raspberry Pi is actually a computer, in this paper we would like to show that it would be possible to perform all classical control simulation exercises without requiring classical software simulation tools and without using any additional computer. Such as commented above, this solution is very interesting since students use the same computer for simulation and for implementation of control loops with I/O capabilities. Furthermore, this option is also very interesting for subjects with a large number of students, where lab sessions can be taught with very low cost (with other solutions, computers with I/O electronic boards would be required).

3.2 Dynamic system analysis Once the Raspberry Pi and the different software packages are installed and configure, students can use SciPy, Matplotlib and NumPy libraries to perform dynamic system analysis and control design activities. Such as commented above, SciPy follows a Matlab-like nomenclature, in such a way that it is very easy for control engineering students to learn about this package. Lets consider the analysis of a step response for a firstorder system with static gain k = 1 and time constant 101

3.3 Implementing a control loop Moreover, once students know how to perform classical simulations on the Raspberry Pi by using embedded functions to make linear system analysis, they can implement their own control loops to practice on digital control concepts. The idea is that they are able to implement control loops using Python, the computing and graphical capabilities of the libraries described above.

IFAC IBCE 2015 102 November 4-6, 2015. Brescia, Italy

Ángeles Hoyo et al. / IFAC-PapersOnLine 48-29 (2015) 099–104

The following code shows a very simple example about the implementation of the discrete time simulation to control a first-order system with a PI controller using the matching pole design method. First, the different required libraries are imported. Afterwards, the continuous first-order system is defined together with the closedloop specification. Then, the discrete model of the firstorder system is obtained and the discrete PI controller is calculated. After that, the simulation data is defined and initialized, following with the implementation of the control loop. Finally, the results are shown graphically. #/ u s r / b i n / p y t ho n from s c i p y import s i g n a l import m a t p l o t l i b . p y p l o t a s p l t import math import numpy a s np # Continuous time s ys t em # Closed−l o o p s p e c i f i c a t i o n K=1.0 tau =10.0 taubc =5.0

As commented above, Raspberry Pi includes a GPIO (General Purpose Input/Output) interface that allows to have a physical communication between the Raspberry Pi and the outside world. This interface is used as a classical input/output board, where Python functions are available to read and write on the corresponding input/output channels. There are many interesting open projects that can be followed to obtain ideas for education (Sobota et al., 2013). On the other hand, wire or wireless communication capabilities can be also used to perform networked-based control or remote control. Python allows to use socket communications in a very easy manner, and thus the control loop presented above can be modified to make the process simulation (or control a real process) remotely. This option has been proposed in this paper such as described in the following section, where a simulated two-tank system is control through the network. 4. PROPOSED PROJECT AND SUGGESTED CONTROL EDUCATION ACTIVITIES

# D i s c r e t e t im e s y s t e m T=taubc / 2 0 . 0 e=math . e a=(math . pow( e ,−T/ tau ) ) b=(K∗(1−a ) )

This section describes a project developed at the University of Almer´ıa (Spain) where the Raspberry Pi and the libraries described above are used to cover all the concepts motivated at the introduction section. So, different pedagogical activities are proposed to this end.

# D i s c r e t e PI c o n t r o l l e r − p o l e matching q0=(1−math . pow( e ,−T/ taubc ) ) /b q1=−a ∗ q0

A two-tank process has been traditionally used at the University of Almer´ıa to introduce basic automatic control concepts (Pasamontes et al., 2012). Students use virtual and remote labs developed in Easy Java Simulations to perform modelling and control activities for the level control problem. The virtual and remote labs are highlevel tools that only allow to introduce parameters and make experiments, but it is not possible to teach and to learn about implementation and communications issues. So, when students start with digital control subjects, they did not use the two-tank process anymore and they are moved to work with DC motors.

# Simulation data N=150 y=np . z e r o s (N) u=np . z e r o s (N) e=np . z e r o s (N) r=np . o n e s (N) # Simulation loop range=np . a r a n g e ( 1 ,N) f o r i in np . n d i t e r ( range , o p f l a g s =[ ’ r e a d w r i t e ’ ] ) : y [ i ]=( a ∗ ( y [ i −1]) ) +(b ∗ ( u [ i −1]) ) e [ i ]=( r [ i ]−y [ i ] ) u [ i ]=( u [ i −1]) +(q0 ∗ e [ i ] ) +(q1 ∗ e [ i −1]) t=np . a r a n g e ( 0 , (N) ∗T, T) plt plt plt plt

. plot (t , y) . show ( ) . plot ( t , u) . show ( )

Therefore, programming and digital control concepts are also very easy to be introduced with the proposed software and hardware tools. 3.4 Communication alternatives The use of Raspberry Pi as hardware platform opens a wide range of possibilities to perform control education activities. Once students learn how to implement and to simulate a control loop as described in the previous section, it is straightforward to modify that code to control a local or a remote real process by using Raspberry Pi. 102

Then, in order to continue working with the two-tank process in the digital control subjects and to introduce more new concepts, the virtual and remote labs for this system were modified to allow remote control capabilities. A socket-based library has been implemented in Java to allow communication activities. Moreover, the Raspberry Pi and SciPy library capabilities described in the previous section are used to perform all the control education tasks. Figure 2 shows an scheme of the proposed system architecture, where as can be observed, the Raspberry Pi is the only computer, and the virtual plant is controlled through a TCP/IP connection. Once this remote option was available, this new feature was combined with all the teaching capabilities provided by the Raspberry Pi and the SciPy library described above. Then, the following control education activities are suggested looking to exploit basic knowledge in control theory, programming, operating systems, simulation, and communications: (1) Installing and configuring Raspberry Pi. An empty Raspberry Pi is provided for each two students. Then, they have to install Raspbian, to configure the

IFAC IBCE 2015 November 4-6, 2015. Brescia, Italy

Ángeles Hoyo et al. / IFAC-PapersOnLine 48-29 (2015) 099–104

103

Fig. 2. Hardware, software, and communication options of the proposed architecture

(2)

(3) (4)

(5)

Debian-based OS and to install SciPy, Matplotlib and NumPy libraries. Afterwards, basic exercises based on simulations of linear systems are proposed to be sure that the installation was correct. Level tank modelling. Students must perform open loop experiments implemented on the Raspberry Pi and with remote connection to the virtual lab process. At this point, a short introduction about the socket communication in Python is provided to the students. Once the experiments are performed, the process model is obtained and a dynamic system analysis is performed using SciPy. Control system design. A PI-based control design is proposed for the level control problem and analyzed by using SciPy. Control loop implementation - simulation. The PI controller designed in the previous task is discretized and the whole control loop is implemented and simulated by code (such as shown in the example presented in section 3.3). Control loop implementation - remote control. Once the control loop is evaluated in simulation, the code is modified to control the virtual tank remotely. Notice that here the sockets library introduced previously for the open-loop experiments must be used again for the remote communication. After making the experiments, the results are analyzed using SciPy.

103

Thus, the proposed system architecture allows students to go through all the different control system design stages, starting with basic control knowledge and finishing with real implementation. Furthermore, the proposed architecture opens an interesting option for networked-based control and event-based control concepts, which are currently hot topics in the control engineering field and that could be transmitted to the students in a very easy manner. 5. CONCLUSION This paper has described how low-cost hardware devices and existing open-source software packages can be used to introduce basic concepts for control engineering education ranging from physics (dynamics and modeling), mathematics (control design methods), electronics (input/output communications), and computer science (networkbased communication and programming). Raspberry Pi has been described as the low-cost hardware platform, and Python language programming together with the SciPy, Matplotlib and NumPy libraries as the programming and software packages to perform the simulation, implementation, and communication tasks. All these hardware and software tools have been used and combined with existing virtual and remote labs to propose a whole control education project based on a two-tank level process. Future works will considered to use the Python control system library (Developers, 2014) on a Raspberry Pi 2.

IFAC IBCE 2015 104 November 4-6, 2015. Brescia, Italy

Ángeles Hoyo et al. / IFAC-PapersOnLine 48-29 (2015) 099–104

REFERENCES K. J. Astr¨ om and P.R. Kumar. Control: A perspective. Automatica, 50:3–43, 2014. K. J. Astr¨ om and R.M. Murray. Feedback Systems: An Introduction for Scientists and Engineers. Princeton University Press, USA, 2008. Python Control Developers. Python Control Documentation. https://media.readthedocs.org/pdf/pythoncontrol/v0.6d/python-control.pdf, 2014. J. W. Eaton, D. Bateman, S. Hauberg, and R. Wehbring. GNU Octave Manual. http://www.gnu.org/software/octave/octave.pdf, 2013. F. Esquembre. Easy Java Simulations. http://www.um.es/fem/EjsWiki/, 2014. ´ M. Pasamontes, J.D. Alvarez, J.L. Guzm´an, and M. Berenguel. Learning switching control: a tank level - control exercise. IEEE Transactions on Education, pages 226–232, 2012. Y. Piguet. Sysquake 5 User Manual. Calerga S`arl, La Tour-de-Peilz, Switzerland, 2013. J. Sarik and I. Kymissis. Lab kits using the arduino prototyping platform. In IEEE Frontiers in Education Conference (FIE), pages T3C–1–T3C–5, Washington, DC, 2010. M. Scott. An introduction to Numpy and Scipy. http://www.engr.ucsb.edu/˜shell/che210d/numpy.pdf, 2014. J. Sobota, R. Pisl, P. Balda, and M. Schlegel. Raspberry pi and arduino boards in control education. In Proceedings of the 10th IFAC Symposium Advances in Control Education, pages 7–12, Sheffield, UK, 2013. G.S. Sundaram, B. Patibandala, H. Santhanam, S. Gaddam, V.K. Alla, G.R. Prakash, S.C.V. Chandracha, S. Boppana, and J.M. Conrad. Bluetooth communication using a touchscreen interface with the raspberry pi. In Proceedings of IEEE Southeastcon, pages 1–4, Jacksonville, FL, 2013. S. Tosi. Matplotlib for Python Developers. Packt Publishing Ltd, UK, 2009. E. Upton and G. Halfacree. Raspberry Pi User Guide. John Wiley & Sons, UK, 2012.

104