You are on page 1of 6

2018 12th IEEE International Conference on Semantic Computing

Module for Virtual Calibration of Sensors of


Agricultural Spraying Systems (temperature, pressure
and flow) Using an Arduino-based Architecture and a
Controller Area Network Bus (CAN)
Pedro B. Andrade1,2, Paulo E. Cruvinel1, Elmer A. G. Peñaloza1,3
1
Embrapa Instrumentation, Brazilian Agricultural Research Corporation, São Carlos, SP, Brazil.
2
Federal University of São Carlos, Department of Electrical Engineering, São Carlos, SP, Brazil.
3
University of São Paulo, Department of Electrical Engineering and Computing, São Carlos, SP, Brazil.
Emails: pedro_borghi@hotmail.com, paulo.cruvinel@embrapa.br, egamboa@usp.br

Abstract- This paper presents a method for the development production has become increasingly necessary because of this
of a sensor’ virtual calibration module for agricultural sprayers, continuous growth of the world population. Seen the resource
i.e., using an Arduino-based architecture, which uses an Atmel constraints and the need to globally feed 9 billion people in
Atmega 328 microcontroller, as well as the CAN protocol for 2050 foresights have argued that more food should be
communication and data analysis. A set of sensors is present in
produced but that at the same time production should become
agricultural spraying systems. They are used to control both the
quality of pesticides application and to ensure the reliability of more sustainable regarding people, planet and profit [2]. These
the sprayers’ processes. In such context, measurements such as calls are correlated and there are requests for more
temperature, flow, and pressure, among other variables, are investments, system innovation, and a better understanding in
important for the decision making processes. Besides, for such how should be the interaction between men and the machines.
tasks all the sensors must be calibrated, as well as be operating Considering production and sustainability, nowadays it is
properly. Such module for virtual calibration makes possible to necessary to produce more, without much advance in the
validate the calibration of these sensors in real time, and also agricultural frontiers. For this, it is necessary to ensure that the
allows emulating a direct operation on the sprayers, i.e., allowing agricultural field and crops are being adequately managed, i.e.,
to checkup if the sensor´s operational procedures are or not
performing the control and monitoring of processes and
correct. In this context, the organization of knowledge and the
establishment of an adequate computational semantics for a parameters in real time. The use of PA consists in the
correct operation of this module present a strategic role, so that application of technologies for the management of variables
users of the agricultural sector can appropriate the technology associated with agricultural production, considering as main
and use it appropriately. factor the increase of production and environmental quality.
Currently, agricultural spraying, for example, is used with
Keywords- semantic computers in agriculture; sensor
calibration; quality of agricultural application; Arduino; CAN bus, a focus on precision agriculture, where control, supervision
precision agriculture. and the highest quality of the application process are sought,
in order to increase the safety and efficiency of the application
I. INTRODUCTION processes. These aspects are also related with the
minimization of the environmental impacts, i.e., resulting from
In the last decades precision agriculture (PA) has been these agrochemical application processes. In such works,
increasingly used for food production and has gained which quantify the economicity of the localized application, it
relevance in the world. This has occurred with the use of is quite common to observe improvements in the relation
techniques for the control and supervision of machines that are cost/benefit, and the minimization of negative externalities
used in the field, as well as with the introduction of the [3]-[5].
analyzes of the quality of what is produced. These aspects can Variables such as temperature, flow and pressure have a
help and guarantee a better performance of plantations. direct influence on these results, impacting on the volume and
Lately the world's population has grown rapidly and there distribution of the drops in the plantation, which directly
are millions of people facing malnutrition. With roughly one influence on the efficiency of the application. If there is no
billion chronically hungry people in the world, 75% of whom control of the pesticide drops, waste may occur. Very fine
depend on agriculture for their livelihoods. Therefore, drops can be carried by the wind, spreading and contaminating
improving agricultural productivity at minimal cost to the the environment, characterizing the drift phenomenon. Very
environment is central to any efforts at poverty alleviation, thick droplets, although reduce the drift, provide less coverage
food security, and environmental improvement [1]. of the application target because the pesticide volume that
Agriculture is essential for the production of food and this leaves can hold is limited due to their size [6]. Therefore, it is

0-7695-6360-0/18/$31.00 ©2018 IEEE 352


DOI 10.1109/ICSC.2018.00072

Authorized licensed use limited to: University of the Phillippines Diliman. Downloaded on April 05,2022 at 04:17:37 UTC from IEEE Xplore. Restrictions apply.
important to know precisely the values of the variables of cRIO can be used to connect any sensor or device in any data
temperature, pressure and flow to have a greater control of the bus mode [9].
application of these agricultural products. B. Display System
For the automation of these sprayers` processes, embedded
computer systems are currently used. However, in this context, The results visualization system used with NI-cRIO is
it has been observed the growing needs for the organization of based on the LabVIEW® Real-Time software, which is a
semantic attributes that can help in the establishment of compiled graphical development environment that contains
mechanisms that involve better man-machine interaction, tools to acquire, analyze and present data. It also makes it
especially in agricultural environments where automation and possible to develop control and measurement systems,
embedded systems are used continuously. including integration with hardware.
Computational semantics is in charge of exploring the For building applications, it graphical programming
relationships between linguistics and computation, making it language uses icons and images instead of lines of text.
possible to construct systems capable of recognizing and LabVIEW® uses dataflow-based programming where this flow
producing information that can be understood by men. It is determines execution. The data is presented by an interface
also responsible for finding attributes that will allow greater called Graphical User Interface (GUI), where the user can
understanding of what is being analyzed by the machine, as interact with the digital devices by graphical elements with
well as the man who uses such devices. Semantic computing is icons and visual indicators, being able to select symbols and
a technology to compose information content (including manipulate them in order to obtain some pratical result. The
software) based on meaning and vocabulary shared by people GUI operating systems are easy to learn and use because
and computers and thereby to design and operate information commands do not need to be memorized [10].
systems [7].
This paper presents the development of a virtual calibration C. Controller Area Network Bus (CAN Bus)
module for temperature, pressure and flow sensors for spray
systems, using an Arduino with possibility of reading in CAN The CAN is a synchronous serial communication protocol.
protocol, and the results are presented in an interface by the Modules connected to a network send messages to the bus at
use of supervisory software. After this introduction, the paper known time intervals, so synchronization is done.
presents session 2, which demonstrates the materials and The CAN network has the characteristic of being multi-
methods used, followed by session 3 which presents a master, where the modules can act as masters and slaves
discussion on the results obtained, and session 4 with the depending on the use [11].
respective conclusions. This protocol works with multicast messages, where all
modules connected to a network receive all messages sent.
II. MATERIAL AND METHODS The connected modules check the status of the bus and
To design the development of the module for virtual analyze if another module with a higher priority is not sending
calibration of sensors in a spraying system, the use of an messages, if this is noticed, the module whose message has the
Arduino and CAN bus architecture is considered. lowest priority interrupts the transmission and allows the
For validation it is considered a development platform that highest priority message to be sent.
was developed at the Brazilian Agricultural Research CAN networks work with two wires with CAN (High) and
Corporation (Embrapa Instrumentation) in partnership with the CAN L (Low) signals. From these wires the modules receive
School of Engineering of São Carlos University of São Paulo the information according to the potential difference of the
(EESC-USP), both from Brazil [8]. wires. The data are represented by Dominant bits and
This platform for sprayers´development uses a National Recessive bits, created according to the conditions present in
Instruments® embedded controller, known as NI-cRIO. Also, the CAN H and CAN L wires.
it is considered a precison source and methods that allow the
evaluation of the signal-to-noise improvement. In addition, for D. Database and Reference Models
the purpose of evaluation of results are considered the
fundaments and theories of errors in sensor measurements. For the organization of a reference database with correct
Therefore, better descriptions are explained below. values, calibrated and high precision sensors are used, which
are subjected to known temperature, pressure or flow
A. Control and processing Unit (NI-cRIO) conditions to obtain voltage values related to these conditions.
It is also considered filtering and correction of outliers, leading
NI-cRIO is an embedded controller for advanced control to a model for the voltage and parameter under analysis. For
and monitoring application, have a real-time processor and an the realization of the filtering it is used, for example, a
FPGA. It offers multiple connectivity ports, is used in technique based on the use of Kalman filter [12-14].
applications that require high-speed signal control or This filter consists on the use of a mathematical method for
processing, hardware acceleration algorithms, reliable the purpose of using measurements of magnitudes performed
hardware tasks, or timing and triggering functions. The NI- over time and generates results that are closer to the actual
values of these measured quantities. The methods to obtain

353

Authorized licensed use limited to: University of the Phillippines Diliman. Downloaded on April 05,2022 at 04:17:37 UTC from IEEE Xplore. Restrictions apply.
and approximate the model may be linear regression with least
squares method, polynomial regression, among others.
D.1. Least Squares Method (5)
Thus this equation (5) must be derivated in parts from the
The Least Squares Method (LSM) is a technique that seeks terms that accompany xi and be equated to zero to find a
to find the mathematical representation that best adjusts a set system of equations, which makes it possible to calculate its
of data. It works trying to minimize the sum of the squares of values.
the differences between the estimated value and the observed
data. To use this method it is necessary that the model be E. Comparison Method
linear in the parameters, i.e., the variables must present a
linear relation. Therefore, must be analyzed the case where the After the construction of a corrected database and the
adjustment curve is a linear function: acquisition of a mathematical model obtained through some of
the forms mentioned earlier, the intelligent calibration and
(1) correction system can use this data as a reference to compare
where, (y) is the variable analyzed, (x) is the variable that the results obtained from the sensors that will be calibrated
influences the response of (y), (b) is the constant parameter, with the results of the models.
which does not depend on (x), (a) is the coefficient parameter Thus, using a comparison method, the system can identify
of the variable (x), the angular coefficient, ei is the error, whether or not a sensor is calibrated. Additionally, if
variation of (y) that is not explained by the model, and (i) necessary a calibration can be performed. The most used
indicates each of the (n) database` observations. The method methods of comparison are, relative change, Euclidean
of least squares helps to find the estimates of (a) and (b), this distance, root mean square error, percent error, among others
method uses a technique that minimizes the sum of the square [17]-[19].
of the error and with this (a) and (b) are discovered, besides it
will represent the graph with the smallest difference between E.1. Relative Change
(y) predicted and (y) analyzed [15]. Therefore:
Relative difference is used to compare two quantities while
taking into account the sizes of the things being compared.
The comparison is expressed as a ratio and is a unitless
(2) number. Its equation can be seen at (6):
The minimization occurs when derivate the equation (2)
with respect to (a) and (b) by using the chain rule and equating
to 0. Thus, one can obtain the equation (3) relative to the
angular coefficient. (6)
where, (x) is the measure variable, and (xref) is the reference
variable.
Notice that the divisor is in absolute expression because for
(3) values greater than the reference value, the relative change
where, ẋ represents the sample mean of x and ẏ represents the should be a positive number and for values that are smaller,
sample mean of y. the relative change should be negative.
D.2. Polynomial Regression E.2. Percent Error
The polynomial regression is a method to estimate the In this case the idea is similar to the one used for the
expected value of a variable (y), given the values of another calculation of relative change, but the result is given in
variable (x). This type of regression is used for models that percentage, so to obtain it, simply multiply the equation (6) by
obey polynomial and non-linear behavior as in the previous 100, and the result will be given in percent error.
case. For these types of model it is necessary to adjust for a
higher degree polynomial function [16]. This technique E.3. Euclidean Distance
follows the same steps of linear regression, but the polynomial
used for the adjustment is of degree greater than 1, i.e., In this case, it is the distance between two points and can
equation (4) is used. be proved by the application of the Pythagorean theorem. The
Euclidean distance is calculated as the square root of the sum
(4) of the squares of the arithmetic difference of the
In this case, the mathematical procedure is the same as in corresponding coordinates of two points, that is:
the least squares method, but the error will now be represented
by a function of degree greater than 1, thus obtaining equation
(5). (7)

354

Authorized licensed use limited to: University of the Phillippines Diliman. Downloaded on April 05,2022 at 04:17:37 UTC from IEEE Xplore. Restrictions apply.
where, d(x,y) is the Euclidean distance, (x) is the measured Besides, for signal processing from sensors is useful to use
point, (xref) is the measured variable at the reference point, (y) filters to improve the signal-to-noise ratio. In this work it is
is the variable at the measured point, and (yref) is the variable being considered the use of Kalman filtering to estimate of the
obtained at the reference point. real values of the quantities as well as the uncertainties
E.4. Root Mean Square Error (RMSE) associated with the measured values. These generated
estimates tend to be closer to the actual values because the
The RMSE is the standard deviation of the residuals weighted mean can be calculated between the calculated value
(prediction errors). Residuals are a measure of how far from and the measured value and with this a better estimation of the
the regression line data points are, RMSE is a measure of how uncertainties of the values is presented. The Kalman filter
spread out these residuals are. In other words, it tells you how contains three distinct steps for its operation, the first being the
concentrated the data is around the line of best fit. The RMSE Kalman gain calculation, the second the current state
is given by: calculation and the third the new estimation error calculation.
For the Kalman gain calculation, the error associated with the
estimated value and the error associated with the measurement
(8) must be considered, equation (9) shows the Kalman gain.
where, (xref) is the reference variable, and (x) is the measure
variable.
(9)
F. Accurate Power Supply where, (K) is the Kalman Gain, (errore) represents the estimate
error, and (errorm) represents the measurement error.
Since the module is going to be used to calibrate The closer the (K) value approaches 1, more accurate the
instruments it is necessary to take into account one power measurements are and the estimates are unstable. The closer
supply that generates a precise and high stability reference the (K) value approaches zero, the measurements will not
voltage. Such voltage will serve as parameters for the show good accuracy and estimates will be stable. The
intelligent calibration and correction system, and is also calculation of the current state is an estimation of the current
responsible for feeding each of the electronic devices used. value of the variable in the system, considering the previous
Most ADC/DAC converters internally have voltage state, the Kalman gain and the most current measurement,
references that are used in the process of converting the signal, equation (10) presents this calculation.
either to quantize its analog signal or convert its digital signal
to analog [20]. At this point, the accuracy and stability of the (10)
reference directly influence conversion performance. where, (statec) represents the estimate of the current state of
the system, (statep)represents the previous system estimate and
measurement is the most current measurement of the system.
III. RESULTS AND DISCUSSION
Currently the CAN networks have been used in embedded For the calculation of the new error in the estimate it is
applications in various air, water and land vehicles, including necessary to know the error of the previous state, these errors
farm machinery. The popularity of applications with CAN are related according to equation (3).
networks is sustained by their own characteristics and
advantages over other standards. The main advantages of (11)
CAN networks involve data communication, the use of only where, (errorc) represents the current error, and (errorp)
two wires, which reduces the cost and facilitates the physical represents the error of the previous state.
implementation, also, are able to transmit high rates of
information in real time, have good flexibility facilitating the The model is a mathematical representation obtained from
removal, addition, and change of devices, as well as being able the data history; this model was used for purposes of
to detect and treat failures that may occur. comparison and calibration of the sensors that are analyzed by
In agricultural spraying systems the most commonly used the intelligent system of calibration and correction.
sensors are:
a) temperature sensors, used to measure the temperature Fig. 1 shows the integration of the calibration modules
of the syrup (pesticides + water), as well as the temperature of with the sensors (temperature, pressure and flow) in the spray
the environment where the spray will be made; system.
b) pressure sensors, used to measure the pressure in the The modules receive an electrical signal from the sensors
spray bar near the spray nozzles; and determine whether or not the sensors are calibrated. The
c) flow sensors, which measure the flow in the tubes and calibration module performs the necessary correction to
in the spray bar, and are used to measure and feed back these deliver the appropriate information to a CAN bus, where the
values in the control system. control and processing unit collects the sensor calibration
information of all modules.

355

Authorized licensed use limited to: University of the Phillippines Diliman. Downloaded on April 05,2022 at 04:17:37 UTC from IEEE Xplore. Restrictions apply.
Microcontrollers, computers and circuits that process data or pressure, or flow, then this value is compared with the
obtained from sensors operate exclusively with digital signals, reference model, which was constructed using the database
and sensors generate signals of analog nature. To convert a and some of the mathematical methods described in section II
signal from the analog form to the digital form, a of this paper. If the result of the comparison is satisfactory this
configuration called analog/digital converter, ADC or simply value is sent to the CAN bus, otherwise this value is corrected
A/D converter was used. These converters are widely used in by the software through emulation and only then the value is
data acquisition and control boards that connect computers sent to the bus.
with measurement devices.

Figure 2. Software and hardware integration architecture as the basis for the
construction of a calibration module for sensors in an
agricultural spray system.

Figure 1. Block diagram of the electro-hydraulic configuration and CAN


network of the sprayer system. In the orange blocks are highlighted the
calibration modules for each variable or sensor.
.
The module that has the Arduino platform is a device of
low cost, is functional and easy programming. The Arduino
Uno is a board consisting of an ATMEL ATMEG328
microcontroller, input and output circuits, and can be easily
connected to a computer via USB cable and is programmed
through a free software called Arduino IDE (Integrated
Development Environment) using a language based on C/C++.
In Fig. 2 is possible to observe how the Arduino module is
connected with the sensors and the agricultural spraying
system. The sensors, which generate analog signals, are
connected directly to the calibration module, which is in
charge of analyzing and correcting the data obtained through
the algorithms. Then, the data is sent to the CAN network
which use the control and processing unit for presenting the
information with the calibrated values by an industrial
supervision software.
Fig. 3 shows a flowchart of the algorithm, i.e.,
implemented for intelligent calibration and correction. As can
Figure 3. Flowchart of the operation of the calibration and
be observed, when the algorithm starts it receives the values of correction algorithm.
the sensor with the parameter to be analyzed, or temperature,

356

Authorized licensed use limited to: University of the Phillippines Diliman. Downloaded on April 05,2022 at 04:17:37 UTC from IEEE Xplore. Restrictions apply.
For the calibration module it is possible to observe that an [3] F. J. Pierce and P. Nowak, “Aspects of precision agriculture, ” XVIII
Reunião Brasileira de Manejo e Conservação do Solo e da Água, Adv.
approach that addresses the problem considering the aspects of Agronomy, v. 67, p. 1-85, 1999.
computational semantics is of great value. This proved to be
relevant for a better match occurred in the inter-connection [4] L. S. Shiratsuchi, P. J. Chistoffoleti and J. R. A. Fontes, “Aplicação
Localizada de Herbicidas, ” 18p. -Documentos/Embrapa Cerrados, ISSN
design of the sensors with the Arduino, Arduino with the CAN 1517-5111; 91, Planaltina, DF: Embrapa Cerrados, 2003.
bus and mainly in the establishment of man-machine interface.
[5] U. R. Antuniassi, “Agricultura de Precisão: aplicação localizada de
This interaction was conceived considering supervisory herbicidas, ” Congresso Brasileiro da Ciência das Plantas Daninhas, 22,
software that is performed in a simple and direct way, since Foz do Iguaçu, PR. Londrina: SBCPD, 2000. p. 25-43.
often the user of the module is not familiar with the computer [6] H. V. Mercaldi, E. A. G. Peñaloza, R. A. Mariano, V. A. Oliveira and P.
language and the module is designed to be used in agricultural E. Cruvinel, “Flow and Pressure Regulation for Agricultural Sprayers
applications. This environment is generally rustic. Appropriate Using Solenoid Valves,” IFAC (International Federation of Automatic
Control) Hosting by Elsevier Ltd, São Carlos, SP, 2017.
semantics were considered primarily for the end users to have
a better understand and have access to the module using it [7] L. Wang and S. Yu, “Semantic Computing and Language Knowledge
Bases,” IOP Conference Series: Materials Science and Engineering,
correctly and thus popularizing the use of this technology. Volume 242, Conference 1, IOP Publishing Ltd. Institute of
Computational Linguistics at Peking University, 2009.

IV. CONCLUSION [8] P. E. Cruvinel, V. A. Oliveira, H. V. Mercaldi, E. A. G. Penaloza and K.


R. Felizardo, “An advanced sensors-based platform for the development
This work presented the design of an intelligent module for of agricultural sprayers,” In: Sergey Y. Yurish (Ed.). Sensors and
calibration and correction of sensors that are used in Applications in Measuring and Automation Control Systems. [S. l.]:
IFSA, pp. 181-204. (Advances in Sensors: Reviews; v. 4), 2016.
agricultural spraying systems. This module can infers
decisions from the use of a reliable database that is constructed [9] M. Rosol, A. Pilat, and A. Turnau, “Real time controller design based on
NI Compact-RIO,” Proceedings of the International Multiconference on
from a priori measurements obtained with temperature Computer Science and Information Technology, pp. 825–830, Oct. 2010.
sensors, bar pressure in the booms that containing the spray
[10] Computer Hope, “What is GUI?,” Available at
nozzles, and flow measurements that are obtained using <https://www.computerhope.com/jargon/g/gui.htm>. Accessed:
flowmeters (internal measurements) and special containers 11/29/2017.
(external measurements at nozzle outlet) used for this purpose. [11] L. B. Fredriksson, “Controller Area Networks and the protocol CAN for
Also, the use of Kalman filtering was considered for the machine control systems,” Mechatronics, v.4 n.2, p.159-92, 1994.
improvement of the signal-to-noise ratio for the signal [12] R. E. Kalman, “A new approach to Linear Filtering and Prediction
processing steps. In addition, it was considered an adequate Problems,” Transaction of the ASME - Journal of basic Engineering,
interconnection arrangement of this intelligent module in 1960.
points near the sensors of a sprayer system, which is very [13] M. A. M. Laia, A. L. M. Levada, L. C. Botega, P. E. Cruvinel, M. F. L.
significant and should be considered adaptively to the different Pereira and A. Macedo, “A Novel Model for Combining Projection and
types of sprayers that are used by farmers during the Image Filtering Using Kalman and Discrete Wavelet Transform in
Computerized Tomography,” 11th IEEE International Conference on
processess of food production. Besides for working in a Computational Science and Engineering. v. 11. p. 219-226. São Paulo,
security range it can allows support for decision making with a 2008.
greater degree of certainty. Additionally, the use of an [14] M. A. M. Laia and P. E. Cruvinel, “An Application Approach to Kalman
Arduino platform was adequate and in accordance with the Filter and CT Scanners for Soil Science,” Principles, Application and
characteristics required for the elaboration of this project, i.e., Assessment in Soil Science, Dr. Burcu E. Ozkaraova Gungor (Ed.),
ISBN: 978-953-307-740-6, InTech, 2011.
for presenting a friendly interface for the adequacy of a
computational semantics that assists in the men-machine [15] T. P. Goodman, “A Least-Squares Method of Computing Balance
Corrections,” ASME Transactions, Journal of Engineering for Industry,
relationship. This platform made it possible to configure a 273-277, August 1964.
calibration supervision algorithm for the sensors that can
[16] J. R. Edwards, “Polynomial regression and response surface
provide measurements of these three considered variables, as methodology,” In C. Ostroff & T. A. Judge (Eds.), Perspectives on
well as the communication based on the use of a CAN bus, organizational fit, pp. 361–372. San Francisco: Jossey-Bass, 2007.
which presented advantages in comparison of other [17] L. Tornqvist, P. Vartia and Y. Vartia, “How should relative changes be
commercial available architectures. measured?” The American Statistician 39 (1), 43–46, 1985.

ACKNOWLEDGMENT [18] P. E. Danielsson, “Euclidean distance mapping,” Computer Graphics


Image Processing, vol. 14, pp. 227-248, 1980.
This work was supported by Embrapa Instrumentation
[19] T. Chai and R. R. Draxler, “Root mean square error (RMSE) or mean
(under grant MP1 No. 01.14.09.0.01.05.05). absolute error (MAE)? - arguments against avoiding RMSE in the
literature,” Geoscience Model Development 7. 1247–1250, 2014.
REFERENCES
[20] R. H. Walden, “Analog-to-digital converter survey and analysis,” IEEE
[1] S. L. Naylor and W. P. Falcon, “Food Security in an Era of Economic J. Sel. Areas Commun., vol. 17, no. 4, pp. 539–550, Apr. 1999.
Volatility,” Population and development review, vol. 36, issue 4,
December, pp. 693–723, 2010.
[2] “Agricultural Knowledge and Innovation Systems in Transition – a
reflection paper,” SCAR-Collaborative Working Group AKIS 117 pp.,
fig., tab., app, March, 2012.

357

Authorized licensed use limited to: University of the Phillippines Diliman. Downloaded on April 05,2022 at 04:17:37 UTC from IEEE Xplore. Restrictions apply.

You might also like