Implementation of bi-fractional ltering on the Arduino Uno hardware platform Waldemar Bauer1 , Aleksandra Kawala-Janik2 1
AGH University of Science and Technology, Department of Automatics and Biomedical Engineering, Al. Mickiewicza 30, 30-059 Kraków Email:
[email protected] 2
Faculty of Electrical Engineering, Automatic Control and Informatics, Opole University of Technology, ul. Proszkowska 76/1, 45-758 Opole, Poland Email:
[email protected]
Abstract. In this paper application of method based on bi-fractional
ltering on the Arduino Uno was proposed. The authors showed that the implementation of a non-integer order lter on a micro-controller hardware platform is possible and gives promising results. Another aspect of potential implementation of such systems involves using biomedical data in particular EEG signals, which were applied during the research carried out for the purpose of this paper.
1 Introduction Nowadays the implementation of non-integer order subsystems on various platform is a broadly researched topic.One of the questions of great importance is to design and develop an algorithm for realisation of non-integer order elements in the discrete implementation (see: [1, 25]). Only a very few years ago the technology based on using biomedical data for the purpose of control was very rare and even voice recognition or touch panels were rarely used and nowadays application of brain signals (EEG) as a source data (although very novel)has become in the past two decades very popular due to the growing interest of researchers all over the world [17, 16, 19]. This is because (in accordance with multiple studies) not only people, but also animals, are able to communicate with computers using biomedical signals [16]. This particularly important for handicapped users, unable to conduct simple tasks such as using keyboard or mouse [17]. The application of EEG signals is a very dicult task, as it relies on real-time analysis and interpretation a data of (frequently) a very poor quality. Therefore a very important role is to choose appropriate signal processing method (see: [16]), and so the concept of using fractional calculus in technical applications became recently very popular, although regarding it theory was developed already in the 19th century. This is because implementation of such ltering (fractional) allows
great exibility in lter shaping, which is not possible while using traditional ltering methods [28] The theory of non-integer order systems can be found in e.g.:[27, 23, 11, 15, 7] and the Oustaloup method was in more detail described in: [24]. It is important to mention that the Oustaloup approximation can be used in simulations, which were described in: [9, 10, 13, 20, 29], in ltering presented in more detail in: [5, 18, 14] and with appropriate care in experiments presented in: [12, 22]. Its sensitivity and stability problems during discretisation were deeply discussed in: [26, 3, 8]. Dierent method of approximation is based on Laguerre functions (see: [6, 30, 1]). The implementation of the algorithm requires the discretisation of the control system designed in a continuous time domain. The earlier results (see: [4]) prove that the transfer function cannot be directly implemented. The further part of this paper is organised as follows, where the bi-fractional lter is presented in a transmitation and dierential equation form. Then the time-domain Oustaloup approximation is shown. The results of experiments are then presented and the main dierences between the Matlab-Simulink and the Arduino Uno hardware platform lter realisation are discussed. Finally the conclusions and future works are drawn.
2 Bi-fractional lter In this paper the authors focused on the digital realisation of bi-fractional lters. The lter can be given by the following transfer function (see [4]):
G(s) =
c s2α + 2bsα + c
(1)
Where:
α is base order b is damping coecient c is free coecient This formula (1) can be represented in the form of a system of dierential equation with zero initial conditions: C α 0 Dt x(t)
(2)
= Ax(t) + Bu y(t) = Cx(t)
with matrix:
0 1 A= −c −2b
0 B= 1
C= c0
Such system can be realized with non-integer order integrators as illustrated with the Fig. 1.
Fig. 1: Block diagram realization of bi-fractional lter in dierential equation form.
3 The Original Ostaloup Non-Integer Time-Domain Approximation The Oustaloup lter approximation with a fractional-order dierentiator G(s) = sα has a large use of potential, especially in applications [21]. An Oustaloup lter can be designed as [24]:
Gt (s) = K
N Y s + ωi0 i=1
s + ωi
(3)
where:
ωi0 = ωb ωu(2i−1−α)/N
(4)
ωb ωu(2i−1+α)/N ωhα
(5)
ωi = K=
s ωu =
ωh ωb
(6) (7)
Because the poles of this approximation spacing from close to −ωh to those very close to −ωb . This spacing is not-linear and more poles are grouping near −ωb . This is one of the main reasons of problems in discretisation process.
Time domain Oustaloup Approximation For zero-initial condition it is possible to describe any part of (3) as follows:
s + ωk0 ⇐⇒ s + ωk
( x˙ k = Ak xk + Bk uk yk = xk + uk
where
Ak = − ωk ,
Bk = ωk0 − ωk
This can be written in vector matrix notation as below:
(8)
KB1 A1 0 0 . . . 0 KB2 B2 A2 0 . . . 0 B 3 B 3 A3 . . . 0 x˙ = x + KB3 u .. .. .. .. . . .. . . . . . . KBN B N B N . . . B N AN y = 1 1 . . . 1 1 x + Ku
(9)
or in brief
x˙ = Ax + Bu y = Cx + Du
(10)
This approach proved to be more robust to dierent discretisation schemes (for more details see: [2]). This form will be use in implementation at the Arduino Uno.
4 Digital realization bi-fractional lter at the Arduino Uno The Arduino Uno is a microcontroller board based on the ATmega328. The Atmega328 has 32 KB of ash memory for storing code (of which 0,5 KB is used for the bootloader). It has also 2 KB of SRAM and 1 KB of EEPROM. The board has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz crystal oscillator, a USB connection, a power jack and an ICSP header. It contains everything needed to support the microcontroller and requires simply only USB cable in order to be connected to a computer.
4.1
Algorithm of calculation non-integer integrator
In order to perform the realisation of bi-fractional ltering on the Arduino Uno platform (based on Fig. 1) an algorithm to calculate response of non-integer integrator has to be created. At this stage the time-domain Oustaloup approximation is being used. Because the considered approximation is realised in the time-domain dierential scheme can be applied for creating the needed algorithm. The proposed algorithm for the value approximation of response noninteger integrator will have the following form:
Data: N order of approximation
A, B, C, D discreet matrix described approximation xp integrator state vector Bu , Ax local variable ut signal value in time t x helper integrator state vector Result: yt non-integer integrator response in time t ; yt = 0; for i = 0 to N − 1 do Bu = B[i] ∗ ut ; Ax = 0; for j = 0 to N − 1 do Ax = Ax + A[i][j] ∗ xp[j];
end
x[i] = Ax + Bu ; yt = yt + C[i] ∗ x[i];
end
xp = x;
return y+ = D ∗ ut
As it was shown above the complexity of this algorithm can be clearly seen and it is constant and has a value of O(n2 ). One can easily observe the presented algorithm worked only at basic arithmetic operation. For this reasons, it can be easily adapted for any hardware platform e.g.: micro-controllers, PLC, FPGA.
5 Experiments and Results The tested EEG signal was recorder using inexpensive EEG headset Emotiv EPOC and was ca. 700 seconds long. The tests were carried out during imagery left- and right-hand movements [16]. An experiment has been conducted in order to compare the performance of Matlab Simulink and Arduino Uno with the bi-fractional lter implementation for EEG signal. The described time domain Oustaloup approximations has been discretaised and implemented on both considered platforms. The scheme of ltering with the use of the Arduino Uno we can seen in Fig. 2.
Fig. 2: Arduino Uno/PC connection schema.
The bi-fractional lter settings and time-domain Oustaloup approximation parameters are:
N =7 ω = [10−6 , 106 ] α = {0.1, 0.7} b = 1.5 c = 2.24
Result of the perfomed ltering for α = 0.1 is shown in the Fig. 3, 4 and the results obtained for α = 0.7 illustrate the Fig. 5, 6. The average error between Matlab Simulink and Arduino Uno implementation for the ltered signal in time has value of 9.5. Considering the fact that the Arduino Uno represents the oating-point numbers as oat, the presented result is very good. The second case when α = 0.7 gives the average error value of 12.48. This shows that such implementation work was correct and was also conrmed with the analysis in the frequency-domain presented in Fig. 4 and 6.
Fig. 3: Comparison ltration result with Oustaloup time domain approximation and Matlab Simulink for
α = 0.1.
6 Conclusions and Further Research In this paper the implementation method of bi-fractional lter on the Arduino Uno platform was proposed. The authors showed that the implementation of
40 30 Matlab Arduino Uno
Magnitude [dB]
20 10 0 −10 −20 −30 −40 −50 −60 0
1
10
10 Frequency [Hz]
Fig. 4: FFT signal ltered by Oustaloup time domain approximation and Matlab Simulink for
α = 0.1.
Fig. 5: Comparison ltration result with Oustaloup time domain approximation and Matlab Simulink for
α = 0.7.
Fig. 6: FFT signal ltered by Oustaloup time domain approximation and Matlab Simulink for
α = 0.7.
non-integer order lter in micro-controller hardware platform is possible and gives good scientic results. Further work will include dierent types of non-integer order lter prototypes, methods of discretisation and implementation on real-time systems hardware platforms.
ACKNOWLEDGEMENT Work realised in the scope of project titled "Design and application of noninteger order subsystems in control systems". Project was nanced by National Science Centre on the base of decision no. DEC-2013/09/D/ST7/03960.
References 1. P. Bania and J. Baranowski. Laguerre polynomial approximation of fractional order linear systems.
In W. Mitkowski, J. Kacprzyk, and J. Baranowski, editors,
Advances in the Theory and Applications of Non-integer Order Systems: 5th Conference on Non-integer Order Calculus and Its Applications, Cracow, Poland, pages 171182. Springer, 2013. 2. J. Baranowski, W. Bauer, and M. Zagórowska.
Stability properties of discrete
Theoretical Developments and Applications of Non-Integer Order Systems, volume 357 of Lecture Notes in Electrical Engineering, pages 93103. Springer International time-domain oustaloup approximation. In S. Domek and P. Dworak, editors,
Publishing, 2016.
3. J. Baranowski, W. Bauer, M. Zagórowska, T. Dziwi«ski, and P. Pi¡tek.
Time-
Methods and Models in Automation and Robotics (MMAR), 2015 20th International Conference On, pages 116120. IEEE,
domain oustaloup approximation.
In
2015. 4. J. Baranowski, W. Bauer, M. Zagórowska, and P. Pi¡tek. On digital realizations of non-integer order lters.
Circuits Syst Signal Process, 2016.
5. J. Baranowski, P. Pi¡tek, W. Bauer, T. Dziwi«ski, and M. Zagórowska.
Bi-
Methods and Models in Automation and Robotics (MMAR), 2014 19th International Conference on, pages fractional lters, part 2: Right half-plane case.
In
369373. IEEE, 2014. 6. J. Baranowski, M. Zagórowska, P. Bania, W. Bauer, T. Dziwi«ski, and P. Pi¡tek.
In Methods and Models in Automation and Robotics (MMAR), 2014 19th International Conference On, pages 379383. IEEE, 2014. Impulse response approximation method for bi-fractional lter.
7. J. Baranowski, M. Zagórowska, W. Bauer, T. Dziwi«ski, and P. Pi¡tek. Applications of direct lyapunov method in caputo non-integer order systems.
ir Elektrotechnika, 21(2):1013, 2015.
Elektronika
8. W. Bauer, J. Baranowski, T. Dziwi«ski, P. Pi¡tek, and M. Zagórowska. Stabiliλ µ sation of magnetic levitation with a pi d controller. In
Methods and Models in Automation and Robotics (MMAR), 2015 20th International Conference On, pages 638642. IEEE, 2015.
9. W. Bauer, J. Baranowski, and W. Mitkowski.
α µ Non-integer order PI D control
Advances in the Theory and Applications of Non-integer Order Systems: 5th Conference on Non-integer Order Calculus and Its Applications, Cracow, Poland, pages 171182. ICU-MM. In W. Mitkowski, J. Kacprzyk, and J. Baranowski, editors,
Springer, 2013. 10. W. Bauer, T. Dziwi«ski, J. Baranowski, P. Pi¡tek, and M. Zagórowska. Comparλ µ ison of performance indices for tuning of pi d controller for magnetic levitation
Advances in Modelling and Control of Noninteger-order Systems - 6th Conference on NonInteger Orfer Caculus and its Applications. Springer, 2014. K. Diethelm. The Analysis of Fractional Dierential Equations: An ApplicationOriented Exposition Using Dierential Operators of Caputo Type. Number no.
system. In K. J. Latawiec, M. ukaniszyn, and R. Stanisªawski, editors,
11.
2004 in Lecture Notes in Mathematics. Springer, 2010. 12. T. Dziwi«ski, W. Bauer, J. Baranowski, P. Pi¡tek, and M. Zagórowska. Robust non-integer order controller for air heater. In Methods and Models in Automation and Robotics (MMAR), 2014 19th International Conference On, pages 434438. IEEE, 2014. 13. T. Dziwi«ski, W. Bauer, J. Baranowski, P. Pi¡tek, and M. Zagórowska. Robust non-integer order controller for air heating process trainer.
In K. J. Latawiec,
Advances in Modelling and Control of Noninteger-order Systems - 6th Conference on Non-Integer Orfer Caculus and its Applications. Springer, 2014. M. ukaniszyn, and R. Stanisªawski, editors,
14. T. Dziwi«ski, P. Pi¡tek, J. Baranowski, W. Bauer, and M. Zagórowska. On the In Methods and Models in Automation and Robotics (MMAR), 2015 20th International Conference On, pages
practical implementation of non-integer order lters. 921924. IEEE, 2015. 15. T. Kaczorek.
Selected Problems of Fractional Systems Theory.
Control and Information Sciences. Springer, 2011. 16. A. Kawala-Janik.
Bio-Signals.
Lecture Notes in
Eciency Evaluation of External Environments Control Using
PhD thesis, University of Greenwich, 2013.
17. A. Kawala-Janik, J. Baranowski, M. Podpora, P. Pi¡tek, and M. Pelc. Use of a costeective neuroheadset emotiv epoc for pattern recognition purposes.
Journal of Computing, 13(1):2533, 2014.
International
18. A. Kawala-Janik, M. Podpora, J. Baranowski, W. Bauer, and M. Pelc. Innovative approach in analysis of eeg and emg signals - comparision of the two novel methIn Methods and Models in Automation and Robotics (MMAR), 2014 19th International Conference on, pages 804807. IEEE, 2014. ods.
19. P. M. Kawala-Janik A. and P. M. Method for eeg signals pattern recognition in embedded systems.
Elektronika ir Elektrotechnika, (3):39, 2015.
20. W. Mitkowski. Approximation of fractional diusion-wave equation.
ica et automatica, 5:6568, 2011.
acta mechan-
Fractional-order systems and controls. Fundamentals and applications. Advances in Industrial Control.
21. C. A. Monje, Y. Chen, B. M. Vinagre, D. Xue, and V. Feliu. Springer-Verlag, London, 2010.
22. A. Obr¡czka and W. Mitkowski. The comparison of parameter identication methods for fractional, partial dierential equation. 270, 2014. 23. K. Oldham and J. Spanier.
Solid State Phenomena,
The fractional calculus.
210:265
Academic Press, New York,
1974. 24. A. Oustaloup, F. Levron, B. Mathieu, and F. M. Nanot. Frequency-band complex
Circuits and Systems I: Fundamental Theory and Applications, IEEE Transactions on, 47(1):2539, 2000. I. Petrá². Fractional-Order Nonlinear Systems: Modeling, Analysis and Simulation. noninteger dierentiator: characterization and synthesis.
25.
Nonlinear Physical Science. Springer, 2011. 26. P. Pi¡tek, M. Zagórowska, J. Baranowski, W. Bauer, and T. Dziwi«ski. Discretisa-
Methods and Models in Automation and Robotics (MMAR), 2014 19th International Conference on, tion of dierent non-integer order system approximations. In pages 429433. IEEE, 2014.
Fractional Dierential Equations: An Introduction to Fractional Derivatives, Fractional Dierential Equations, to Methods of Their Solution and Some of Their Applications. Mathematics in Science and Engineering. Elsevier
27. I. Podlubny.
Science, 1999. 28. A. G. Radwan, A. S. Elwakil, A.S., and A. M. Soliman, A.M. On the generalization of second-order lters to the fractional-order domain.
and Computers, 18(02):361386, 2009.
Journal of Circuits, Systems
29. M. Zagórowska, J. Baranowski, P. Bania, W. Bauer, T. Dziwi«ski, and P. Pi¡tek.
Methods and Models in Automation and Robotics (MMAR), 2015 20th International Conference On, pages 104109. IEEE, 2015. Parametric optimization of pd controller using laguerre approximation. In
30. M. Zagórowska, J. Baranowski, P. Bania, P. Pi¡tek, W. Bauer, and T. Dziwi«ski. Impulse response approximation method for fractional order lag. In K. J. Lataw-
Advances in Modelling and Control of Noninteger-order Systems - 6th Conference on Non-Integer Orfer Caculus and its Applications. Springer, 2014.
iec, M. ukaniszyn, and R. Stanisªawski, editors,