第一篇:基于嵌入式ARM平台的远程IO数据采集系统的研究和开发.
Research and Development of the Remote I/O Data Acquisition System Based on Embedded ARM Platform
INTRODUCTION
With the wide use of the networked, intelligent and digital distributed control system, the data acquisition system based on the single-chip is not only limited in processing capacity, but also the problem of poor real-time and reliability.In recent years, with the rapid development of the field of industrial process control and the fast popularization of embedded ARM processor, it has been a trend that ARM processor can substitute the single-chip to realize data acquisition and control.Embedded ARM system can adapt to the strict requirements of the data acquisition system, such as the function, reliability, cost, size, power consumption, and so on.In this paper, a new kind of remote I/O data acquisition system based on ARM embedded platform has been researched and developed, which can measure all kinds of electrical and thermal parameters such as voltage, current, thermocouple, RTD, and so on.The measured data can be displayed on LCD of the system, and at the same time can be transmitted through RS485 or Ethernet network to remote DAS or DCS monitoring system by using Modbus/RTU or Modbus/TCP protocol.The system has the dual redundant network and long-distance communication function, which can ensure the disturb rejection capability and reliability of the communication network.The new
generation remote data acquisition and moni-toring system based on the high-performance embedded ARM microprocessor has important application significance.STRUCTRUE DESIGN OF THE WHOLE SYSTEM
The whole structure chart of the remote data acquisition and monitoring system based on embedded ARM platform is shown in Figure 1.In the scheme of the system, the remote I/O data acquisition modules are developed by embedded ARM processor, which can be widely used to diversified industries such as electric power, petroleum, chemical, metallurgy, steel, transportation and so on.This system is mainly used for the concentrative acquisition and digital conversion of a variety of electrical and thermal signals such as voltage, current, thermal resistance, thermo-couple in the production process.Then the converted data can be displayed on the LCD directly, and also can be sent to the embedded controller through RS485 or Ethernet network communication interface by using Modbus/RTU or Modbus/TCP protocol.The data in the embedded controller platform is transmitted to the work-stations of remote monitoring center by Ethernet after further analyzed and pro-cessed.At the same time, these data can be stored in the real time database of the database server in remote monitoring center.The system has the dual redun-dant network and long-distance communication
function, which can ensure the disturb rejection capability and reliability of the communication network.The hardware platform of the Remote I/O data acquisition system based on emb-edded ARM uses 32-bit ARM embedded microprocessor, and the software plat-form uses the real-time multi-task operating system uC/OS-II, which is open-source and can be grafted, cut out and solidified.The real time operating system(RTOS makes the design and expansion of the application becomes very easy, and without more changes when add new functions.Through the division of the appli-cation into several independent tasks, RTOS makes the design process of the application greatly simple.Figure 1 Structure of the whole system THE HARDWARE DESIGN OF THE SYSTEM
The remote I/O data acquisition system based on embedded ARM platform has high universality, each acquisition device equipped with 24-way acquisition I/O channels and isolated from each other.Each I/O channel can select a variety of voltage and current signals, as well as temperature signals such as thermal resis-tance, thermocouple and so on.The voltage signals in the range of 0-75 mV ,1-5V ,0-5V, and so on, the current signals in the range of 0-10mA and 4-20 mA, the thermal resistance measurement components including Cu50, Cu100, Pt50, Pt100, and the thermocouple measurement components including K, E, S, T, and so on.Figure2.Structure of the remote I/O data acquisition system based on ARM processor The structural design of the embedded remote I/O data acquisition system is shown in Figure 2.The system equipped with some peripherals such as power, keyboard, reset, LCD display, ADC, RS485, Ethernet, JTAG, I2C, E2PROM, and so on.The A/D interface circuit is independent with the embedded system, which is independent with the embedded system, which is system has setting buttons and 128*64 LCD, which makes the debugging and modification of the parameters easy.The collected data can be sent to the remote embedded controller or DAS, DCS system by using
Modbus/RTU or Modbus/TCP protocol through RS485 or Eth-ernet communication interface also, and then be used
for monitoring and control after farther disposal.The system of RS485 has a dual redundant network and long-distance communication function.As the embedded Ethernet interface makes the remote data exchange of the applications become very easy, the system can choose RS485 or Ethernet interface through jumper to communicate with host computer.Ethernet interface use independent ZNE-100TL intelligent embedded Ethernet to serial port conversion module in order to facilitate the system maintenance and upgrade.The ZNE-100TL module has an adaptive 10/100M Ethernet interface, which has a lot of working modes such as TCP Server, TCP Client, UDP, Real COM, and so on, and it can support four connections at most.Figure3.Diagram of the signal pretreatment circuit
Figure 3 shows the signal pretreatment circuit diagram.The signals of thermo-couple such as K,E,S,T etc and 0-500mV voltage signal can connect to the positive end INPx and the negative end INNx of the simulate multiplexers(MUX directly.The 4-20mA current signal and 1-5V voltage signal must be transformed by resis-tance before connecting to the positive end INPx and the negative end INNx of the MUX of certain channel.The RTD thermal resistance signals such as Cu50, Cu100, Pt50 and Pt100 should connect one 1mA constant current before connecting to the positive end INPx and the negative end INNx of the MUX of certain channel.Figure4.Diagram of ADC signal circuit Figure 4 shows the ADC signal circuit, which using the 16-bit ADC chip AD7715.The connection of the chip and the system is simple and only need
five lines which are CS(chip select, SCLK(system clock, DIN(data input, DOUT(data output and DRDY(data ready.As the ARM microprocessor has the characteristics of high speed, low power, low voltage and so on, which make its capacity of low-noise, the ripple of power, the transient response performance, the stability of clock source, the reliability of power control and many other aspects should be have higher request.The system reset circuit use special microprocessor power monitoring chip of MAX708S, in order to improve the reliability of the system.The system reset circuit is shown in Figure 5.Figure5.Diagram of system reset circuit
SOFTWARE DESIGN AND REALIZATION OF THE SYSTEM
The system software of the remote I/O data acquisition system based on embedded ARM platform use the real-time operating system(RTOS uC/OS-II, which is open-source and can be grafted,cut out and solidified.The key part of RTOS is the real-time multi-task core, whose basic functions including task management, resource management, system management, timer management, memory management, information management, queue management and so on.These functions are used though API service functions of the core.The system software platform use uC/OS-II real-time operating system core simplified the design of application system and made the whole structure of the system simple and the complex application hierarchical.The design of the whole system includes the tasks of the operating system and a series of user applications.The main function of the system is mainly to realize the initialization of the system hardware and the operating system.The initialization of hardware includes interr-upt、keyboard、LCD and so on.The initialization of operating system includes the control blocks and events control blocks, and before the start of multi-task schedu-ling, one task must be started at least.A start task has been created in this system, which is mainly responsible for the initialization and startup of clock, the start-up of interruption, the initialization of communication task module, as
well as the division of tasks and so on.The tasks must be divided in order to complete various functions of the real-time multi-task system.Figure6.Functional tasks of the system software Figure6 shows the functional tasks of the system software.According to importance of the tasks and the demands of real-time, the system applications are divided into six tasks with different priority, which including the tasks of A/D data acquisition, system monitoring, receive queue, data send, keyboard input, LCD display.The A/D data acquisition task demands the highest real-time requirements and the LCD display task is the lowest.Because each task has a different priority, the higher-priority task can access the ready one by calling the system hang up function or delay function.Figure7.Chart of AD7715 data transfer flow Figure 7 shows the data conversion flow of AD7715.The application A/D conversion is an important part of the data acquisition system.In the uC/OS-II real-time operating system core, the realization process of A/D driver depends mainly on the conversion time of A/D converter, the analog frequency of the conversion value, the number of input channels, the conversion frequency and so on.The typical A/D
conversion circuit is made up of analog multiplexer(MUX, amplifier and analog to digital converter(ADC.Figure8.Diagram of the application transfer driver Figure8 shows the application procedure transfer driver.The driver chooses the analog channel to read by MUX, then delay a few microseconds in order to make the signal pass through the MUX, and stabilize it.Then the ADC was triggered to start the conversion and the driver in the circle waiting for the ADC until its completion of the conversion.When waiting is in progress, the driver is detecting the ADC state signal.If the waiting time is longer than the set time, the cycle should be end.During waiting time of the cycle, if the conversion completed signal by ADC has been detected, the driver should read the results of the conversion and then return the result to the application.Figure9.Diagram of serial receive Figure9 shows the serial receive diagram with the buffer and signal quantity.Due to the existence of serial peripheral equipment does not match the speed of CPU, a buffer zone is needed, and when the data is sending to the serial, it need to be written to the buffer, and then be sent out through serial one by one.When the data is received from the serial port, it will not be processed until several bytes have been received, so the advance data can be stored in buffer.In practice, two buffer zones, the receiving buffer and the sending buffer, are needed to be opened from the memory.Here the buffer zone is defined as loop queue data structure.As the signal of uC/OS-II provides the overtime waiting mechanism, the serial also have the overtime reading and writing ability.If the initialization of the received data signal is 0, it expresses the loop buffer is empty.After the interrupt received, ISR read the received bytes from the UART receiving buffer, and put into receiving buffer region, at last wake the user task to execute read operation with the help of received signal.During the entire
process, the variable value of the current bytes in recording buffer can be inquired, which is able to shows whether the receive buffer is full.The size of the buffer zone should be set reasonable to reduce the possibility of data loss, and to avoid the waste of storage space.CONCLUSIONS
With the rapid development of the field of industrial process control and the wide range of applications of network, intelligence, digital distributed control System, it is necessary to make a higher demand of the data accuracy and reliability of the control system.Data acquisition system based on single-chip has been gradually eliminated because the problem of the poor real-time and reliability.With the fast popularization of embedded ARM processor, there has been a trend that ARM processor can alternate to single-chip to realize data acquisition and control.The embedded ARM system can adapt to the strict requirements of the data acquisition system, such as the function, reliability, cost, size, power consum-ption, and so on.In this paper, A kind of ARM-based embedded remote I/O data acquisition system has been researched and developed, whose hardware platform use 32-bit embedded ARM processor, and software platform use open-source RTOS uC/OS-II core.The system can be widely applied to electric power, petroleum, chemical, metallurgy, steel, transportation and so on.And it is mainly used in the collection and monitoring of all
kinds of electrical and thermal signals such as voltage, current, thermal resistance, thermocouple data of the production process.Then these data can be sent to the remote DAS, DCS monitoring system through RS485 or Ethernet interface.The system has the dual redundant network and long-distance communication function, which can ensure the disturb rejection capability and reliability of the communication network.基于嵌入式ARM平台的远程I / O数据采集系统的研究和开发
导言
随着网络化,智能化,数字化分布式控制系统的广泛使用,基于单芯片的数据采集系统不仅在处理能力上受限制,并且在实时性和可靠性方面也出现了问题。近几年来,随着工业过程控制领域的迅速发展和嵌入式ARM处理器的迅速普及,ARM处理器代替单芯片实现数据的采集和控制成为了趋势。嵌入式ARM系统能适应数据采集系统的严格要求,如功能性,可靠性,成本,体积,功耗等等。
在本文中提出一种新型的基于ARM嵌入式平台的远程I / O数据采集系统已被研制开发,它可以衡量各种电气和热参数,如电压,电流,热电偶,热电阻等等。那个测量数据可以显示在液晶显示器的系统中,同时可通过使用Modbus / RTU或的Modbus / TCP协议从RS485或以太网网络传送到DAS或DCS远程监控
系统。该系统具有双冗余网络和长途电通信功能,它可以确保通信网络的干扰抑制能力和可靠性。基于高性能嵌入式ARM微处理器的新一代远程数据采集和监控系统具有重要的应用意义。
整个系统的结构设计
基于嵌入式ARM的平台的远程数据采集和监控系统的整个结构图在以下的图1中展示。在这系统的计划中,通过使用广泛用于多种行业如电气电力,石油,化工,冶金,钢铁,运输等的嵌入式ARM处理器来开发远程I / O数据采集模块。该系统主要用于的集中采购和将各种电和热信号如电压,热电阻,热电偶在生产过程中进行数字转换。转换的数据可直接在液晶显示器上显示,也可以通过使用的Modbus / RTU或的Modbus / TCP协议的RS485总线或以太网网络通信接口被发送到嵌入式控制器。嵌入控制器平台的数据通过进一步以太网的分析和处理被传送至远程监控中心的工作站。与此同时,这些数据可以存储在远程监控中心数据库服务器的实时数据库中。该系统具有双冗余网络和远程通讯功能,它可以确保通信网络的干扰抑制能力和可靠性。
基于嵌入式ARM远程I / O数据采集系统的硬件平台使用32位ARM嵌入式微处理器和软件平台使用的是开源的并且可移植,削减和巩固的实时多任务操作系统的第二代UC / OS核心。实时操作系统(RTOS)使设计和应用的扩大变得非常容
易,增加新的功能时也没多大变化。通过几个独立的任务的应用,实时操作系统使得应用的设计过程极为简单。
系统的硬件设计
基于嵌入式ARM平台的远程I / O数据采集系统具有很高的普遍性,每个购置设备配备24收购方式的I / O渠道且彼此孤立。每个I / O通道可以选择不同的电压和电流信号,以及温度信号如热电阻,热电偶等。在05V的,010毫安和4100TL智能嵌入式以太网串口转换模块。该ZNE500mV的电压信号可以直接接到模拟多路复用器(复用器)的INPx正极和INNx负极。45V的电压信号必须用阻抗转换。热电阻的电阻信号如Cu50,Cu100,Pt50和Pt100应在接到某些频道的复用器INPx正极和INNx负极前连接一1毫安的恒流源。
图4显示了使用16位ADC芯片AD7715的ADC信号电路。芯片与系统的连接非常简单,只需要CS(芯片选择),SLCK(系统时钟),DIN(数据输入),DOUT(数据输出)和DRDY(数据准备)5根线。
由于ARM微处理器具有高速,低功耗,低电压等优点,这使它在低噪音,纹波权力,瞬态响应性能,时钟来源的稳定,功率控制和许多其他方面需要有更高的要求。为了改善系统的可靠性该系统复位电路中使用特殊的微处理器电源监测芯片MAX708S。图5展示了该系统复位电路。
系统软件的设计与实现
基于嵌入式ARM平台的远程I / O数据采集系统的软件使用的是开源的并且可移植,削减和巩固的实时多任务操作系统的第二代UC / OS核心。RTOS的关键部分是实时多任务的核心,其基本功能包括任务管理,资源管理,系统管理,计时器管理,内存管理,信息管理,队列管理等。通过API服务职能核心使用这些功能。
该系统软件平台使用的是单一化的uC/ OS第二代实时简化操作系统核心,使整个结构系统简单和应用层次复杂。整个系统的设计包括操作系统的任务和一系列的用户应用程序。系统的主要职能是实现系统硬件和操作系统的初始化。硬件初始化包括中断,键盘,液晶显示器等。操作系统初始化包括控制模块和事件控制,在多任务调度前,至少有一个任务开始。一个开端任务已建立在这一系统,这系统主要负责初始化和启动的时钟,开办中断,通信任务模块的初始化,以及任务分工等。为了完成实时多任务系统的多种职能那个任务必须被划分。
图6显示系统软件的功能任务。根据任务的重要性和实时要求,系统的应用曾划分为六个不同优先级的任务,其中包括A / D数据采集任务,系统监控,接受队列,数据传送,键盘输入,液晶显示屏显示。A / D数据采集任务要求最高的实时要求和液晶显示器显示任务是最低的。因为每个任务都有不同的优先事项,通过使用系统挂断功能或延迟功能更高的优先任务可以开始已经准备好的任务。
图7显示的是AD7715的数据转换流。A / D转换器的应用是数据采集系统的一个重要组成部分。在uS/ OS的第二代实时操作系统的核心中,A / D驱动程序的实现过程主要取决于A / D转换器的转换时间,有转换价值的模拟频率,输入通
道的数量,转换频率等等。典型的A / D转换电路由模拟复用器(复用器),放大器和模拟到数字转换器(ADC)组成。
图8显示了申请程序转移的驱动程序。驱动程序可以在模拟通道读取由复用器,那么几微秒的延迟,以便使信号通过多路开关,并使其稳定。然后,当转换开始时,ADC被触发,并且驱动程序在一个周期内等待ADC的触发,直到完成转换。当等待的进展,该驱动程序检测ADC的状态信号。如果等待时间比规定的时间越长,周期应该结束。在等待的周期时间,如果转换完成ADC的信号被检测到,驱动程序应改为转换的结果,然后将结果返回给应用程序。
图9显示了缓冲区和信号量的序列接收图。由于外围串行设备的存在CPU的运行速度匹配,一个缓冲区是必要的,当数据发送到序列,它必须被写入缓冲区,然后通过串行逐一地被发送出去。当从串行端口收到数据,这些数据将不会被处理直到收到一些字节,因此先前的数据可以存储在缓冲区中。在实践中,两个缓冲区,一个接收缓冲区和一个发送缓冲区,它们是需要从内存开放出来。在这里缓冲区像循环队列数据结构一样被定义。
由于uC/OS-II提供额外时间等待机制的信号,串口也具有额外的阅读和写作能力。如果收到的数据信号初值为0,它表示循环缓冲区是空的。在中断收到后,ISR从UART接受缓冲区中读到收到的数据,并投入接收缓冲区域,最后通过收到的数据开始用户执行读操作的的任务。在整个过程中,变量价值目前字节在存储缓冲区中的字节的变量值是可以被询问的,这能够表明接收缓冲区是否已满。为了降低数据丢失的可能性和避免浪费存储空间应合理地设置缓冲区的大小。
结论
随着工业过程控制领域的快速发展和网络,智能,数字化分布式控制系统广泛应用,有必要发展对数据准确性和控制可靠性要求更高的系统。由于较差的实时性和可靠性基于单片机数据采集系统已逐步被淘汰。随着嵌入式ARM处理器的迅速普及,ARM处理器替代单芯片实现数据采集与控制成为了一种新的趋势。嵌入式ARM系统能够适应数据采集系统的严格要求,如功能,可靠性,成本,大小,耗电量等等。
在本文中一种基于ARM的嵌入式远程I / O数据采集系统已被研究和开发,其硬件平台采用32位嵌入式ARM处理器和软件平台的使用开源的RTOS uS/ OS-Ⅱ核心。该系统可广泛应用于电力,石油,化工,冶金,钢铁,交通运输等方面。这是主要用于收集和监测各种电气和热信号,如电压,电流,热电阻,生产过程中的热电偶数据。然后通过RS485或以太网接口将这些数据发送到远程的DAS,DCS控制系统的监测系统。该系统具有双冗余网络和长途通信功能,它可以确保干扰抑制和通信网络的可靠性。
第二篇:基于嵌入式ARM平台的远程I O数据采集系统的研究和开发
苏州大学本科生毕业设计(论文)
Research and Development of the Remote I/O Data Acquisition System Based on Embedded ARM Platform
INTRODUCTION
With the wide use of the networked, intelligent and digital distributed control system, the data acquisition system based on the single-chip is not only limited in processing capacity, but also the problem of poor real-time and reliability.In recent years, with the rapid development of the field of industrial process control and the fast popularization of embedded ARM processor, it has been a trend that ARM processor can substitute the single-chip to realize data acquisition and control.Embedded ARM system can adapt to the strict requirements of the data acquisition system, such as the function, reliability, cost, size, power consumption, and so on.In this paper, a new kind of remote I/O data acquisition system based on ARM embedded platform has been researched and developed, which can measure all kinds of electrical and thermal parameters such as voltage, current, thermocouple, RTD, and so on.The measured data can be displayed on LCD of the system, and at the same time can be transmitted through RS485 or Ethernet network to remote DAS or DCS monitoring system by using Modbus/RTU or Modbus/TCP protocol.The system has the dual redundant network and long-distance communication function, which can ensure the disturb rejection capability and reliability of the communication network.The new generation remote data acquisition and moni-toring system based on the high-performance embedded ARM microprocessor has important application significance.STRUCTRUE DESIGN OF THE WHOLE SYSTEM
The whole structure chart of the remote data acquisition and monitoring system based on embedded ARM platform is shown in Figure 1.In the scheme of the system, the remote I/O data acquisition modules are developed by embedded ARM processor, which can be widely used to diversified industries such as electric power, petroleum, chemical, metallurgy, steel, transportation and so on.This system is mainly used for the concentrative acquisition and digital conversion of a variety of
苏州大学本科生毕业设计(论文)
electrical and thermal signals such as voltage, current, thermal resistance, thermo-couple in the production process.Then the converted data can be displayed on the LCD directly, and also can be sent to the embedded controller through RS485 or Ethernet network communication interface by using Modbus/RTU or Modbus/TCP protocol.The data in the embedded controller platform is transmitted to the work-stations of remote monitoring center by Ethernet after further analyzed and pro-cessed.At the same time, these data can be stored in the real time database of the database server in remote monitoring center.The system has the dual redun-dant network and long-distance communication function, which can ensure the disturb rejection capability and reliability of the communication network.The hardware platform of the Remote I/O data acquisition system based on emb-edded ARM uses 32-bit ARM embedded microprocessor, and the software plat-form uses the real-time multi-task operating system uC/OS-II, which is open-source and can be grafted, cut out and solidified.The real time operating system(RTOS)makes the design and expansion of the application becomes very easy, and without more changes when add new functions.Through the division of the appli-cation into several independent tasks, RTOS makes the design process of the application greatly simple.Figure 1 Structure of the whole system
苏州大学本科生毕业设计(论文)
THE HARDWARE DESIGN OF THE SYSTEM
The remote I/O data acquisition system based on embedded ARM platform has high universality, each acquisition device equipped with 24-way acquisition I/O channels and isolated from each other.Each I/O channel can select a variety of voltage and current signals, as well as temperature signals such as thermal resis-tance, thermocouple and so on.The voltage signals in the range of 0-75 mV ,1-5V ,0-5V, and so on, the current signals in the range of 0-10mA and 4-20 mA, the thermal resistance measurement components including Cu50, Cu100, Pt50, Pt100, and the thermocouple measurement components including K, E, S, T, and so on.Figure2.Structure of the remote I/O data acquisition system based on ARM processor
The structural design of the embedded remote I/O data acquisition system is shown in Figure 2.The system equipped with some peripherals such as power, keyboard, reset, LCD display, ADC, RS485, Ethernet, JTAG, I2C, E2PROM, and so on.The A/D interface circuit is independent with the embedded system, which is independent with the embedded system, which is system has setting buttons and 128*64 LCD, which makes the debugging and modification of the parameters easy.The collected data can be sent to the remote embedded controller or DAS, DCS system by using Modbus/RTU or Modbus/TCP protocol through RS485 or Eth-ernet communication interface also, and then be used for monitoring and control
苏州大学本科生毕业设计(论文)
after farther disposal.The system of RS485 has a dual redundant network and long-distance communication function.As the embedded Ethernet interface makes the remote data exchange of the applications become very easy, the system can choose RS485 or Ethernet interface through jumper to communicate with host computer.Ethernet interface use independent ZNE-100TL intelligent embedded Ethernet to serial port
conversion module in order to facilitate the system maintenance and upgrade.The ZNE-100TL module has an adaptive 10/100M Ethernet interface, which has a lot of working modes such as TCP Server, TCP Client, UDP, Real COM, and so on, and it can support four connections at most.Figure3.Diagram of the signal pretreatment circuit
Figure 3 shows the signal pretreatment circuit diagram.The signals of thermo-couple such as K,E,S,T etc and 0-500mV voltage signal can connect to the positive end INPx and the negative end INNx of the simulate multiplexers(MUX)directly.The 4-20mA current signal and 1-5V voltage signal must be transformed by resis-tance before connecting to the positive end INPx and the negative end INNx of the MUX of certain channel.The RTD thermal resistance signals such as Cu50, Cu100, Pt50 and Pt100 should connect one 1mA constant current before connecting to the positive end INPx and the negative end INNx of the MUX of certain channel.苏州大学本科生毕业设计(论文)
Figure4.Diagram of ADC signal circuit
Figure 4 shows the ADC signal circuit, which using the 16-bit ADC chip AD7715.The connection of the chip and the system is simple and only need five lines which are CS(chip select), SCLK(system clock), DIN(data input), DOUT(data output)and DRDY(data ready).As the ARM microprocessor has the characteristics of high speed, low power, low voltage and so on, which make its capacity of low-noise, the ripple of power, the transient response performance, the stability of clock source, the reliability of power control and many other aspects should be have higher request.The system reset circuit use special microprocessor power monitoring chip of MAX708S, in order to improve the reliability of the system.The system reset circuit is shown in Figure 5.苏州大学本科生毕业设计(论文)
Figure5.Diagram of system reset circuit
SOFTWARE DESIGN AND REALIZATION OF THE SYSTEM The system software of the remote I/O data acquisition system based on embedded ARM platform use the real-time operating system(RTOS)uC/OS-II, which is open-source and can be grafted, cut out and solidified.The key part of RTOS is the real-time multi-task core, whose basic functions including task management, resource management, system management, timer management, memory management, information management, queue management and so on.These functions are used though API service functions of the core.The system software platform use uC/OS-II real-time operating system core simplified the design of application system and made the whole structure of the system simple and the complex application hierarchical.The design of the whole system includes the tasks of the operating system and a series of user applications.The main function of the system is mainly to realize the initialization of the system hardware and the operating system.The initialization of hardware includes interr-upt、keyboard、LCD and so on.The initialization of operating system includes the control blocks and events control blocks, and before the start of multi-task schedu-ling, one task must be started at least.A start task has been created in this system, which is mainly responsible for the initialization and startup of clock, the start-up of interruption, the initialization of communication task module, as well as the division of tasks and so on.The tasks must be divided in order to complete various functions of the real-time multi-task system.苏州大学本科生毕业设计(论文)
Figure6.Functional tasks of the system software
Figure6 shows the functional tasks of the system software.According to importance of the tasks and the demands of real-time, the system applications are divided into six tasks with different priority, which including the tasks of A/D data acquisition, system monitoring, receive queue, data send, keyboard input, LCD display.The A/D data acquisition task demands the highest real-time requirements and the LCD display task is the lowest.Because each task has a different priority, the higher-priority task can access the ready one by calling the system hang up function or delay function.苏州大学本科生毕业设计(论文)
Figure7.Chart of AD7715 data transfer flow
Figure 7 shows the data conversion flow of AD7715.The application A/D
conversion is an important part of the data acquisition system.In the uC/OS-II real-time operating system core, the realization process of A/D driver depends mainly on the conversion time of A/D converter, the analog frequency of the conversion value, the number of input channels, the conversion frequency and so on.The typical A/D conversion circuit is made up of analog multiplexer(MUX), amplifier and analog to digital converter(ADC).苏州大学本科生毕业设计(论文)
Figure8.Diagram of the application transfer driver
Figure8 shows the application procedure transfer driver.The driver chooses the analog channel to read by MUX, then delay a few microseconds in order to make the signal pass through the MUX, and stabilize it.Then the ADC was triggered to start the conversion and the driver in the circle waiting for the ADC until its completion of the conversion.When waiting is in progress, the driver is detecting the ADC state signal.If the waiting time is longer than the set time, the cycle should be end.During waiting time of the cycle, if the conversion completed signal by ADC has been detected, the driver should read the results of the conversion and then return the result to the application.苏州大学本科生毕业设计(论文)
Figure9.Diagram of serial receive
Figure9 shows the serial receive diagram with the buffer and signal quantity.Due to the existence of serial peripheral equipment does not match the speed of CPU, a buffer zone is needed, and when the data is sending to the serial, it need to be written to the buffer, and then be sent out through serial one by one.When the data is received from the serial port, it will not be processed until several bytes have been received, so the advance data can be stored in buffer.In practice,two buffer zones, the receiving buffer and the sending buffer, are needed to be opened from the memory.Here the buffer zone is defined as loop queue data structure.As the signal of uC/OS-II provides the overtime waiting mechanism, the serial also have the overtime reading and writing ability.If the initialization of the received data signal is 0, it expresses the loop buffer is empty.After the interrupt received, ISR read the received bytes from the UART receiving buffer, and put into receiving buffer region, at last wake the user task to execute read operation with the help of received signal.During the entire process, the variable value of the current bytes in recording buffer can be inquired, which is able to shows whether the receive buffer is full.The size of the buffer zone should be set reasonable to reduce the possibility of data loss, and to avoid the waste of storage space.CONCLUSIONS
With the rapid development of the field of industrial process control and the
苏州大学本科生毕业设计(论文)
wide range of applications of network, intelligence, digital distributed control System, it is necessary to make a higher demand of the data accuracy and reliability of the control system.Data acquisition system based on single-chip has been gradually eliminated because the problem of the poor real-time and reliability.With the fast popularization of embedded ARM processor, there has been a trend that ARM processor can alternate to single-chip to realize data acquisition and control.The embedded ARM system can adapt to the strict requirements of the data acquisition system, such as the function, reliability, cost, size, power consum-ption, and so on.In this paper, A kind of ARM-based embedded remote I/O data acquisition system has been researched and developed, whose hardware platform use 32-bit embedded ARM processor, and software platform use open-source RTOS uC/OS-II core.The system can be widely applied to electric power, petroleum, chemical, metallurgy, steel, transportation and so on.And it is mainly used in the collection and monitoring of all kinds of electrical and thermal signals such as voltage, current, thermal resistance, thermocouple data of the production process.Then these data can be sent to the remote DAS, DCS monitoring system through RS485 or Ethernet interface.The system has the dual redundant network and long-distance communication function, which can ensure the disturb rejection capability and reliability of the communication network.苏州大学本科生毕业设计(论文)
基于嵌入式ARM平台的远程I / O数据采集系统的研究和开发
导言
随着网络化,智能化,数字化分布式控制系统的广泛使用,基于单芯片的数据采集系统不仅在处理能力上受限制,并且在实时性和可靠性方面也出现了问题。近几年来,随着工业过程控制领域的迅速发展和嵌入式ARM处理器的迅速普及,ARM处理器代替单芯片实现数据的采集和控制成为了趋势。嵌入式ARM系统能适应数据采集系统的严格要求,如功能性,可靠性,成本,体积,功耗等等。
在本文中提出一种新型的基于ARM嵌入式平台的远程I / O数据采集系统已被研制开发,它可以衡量各种电气和热参数,如电压,电流,热电偶,热电阻等等。那个测量数据可以显示在液晶显示器的系统中,同时可通过使用Modbus / RTU或的Modbus / TCP协议从RS485或以太网网络传送到DAS或DCS远程监控系统。该系统具有双冗余网络和长途电通信功能,它可以确保通信网络的干扰抑制能力和可靠性。基于高性能嵌入式ARM微处理器的新一代远程数据采集和监控系统具有重要的应用意义。
整个系统的结构设计
基于嵌入式ARM的平台的远程数据采集和监控系统的整个结构图在以下的图1中展示。在这系统的计划中,通过使用广泛用于多种行业如电气电力,石油,化工,冶金,钢铁,运输等的嵌入式ARM处理器来开发远程I / O数据采集模块。该系统主要用于的集中采购和将各种电和热信号如电压,热电阻,热电偶在生产过程中进行数字转换。转换的数据可直接在液晶显示器上显示,也可以通过使用的Modbus / RTU或的Modbus / TCP协议的RS485总线或以太网网络通信接口被发送到嵌入式控制器。嵌入控制器平台的数据通过进一步以太网的分析和处理被传送至远程监控中心的工作站。与此同时,这些数据可以存储在远程监控中心数据库服务器的实时数据库中。该系统具有双冗余网络和远程通讯功能,它可以确保通信网络的干扰抑制能力和可靠性。
基于嵌入式ARM远程I / O数据采集系统的硬件平台使用32位ARM嵌入式微处理器和软件平台使用的是开源的并且可移植,削减和巩固的实时多任务操作系统的第二代UC / OS核心。实时操作系统(RTOS)使设计和应用的扩大变得非常容易,增加新的功能时也没多大变化。通过几个独立的任务的应用,实时操作系统使得应用的设计过程极为简单。
苏州大学本科生毕业设计(论文)
系统的硬件设计
基于嵌入式ARM平台的远程I / O数据采集系统具有很高的普遍性,每个购置设备配备24收购方式的I / O渠道且彼此孤立。每个I / O通道可以选择不同的电压和电流信号,以及温度信号如热电阻,热电偶等。在05V的,010毫安和4100TL智能嵌入式以太网串口转换模块。该ZNE500mV的电压信号可以直接接到模拟多路复用器(复用器)的INPx正极和INNx负极。45V的电压信号必须用阻抗转换。热电阻的电阻信号如Cu50,Cu100,Pt50和Pt100应在接到某些频道的复用器INPx正极和INNx负极前连接一1毫安的恒流源。
图4显示了使用16位ADC芯片AD7715的ADC信号电路。芯片与系统的连接非常简单,只需要CS(芯片选择),SLCK(系统时钟),DIN(数据输入),DOUT(数据输出)和DRDY(数据准备)5根线。
由于ARM微处理器具有高速,低功耗,低电压等优点,这使它在低噪音,纹波权力,瞬态响应性能,时钟来源的稳定,功率控制和许多其他方面需要有更高的要求。为了改善系统的可靠性该系统复位电路中使用特殊的微处理器电源监测芯片MAX708S。图5展示了该系统复位电路。
系统软件的设计与实现
苏州大学本科生毕业设计(论文)
基于嵌入式ARM平台的远程I / O数据采集系统的软件使用的是开源的并且可移植,削减和巩固的实时多任务操作系统的第二代UC / OS核心。RTOS的关键部分是实时多任务的核心,其基本功能包括任务管理,资源管理,系统管理,计时器管理,内存管理,信息管理,队列管理等。通过API服务职能核心使用这些功能。
该系统软件平台使用的是单一化的uC/ OS第二代实时简化操作系统核心,使整个结构系统简单和应用层次复杂。整个系统的设计包括操作系统的任务和一系列的用户应用程序。系统的主要职能是实现系统硬件和操作系统的初始化。硬件初始化包括中断,键盘,液晶显示器等。操作系统初始化包括控制模块和事件控制,在多任务调度前,至少有一个任务开始。一个开端任务已建立在这一系统,这系统主要负责初始化和启动的时钟,开办中断,通信任务模块的初始化,以及任务分工等。为了完成实时多任务系统的多种职能那个任务必须被划分。
图6显示系统软件的功能任务。根据任务的重要性和实时要求,系统的应用曾划分为六个不同优先级的任务,其中包括A / D数据采集任务,系统监控,接受队列,数据传送,键盘输入,液晶显示屏显示。A / D数据采集任务要求最高的实时要求和液晶显示器显示任务是最低的。因为每个任务都有不同的优先事项,通过使用系统挂断功能或延迟功能更高的优先任务可以开始已经准备好的任务。
图7显示的是AD7715的数据转换流。A / D转换器的应用是数据采集系统的一个重要组成部分。在uS/ OS的第二代实时操作系统的核心中,A / D驱动程序的实现过程主要取决于A / D转换器的转换时间,有转换价值的模拟频率,输入通道的数量,转换频率等等。典型的A / D转换电路由模拟复用器(复用器),放大器和模拟到数字转换器(ADC)组成。
图8显示了申请程序转移的驱动程序。驱动程序可以在模拟通道读取由复用器,那么几微秒的延迟,以便使信号通过多路开关,并使其稳定。然后,当转换开始时,ADC被触发,并且驱动程序在一个周期内等待ADC的触发,直到完成转换。当等待的进展,该驱动程序检测ADC的状态信号。如果等待时间比规定的时间越长,周期应该结束。在等待的周期时间,如果转换完成ADC的信号被检测到,驱动程序应改为转换的结果,然后将结果返回给应用程序。
图9显示了缓冲区和信号量的序列接收图。由于外围串行设备的存在CPU的运行速度匹配,一个缓冲区是必要的,当数据发送到序列,它必须被写入缓冲区,然后通过串行逐一地被发送出去。当从串行端口收到数据,这些数据将不会被处理直到收到一些字节,因此先前的数据可以存储在缓冲区中。在实践中,两个缓冲区,一个接收缓冲区和一个发送缓冲区,它们是需要从内存开放出来。在这里缓冲区像循环队列数据结构一样被定义。
由于uC/OS-II提供额外时间等待机制的信号,串口也具有额外的阅读和写作能力。如
苏州大学本科生毕业设计(论文)
果收到的数据信号初值为0,它表示循环缓冲区是空的。在中断收到后,ISR从UART接受缓冲区中读到收到的数据,并投入接收缓冲区域,最后通过收到的数据开始用户执行读操作的的任务。在整个过程中,变量价值目前字节在存储缓冲区中的字节的变量值是可以被询问的,这能够表明接收缓冲区是否已满。为了降低数据丢失的可能性和避免浪费存储空间应合理地设置缓冲区的大小。
结论
随着工业过程控制领域的快速发展和网络,智能,数字化分布式控制系统广泛应用,有必要发展对数据准确性和控制可靠性要求更高的系统。由于较差的实时性和可靠性基于单片机数据采集系统已逐步被淘汰。随着嵌入式ARM处理器的迅速普及,ARM处理器替代单芯片实现数据采集与控制成为了一种新的趋势。嵌入式ARM系统能够适应数据采集系统的严格要求,如功能,可靠性,成本,大小,耗电量等等。
在本文中一种基于ARM的嵌入式远程I / O数据采集系统已被研究和开发,其硬件平台采用32位嵌入式ARM处理器和软件平台的使用开源的RTOS uS/ OS-Ⅱ核心。该系统可广泛应用于电力,石油,化工,冶金,钢铁,交通运输等方面。这是主要用于收集和监测各种电气和热信号,如电压,电流,热电阻,生产过程中的热电偶数据。然后通过RS485或以太网接口将这些数据发送到远程的DAS,DCS控制系统的监测系统。该系统具有双冗余网络和长途通信功能,它可以确保干扰抑制和通信网络的可靠性。
第三篇:基于嵌入式ARM的远程视频监控系统研究.
基于嵌入式ARM的远程视频监控系统研究
随着科技的进步,视频监控系统正在向嵌入式、数字化、网络化方向发展。嵌入式视频监控系统充分利用大规模集成电路和网络的科技成果,实现了体积小巧、性能稳定、通讯便利的监控产品。本文以S3C2410为核心硬件平台开发了基于嵌入式的远程视频监控系统,并对关键技术进行了论述和研究。首先给出了系统总体软硬件设计方案,针对本系统硬件对vivi进行了修改和移植,对编译和移植Linux内核以及制作YAFFS文件系统也做了深入的研究,重点讨论了在嵌入式Linux操作系统下开发USB接口摄像头驱动程序和利用linux提供的Video4Linux API函数实现视频数据采集,其次采用背景差法实现了对视频图像中运动目标的检测,然后通过MJPEG压缩算法实现了视频数据压缩,接着介绍了在Linux下基于TCP/IP协议的socket编程,实现了视频数据的网络发送。最后着重论述了嵌入式Web服务器的设计,编写了视频监控主界面程序,并实现了基于B/S模式的视频监控系统结构。本系统采用模块化设计方法,使得设计更加简洁、高效,具有良好的扩展性和易用性,有利于系统升级。另外采用嵌入式的方法,系统成本较低,易于推广使用。
【关键词相关文档搜索】: 控制理论与控制工程;ARM;嵌入式Linux;USB摄像头;Video4Linux;嵌入式Web服务器
【作者相关信息搜索】: 南京理工大学;控制理论与控制工程;陈青林;李保国;
第四篇:嵌入式生产数据采集系统研究论文
摘要:当今社会,科学技术不断发展,不断改变,不断创新,同一个行业的企业之间的竞争也越来越激烈。在如此强烈的竞争环境下,企业如果想要获得更多的利益,想要有更好的社会地位,就必须不断改革创新,获得先进的科学技术,将先进技术应用到企业的各个方面。企业建立相应的管理部门,对技术人员进行管理,让企业的生产能够顺利开展。
关键词:RFID的嵌入式;生产数据采集;研究与设计
一、对RFID技术的理解
RFID技术就是一种自动识别技术,读写器和电子标签是基本部件,不管是好的环境还是坏的的环境都能够使用RFID技术,而且不用很多人都看着这个技术进行,甚至都不用人工操作这项技术。RFID技术的识别速度非常快,操作起来也不难,每个步骤都很容易操作,而且RFID技术的应用也越来越广泛,成本不断降低,能够被大部分人接受这个价格。RFID技术的使用寿命相对于其它的技术来讲也比较长,不仅减少了资源的浪费,而且也为企业带来了更多的利益。
二、数据采集终端硬件的主体设计
(一)电源电路。在设备运行过程中,一般情况下,工作电压是1。8伏特,和其他的设备不太一样,数字电源和模拟电源之间有什么不一样,该设备就不能准确的识别出来。在实际应用过程中,要多设计几条电路线,很有可能会出现多种应用电源的情况,也要应对一些突发事件,避免出现突发事件的时候,手忙脚乱,以至于连最基本的问题都无法顺利解决。电源电路多线路的设计特点,提高了生产的质量,也促进了企业的发展[1]。
(二)系统时钟电路。在实际应用数据采集系统的时候,要合理的利用LPC2210ARM7微控器,在使用过程中,可以通过两种不同的电路进行合理的使用,一种是外部晶振电路,还有一种是外部时钟源电路,而且内部的电路还是可以调节的,以便提高设备的运行速度,运行速度也是有限制的,最大的不能超过60赫兹。在使用系统时钟电路的时候,要严格按照要求进行生产数据的采集。
(三)建立复位电路。复位电路芯片的选择十分重要,任何的选择都可能影响企业的日常运行操作,供电电压要保持在一定的范围内,不要太低,也不要太高,保持在正常的范围内就行[2]。复位电路的电压最高是2.93伏特,如果超过2.93伏特,就不能正常进行,要是想要正常的运行设备,必须严格控制电压,只有电压低于2.93伏特的时候,设备才能正常的运行。
三、数据采集终端的外围设计
(一)图形液晶模块接口的电路设计。这类电路设计主要应用的是点阵图形,最大的优点就是可以容阔其他的模块。使用点阵图形液晶模块接口的电路设计时,如果输入正确的指令,在点阵图形模块中就可能同时出现中文和英文。而且点阵图形模块接口的电路设计可以降低设备的操作难度,符合大众的需求,让几乎每一个人都能体会到该设计的应用。
(二)键盘输入电路设计。一般的工作都会应用到电脑,用电脑就会用到键盘,每一个技术人员对于电脑键盘的操作都不陌生,可以用键盘输入数据,统计数据,制作数据报表,计算工程利益预估的价格等,这就是人和机器很好结合的表现。在设计电路的时候,键盘输入电路的设计最为普遍,很多人能够充分的了解该项设计内容,也能很好的接受键盘输入电路设计,并且应用到实际的工作生产过程中。而且现在学校中计算机的教育会先教学生使用键盘,随着人们不断的学习,键盘的使用已经扎根在人们的脑子里了。
四、结语
目前,我国的经济发展非常快,也发展的非常好,生产数据的采集还有很多不足之处,需要各个企业不断改革创新,争取建立最适合我国经济发展的生产数据采集系统。各个企业的设计部门应该在现有电路设计的基础上不断完善电路设计内容,相关技术人员对于所使用的电路设计也要熟练的掌握其基本要领。在当今社会中,通过解决工作过程中不断出现的一个又一个的问题,不断完善电路设计。企业也要经常召开会议,对于技术的改革创新进行不断探讨。在实际生产过程中,企业要建立相关的部门,专门负责生产过程中的设计问题,如果出现什么问题,要及时的解决问题,不要累积问题,让问题的危害扩大。企业的相关部门也要对技术人员进行培训,很多技术在不断改革创新,就需要专业的技术人员对新技术做到熟悉了解,能够把新技术熟练的应用到生产过程中,推动企业的发展,避免企业在社会日益发展的潮流中被淘汰下去。
参考文献
[1]张开生,石瑞华,薛杨。基于RFID技术的服装生产过程管理系统设计[J]。单片机与嵌入式系统应用,2018,18(04):43—48。
[2]嘉丹丹,蒋高明,丛洪莲,吴志明,焦洋。应用ZigBee技术的纬编生产数据实时采集系统[J]。纺织学报,2016,37(12):129—133。
第五篇:基于ARM嵌入式的远程监控系统设计
基于ARM嵌入式的远程监控系统设计
摘要:基于ARM 内核的嵌入式系统在远程监控报警系统中的设计实现与应用。核心部分主要包 括 ARM 嵌入式平台设计及 μC-OS 嵌入式实时操作系统移植;人机交互界面 μCGUI 的设计与实现;远程通讯及自动报警等;系统的设计还考虑到了扩展性和通用性以及与其他监控设备无缝连接等问题。
关键词: ARM;μC/OS-II;μCGUI;远程监控 引言
监控系统现已成为现代化生产、生活中不可缺少的重要组成部分。目前,监控系列产品 种类繁多,大部分广泛应用于交通、医院、银行、家居、学校等安防领域。
随着嵌入式系统的出现,尤其是基于 ARM 内核芯片的嵌入式系统的出现,使得监控系统的应用领域更为广泛。本文设计的远程监控报警系统除了作为安防功能外,还可以应用于以下领域:通讯领域:远程通讯、视频会议和视频点播、证券、远程教育等。医疗领域:病房监护、远程诊断等。工业领域:远程设备诊断、维护、维修,远程生产监控等。家用领域:家用电器远程维护;电、气、火等重大事故自动报警等。
系统设计
2.1系统组成
本文设计的远程监控系统主要由中心控制器、数据终端、传感器模块、通讯模块、接口模块等几部分组成。系统组成图(如图 1)。
2.2中心控制器 系统核心负责数据采集判断处理。为了提高系统工作效率,这里使用的是三星公司的 S3C2410芯片作为处理器。S3C2410 芯片是一款高性价比的 ARM 芯片,非常适合作手机、PDA 等手持设备。主要特性包括: ARM920T 内核,最高工作频率 203MHz,LCD 控制器:可直接驱动真彩液晶屏,最高支持 2048×1024 真彩液晶屏,2 个 USB Host端口,1 个USB Device端口,支持 Nand flash 启动模式,SD 卡接口,UART、IIC、SPI、IIS 等多种类 型串行接口,4 通道DMA。
本文的监控系统的 CPU 核心部分使用的是标准的 SO-DIMM200 金手指接口,便于后期维护和升级。如果该监控系统的使用环境较为苛刻,可以将 CPU替换为S3C2440芯片。S3C2440完全兼容S3C2410全部特性(注意:芯片引脚不完全兼容)。与S3C2410芯片相比,S3C2440的性能更为优越:最高工作频率可达500MHz,内部集成CMOS摄像头接口,但价格较昂贵。
图1 监控系统组成框图
2.3数据终端 数据终端的主要功能是对监控数据进行分析、处理,及时将数据汇报给监控人员。同时,监控人员可以根据现场情况,使用数据终端对监控的设备进行远程控制。数据终端最大优势 就是安全、可靠、便于携带。一般情况下为了节约成本,可以将手机、PDA 等移动通讯设备作为数据终端使用。但是如果作为对高危环境或精密仪器的监控系统,数据终端需要专业定制。这里使用的是中心控制器的作为数据终端,即中心控制器既作为数据采集发送中心,也可数据接收处理中心使用。
2.4通讯模块
通讯模块主要负责远程数据通讯。带有 RS232/485、GPRS、CDMA 等一种或多种通讯 方式。需要根据现场环境和用户需要进行定制。通讯模块与控制器通过接口总线连接,连接 方式为 TTL/RS232/RS485 等。
2.5传感器模块
传感器模块的主要功能是感知外部环境,对外部环境进行实时监测。由人体红外传感器、振动传感器、超声波传感器、可燃气体传感器、温度传感器、湿度传感器等一种或多种传感 器组成。可根据现场监测环境不同进行定制。
2.6接口模块
接口模块主要作为系统扩展功能使用,将控制器的 A/D 转换、I2C、SPI 等多种接口进行 外部扩展。接口模块没有特定的功能,但可以根据需要与其他设备连接,例如可以与工业仪 器仪表或设备连接,实时对仪器或设备进行监控。
接口模块虽然不是监控系统的主要部分,但是对于整个系统来说却是不可缺少。因为本文的监控系统主要考虑到了系统的可扩展性和与其它系统无缝连接。通过接口模块可以很方 便的对监控系统进行升级,并且可以实现与其他系统或设备的无缝连接。这也是本系统区优 于其他监控系统的主要功能。软件设计
3.1工作软件
系统的软件设计较为复杂,这里只给出了整个工作软件流程(如图 2)。
图2 软件流程图
3.2操作系统移植
S3C2410 芯片支持多种嵌入式操作系统,如 WINCE、uCLinux 等。但考虑到监控系统 的实时性要求,这里使用的是 μC/OS-II 嵌入式实时操作系统。μC/OS-II 是一个源码公开、可移植、可固化、可裁剪、占先式的实时多任务操作系统。其绝大部分源码是用 ANSI C 写的。整个嵌入式系统分为两大层:硬件层和软件层。这里主要研究软件层的架构。软件层主要分为四个部分:实时操作系统内核,与处理器相关部分,与应用程序相关部分,用户的应用程序。移植 μC/OS-II 系统需要修改的文件有:应用程序相关文件: OS_CFG.H INCLUDE.H; 处理器相关文件: OS_CPU.H、OS_CPU_A.ASM、OS_CPU_C.C。
3.2.1 与处理器相关的代码
这是移植中最关键的部分。内核将应用系统和底层硬件有机的结合成一个实时系统,要 使同一个内核能适用于不同的硬件体系,就需要在内核和硬件之间有一个中间层,这就是与 处理器相关的代码。处理器不同。这部分代码也不同。我们在移植时需要自己移植这部分代 码。
a)OS_CPU.H
包括了用#define 定义的与处理器相关的常量,宏和类型定义,有系统数据类型定义,栈 增长方向定义,关中断和开中断定义,系统软中断的定义等等。
b)OS_CPU_A.ASM
这部分需要对处理器的寄存器进行操作,所以必须用汇编语言来编写。包括四个子函数: OSStartHighRdy(),OSCtxSw(),OSIntCtxSw(),OSTickISR()。OSStartHighRdy()在多任务系统启动函数 OSStart()中调用。完成的功能是:设置系统运行标志位 OSRunning = TRUE;将就绪表中最高优先级任务的栈指针 Load 到 SP 中,并强制中断返回。这样就绪的最高优先级任务就如同从中断里返回到运行态一样,使得整个系统得以运转。OSCtxSw()在任务级任 务切换函数中调用的。任务级切换是通过 SWI 或者 TRAP 人为制造的中断来实现的。ISR 的向 量地址必须指向 OSCtxSw()。这一中断完成的功能:保存任务的环境变量(主要是寄存器的值, 通过入栈来实现),将当前 SP 存入任务 TCB 中,载入就绪最高优先级任务的 SP,恢复就绪最高优先级任务的环境变量,中断返回。这样就完成了任务级的切换。OSIntCtxSw()在退出中断 服务函数 OSIntExit()中调用,实现中断级任务切换.由于是在中断里调用,所以处理器的寄存器入栈工作已经做完,就不用作这部分工作了。具体完成的任务;调整栈指针(因为调用函数会使任务栈结构与系统任务切换时堆栈标准结构不一致),保存当前任务 SP,载入就绪 最高优先级任务的 SP,恢复就绪最高优先级任务的环境变量,中断返回。这样就完成了中断级任务切换。OSTickISR()系统时钟节拍中断服务函数,这是一个周期性中断,为内核提供
时钟节拍。频率越高系统负荷越重。其周期的大小决定了内核所能给应用系统提供的最小时 间间隔服务。一般只限于 ms 级(跟 MCU 有关),对于要求更加苛刻的任务需要用户自己建立中断来解决.该函数具体内容:保存寄存器(如果硬件自动完成就可以省略),调 OSIntEnter(),调用 OSTimeTick(),调用 OSIntExit(),恢复寄存器,中断返回。
c)OS_CPU_C.C
该文件中共定义了 6 个函数,但是最重要的是 OSTaskStkInit().其他都是对系统内核的扩展 时用的.OSTaskStkInit()是在用户建立任务时系统内部自己调用的,对用户任务的堆栈进行初始化。使建立好的进入就绪态任务的堆栈与系统发生中断并且将环境变量保存完毕时 的栈结构一致。这样就可以用中断返回指令使就绪的任务运行起来。
3.2.2与应用相关的代码
这部分包括两个文件:OS_CFG.H, INCLUDES.H。用户根据自己的应用系统来定制合适 的内核服务功能。OS_CFG.H 来配置内核,用户根据需要对内核进行定制,留下需要的部分,去掉不需要的部分,设置系统的基本情况。比如系统可提供的最大任务数量,是否定制邮箱服务,是否需要系统提供任务挂起功能,是否提供任务优先级动态改变功能等等。INCLUDES.H 系统头文件,整个实时系统程序所需要的文件,包括了内核和用户的头文件。
3.3用户图形接口
虽然 μC/OS-II 操作系统具有很高的实时性,但不像 WINCE、uCLinux 等操作系统那样 有良好的图形界面支持。所以,在使用液晶和触摸屏的情况下需要移植用户图形接口程序。这里使用的是 μC/GUI。μC/GUI 是一个软件模块集合,通过该模块可以在我们的嵌入式产品 中加入用户图形接口(GUI)。μC/GUI 具有很高的执行效率,并且与处理器和 LCD 控制器相 独立。该模块可以工作在单任务或者多任务环境,可以支持不同大小的显示方式。
通过 μC/GUI 我们可以很方便的在液晶屏绘制图形和界面。如果需要多种字体支持,必 须自己将相应的字体字库加入到 μC/GUI 中。为了避免出现乱码,尽量使用 GB2312 国标字库。
3.4关于字库的兼容性问题
我们国内通常使用的汉字字库是 GB 码,但国际上使用的是 UNICODE 码,所以如果数据终端使用的是手机、PDA 等移动通信设备,那么在数据发送前必须进行字码转换,即 GB 码 转换为 UNICODE 码或者 UNICODE 码转换为 GB 码。由于 GB 码与 UNICODE 码在排列组合上没有任何规律,所以通常字码转换的方法就是 查表法。
4结束语
基于 ARM9 嵌入式系统的远程监控系统与以往的监控系统不同,高性能的处理器芯片大大提高了系统的性能。使监控系统能够工作在比较恶劣的环境中。并且在设计上充分考虑到了系统的可扩展性和兼容性问题,实现了本系统与其他系统的无缝连接。以满足不同工作环 境的需要。
作者创新观点:本文设计的远程监控系统应用范围更广,更灵活、方便。通过各个功能模块 的不同组合,可以十分方便快速的应用于各个领系域,真正实现智能化、自动化且具有较高 的性价比。