You are on page 1of 5

A Data Acquisition System Based on Raspberry Pi:

Design, Construction and Evaluation


Alireza Akhoondi Asadi*, Shahriar Bagheri*, Ahmed Imam*, Ehsan Jalayeri*, Witold Kinsner t and
Nariman Sepehri*
*Dept. of Mechanical Engineering
t Dept. of Electrical and Computer Engineering
University of Manitoba, 75A Chancellors Circle, Winnipeg, MB R3T 5V6
Email: akhoonda@myumanitoba.ca

Abstract- This paper presents the construction of a low-cost is developed based on ARM-Cortex microcontroller. The mi-
data acquisition system (DAS) prototype based on Raspberry crocontroller is connected to a PC equipped with LabView
Pi-2 microcomputer. The prototype is designed to operate as a through TCPIIP protocol. In [3], AVR-based data acquisition
standalone system without the need for an additional personal
computer (PC). It performs the data acquisition, online plotting board was designed. More recent literature ([4] and [5]) focus
and data logging, simultaneously. This is a general-purpose setup, on designing DAS for specific applications. In [4], the popular
as it is capable of reading any analog sensor giving output in the Raspberry Pi microcomputer was used as a LAN server to
designed range, or through appropriate signal conditioning. The receive and update patient data in a hospital scenario. Further,
system is tested in a Mechanical laboratory by collecting data in [5], Raspberry Pi was used as a portable very low frequency
which are compared to a benchmark DAS. Statistical analyses
are also performed on the acquired data. It is proved that both (VLF) data logger.
signals are identical with only minor differences. This work is different from the above mentioned studies and
Keywords- Data Acquisition System, Prototype, Raspberry Pi is not designed to compete with any high quality DAS. Pro-
posed design is a compact, portable standalone system, that is,
no PC is required for data storage or manipulation. Therefore,
I. INTRODUCTION
the overall cost of the prototype is reduced. Cost, is considered
Data collection and storage are an integral part of a day- an important factor since the targets of the proposed DAS are
to-day laboratory work. Researchers and engineers need to small-scale industries and academic research laboratories.
constantly monitor machines and systems through series of The rest of this paper is organized as follows: Section II
sensor information. The information is often visualized as describes the system architecture with brief overview of the
graph and/or chart. In order to acquire data from any source, Raspberry Pi microcomputer. Section III presents the experi-
a data acquisition system (DAS) is required. Although DAS mental test that was performed to validate the functionality of
boards come in variety of models and capabilities, most com- the system. A comprehensive statistical analysis is performed
mercially available DASs have at least one of the following and results are presented in Section III-B. This is to ensure that
two main features: they sketch an online graph of the signal, the quality and accuracy of the acquired data is comparable
and they store data samples for post experiment analysis. to a benchmark DAS board. The benchmark, used in this
Choosing a DAS board to select is application dependent. experiment, is the Quanser Q8 data acquisition device [6].
For example, many applications require high resolution analog Finally, Section IV presents the highlights of this study.
to digital conversion (ADC), while other applications might
require high sampling rate. In such cases one should look for II. PI-BASED DAS ARCHITECTURE
DAS board that offers such capabilities.
The idea of using microprocessors for data acquisition has Typically, data acquisition process involves reading sensory
been around for sometime. For instance, back in the 1990, information from one or more sensors, converting obtained
authors in [1] propose a data acquisition system designed data into digital form (ADC conversion), plotting and storing
specifically for photo voltaic (PV) systems. Authors propose a information onto the memory. Several components of the data
microsystem architecture based on MC68B09 microprocessor acquisition process are illustrated in Fig. 1. Following, is the
which is capable of data collection and analysis. The data explanation of how different components of Fig. 1 are selected
collection in [1] is in real-time and through RS232 serial or designed for the proposed Pi-based DAS.
interface. Analog sensors measure a physical quantity (e.g. temper-
Much has changed since the 1990. During the past few ature, pressure) and generate a voltage proportional to the
years, several low-cost embedded platforms entered the elec- quantity being measured. There are different types of sensors
tronics market. Most of these platforms are open-source and with different output characteristics. Nevertheless, typical ana-
easy to program and operate. This fact made these systems log sensors used in daily laboratory work generate an output
popular among the scientific community. In [2], a DAS board voltage between 0 to 10 V.

978-1-5090-0996-1/16/$3l.00 2016 IEEE

Authorized licensed use limited to: UNIVERSITY OF MANITOBA. Downloaded on October 02,2020 at 18:44:57 UTC from IEEE Xplore. Restrictions apply.
The analog voltage obtained from the sensor should be computer has several features that are beneficial for a data
converted to digital form. This is accomplished through an acquisition application. For example, Raspberry Pi is equipped
analog to digital converter (ADC). There are different variety with a high-definition multimedia interface (HDMI) port. This
of ADCs, available with different characteristics (resolution, feature helpes develop a standalone system that is not depen-
conversion speed, etc.). In this study, Arduino Mega2S60 is dent on seperate personal computer (PC) for data visualization
used to perform the analog to digital conversion [7] . There are (real-time plots). Furthermore, the Raspbian Operating System
two main reasons behind selecting Arduino Mega as the ADC (OS) [12], installed on Raspberry Pi, provides flexibility and
for this particular experiment. First, the Arduino Software freedom of choice for the system developer to select desired
(Integrated Development Environment or IDE) provides an programming language.
easy-to-use platform to write, debug and compile programs As mentioned earlier, the 12C protocol requires a master
onto the microcontroller processor. Second, since Arduino and a slave device. Here and in this prototype, Raspberry
Mega is a microcontroller, it provides a suitable and flexible Pi (defined as the master device), sends a request signal to
platform for further improvements and modifications of the the Arduino Mega (defined as the slave device) to capture
designed DAS board. For instance, it would be possible to use sensor data, perform ADC, and send the digitized value back
the PWM outputs of the Arduino and generate output PWM to Raspberry Pi. An overview of the wiring diagram of the
signals for control applications. proposed architecture is shown in Fig. 2.
This Arduino microcontroller runs on an ATmega2S60
microprocessor. The board has 16 analog inputs, 8 of which III. EXPERIMENTAL EVALUATION
are used in this experiment. Maximum resolution of the
Arduino ADC is lO-bits. However, 8-bit resolution conversion A. Test Rig
is used here to digitize analog inputs. Moreover, ATmega2S60
uses successive approximation conversion. As a result, the In order to assess the developed Raspberry Pi-based DAS
conversion time is deterministic and the converter consumes a laboratory experiment was performed. The test involved
less power than flash converters [8]. reading data from three pressure sensors (Kl pressure trans-
Once the AD conversion is done, digitized sensor data ducer developed by Ashcroft Inc. [l3]). Pressure sensors were
connected to an excavator machine shown in Fig. 3. Pressure
should be transferred to the embedded computer, as was
sensors are marked with yellow hallow circles. This experi-
shown in Fig. l. This data transmission could be accomplished
mental test took place at the Fluid Power and Tele-Robotics
through number of different interfacing protocols. In this
study, inter-integrated circuit (12C) is selected as an interface Research Laboratory, University of Manitoba. Both Quanser
Q8, and Pi-based DAS captured pressure data simultaneously.
between the ADC and embedded computer. 12C is a type of
synchronous data transmission protocol, as it has a dedicated The machine operated for approximately 5 minutes.
transmission line for the clock [9]. 12C communication is
implemented bi-directionally with a master and a slave device B. Result
that communicate with each other through a serial clock line
Three pressure sensors mentioned earlier were connected
(SCL) and serial data line (SDA). The slave device can send
to the analog input of both the Pi-based DAS and Quanser
an interrupt request to the master device, and the master device
Q8. Quanser board samples the analog pressure signal with
establishes the communication using the SCL and SDA lines
the frequency of 100 samples per second (Sps). This results
[lO].
in 30, 000 samples after five minutes. On the other hand,
Raspberry Pi DAS has lower sampling rate and samples the
input analog signal at 20 Sps, which results in 6, 000 samples.
It should be mentioned that (according to the Nyquist sampling
theorem), the highest frequency component, in this case, can
be up to lO Hz for the Pi-based DAS. This covers a wide range
of mechanical systems. However, Pi-based DAS is capable of
capturing higher frequencies by disabling the online plotting.
Table I compares important features of the Quanser Q-8
with the proposed Pi-based DAS. This table is filled with
information obtained from [6] and [14].
Results obtained for all three pressure sensors are illustrated
in Fig. 4 through Fig. 6.
It can be observed from these Figures that both the Quanser
Fig. 1. Typical data acquisition process. signal, and Pi signal follow the same trend. However, in order
show that both signals are identical further statistical analysis
Finally, the heart of the proposed data acquisition board is required. Next section discusses the statistical analysis in
is a Raspberry Pi-2 microcomputer [11]. This single-board more details.

Authorized licensed use limited to: UNIVERSITY OF MANITOBA. Downloaded on October 02,2020 at 18:44:57 UTC from IEEE Xplore. Restrictions apply.
Fig. 2. Wiring diagram of the proposed DAS.

Chamber One Pressure Sensor (P, ) Chamber Two Pressure Sensor (P,) 4.5
- Pi-based DAS
~ 4
--- Quanser 08 OAS
(;
if>
<::
Q)
3.5
CfJ
i£ ~ 3
"
if>
if>
Q)
"0

Cl.
,e 2.5
<::
Display Unit c. OJ
E ro
::;; 2
"
Cl.
i

.. . "D"' I...... L~~~ ~. ' ' ..............


50 100 150 200 250 300
Time [s]

Analog Inputs Fig. 5. P2 pressure data.

. __________~~sy_b_e.!"~~!! ~~~ ________ _ 6 ,-----,-----,-----,-----~--r-=p~i-~


ba=
sed~D~
AS~
--- Quanser 08 DAS

Fig. 3. Experimental test setup. I


5 ,-----,------,------,------,---r-~p=
i-b=
as=
ed~D~
A~S~
4 .5 --- Quanser 0 8 DAS

~3 . 5

~ 3
.a
·15,2.5
ro
::;; 2 I o 50 100 150 200 250 300
Time [s]
1.5
Fig. 6. Pp pressure data.
0.5 " - - - - " - - - - - ' - - - - - ' - - - - - - ' - - - - - - ' - - - - - '
o 50 100 150 200 250 300
Time [s]

1 n=N
Fig. 4. PI pressure data.
J-l = N L
n= l
Xn (1)

C. Statistical Analysis
Initially, the first and second statistical moments are calcu- 0- 2 = (2)
lated for the complete data set; namely, mean (J-l) and variance
(0- 2 ). They can be calculated by (1) and (2), respectively [15] . Table II tabulates the mean and variance of the data for all
0- 2 shows how data is spread-out from mean. three pressure sensors.

Authorized licensed use limited to: UNIVERSITY OF MANITOBA. Downloaded on October 02,2020 at 18:44:57 UTC from IEEE Xplore. Restrictions apply.
Table I
COMPARISON BETWEEN PI- BASED AND QUA NSE R Q8 DAS

Item Raspberry-Pi Based DAS [11] Quanser Q8 [6]


Software/Hardware req uirement Does not require additional Software/Hardware Requires PC with Operating System (e.g. Windows, Linux)
Number of analog inputs 8 8
Number of analog outputs 0 8
Input voltage range 0 - 10 V ± 10 V
Max ADC resolution 10 bits 14 bits
ADC conversion time 13J.is to 260J.is ~ 4J.is

Table II 2 0.8
PI-B ASED AN D QUANSER Q8 DAS MEASUREMEN TS 1.8 Q)
c gO.6
~ 1.6 ro
Pressure sensor Pi-based DAS Quanser Q8 :2:1.4
"---- ~0.4
(T2 (T2
J.i J.i
1.2 0.2
PI 1.5399 0.6452 1.7165 0.7580 0 20 40 60 20 40 60
P2 1.1204 0.3394 1.2629 0.3778
Pp 1.6939 0.6044 1.8779 0.6774 1.2 3.4
VJ
VJ VJ
Q)
1 '00 3
c 0
3:
Ql
t
Vi 0.8
::J
Furthennore, third and forth statistical moments are calcu- ~ 2.6
lated through (3) and (4).
0 20 40 60 0 20 40 60
n=N Time [sl Time [sl

Skewness = N1 '~ x - f-L ]3


" [~ (3)
Fig. 8. Stationarity Calculation for the Pi-based DAS.
n=l

n=N
2
Kurtosis = 1- '~ x __
" [_n - f-L ]4 - 3 (4) c
Q)

N (Y ~ 1.8 ----........___- - -_______ g 0 .8


n=l
:2: 1.6 ""'- ro
~0.6
Figure 7 illustrates four statistical moments for data ob- 1.4 '---_ _ _ _ _ __
~ ~

tained from Quanser Q8 and Pi-based DAS. o 20 40 60 0 20 40 60

0.5 r - - - - - - - - - - - - , 3.5
4 l:l12 VJ
Q) '00
~
Q)
1 .@
::J
3
-'" ~
en 0.8 2.5

o 20 40 60 0 20 40 60 o 20 40 60 o 20 40 60
Time [sl Time [sl

30 Fig. 9. Stationarity Calculation for the Quanser Q8 DAS.


VJ
.~ 20
t
::J
~ 10
Another interesting characteristic of a discrete signal is the
60 0 20 40 60 Probability Mass Function (PMF). Therefore, PMF is also
Time [sl Time [sl studied here for both acquired signals. According to [17], when
skewness and kurtosis variations are relatively large, the so-
Fig. 7. Statistical moments of acquired data; solid line: Pi-based DAS, dashed
line: Quanser Q8 DAS. called Burr distribution can be a proper fit to the data. This is
the case for the acquired data as was shown in Fig. 7. Through
the study of histograms shown in Fig. 10, it is determined that
The concept of stationarity is important to further analyze
the distribution of both signals are Burr XII distribution given
any non-independent data. This is the basis for many data
by (5).
analysis methods [16]. The stationarity calculations for both
Pi-based and Quanser Q8 DAS are shown in Fig. 8 and Fig. x c- 1
9, respectively. As illustrated in Fig. 8 and Fig. 9 , mean and f(x; c, k) = ck (1 + xc )k+l (5)
variance variations are less than 5%. Thus, the data is weakly
where parameters c and k are called shape parameters [17].
stationary.

Authorized licensed use limited to: UNIVERSITY OF MANITOBA. Downloaded on October 02,2020 at 18:44:57 UTC from IEEE Xplore. Restrictions apply.
[7] Arduino, 2016. Retrieved from Arduino at https://www.arduino.cc/.

ILl~~=~ :
Accessed: 2016-07-17.
[8] G. F. Gross Jr, "Deterministic successive approximation analog-to-digital
converter," Dec. 5 2000. US Patent 6,157,338.
[9] I. Susnea and M. Mitescu, Microcontrollers in practice, vol. 18. Springer
Science & Business Media, 2005.
[l0] Y.-J. Kim , "I2c communication system and method enabling bi-
Q5 1 1.5 2 Z5 3 15 4 4.5 5
directional communications," Jan. 4 2005. US Patent App. 111028,319.

rl ~. •
c
[11] Raspberry Pi , 2016. Retrieved from Raspberry Pi at
https://www.raspberrypi.orgl, Accessed: 2016-07-15.
[12] Raspbian OS, 2016. Retrieved from Raspbian at
https://www.raspbian.org/, Accessed: 2016-07-17.
[13] Ashcroft, 2016. Retrieved from Ashcroft at http://www.ashcroft.com/.
Accessed: 2016-07-17.
[l4] ATmega 2560, 2016. Retrieved from Atmel at
a:000.5 1 1.5 2 2.5 3 3.5 4 4.5 5 http://www.atmel.comldevices/ATMEGA2560.aspx?tab=overview,
Amplitude [V] Accessed: 2016-07-17.
[l5] J. C. Sprott, Chaos and time-series analysis, vol. 69. Oxford University
Fig. 10. Normalized Histogram and Probability Mass Function Comparison; Press Oxford, 2003.
solid line: Pi-based DAS, dashed line: Quanser Q8 DAS. [l6] G. Nason , "Stationary and non-stationary time series," Statistics in
Volcanology. Special Publications of IAVCEI, vol. 1, pp. 000- 000, 2006.
[17] P. R. Tadikamalla, "A look at the burr and related distributions," Inter-
national Statistical Review/Revue Internationale de Statistique, pp. 337-
IV. CONCLUDING REMARKS 344, 1980.
In this paper, an architecture of a Raspberry Pi-based data
acquisition prototype was described. The design aimed to
provide a cost efficient and reliable data acquisition solution,
targeting small-scale industries and research laboratories. Tests
were performed to assess the functionality of the device.
Furthermore, a comparison between the proposed Pi-based
DAS with Quanser Q8 DAS was provided. Results showed
that the Pi-based DAS is able to successfully plot pressure
sensors concurrently. Statistical analysis performed on both
Quanser and Pi signals showed that both signals are identical,
with minor differences. The Pi-based DAS sampling frequency
was, however, lower than Quanser Q8 DAS. This, might cause
problems, should this device is to be used for systems with
fast dynamics that require higher sampling frequency.

ACKNOWLEDGMEN T
Authors would like to thank Mr. Ali Maddahi, Ph.D student,
and Mr. Moosa Rafiq, MS.c. student in the Fluid Power and
Tele-Robotics Research Laboratory of University of Manitoba
for helping during the statistical analysis of data, and running
the test rig.
REFERENCES
[1] M. Benghanem and A. Maafi, "Data acquisition system for photovoltaic
systems performance monitoring," IEEE Transactions on Instrumenta-
tion and Measurement, vol. 47, no. 1, pp. 30-33, 1998.
[2] P. Hiren and P. Dipak, "Gui based data acquisition system using arm-
cortex m3 microcontroller," lJCSIT) International Journal of Computer
Science and Information Technologies, vol. 3, no. 1, pp. 3199-3204,
2012.
[3] H. Shaikh Yusuf, A. Khan, and S. Behere, "Avr microcontroller based
data acquisition system for laboratory experiments," Advances in Applied
Science Research, vol. 3, no. 1, pp. 208- 215, 2012.
[4] M. Ravi and K. Muralidhar, "Raspberry pi based data sensing and
logging system using wireless sensor nodes (wsn) and local area network
(Ian)," in International Journal of Engineering Research and Technology,
vol. 4, ESRSA Publications, 2015.
[5] Y. Soon, K. Gan, and M. Abdullah, "Development of very low frequency
(vlf) data acquisition system using raspberry pi," in 2015 International
Conference on Space Science and Communication (lconSpace), pp. 485-
488, IEEE, 2015.
[6] Quanser Q8, 2016. Retrieved from Quanser at
http://www.quanser.com/products/q8. Accessed: 2016-07-15.

Authorized licensed use limited to: UNIVERSITY OF MANITOBA. Downloaded on October 02,2020 at 18:44:57 UTC from IEEE Xplore. Restrictions apply.

You might also like