Design of Automatic Meteorological Data Acquisition System Based on ARM and CAN Bus
Jvfang Jin1
Department of Electrical Engineering Chengdu University of Information Technology Chengdu, China [email protected]
AbstractAimed at the current situation that the domestic automatic meteorological data acquisition system is almost based the use of foreign products, a design method of multi-channel meteorological data acquisition system was given which based on ARM and CAN Bus. In the design, it fulfills the acquisition requirements of the analog signals, digital signals and intelligent sensor data through a combination of hardware and software technologies. In order to improve systems real-time answering capability and multi-task processing capability, it is used main collector + external bus + sub-collector + sensors + peripheral equipment in structure design of hardware. At the same time, it is transplanted Linux operating system to improve the reliability and scalability of system. It is translated Linux operating system to embedded processor, and making use of Internet to send meteorological data in Linux operating system. Then the complicated cabling project could be omitted, the data were sent without PC, and in favor of constituting Large-scale meteorological monitoring network. (Abstract) KeywordsData acquisition; Embedded Linux; CAN bus; Driver(key words)
Baoqiang Wang2
Department of Electrical Engineering Chengdu University of Information Technology Chengdu, China [email protected] expansion, improving the timeliness and accuracy of the meteorological observation, and achieving the commands of automatic meteorological observation. II. SYSTEM DESIGN
As shown in Fig.1, the design of the automated meteorological data acquisition system is based on the embedded Linux and the CAN bus.
I.
INTRODUCTION
Figure.1 Automatic Meteorological Data Acquisition System
Nowadays meteorology has been closely related to the human civil and industrial activities. Meteorological detection plays an important role in defense, social and economic development. With the gradual implement of national sustainable development strategies, meteorology detection is more and more important for us. Meanwhile, there are everincreasing demands for meteorological observations. The traditional design pattern of meteorological data acquisition system was based on the single-chip microcomputer. In this situation, there are many problem including system precision, real-time analysis capabilities, the man-machine interface and so on.Computing power, storage capacity and the amount of information were limited by this technica. In the same time, both the distance of data transmission and the use of data acquisition module with PC or notebook computer cost too much money and time. Compared with the situations above, the pattern of using embedded LINUX system assumes a higher real-time and stability in meteorological data acquisition, meanwhile the hardware smaller, power consumption lower and expansibility better. The Linux operating system supports the TCP / IP protocol, so it can transmit data directly without PC. This pattern also has many other advantages, such as speeding up the development of the system, facilitating the works of the future
978-0-7695-3962-1/10 $26.00 2010 IEEE DOI 10.1109/ICMTMA.2010.598 989
Embedded Linux is a kind of small operating system, which is composed by a cut-off core (kernel) and several modules that depended on the needs. Its characteristics are as follows, micro-kernel of only several hundred KB; supporting X86 and more than 30 kinds of 8bit ~ 64 bit of the MPU and MCU, supporting a variety of ROM memory; the features of multi-tasking, multi-process and a certain degree of real-time; supporting completed communications network; supporting TCP / IP protocol and other common agreement; supporting self-developed agreement; a graphical user interface (GUI); supporting network, database and multimedia and communicating data by the network and processing data in real time; source opened which can be cut according to specific needs; a series of development tools;a good property of software open and the program on the Linux host can be transplanted to embedded Linux system freely, a strong technical support and so on. CAN (controller area network) field bus is a kind of serial multi-master communication network. CAN is not only a network, but also a kind of protocol. Its main features are as follows, the pattern based on the CSMA / CD-CR model, the use of non-destructive arbitration mechanism, short-frame data structure; the CRC data check function, the data transmission
based on the differential approach, queue priority according to message ID, the system well expansibility, anti-interference ability and reliability. The automatic meteorological data acquisition system which is based on the multi-tasking, real-time embedded Linux OS and the CAN network constitutes a building-block structure, facilitating future updates or changes. A. System Hardware Design As shown in Fig.1 above, automatic meteorological data acquisition systems hardware consists of main collector, subcollector, sensors and peripheral equipment (including power supply, [terminal] computer, communications interface and external memory). The main collector and sub-collector microprocessor adopt an ATMEL chip AT91SAM9263 which based on the ARM926EJ-S processor. Its frequency is up to 200MHz and it has a CAN bus controller integrated in chip. Sub-collector is hang on to the main collector through CAN bus. In order to achieve the minimum allocation of automatic meteorological data acquisition system, the main collector is joined only several basic meteorological elements sensors, taking charge of the collection of the basic meteorological data (Its structure is shown in Fig.2).
Figure.3 Sub-collector Structure of Automatic Meteorological Data Acquisition System
When the system is needed of being expanded or increasing element sensors as the change of environment or technology progress, we have no need to change the connection of the existing sensors and wiring. We just need to add new subcollector and /or sensors to the system and conduct simple software upgrade or configuration. B. System Software Design System software includes embedded operating system and application software. We have chosen a high real-time, costeffective, stable and multi-tasking operating systemLINUX OS as the platform of the system software design according to the needs of the design. 1) Construction of Embedded Linux System The system software is mainly built in the main collector, including three elements at least: bootstrap program, Linux micro-kernel and initialization process. In addition, there are several functions needed to be expanded, such as, the achievement of the agreement to CAN master, the achievement to jffs2 file system in the internal memory and external memory card, the basic collection, processing, storage and internet transmission of the data, the establishment of the Web server and remote parameter settings, data monitoring, the loading of data files and the main collector reset. Sub-collector software is needed to achieve the agreement to CAN slave, scans its articulated sensor according to the predetermined sampling frequency and converts the electric signal obtained into a readable microcontroller signal, gains the sequence of measurements of meteorological variables, converts the measurements of meteorological variables , changes the sensor output signal into meteorological units, gets the instantaneous sampling values, and sampling values will be sent to the CAN bus according to CAN agreement. 2) Reduction and Compilation of the Kernel Micro-computer's storage space is small, while the standard Linux is a PC OS, which needs to reduce the Linux kernel. It can only retain some modules that the embedded system needs and must remove some useless modules when compiling the kernel. In order to satisfy a certain degree of real-time requirements, it should shield the kernels virtual memory management mechanisms. There are two ways to launching
Figure.2 Main collector structure of automatic meteorological Data Acquisition System
In addition, the main collector is in charge of collecting, controlling, processing, storing, transmitting all kinds of meteorological factors data and fulfilling the function that configures and manages the sub-collector. The sub-collector is composed of hardware and embedded software. In order to simplify the design trouble of the system, sub-collector microprocessor also adopts the same chip AT91SAM9263.It is mainly responsible for collecting corresponding meteorological data. At the same time, it is also responsible for scanning its articulated sensor according to the predetermined sampling frequency in the working condition and sending the sampling data to the main collector after receiving the synchronization signal which is sent by the main collector. Its structure is shown in Fig.3,
990
Linux, one is that drivers were directly compiled into the kernel; the other is that drivers were loaded at runtime (that is, kernel module). The advantages of the former are that users can call them at any time without installing them, but it largely costs storage space. The latter is that drivers were prepared in the form of module, and they will be loaded into kernel when needed. Maybe it would increase the occupation of system resources and running time, but it is negligible compared to the huge consumption of kernel resources. Meanwhile, this way can provide many conveniences for the software development. When the users need to modify a hardware driver or correct their errors, they can dynamically unload the old version and load the new version; but if the driver has been wrote into the kernel, the users must recompile the kernel and restart the system when testing procedures after each revise. Therefore, the system is chosen the second approach to start the kernel. 3) Device Drivers Operating system is responsible for managing software and hardware of the system. Device drivers play the role as a bridge between the hardware and user application program. They make the application program have nothing to do with the underlying hardware through interface function provided by them. For the system, we need to prepare drives for I/O port, serial and CAN controller. There are three types of equipment in Linux system, Character Devices, Block Devices and Network Equipment. Character devices can only be read and write data sequentially, and provide byte-stream operation to the external. Block devices can be read and write data randomly. All these three types of equipments have a rough same structure of the drivers. a) The structure of device drivers In Linux system, the equipment is generally mapped to a special device file. The user can freely perform any operation on it like an ordinary file. Each device is treated as a file in Linux so that the application program can use system calls, such as read and write, to operate it as an ordinary file. The structure of the Linux device drivers is shown in Fig.4.
For the Character and Block Devices, Linux kernel have been conducted an unified abstraction on their file operations, such as open, close, read, write, ioctl, poll, mmap and so on, which are embodied in the structure file_operations included in the fs.h document. struct file_operations{Struct module*owner;
// Module owner
loff_t(*llseek) (struct file*,loff_t,int);
// file-moved pointer, only be used for random access devices
ssize_t(*write)(struct
file*,const
char*,size_t,loff_t*);
//Write data to the characters device
ssize_t(*read)(struct file*,char*,size_t,loff_t*);
//Read data from the device, similar to write
unsigned int(*poll)(struct file*,struct poll_table_struct*);
//Query the state of equipment
int(*ioctl)(struct inode*,struct file*,unsigned int,unsigned long); //control equipment, commands except reading and writing int(*mmap)(struct file*,struct vm_area_struct*); //Map the content of the equipment to address space int(*lock)(struct file*,int,struct file_lock*); //File locking for mutually exclusive visit when file is sharing Int(*open)(struct inode*,struct file*); // Open the device and perform I/O operation int(*release)(struct inode*,struct file*); //Shut down equipment and release the resources }; Seen from the definition of the structure file_operations above, all of its members are function pointers. So in essence, the core of function jump table visits the driver by this structure. The structure used in the procedure is as follows: static struct file_operations test_fops= { owner:THIS_MODULE, write:test_write, read:test_read, ioctl:test_ioctl, open:test_open, release:test_release, }; In the Linux kernel, it uses the macros module_init () and module_exit to initialize the driver module and record the name of function that had quitted, the template of driver is as follows,
Figure.4 Structure of Linux Device Driver
b) The template of drivers
#include<linux/module.h> #include<linux/config.h> #include<linux/init.h> Static int__init name_of_initialization_routine(void)
991
{ /* Driver initialization and operational definition */ } Static void__exit name_of_cleanup_routine(void) { /*The handling operations after the ending of the driver*/
time of meteorological detection, high precision, high degree of automation, cost-effective, a long-time and continuous observations, good reliability, high stability, anti-jamming, etc.
}
module_init(name_of_initialization_routine); module_exit(name_of_cleanup_routine); The drivers of the meteorological data acquisition system can be prepared according to the driver template supplied above. Drivers that should mainly include CAN bus driver, clock driver, serial driver and some hardware drivers. They can be loaded when the system starts at boot time by the kernel module after they were completed and compiled successfully. Then, user application program can directly manage and configure the software and hardware of the Automatic Meteorological Data Acquisition System according to document. 4Application software Application software mainly includes system data quality control software, data processing software and Web browser interface. The data quality control software of the system pretreats the data that collected, removes the unreasonable data. Then the data obtained is transmitted to data processing software for processing, forming the specified data format. A data browse page for the users will be provided by Web browser. Users can modify, add and delete the data through the browse page. At the same time, users can achieve the function of data query and data retrieval. The implementation of the system is shown right in Fig.5. III. CONCLUSION
Figure.5 Implementation flow chart of system
ACKNOWLEDGMENT The authors of the paper are grateful to Chengdu University of Information Technology. REFERENCES
[1] Z.L.Ao, The Design and Implementation of Automatic Meteorological Data Acquisition System Based on CAN Bus. Computer Measurement and Control, pp.491-498,2006. Z. K. Hu and J.Q. Li, Design of Automatic Meteorological Data Acquisition System Based on Embedded Linux. Electronics Engineers, Vol. 30, No. 2, pp. 69-71, 2004. Z. K. Hu and J.Q. Li, Design of Automatic Meteorological Data Acquisition System Based on Embedded Linux. Electronics Engineers, Vol. 30, No. 2, pp. 69-71, 2004. Z. B. Shu, et al, Field Bus Motion Control System. Publishing House of Electronics Industry, 2006. Z. J. Li, Field Bus and its Applications Technology. Machinery Industry Press, pp.495, 2005. Zhou Yu, et al, The Design and Implementation of driver of CAN bus based on Embedded Linux. Computers and automation technology, Vol. 34, No. 8, pp. 50-52, 2008. Peng Yu, Embedded Data Acquisition System Based Linux, Technology Center.
[2]
[3]
[4]
The system, whose design is based on Embedded Linux and CAN bus architecture, has a building-block structure and intelligent function modules. In terms of software design, it supports any combination of systems function modules. So, there is no need to change the original hardware and software design, just to add new sub-collector and/or sensors to the system and conduct simple software upgrade/configuration. The advantages of such a design are as follows, a higher real-
[5] [6]
[7]
992