Data acquisition system based on transducers with Modbus communication

. In this paper we propose an application written in LabVIEW through which a number of transducers or sensors are controlled so that the data from them are taken according to a certain algorithm and also this application realize the data processing. Control consists in selection for each of these transducers, their inputs selection and retrieves information from them. The physical connection between used transducers and master is made through RS - 485 bus and the transmission protocol used is Modbus RTU.


Introduction
It is known that a data acquisition system can be defined as a measurement system that allows both visualization and recording of the evolution over time of several analog or numerical quantities. The traditional operator's control function has been replaced by instruments and sensors that give very accurate measurements and indications, making the control function totally operator-independent. The processes can be fully automated. Instrumentation and sensors are an integral part of process control, and the quality of process control is only as good as its measurement system [1]. The instrumentation and sensors send the collected data, representing the controlled quantities' values through electrical signals. The current practice involves their digital transmission, that's means the transfer of binary codes to the equipment that allows the visualization or processing of this acquired data. Here are many solutions both in terms of the hardware configuration of the data transmission structure and software solutions for their implementation. One of these possibilities is to use the RS-485 serial transmission bus together with the Communication Modus protocol [2]. The advantages of using the RS-485 bus and the Modbus protocol in distributed control systems are well known. Sensor reading, which provides a user with digital data in accordance with the Modbus RTU protocol, is not a technical problem and various technical solutions are known in this area [3]. In the context of current developments regarding the concept of Internet of Things, Modbus communication protocols can be a reference point as a potential for the extension of sensor networks [4]. Thus, gateway units can be developed, specific to dedicated IoT protocols, especially for the Modbus communication protocol [5]. At the moment, solutions are being sought for the adaptation and reliability of this protocol in order to be used especially in applications for monitoring electricity consumption using smart meters, as shown in the paper [6].
The purpose of this paper is to present a solution that allows the acquisition of data through a Modbus communication protocol and thus complete the solutions known in this field, by the fact that data collection is done automatically according to a specific algorithm. This algorithm aims to obtain functional characteristics of the input-output type based on predefined values of input sizes. Thus, automatic measurements are performed and graphs of the evolution of the quantities subjected to observation under predetermined conditions are provided to the user. The algorithm is validated by means of a laboratory stand in which various transducers are used for various physical quantities connectable on the RS-485 bus with data transfer via Modbus RTU protocol.

Hardware structure
The used sensors are a family of environment sensors with an RS-485 interface and these communicate using standard Modbus RTU protocol. We used the Tibbo four types of sensors: the ambient temperature sensor (BP#01), ambient temperature and humidity sensor (BP#02), ambient light sensor (BP#03), and 3-axis accelerometer (BP#04). All of these are typically wired to a twisted pair cable, which distributes power and carries RS485 "+" and "-" lines and sensors accept the supply voltage in the 4V to 15V range.
Each of the 4 sensors used in the acquisition system is made using the measurement integrated circuits specific to the controlled quantities. The structure circuits of the sensors used, as well as their main measurement parameters [7], are presented in the table 1: 0.1G Figure 1 shows the sensor capsule, with the specification that it is common to all 4 types of sensors used. The RS-485 applications use data communication over twisted-pair cable because the noise from external sources couple equally into both signal lines as common-mode noise, which is rejected by the differential receiver input.
Using only one signal pair means half-duplex communication mode and that implies the data driving and receiving to occur at different times and necessitate the controlled operation of all nodes via direction control signals, such as Transmitter/Receiver Enable signals. RS-485 standard conforms transmitters provide a differential output of a minimum 1.5 V across a 54-Ω load, whereas standard conform receivers detect a differential input down to 200 mV. The two values provide a sufficient margin for a reliable data transmission even under severe signal degradation across the cable and connectors. This robustness is the main reason why RS-485 is well suited for long-distance networking in a noisy environment.
Based on these considerations is build the experiment configuration with the sensors connected to the RS-485 bus and this configuration is shown in figure 2. Because the sensors, which represent the slave devices, communicate with a master device or equipment through RS-485 serial bus and when the master device is a PC or laptop, they should have a compatible port for connection to this serial bus. The current and usual PC or laptop communication port is the USB port and in these cases for connecting the sensors is required a USB to RS-485 adapter. In developing this application is used the UT-850 converter (a Data Communications product), which ensures a data transfer rate of up to 921.6 Kbps. This RS-485/422 to USB converter adds a virtual serial port on a desktop or laptop so that the outputs are automatically configured as additional COM ports.
Parameters of the data communication through RS-485 bus are [8]:  Half-duplex (two-wire) RS-485 interface  Communications parameters: 38400-8-N-1  Modbus RTU protocol  Sensors powered via the USB port and RS-485 adapter

Software presentation
The software used to control the data acquisition from the sensors and also the data processing that we propose in this paper is built in the LabVIEW graphical programming environment and like all applications builds in LabVIEW is named virtual instrument. A virtual instrument has three components, i.e., a front panel that is the user interface, a block diagram that is the proper program and icon used in the hierarchical structure of the virtual instrument. The virtual instrument build for this application consists of the main program and a number of subprograms, called SubVI used to simplify the diagram block configuration. This programming environment was chosen due to its ease of use, the multitude of functions and libraries available and even due to the fact that in the current context of the development of IoT technologies there are more and more implementations of specific IoT programs in LabVIEW [9]. Also, this programming environment is widely used in terms of creating hardware and software platforms that allow the development of online laboratories both in the IoT context and especially in the current pandemic context.

Front panel
The front panel consists of three components through which the user can interact with the virtual instrument. a. The first component is dedicated to the necessary settings for communication with the sensors on the bus via the Modbus protocol. The parameters are set according to the previous specifications [8]. b. The second component is used for the selection of one of the two working modes, namely: manual query (acquisition), figure 3, or automatic query (acquisition), figure 4. For the manual query, the user has a TAB control to choose the sensor to be read (BP # 01 ... BP # 04). For the automatic query, all the 4 sensors will be interrogated cyclically, thus 7 values of the measured quantities will be displayed simultaneously: temperature from the BP # 01 sensor, temperature and humidity from the BP # 02 sensor, light intensity from the BP # 03 sensor, as well as the movements along the X, Y and Z axes from the BP # 04 sensor (Giro).

Block diagram
The block diagram represents the program itself and is built with operations, functions, and programming structures from LabVIEW libraries.
The main programming structure in making the virtual instrument is a WHILE loop that makes the program work until the user presses the STOP button. While running the program, the user can always switch between the two operating modes of the virtual instrument, namely, Manual Acquisition mode or Cyclic Acquisition mode.
Switching between the two working modes is performed by means of a Case structure controlled with TAB Control.
For the Manual Acquisition mode, the user has another tab control, Select Device, with which he can select any of the four sensors on the bus. The selection is made by the ID of each sensor and to read the information available to it is chosen is used the list of Modbus registers for each sensor [10]. Based on the two identifiers, subVIs are made for each of the 4 sensors using Modbus functions from the NI Modbus library, as shown in figure 5.

Registers reading
The measured values are thus taken over and transmitted to Chart type indicators to represent their evolution over time. Each graphical indicator is activated with the selection of the respective sensor and for this their Property type nodes are used with the choice of the Visible property. The block diagram of the virtual instrument for the operation corresponding to the Manual Acquisition mode is presented in figure 6.  The selection of each sensor is made by using the iteration variable of this structure which also controls a CASE structure by connecting that to the Case selector. Thus, in each cycle, the iteration variable is incremented and, by default, the next sensor is selected. This selection procedure is resumed after each reading package of all sensors.
The iterative reading of each sensor is done by calling the same SubVI used in the manual acquisition mode.
Because the values read on the bus correspond to a single sensor at a time, all other sensors send the value 0 at that time, in order to retain all the values, read in a cycle of the FOR loop, a displacement register associated with this FOR structure is used.
The values read from each sensor are taken through local variables and converted from numeric format to string format via the Number to Fractional String Function. These functions convert a number to an F-format (fractional notation), floating-point string at least width characters wide or wider if necessary.
The strings representing the read values are added with the information about the time (date and time) of their acquisition obtained with the Gate Date/Time in Seconds function and all are grouped in an array using the Build Array function.
Each new data packet is inserted into the array containing data from previous acquisitions, retrieved through the Shift Register, using the Insert into Array Function. All these data are sequentially displayed in Table. Although it has imposed constraints since its inception more than 40 years ago, related to the speed of data transmission, the maximum number of devices that can be interconnected and possible problems caused by potential sources of interference, the Modbus protocol is widely used, especially in energy consumption monitoring applications and as seen in the present case and in terms of managing a network of sensors [11]. Even though there is more and more talk these days about wireless sensor networks (WSN) [12], wired sensor networks have not yet reached their maximum potential and are still widely used, especially in environments where it is not possible to provide good protection against any type of interference [13]. Thus, we will always try to find the simplest and most reliable solutions to improve technologies that allow the acquisition of various data from different sensors to achieve high-performance monitoring systems, especially in the context of new IoT technologies [14,15].

Conclusions
This paper presents its own contribution related to the Modbus communication protocol and its use in a network of sensors. Thus, through its own algorithm implemented in LabVIEW, a manual and automatic reading of 4 types of sensors was achieved (temperature sensor, temperature and humidity sensor, light sensor and accelerometer). In the manual operation mode of the program, it allows the user to select the type of sensor from which he wants to take the data so that later they can be processed and displayed as a graph. In the automatic reading mode, an automatic reading of all the sensors is performed and the results are displayed in the form of graphs specific to each sensor. Thus, an overview can be made of some important physical parameters in a certain area proposed to implement such a monitoring system using a network of sensors that use the Modbus communication protocol. The hardware structure can be expanded to 255 sensors with the appropriate settings for their identifiers. The length of the bus, according to RS485 specifications, can be extended up to 1200 meters, which ensures a relatively large coverage area. Any addition of sensors in the structure implies a minimal intervention in the program regarding only the number of sensors that will be read either manually or cyclically. The entire system of acquisition, processing and display of results implemented and presented in this paper has a special reliability being tested both in the laboratories of the University of Petrosani and in external environmental conditions and has proven its effectiveness and accuracy. The major advantage of this system