Real-Time Embedded Control System for a Portable Meteorological Station ( Sistema de Control Embebido en Tiempo Real para una Estación Meteorológica Portátil )

The aim of this work is to design and code an embedded system for a portable automatic weather station. The portable station includes high performance sensors to measure parameters such as: i) wind speed and direction, micro perturbations and wind gusts, ii) air temperature, iii) solar radiation, iv) relative humidity, and v) atmospheric pressure. The main contribution of this work is the development of an embedded control system operating in real time. This system is based on a Field Programmable Gate Array (FPGA) device. The method developed guarantees high-resolution data acquisition of a number of samples in real time. The samples obtained are grouped and stored in a database, which will be used as a starting point for further analysis.


Introduction
Ecuador faces the lack of high quality meteorological data due to the outdated equipment and obsolete methods for data analysis.In order to solve this problem, the National Institute of Meteorology and Hydrology (INAMHI) is implementing a campaign for replacing conventional weather stations with new equipment; however, the replacement cannot be completed in a short period of time covering the whole country.It is also imperative to include data transmission devices in most of the new stations, to have a faster access to collected data and to analyze data through new control methods.
According to INAMHI (INAMHI, 2014), the national network of weather stations counts with 519 meteorological stations in Ecuador, of which 41% use pluviometers, a 29% of the stations are employed for climatology, and a merely 2% are used for agro meteorological research (13 stations).It is important to emphasize that an important public network of automatic meteorological stations exists at the south of the country, in the provinces of Loja, El Oro and Zamora Chinchipe.
Unfortunately most of these stations are out of service, in technical obsolescence state, or they are insufficient for satisfying the country needs.
According to Popa (2011) there are a variety of solutions for climate monitoring.The classic solution consists of static meteorological stations that collect data and later to submit data by wired systems to a main station.The problem with this approach is that it needs constant maintenance and supervision.Another solution is based on a network of wireless sensors that are placed in the desired zone.These devices collect all the weather information and then transmit it to the main base.
The most common way of monitoring meteorological variables is through the use of Automatic Weather Stations (AWS) (Abbate, Avvenuti, Carturan, & Cesarini, 2013), which can be used as main platform for wireless sensors networks.With the improvement of research and development in automatic static meteorological stations, manual stations are gradually transforming into manual and automatic stations that can be operated easily (Jian-Ming Li, 2010). Zhen Fang (2010) proposed a practical and economical solution that consists of a micro station that is portable, has a small size, and brings several other benefits.
The system presented in this paper is based on Field Programmable Gate Array (FPGA) devices, which allow programing based on logical blocks.These elements permit high-level parallel processing and analysis of different meteorological parameters.A 16-bit analog input/output central processing unit (CPU) was used for that purpose.The control program, that includes filtering and signal scaling through FPGA devices, was developed in LabVIEW.This method guarantees high-resolution and a big number of samples on the data acquisition in real time.These samples are grouped and stored in a database, which is used as a starting point for further analysis according to the methodology which will be established in the Section 3.1.This paper presents in Section 2 basic definitions on FPGAs and real-time control.Section 3 provides technical details of the proposed solution.In Section 4, preliminary results and implementation aspects are covered.Finally, the article concludes with future work.

Methodology
Embedded systems use automation specific functions based on programmable CPUs.The programming of these systems can be done with different development tools.This section provides the basis of these tools.

Field programmable gate array
A Field Programmable Gate Array (FPGA) consists of a combinational array of interconnected logic gates that can be configured after manufacturing hence field programmable.The FPGA configuration is generally specified using a hardware description language (HDL), similar to that used for an application-specific integrated circuit (ASIC).The digitally generated program reorders physically the logic gates to obtain the required configuration once its compile.
The gates are connected to Look Up Tables (LUT) which are used to save processing time.Jointly with the shift register and multiplexors, specialized high performance circuits can be developed, heavily depending of the amount of combinational gates contained in the FPGA cells.
The current development of FPGAs technology focuses on the implementation of dedicated functions such as: RAM memory management, signal processing blocks of high performance, high speed memory interface, and logical blocks with arithmetic and control specific functions.

Real time control systems
The development of real-time systems allows to handling big amounts of data at high speed for information processing, and for improving the system response, either in control and problem solving (Giannone et al., 2011).The real time processor provides determinism in the sense that the system is enabled to determine or predict with precision whether the program blocks are executed, obtaining as a result a dedicated system for specific applications (Salzmann, Gillet, & Huguenin, 2000).
The LabVIEW real time (RT) processors use a FPGA to perform the data acquisition.These RT processors are able to use all their resources in data treatment.This is possible since each FPGA data input is configured to create First in First out (FIFO) data storage buffer which are transmitted to the processor's memory, and processed (Zheng, Liu, Zhang, Zhuang, & Yuan, 2014).Figure 1 shows a simplified embedded system diagram for data acquisition using FPGA and RT.

Embedded control system operating in real time
The block diagram shown in Figure 2 represents the internal operation of the control system, data acquisition and data base storage.It also describes the interrelationships between the memory blocks and the data buses.An embedded system that works with low energy consumption is created to ensure continuous operation and no human supervision.
The hardware configuration is mainly conformed by an embedded system based in two technologies: i) Field Programmable Gate Arrays (FPGA) for high speed data acquisition, and ii) real time processing (RT) for data administration.
The data acquisition is done through one analogic module and one digital module, and each module performs the analog-digital conversion required by the FPGA.Through a Peripheral Component Interconnect (PCI) data bus, the FPGA communicates with the real time processor (RT).This acquires the data from the FIFO and converts them into a double data type format achieving the format needed to perform logical operations.Wind ultrasonic sensor connects to RT using RS-232 protocol, and the sampling is made every second.

Software Functional Description
The software design is also divided into two main parts: i) FPGA, and ii) real time processor.In the case of the FPGA, an analogical channel configuration was performed to set their voltage levels and measurement type.
In order to start the data acquisition at different voltage levels, digital low-pass filters Butterworth were created with a cutoff frequency of 400 mHz.This action eliminates noise from temperature sensor, avoiding the use of physical analogical filters (reducing energy consumption) and improving uncertainty in signal measurements.
The signal processing filter applied to the control system is fitted with the Butterworth polynomials.
In this work the four degree of Butterworth showed in Equation 1 is proposed (Paarmann, 2001).
where H(s) is the cutoff amplitude in decibels (dB) and (s) is the cutoff frequency (Hz).
This model achieves high speed and precision for the acquisition and transmission of suspicious values.
The signals of radiation, humidity, and pressure sensors are fitted based on the signal processing filter.Data collection of each element is made through a direct access to memory (DMA).The FIFO data storage is used to communicate FPGA and RT.This represents an increment on speed data transmission due to the FPGA memory use and the RAM memory of the RT host.
Similarly, a specialized data acquisition and signal filtering over the FPGA processor is developed (Cantó Navarro, 2010).
The wind data signal obtained through the ultrasonic anemometer is sent to the controller through the RS-232 serial protocol to then choose the important information using logic digital gates.In order to implement an edge detector, the signals are processed using digital converters and a state machine to restart the pulse counter value to zero every ten minutes.
Finally, the stored arrangements are sent to an iterative loop to perform averages every ten minutes of each meteorological variable recorded by the station.The data is printed out in a plain text format that corresponds to the database which stores in the non-volatile memory of the device.

Results and Discussion
In order to test the real time and FPGA based control system, a portable meteorological station shown in Figure 3 was used.A portable meteorological station should have capacity to keep up to seven different sensors (Barrenetxea et al., 2008) as in this case.All the sensors are located on a 10-meter mast as recommended by the general standards and practices from the World Meteorology Organization.

Figure 3. Portable meteorological station
The power supply is composed of a voltage regulator with 1V, 5V and 12V taps and a 50W photovoltaic cell to power the entire system.The solar cell supplies 2.79A at 17.9V to a sealed 12V and 34A rechargeable battery.
The control system implementation was performed in a cRIO 9068 CPU which includes a Field Programmable Gate Array (FPGA) for data acquisition and a real-time processor (RT) in its own architecture.The control algorithms were developed using the LabVIEW platform, a graphical environment that use G programing (Chouder, Silvestre, Taghezouit, & Karatepe, 2013).
Figure 4 shows the recorded values of the sensors installed on the portable system.The stored data corresponds to the period from July 4th to July 11th, 2014 at a temporal resolution of ten minutes.Table 1 shows the daily average of each parameter analyzed using the proposed approach.The advantages of using this approach over traditional technologies are: scalability, precision, data acquisition speed, application-oriented configuration, portability, robustness, energy supply autonomy, and parallel programing.A deeper evaluation of our approach is currently in process.

Conclusions and Future Work
In this work, the programming development of a portable automatic weather station with capabilities to measure meteorological variables was presented.The design included a sustainable solution which is based on a photovoltaic system to ensure continuous operation and protection against failures due to lack of energy and unexpected reboots.
In order to validate the results obtained from the proposed weather automatic station, the portable system will be installed at the Villonaco wind farm in Ecuador where a fixed weather station is installed.In the near future, the portable weather station will be connected to Internet in order to broadcast the obtained information.Also an exhaustive analysis is planned using some data mining techniques.

Figure 1 .Figure 2 .
Figure 1.Embedded system for data acquisition with FPGA and RT

Figure 4 .
Figure 4. Plots of the collected data sample: Up) Pressure, global radiation, diffuse radiation, and wind direction.Down) T0-T4 Temperature, Humidity, Pluvial precipitation and Wind speed.