Design of measurement and control system based on Linux-based embedded system as the core

0 Preface

Currently, in the field of industrial control, network control technology is developing rapidly. Network control requires that the measurement and control system must have two functions: on the one hand, it must complete complex measurement and control tasks on the spot, usually some tasks have certain real-time requirements; on the other hand, it requires the measurement and control system to be connected to a certain type of control network. Realize remote monitoring. In most measurement and control systems currently in use, the hardware of the embedded system uses 8/16-bit single-chip microcomputers; the software mostly uses assembly language programming, which only contains a simple loop processing control flow; between the single-chip microcomputer and the single-chip or upper computer Communication is networked through RS232 and RS485. These networks have the problems of slow communication speed, poor networking functions, and difficulty in development. The industrial Ethernet has been gradually improved, and it has gained more and more applications in the field of industrial control. Industrial Ethernet uses the TCP/IP protocol, which is convenient for networking and has the advantages of high-speed control network. Now, the decline in the price of 32-bit embedded CPUs and the increase in performance indicators provide the possibility for the wide application of embedded systems. Based on the above situation, we apply the embedded system to the measurement and control system, which can greatly improve the performance of the measurement and control system. The embedded system is generally developed with an embedded operating system. In the choice of embedded operating system, because Linux has a complete and open source code, the system can be modified and optimized for specific applications, the kernel is stable, it is suitable for a variety of CPUs and a variety of hardware platforms, and supports the network. Therefore, Linux is selected as Embedded operating system.

1 Overall design of the measurement and control system

1.1 Design goals

The measurement and control system takes the Linux-based embedded system as the core, and the design goals are summarized as follows:

(1) Measurement and control tasks are completed on site. The measurement and control system adopts a decentralized control strategy, and the upper computer only plays a role of status monitoring when the system is running normally. The completion of data measurement, data processing, process control and other tasks at the industrial site can ensure the real-time completion of some tasks.

(2) It has certain self-diagnosis and self-correction functions, and uploads the fault situation to the upper computer, which is convenient for maintenance personnel to check and troubleshoot. With dynamic display and data storage capabilities.

(3) The measurement and control system can be connected to the industrial Ethernet, and remote monitoring can be realized through the industrial Ethernet.

1.2 Technical route

The embedded system takes the embedded microprocessor as the core and runs the embedded Linux operating system. The application program can be updated through the network; the human-machine dialogue can be carried out through the keyboard; the data can be displayed on the spot through the LCD; the important data can be stored in the Flash memory in the form of a file; the data and alarm information can be transmitted to the upper computer through the serial port, or through the Ethernet The port publishes information to Industrial Ethernet or the Internet, and the user checks the device status through the display interface, sets the device parameters, and realizes remote monitoring and remote maintenance.

1.3 Overall block diagram

Design of measurement and control system based on Linux-based embedded system as the core

2 The design of embedded system based on Linux

2.1 Hardware design

Consider that the general measurement and control system requires more functions for embedded systems: keyboard interface, display interface, A/D (or D/A) conversion unit, expandable I/O interface, printer interface, serial communication with PC Line interface, Ethernet interface, etc. The hardware block diagram of the implemented embedded system is as follows:

Design of measurement and control system based on Linux-based embedded system as the core

For the application of measurement and control system, choose Motorola's Coldfire series MCF5307. MCF5307 is a high-performance, low-cost, highly integrated microprocessor designed for embedded control applications. MCF5307 has a processing capacity of 70 MIPS, an operating frequency of 88.47 MHz, and a bus frequency of 44.236 MHz. It provides hardware support for running Linux. The development board also integrates 16 M SDRAM, 2 M FLASH, 10 baseT Ethernet interface, RS232/RS485 serial port, I/O interface, etc.

2.2 Software design

Embedded operating system is the core of the entire embedded system. We choose Linux, but the typical Linux is configured for the desktop, the kernel is very large, and the RAM storage capacity of the embedded system is very small, therefore, to load the Linux operating system into the limited memory, it must be tailored. The main technologies involved in the cutting process are:

(1) Simplification of the kernel. Standard Linux is PC-oriented and integrates many functions required by PCs but not needed by embedded systems. For some functional blocks that can be added or removed independently, when compiling the kernel, only the functional support modules required by the embedded system are retained, and unnecessary functions are deleted. For example, if the measurement and control system is to be connected to the Ethernet, it must provide support for TCP/IP, and add the TCP/IP stack when compiling; while peripherals such as SCSI and Floppy are completely unnecessary in our embedded system. It can be removed from time to time. In this way, the recompiled kernel is significantly reduced.

(2) Shielding of virtual memory mechanism. After analysis, it is found that virtual memory is one of the reasons leading to the lack of real-time performance of Linux. Some tasks in industrial control must meet certain real-time requirements, and the virtual memory management mechanism of the shielding kernel can enhance the real-time performance of Linux. When a certain mechanism of the kernel is to be changed, it is generally not necessary to rewrite the code on a large scale, and the method of conditional compilation can be used. The idea is to use #ifdef or #ifndef to shield existing statements, and include your own code in the #else macro compilation statement. The mechanisms for realizing virtual memory are: address mapping mechanism, memory allocation and recovery mechanism, cache and refresh mechanism, page request mechanism, exchange mechanism, memory sharing mechanism. The data structure and function of these mechanisms will be shielded or modified, and modified and modified. Related documents. The files that need to be changed are mainly in the /include/linux, /mm, /drivers/char, /fs, /ipc/kernel, and /init directories. The main changes are as follows: The main data structure related to virtual memory is vm_area_struct. Remove the vm_area_struct in the mm_struct structure of the process. vm_area_struct uses vm_ops to abstract out the processing methods for virtual memory and shield functions related to virtual memory operations. The memory mapping is mainly implemented by do_mmap(), and the code of this function is rewritten. Cancel the exchange operation, shield the structure and function declaration used for the exchange, and the code that realizes the exchange. Cancel the kernel daemon kswapd.

(3) The preparation of the device driver. After determining the basic functions of the kernel, it is necessary to write a driver for a specific device, which can be written in accordance with the rules for writing a driver under Linux. The written device driver should have the following functions: â‘  initialize and release the device; â‘¡ transfer data from the kernel to the hardware and read data from the hardware; â‘¢ read the data passed by the application to the device file and return the data requested by the application â‘£Detect and deal with equipment errors.

After the above steps are implemented, a small Linux operating system is constructed. The constructed Linux includes process management, memory management and file management, and supports multitasking in parallel; a file system based on flash memory is developed, applications and important data are stored in the flash file system in the form of files; there is a complete TCP/IP protocol Stack, Linux has built-in support for Ethernet controller, which can be connected to industrial Ethernet through Ethernet port to realize remote monitoring.

It is also necessary to transplant the tailored kernel to the target board used. Usually, when the kernel is transplanted, the kernel must first be compiled into the target code for the processor. And the embedded microprocessor MCF5307 we use is the ColdFire series. It has some differences from other CPUs. Some kernel programs need to be rewritten. It involves writing Linux boot code and modifying the code related to the architecture, mainly memory management. And interrupt processing part. Use Flash as the startup device of the system, and put the boot code on Flash. After the system is powered on, the basic hardware initialization is performed by the boot code, and then the kernel image is loaded into the memory to run.

For the development of application programs, for specific applications of the measurement and control system, use Linux to provide API interfaces to develop application programs. The measurement and control system has to complete multiple tasks. Because the virtual memory mechanism is shielded, all tasks share physical memory and exist in a unified linear space. The address in the task is the real physical address. Since no address space mapping is required, the context switching time during task switching is greatly reduced, the response speed is improved, and the real-time performance is enhanced. Linux adopts priority-based round-robin scheduling strategy, which can realize multiple tasks in parallel. The real-time requirements of each task are different, and the tasks with high real-time requirements can be divided into real-time processes by dividing priorities, which have higher priority and are scheduled first to ensure certain real-time requirements. The tasks communicate through mechanisms such as semaphores and message queues.

The main modules of software development in embedded systems are: data acquisition module, data processing module, data display module, communication and data release module, and fault diagnosis module. Among them, the fault diagnosis module realizes real-time self-diagnosis, and performs partial tests on the system during the working period of the system. That is, the diagnostic program is set in the interrupt service program with the lowest interrupt level in the embedded system, and real-time diagnosis is performed without affecting the system's work. If a fault is found and there is still an error after the follow-up diagnosis, it will be displayed on the display interface and uploaded to the host computer to ensure the reliability of the system.

In the development of embedded Linux, the master-slave mode is adopted to connect the target board and the host computer through a serial port or an Ethernet port. The GNU series of tools are used. GNU has free and open source code, which also provides convenience for us to develop Linux-based applications. It includes a series of development and debugging tools. The main components are:

gcc: Compiler, which can be made into a form of cross-compilation, that is, develop and compile binary files that can be run on the target machine on the host machine;

Binutils: Some auxiliary tools, including objdump (can decompile binary files), as (assembler compiler), ld (linker), etc.;

Gdb: Debugger, you can use a variety of cross-debugging methods, such as gdbserve (using Ethernet network debugging).

Finally, burn the debugged kernel and application program to the flash memory. The tailored Linux has been successfully transplanted to the target platform and runs well on the development board. After testing, it has met the general real-time requirements.

3 Conclusion

The Linux-based embedded system we developed is used in the measurement and control system, which can meet the requirements of the current industrial control field for the measurement and control system, and ensure the real-time and reliability of the completion of the measurement and control task. It can be connected to the industrial Ethernet for remote monitoring. Its hardware and interface adopt the form of plug-in board, with simple structure, easy to install and unload, and convenient for system integration and maintenance. In terms of software, users can modify or delete correspondingly for specific applications, which improves the development efficiency of the measurement and control system and has a good application prospect in the field of industrial control.

Sony Adapter

High efficient charging speed for Sony laptop, stable current outlet can offer power for the laptop at the same time charge the laptop battery. The best choice for your replacement adapter.We can meet your specific requirement of the products, like label design. The plug type is US/UK/AU/EU. The material of this product is PC+ABS. All condition of our product is 100% brand new.


Our products built with input/output overvoltage protection, input/output overcurrent protection, over temperature protection, over power protection and short circuit protection. You can send more details of this product, so that we can offer best service to you!


Adapter For Sony,Charger For Sony,Laptop Charger For Sony ,Sony Laptop Adapter

Shenzhen Waweis Technology Co., Ltd. , https://www.waweispowerasdapter.com

This entry was posted in on