"Gate system is an important part of water resources dispatching. At present, manual and partial electric operation methods are mostly used in China, and there are few reports on the real realization of intelligent control of gate. The embedded technology based on Linux operating system is adopted to realize the local / remote automatic monitoring of water conservancy gate, which integrates video monitoring and real-time monitoring of water level, gate position, storage capacity, flow and other parameters.
Linux and embedded system
Embedded system is a special computer system with application as the center, computer technology as the basis, software and hardware can be tailored to meet the strict requirements of practical application on function, reliability, cost, volume and power consumption. It is oriented to specific applications, with high reliability and long market life cycle. Because the function of embedded system is more and more complex and the hardware condition is better and better, the selection of appropriate embedded operating system has become the key problem of system development.
At present, there are two main development methods of embedded system: one is to rely on the development platform and components provided by existing commercial software, such as VxWorks, UC / OS, Windows CE, QNX, etc. with mature technology and powerful function, it provides a large number of available function call interfaces, which greatly shortens the product development cycle, but the price is not cheap; The second is to develop based on Free Software Linux, customize it according to the needs of your own system, and do not have to pay additional fees for obtaining the use license, which can greatly reduce the development cost.
Linux is a multi task and multi process embedded operating system based on UNIX core, which supports a wide range of computer hardware. Developers can modify and customize the operating system according to their own needs. It has a large number of open application code to use, and Linux has C, C + +, Object C compiler GCC that can support up to 11 operating platforms. It has powerful functions and execution efficiency 20% ~ 30% higher than that of the general compiler. In the embedded operating system based on Linux, many improved varieties cater to the embedded / real-time market, including RTLinux (real-time Linux) μ Clinux (Linux for non MMU memory management unit processors), MontaVista Linux (Linux distribution for arm, MIPs, PPC), arm2linux (Linux on ARM), etc. In view of the current gate intelligent monitoring system does not have high requirements for real-time operation, we choose red hat 9.0 based on Linux 2.4.22 kernel as the development environment in this application.
Linux custom kernel configuration
Due to the limited storage space of embedded system, it is necessary to customize Linux for embedded system, that is, to reduce unnecessary modules in the kernel, such as peripheral support modules such as SCSI and floppy.
(1) Clear setting environment make mrproper
(2) Set configuration make config
(3) Compile kernel and module make dep; make clean ; make bzImage ; make modules
The compiled kernel files are / usr / SRC / Linux / arch / i386 / boot / bzimage and / usr / SRC / Linux / system. Map
Making system electronic disk
In the standard Linux environment, mount the electronic disk to / ramdisk, and make boot and startup on the electronic disk.
(1) Modify Lilo. Conf file, and the system starts directly from the electronic disk.
(2) Create a kernel file system ext2: mke2f s - I 8192 - M 0 / dev / RAM 50, and in the / ramdisk directory, establish the necessary directory files for running the system: Bin dev etc lib MNT proc SBIN TMP usr VaR, as well as the necessary files in various directories, especially the library files required by the application.
(3) Put the kernel file into ramdisk: # DD if = bzimage of = / dev / RAM BS = 1K. And load the root system file: # DD if = / TMP / RAM image. GZ of = / dev / fd0 BS = 1K seek = number of kernel data blocks. Ram image. Gzj is the compressed root system file, and the number of kernel data blocks is the size of the kernel.
Quick start and startup screen
Since the system is developed based on rad hat 910, the startup process is long. It takes more than 30 seconds from the system power on to the system console displaying "login". Through the test, a lot of time is spent on hardware initialization when the kernel starts. For example, Linux needs to detect a total of 20 ide interfaces (including master and slave disks). By modifying the definition value of max-hwifs in Linux source code from 10 to 1, it can reduce the time for Linux to detect ide interfaces and shorten the system startup time. To really speed up the startup time is to rewrite the startup scripts such as RC. Sysinit and RC, so that the system can only do the necessary initialization of hardware modules and services.
During quick startup, you only need to display the user-defined interface. You can replace the original data in linuxlogo. H with 256 color 640x480 pixel picture data in 1pcx or 1tif format, and make a few modifications to the driver / video / fbcon. C source code. Change the macro definition logo - H 80 to 640, logo - W 80 to 480, and modify the corresponding functions.
Abnormal shutdown
During the use of the system, in order to facilitate the use of users, abnormal shutdown should be supported, that is, to avoid possible problems when the power supply is directly cut off. Usually, the EXT2 file system is a non log file system. When the system is restarted, it will spend a lot of time to check the file system, and sometimes even produce fatal errors, forcing users to manually use the command fsck to check the file system.
Using the general logging file ext3 system, the reliability of data recovery will be ensured through logging. The file system will not be required to be checked when the system is restarted, and the operation speed and stability are good. Upgrade the original EXT2 file system to ext3: tune2fs - J / dev / HDA6, and change the file system type of the partition from ext2 to ext3 in the / etc / fstab file. After using the ext3 log file system, there is no need to check the file system (fsck) frequently. Therefore, it is necessary to use the tune2fs - I 0 - C 0 / dev / HDA6 command to turn off the file system check. At the same time, the purpose of reducing the system startup time is achieved.
Composition of gate intelligent monitoring system
System structure and function
The gate intelligent monitoring system is composed of control cabinet in the central control room, on-site gate hoist, front-end video monitoring point, on-site water level, gate position monitoring point and relevant auxiliary equipment. The system structure is shown in Figure 1. The monitoring system takes the embedded system based on Linux as the core, and its functions are as follows:
(1) Intelligent control of gate lifting, lowering and stopping, as well as intelligent control of alarm and emergency flood discharge;
(2) 8-channel digital mpeg24 compressed streaming media video to remotely monitor the water regime, gate status and operation through video images;
(3) Real time water regime data monitoring, automatic measurement and reporting of water level, flow and water volume, so as to provide basis for flood control and water volume dispatching;
(4) Historical data statistics, generate corresponding process lines and reports.
Hardware implementation
The control cabinet in the central control room is required to have video monitoring and data curve display functions. It adopts CRT monitor and passive backplane. The half length CPU board adopts pci6870. The CPU uses Intel's PIII Celeron 1.2ghzmhz, the memory is 256MB, the Ethernet interface is 10MHz rtl-8139a, and the four-way video acquisition card is flying picture dvs4816avc. The CPU board is connected with the sampling module and output module through PC104 bus, and the electronic disk adopts 64M FlashDisk.
Software implementation
The software of the system has two parts, namely, embedded operating system and application program (the structure is shown in Figure 2). Basic embedded operating systems include:
(1) Bootloader (initialize the processor, initialize the necessary devices, download the system image, and initialize the operating system);
(2) Embedded Linux kernel (including memory management, process management, inter process communication, and other configurable hardware drivers, TCP / IP network stack);
(3) Root file system.
Summary and Prospect
The application of embedded Linux in gate intelligent monitoring system is of positive significance to reduce cost and improve reliability and stability.
In this system, ext3 file system is adopted. In order to further improve the reliability of the system, JFFS or JFFS2 log file system specially designed for flash memory can also be used in the future. Because JFFS2 adopts a new storage mode, supports loss balance and has power-off protection function, it can recover quickly after file crash. Therefore, JFFS2 file system is more suitable for embedded systems with flash as storage device.
Responsible editor: GT, read the full text“
Our other product: