第一篇:基于嵌入式ARM平臺(tái)的遠(yuǎn)程IO數(shù)據(jù)采集系統(tǒng)的研究和開(kāi)發(fā).
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平臺(tái)的遠(yuǎn)程I / O數(shù)據(jù)采集系統(tǒng)的研究和開(kāi)發(fā)
導(dǎo)言
隨著網(wǎng)絡(luò)化,智能化,數(shù)字化分布式控制系統(tǒng)的廣泛使用,基于單芯片的數(shù)據(jù)采集系統(tǒng)不僅在處理能力上受限制,并且在實(shí)時(shí)性和可靠性方面也出現(xiàn)了問(wèn)題。近幾年來(lái),隨著工業(yè)過(guò)程控制領(lǐng)域的迅速發(fā)展和嵌入式ARM處理器的迅速普及,ARM處理器代替單芯片實(shí)現(xiàn)數(shù)據(jù)的采集和控制成為了趨勢(shì)。嵌入式ARM系統(tǒng)能適應(yīng)數(shù)據(jù)采集系統(tǒng)的嚴(yán)格要求,如功能性,可靠性,成本,體積,功耗等等。
在本文中提出一種新型的基于ARM嵌入式平臺(tái)的遠(yuǎn)程I / O數(shù)據(jù)采集系統(tǒng)已被研制開(kāi)發(fā),它可以衡量各種電氣和熱參數(shù),如電壓,電流,熱電偶,熱電阻等等。那個(gè)測(cè)量數(shù)據(jù)可以顯示在液晶顯示器的系統(tǒng)中,同時(shí)可通過(guò)使用Modbus / RTU或的Modbus / TCP協(xié)議從RS485或以太網(wǎng)網(wǎng)絡(luò)傳送到DAS或DCS遠(yuǎn)程監(jiān)控
系統(tǒng)。該系統(tǒng)具有雙冗余網(wǎng)絡(luò)和長(zhǎng)途電通信功能,它可以確保通信網(wǎng)絡(luò)的干擾抑制能力和可靠性。基于高性能嵌入式ARM微處理器的新一代遠(yuǎn)程數(shù)據(jù)采集和監(jiān)控系統(tǒng)具有重要的應(yīng)用意義。
整個(gè)系統(tǒng)的結(jié)構(gòu)設(shè)計(jì)
基于嵌入式ARM的平臺(tái)的遠(yuǎn)程數(shù)據(jù)采集和監(jiān)控系統(tǒng)的整個(gè)結(jié)構(gòu)圖在以下的圖1中展示。在這系統(tǒng)的計(jì)劃中,通過(guò)使用廣泛用于多種行業(yè)如電氣電力,石油,化工,冶金,鋼鐵,運(yùn)輸?shù)鹊那度胧紸RM處理器來(lái)開(kāi)發(fā)遠(yuǎn)程I / O數(shù)據(jù)采集模塊。該系統(tǒng)主要用于的集中采購(gòu)和將各種電和熱信號(hào)如電壓,熱電阻,熱電偶在生產(chǎn)過(guò)程中進(jìn)行數(shù)字轉(zhuǎn)換。轉(zhuǎn)換的數(shù)據(jù)可直接在液晶顯示器上顯示,也可以通過(guò)使用的Modbus / RTU或的Modbus / TCP協(xié)議的RS485總線或以太網(wǎng)網(wǎng)絡(luò)通信接口被發(fā)送到嵌入式控制器。嵌入控制器平臺(tái)的數(shù)據(jù)通過(guò)進(jìn)一步以太網(wǎng)的分析和處理被傳送至遠(yuǎn)程監(jiān)控中心的工作站。與此同時(shí),這些數(shù)據(jù)可以存儲(chǔ)在遠(yuǎn)程監(jiān)控中心數(shù)據(jù)庫(kù)服務(wù)器的實(shí)時(shí)數(shù)據(jù)庫(kù)中。該系統(tǒng)具有雙冗余網(wǎng)絡(luò)和遠(yuǎn)程通訊功能,它可以確保通信網(wǎng)絡(luò)的干擾抑制能力和可靠性。
基于嵌入式ARM遠(yuǎn)程I / O數(shù)據(jù)采集系統(tǒng)的硬件平臺(tái)使用32位ARM嵌入式微處理器和軟件平臺(tái)使用的是開(kāi)源的并且可移植,削減和鞏固的實(shí)時(shí)多任務(wù)操作系統(tǒng)的第二代UC / OS核心。實(shí)時(shí)操作系統(tǒng)(RTOS)使設(shè)計(jì)和應(yīng)用的擴(kuò)大變得非常容
易,增加新的功能時(shí)也沒(méi)多大變化。通過(guò)幾個(gè)獨(dú)立的任務(wù)的應(yīng)用,實(shí)時(shí)操作系統(tǒng)使得應(yīng)用的設(shè)計(jì)過(guò)程極為簡(jiǎn)單。
系統(tǒng)的硬件設(shè)計(jì)
基于嵌入式ARM平臺(tái)的遠(yuǎn)程I / O數(shù)據(jù)采集系統(tǒng)具有很高的普遍性,每個(gè)購(gòu)置設(shè)備配備24收購(gòu)方式的I / O渠道且彼此孤立。每個(gè)I / O通道可以選擇不同的電壓和電流信號(hào),以及溫度信號(hào)如熱電阻,熱電偶等。在05V的,010毫安和4100TL智能嵌入式以太網(wǎng)串口轉(zhuǎn)換模塊。該ZNE500mV的電壓信號(hào)可以直接接到模擬多路復(fù)用器(復(fù)用器)的INPx正極和INNx負(fù)極。45V的電壓信號(hào)必須用阻抗轉(zhuǎn)換。熱電阻的電阻信號(hào)如Cu50,Cu100,Pt50和Pt100應(yīng)在接到某些頻道的復(fù)用器INPx正極和INNx負(fù)極前連接一1毫安的恒流源。
圖4顯示了使用16位ADC芯片AD7715的ADC信號(hào)電路。芯片與系統(tǒng)的連接非常簡(jiǎn)單,只需要CS(芯片選擇),SLCK(系統(tǒng)時(shí)鐘),DIN(數(shù)據(jù)輸入),DOUT(數(shù)據(jù)輸出)和DRDY(數(shù)據(jù)準(zhǔn)備)5根線。
由于ARM微處理器具有高速,低功耗,低電壓等優(yōu)點(diǎn),這使它在低噪音,紋波權(quán)力,瞬態(tài)響應(yīng)性能,時(shí)鐘來(lái)源的穩(wěn)定,功率控制和許多其他方面需要有更高的要求。為了改善系統(tǒng)的可靠性該系統(tǒng)復(fù)位電路中使用特殊的微處理器電源監(jiān)測(cè)芯片MAX708S。圖5展示了該系統(tǒng)復(fù)位電路。
系統(tǒng)軟件的設(shè)計(jì)與實(shí)現(xiàn)
基于嵌入式ARM平臺(tái)的遠(yuǎn)程I / O數(shù)據(jù)采集系統(tǒng)的軟件使用的是開(kāi)源的并且可移植,削減和鞏固的實(shí)時(shí)多任務(wù)操作系統(tǒng)的第二代UC / OS核心。RTOS的關(guān)鍵部分是實(shí)時(shí)多任務(wù)的核心,其基本功能包括任務(wù)管理,資源管理,系統(tǒng)管理,計(jì)時(shí)器管理,內(nèi)存管理,信息管理,隊(duì)列管理等。通過(guò)API服務(wù)職能核心使用這些功能。
該系統(tǒng)軟件平臺(tái)使用的是單一化的uC/ OS第二代實(shí)時(shí)簡(jiǎn)化操作系統(tǒng)核心,使整個(gè)結(jié)構(gòu)系統(tǒng)簡(jiǎn)單和應(yīng)用層次復(fù)雜。整個(gè)系統(tǒng)的設(shè)計(jì)包括操作系統(tǒng)的任務(wù)和一系列的用戶應(yīng)用程序。系統(tǒng)的主要職能是實(shí)現(xiàn)系統(tǒng)硬件和操作系統(tǒng)的初始化。硬件初始化包括中斷,鍵盤(pán),液晶顯示器等。操作系統(tǒng)初始化包括控制模塊和事件控制,在多任務(wù)調(diào)度前,至少有一個(gè)任務(wù)開(kāi)始。一個(gè)開(kāi)端任務(wù)已建立在這一系統(tǒng),這系統(tǒng)主要負(fù)責(zé)初始化和啟動(dòng)的時(shí)鐘,開(kāi)辦中斷,通信任務(wù)模塊的初始化,以及任務(wù)分工等。為了完成實(shí)時(shí)多任務(wù)系統(tǒng)的多種職能那個(gè)任務(wù)必須被劃分。
圖6顯示系統(tǒng)軟件的功能任務(wù)。根據(jù)任務(wù)的重要性和實(shí)時(shí)要求,系統(tǒng)的應(yīng)用曾劃分為六個(gè)不同優(yōu)先級(jí)的任務(wù),其中包括A / D數(shù)據(jù)采集任務(wù),系統(tǒng)監(jiān)控,接受隊(duì)列,數(shù)據(jù)傳送,鍵盤(pán)輸入,液晶顯示屏顯示。A / D數(shù)據(jù)采集任務(wù)要求最高的實(shí)時(shí)要求和液晶顯示器顯示任務(wù)是最低的。因?yàn)槊總€(gè)任務(wù)都有不同的優(yōu)先事項(xiàng),通過(guò)使用系統(tǒng)掛斷功能或延遲功能更高的優(yōu)先任務(wù)可以開(kāi)始已經(jīng)準(zhǔn)備好的任務(wù)。
圖7顯示的是AD7715的數(shù)據(jù)轉(zhuǎn)換流。A / D轉(zhuǎn)換器的應(yīng)用是數(shù)據(jù)采集系統(tǒng)的一個(gè)重要組成部分。在uS/ OS的第二代實(shí)時(shí)操作系統(tǒng)的核心中,A / D驅(qū)動(dòng)程序的實(shí)現(xiàn)過(guò)程主要取決于A / D轉(zhuǎn)換器的轉(zhuǎn)換時(shí)間,有轉(zhuǎn)換價(jià)值的模擬頻率,輸入通
道的數(shù)量,轉(zhuǎn)換頻率等等。典型的A / D轉(zhuǎn)換電路由模擬復(fù)用器(復(fù)用器),放大器和模擬到數(shù)字轉(zhuǎn)換器(ADC)組成。
圖8顯示了申請(qǐng)程序轉(zhuǎn)移的驅(qū)動(dòng)程序。驅(qū)動(dòng)程序可以在模擬通道讀取由復(fù)用器,那么幾微秒的延遲,以便使信號(hào)通過(guò)多路開(kāi)關(guān),并使其穩(wěn)定。然后,當(dāng)轉(zhuǎn)換開(kāi)始時(shí),ADC被觸發(fā),并且驅(qū)動(dòng)程序在一個(gè)周期內(nèi)等待ADC的觸發(fā),直到完成轉(zhuǎn)換。當(dāng)?shù)却倪M(jìn)展,該驅(qū)動(dòng)程序檢測(cè)ADC的狀態(tài)信號(hào)。如果等待時(shí)間比規(guī)定的時(shí)間越長(zhǎng),周期應(yīng)該結(jié)束。在等待的周期時(shí)間,如果轉(zhuǎn)換完成ADC的信號(hào)被檢測(cè)到,驅(qū)動(dòng)程序應(yīng)改為轉(zhuǎn)換的結(jié)果,然后將結(jié)果返回給應(yīng)用程序。
圖9顯示了緩沖區(qū)和信號(hào)量的序列接收?qǐng)D。由于外圍串行設(shè)備的存在CPU的運(yùn)行速度匹配,一個(gè)緩沖區(qū)是必要的,當(dāng)數(shù)據(jù)發(fā)送到序列,它必須被寫(xiě)入緩沖區(qū),然后通過(guò)串行逐一地被發(fā)送出去。當(dāng)從串行端口收到數(shù)據(jù),這些數(shù)據(jù)將不會(huì)被處理直到收到一些字節(jié),因此先前的數(shù)據(jù)可以存儲(chǔ)在緩沖區(qū)中。在實(shí)踐中,兩個(gè)緩沖區(qū),一個(gè)接收緩沖區(qū)和一個(gè)發(fā)送緩沖區(qū),它們是需要從內(nèi)存開(kāi)放出來(lái)。在這里緩沖區(qū)像循環(huán)隊(duì)列數(shù)據(jù)結(jié)構(gòu)一樣被定義。
由于uC/OS-II提供額外時(shí)間等待機(jī)制的信號(hào),串口也具有額外的閱讀和寫(xiě)作能力。如果收到的數(shù)據(jù)信號(hào)初值為0,它表示循環(huán)緩沖區(qū)是空的。在中斷收到后,ISR從UART接受緩沖區(qū)中讀到收到的數(shù)據(jù),并投入接收緩沖區(qū)域,最后通過(guò)收到的數(shù)據(jù)開(kāi)始用戶執(zhí)行讀操作的的任務(wù)。在整個(gè)過(guò)程中,變量?jī)r(jià)值目前字節(jié)在存儲(chǔ)緩沖區(qū)中的字節(jié)的變量值是可以被詢問(wèn)的,這能夠表明接收緩沖區(qū)是否已滿。為了降低數(shù)據(jù)丟失的可能性和避免浪費(fèi)存儲(chǔ)空間應(yīng)合理地設(shè)置緩沖區(qū)的大小。
結(jié)論
隨著工業(yè)過(guò)程控制領(lǐng)域的快速發(fā)展和網(wǎng)絡(luò),智能,數(shù)字化分布式控制系統(tǒng)廣泛應(yīng)用,有必要發(fā)展對(duì)數(shù)據(jù)準(zhǔn)確性和控制可靠性要求更高的系統(tǒng)。由于較差的實(shí)時(shí)性和可靠性基于單片機(jī)數(shù)據(jù)采集系統(tǒng)已逐步被淘汰。隨著嵌入式ARM處理器的迅速普及,ARM處理器替代單芯片實(shí)現(xiàn)數(shù)據(jù)采集與控制成為了一種新的趨勢(shì)。嵌入式ARM系統(tǒng)能夠適應(yīng)數(shù)據(jù)采集系統(tǒng)的嚴(yán)格要求,如功能,可靠性,成本,大小,耗電量等等。
在本文中一種基于ARM的嵌入式遠(yuǎn)程I / O數(shù)據(jù)采集系統(tǒng)已被研究和開(kāi)發(fā),其硬件平臺(tái)采用32位嵌入式ARM處理器和軟件平臺(tái)的使用開(kāi)源的RTOS uS/ OS-Ⅱ核心。該系統(tǒng)可廣泛應(yīng)用于電力,石油,化工,冶金,鋼鐵,交通運(yùn)輸?shù)确矫妗_@是主要用于收集和監(jiān)測(cè)各種電氣和熱信號(hào),如電壓,電流,熱電阻,生產(chǎn)過(guò)程中的熱電偶數(shù)據(jù)。然后通過(guò)RS485或以太網(wǎng)接口將這些數(shù)據(jù)發(fā)送到遠(yuǎn)程的DAS,DCS控制系統(tǒng)的監(jiān)測(cè)系統(tǒng)。該系統(tǒng)具有雙冗余網(wǎng)絡(luò)和長(zhǎng)途通信功能,它可以確保干擾抑制和通信網(wǎng)絡(luò)的可靠性。
第二篇:基于嵌入式ARM平臺(tái)的遠(yuǎn)程I O數(shù)據(jù)采集系統(tǒng)的研究和開(kāi)發(fā)
蘇州大學(xué)本科生畢業(yè)設(shè)計(jì)(論文)
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
蘇州大學(xué)本科生畢業(yè)設(shè)計(jì)(論文)
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
蘇州大學(xué)本科生畢業(yè)設(shè)計(jì)(論文)
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
蘇州大學(xué)本科生畢業(yè)設(shè)計(jì)(論文)
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.蘇州大學(xué)本科生畢業(yè)設(shè)計(jì)(論文)
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.蘇州大學(xué)本科生畢業(yè)設(shè)計(jì)(論文)
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.蘇州大學(xué)本科生畢業(yè)設(shè)計(jì)(論文)
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.蘇州大學(xué)本科生畢業(yè)設(shè)計(jì)(論文)
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).蘇州大學(xué)本科生畢業(yè)設(shè)計(jì)(論文)
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.蘇州大學(xué)本科生畢業(yè)設(shè)計(jì)(論文)
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
蘇州大學(xué)本科生畢業(yè)設(shè)計(jì)(論文)
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.蘇州大學(xué)本科生畢業(yè)設(shè)計(jì)(論文)
基于嵌入式ARM平臺(tái)的遠(yuǎn)程I / O數(shù)據(jù)采集系統(tǒng)的研究和開(kāi)發(fā)
導(dǎo)言
隨著網(wǎng)絡(luò)化,智能化,數(shù)字化分布式控制系統(tǒng)的廣泛使用,基于單芯片的數(shù)據(jù)采集系統(tǒng)不僅在處理能力上受限制,并且在實(shí)時(shí)性和可靠性方面也出現(xiàn)了問(wèn)題。近幾年來(lái),隨著工業(yè)過(guò)程控制領(lǐng)域的迅速發(fā)展和嵌入式ARM處理器的迅速普及,ARM處理器代替單芯片實(shí)現(xiàn)數(shù)據(jù)的采集和控制成為了趨勢(shì)。嵌入式ARM系統(tǒng)能適應(yīng)數(shù)據(jù)采集系統(tǒng)的嚴(yán)格要求,如功能性,可靠性,成本,體積,功耗等等。
在本文中提出一種新型的基于ARM嵌入式平臺(tái)的遠(yuǎn)程I / O數(shù)據(jù)采集系統(tǒng)已被研制開(kāi)發(fā),它可以衡量各種電氣和熱參數(shù),如電壓,電流,熱電偶,熱電阻等等。那個(gè)測(cè)量數(shù)據(jù)可以顯示在液晶顯示器的系統(tǒng)中,同時(shí)可通過(guò)使用Modbus / RTU或的Modbus / TCP協(xié)議從RS485或以太網(wǎng)網(wǎng)絡(luò)傳送到DAS或DCS遠(yuǎn)程監(jiān)控系統(tǒng)。該系統(tǒng)具有雙冗余網(wǎng)絡(luò)和長(zhǎng)途電通信功能,它可以確保通信網(wǎng)絡(luò)的干擾抑制能力和可靠性?;诟咝阅芮度胧紸RM微處理器的新一代遠(yuǎn)程數(shù)據(jù)采集和監(jiān)控系統(tǒng)具有重要的應(yīng)用意義。
整個(gè)系統(tǒng)的結(jié)構(gòu)設(shè)計(jì)
基于嵌入式ARM的平臺(tái)的遠(yuǎn)程數(shù)據(jù)采集和監(jiān)控系統(tǒng)的整個(gè)結(jié)構(gòu)圖在以下的圖1中展示。在這系統(tǒng)的計(jì)劃中,通過(guò)使用廣泛用于多種行業(yè)如電氣電力,石油,化工,冶金,鋼鐵,運(yùn)輸?shù)鹊那度胧紸RM處理器來(lái)開(kāi)發(fā)遠(yuǎn)程I / O數(shù)據(jù)采集模塊。該系統(tǒng)主要用于的集中采購(gòu)和將各種電和熱信號(hào)如電壓,熱電阻,熱電偶在生產(chǎn)過(guò)程中進(jìn)行數(shù)字轉(zhuǎn)換。轉(zhuǎn)換的數(shù)據(jù)可直接在液晶顯示器上顯示,也可以通過(guò)使用的Modbus / RTU或的Modbus / TCP協(xié)議的RS485總線或以太網(wǎng)網(wǎng)絡(luò)通信接口被發(fā)送到嵌入式控制器。嵌入控制器平臺(tái)的數(shù)據(jù)通過(guò)進(jìn)一步以太網(wǎng)的分析和處理被傳送至遠(yuǎn)程監(jiān)控中心的工作站。與此同時(shí),這些數(shù)據(jù)可以存儲(chǔ)在遠(yuǎn)程監(jiān)控中心數(shù)據(jù)庫(kù)服務(wù)器的實(shí)時(shí)數(shù)據(jù)庫(kù)中。該系統(tǒng)具有雙冗余網(wǎng)絡(luò)和遠(yuǎn)程通訊功能,它可以確保通信網(wǎng)絡(luò)的干擾抑制能力和可靠性。
基于嵌入式ARM遠(yuǎn)程I / O數(shù)據(jù)采集系統(tǒng)的硬件平臺(tái)使用32位ARM嵌入式微處理器和軟件平臺(tái)使用的是開(kāi)源的并且可移植,削減和鞏固的實(shí)時(shí)多任務(wù)操作系統(tǒng)的第二代UC / OS核心。實(shí)時(shí)操作系統(tǒng)(RTOS)使設(shè)計(jì)和應(yīng)用的擴(kuò)大變得非常容易,增加新的功能時(shí)也沒(méi)多大變化。通過(guò)幾個(gè)獨(dú)立的任務(wù)的應(yīng)用,實(shí)時(shí)操作系統(tǒng)使得應(yīng)用的設(shè)計(jì)過(guò)程極為簡(jiǎn)單。
蘇州大學(xué)本科生畢業(yè)設(shè)計(jì)(論文)
系統(tǒng)的硬件設(shè)計(jì)
基于嵌入式ARM平臺(tái)的遠(yuǎn)程I / O數(shù)據(jù)采集系統(tǒng)具有很高的普遍性,每個(gè)購(gòu)置設(shè)備配備24收購(gòu)方式的I / O渠道且彼此孤立。每個(gè)I / O通道可以選擇不同的電壓和電流信號(hào),以及溫度信號(hào)如熱電阻,熱電偶等。在05V的,010毫安和4100TL智能嵌入式以太網(wǎng)串口轉(zhuǎn)換模塊。該ZNE500mV的電壓信號(hào)可以直接接到模擬多路復(fù)用器(復(fù)用器)的INPx正極和INNx負(fù)極。45V的電壓信號(hào)必須用阻抗轉(zhuǎn)換。熱電阻的電阻信號(hào)如Cu50,Cu100,Pt50和Pt100應(yīng)在接到某些頻道的復(fù)用器INPx正極和INNx負(fù)極前連接一1毫安的恒流源。
圖4顯示了使用16位ADC芯片AD7715的ADC信號(hào)電路。芯片與系統(tǒng)的連接非常簡(jiǎn)單,只需要CS(芯片選擇),SLCK(系統(tǒng)時(shí)鐘),DIN(數(shù)據(jù)輸入),DOUT(數(shù)據(jù)輸出)和DRDY(數(shù)據(jù)準(zhǔn)備)5根線。
由于ARM微處理器具有高速,低功耗,低電壓等優(yōu)點(diǎn),這使它在低噪音,紋波權(quán)力,瞬態(tài)響應(yīng)性能,時(shí)鐘來(lái)源的穩(wěn)定,功率控制和許多其他方面需要有更高的要求。為了改善系統(tǒng)的可靠性該系統(tǒng)復(fù)位電路中使用特殊的微處理器電源監(jiān)測(cè)芯片MAX708S。圖5展示了該系統(tǒng)復(fù)位電路。
系統(tǒng)軟件的設(shè)計(jì)與實(shí)現(xiàn)
蘇州大學(xué)本科生畢業(yè)設(shè)計(jì)(論文)
基于嵌入式ARM平臺(tái)的遠(yuǎn)程I / O數(shù)據(jù)采集系統(tǒng)的軟件使用的是開(kāi)源的并且可移植,削減和鞏固的實(shí)時(shí)多任務(wù)操作系統(tǒng)的第二代UC / OS核心。RTOS的關(guān)鍵部分是實(shí)時(shí)多任務(wù)的核心,其基本功能包括任務(wù)管理,資源管理,系統(tǒng)管理,計(jì)時(shí)器管理,內(nèi)存管理,信息管理,隊(duì)列管理等。通過(guò)API服務(wù)職能核心使用這些功能。
該系統(tǒng)軟件平臺(tái)使用的是單一化的uC/ OS第二代實(shí)時(shí)簡(jiǎn)化操作系統(tǒng)核心,使整個(gè)結(jié)構(gòu)系統(tǒng)簡(jiǎn)單和應(yīng)用層次復(fù)雜。整個(gè)系統(tǒng)的設(shè)計(jì)包括操作系統(tǒng)的任務(wù)和一系列的用戶應(yīng)用程序。系統(tǒng)的主要職能是實(shí)現(xiàn)系統(tǒng)硬件和操作系統(tǒng)的初始化。硬件初始化包括中斷,鍵盤(pán),液晶顯示器等。操作系統(tǒng)初始化包括控制模塊和事件控制,在多任務(wù)調(diào)度前,至少有一個(gè)任務(wù)開(kāi)始。一個(gè)開(kāi)端任務(wù)已建立在這一系統(tǒng),這系統(tǒng)主要負(fù)責(zé)初始化和啟動(dòng)的時(shí)鐘,開(kāi)辦中斷,通信任務(wù)模塊的初始化,以及任務(wù)分工等。為了完成實(shí)時(shí)多任務(wù)系統(tǒng)的多種職能那個(gè)任務(wù)必須被劃分。
圖6顯示系統(tǒng)軟件的功能任務(wù)。根據(jù)任務(wù)的重要性和實(shí)時(shí)要求,系統(tǒng)的應(yīng)用曾劃分為六個(gè)不同優(yōu)先級(jí)的任務(wù),其中包括A / D數(shù)據(jù)采集任務(wù),系統(tǒng)監(jiān)控,接受隊(duì)列,數(shù)據(jù)傳送,鍵盤(pán)輸入,液晶顯示屏顯示。A / D數(shù)據(jù)采集任務(wù)要求最高的實(shí)時(shí)要求和液晶顯示器顯示任務(wù)是最低的。因?yàn)槊總€(gè)任務(wù)都有不同的優(yōu)先事項(xiàng),通過(guò)使用系統(tǒng)掛斷功能或延遲功能更高的優(yōu)先任務(wù)可以開(kāi)始已經(jīng)準(zhǔn)備好的任務(wù)。
圖7顯示的是AD7715的數(shù)據(jù)轉(zhuǎn)換流。A / D轉(zhuǎn)換器的應(yīng)用是數(shù)據(jù)采集系統(tǒng)的一個(gè)重要組成部分。在uS/ OS的第二代實(shí)時(shí)操作系統(tǒng)的核心中,A / D驅(qū)動(dòng)程序的實(shí)現(xiàn)過(guò)程主要取決于A / D轉(zhuǎn)換器的轉(zhuǎn)換時(shí)間,有轉(zhuǎn)換價(jià)值的模擬頻率,輸入通道的數(shù)量,轉(zhuǎn)換頻率等等。典型的A / D轉(zhuǎn)換電路由模擬復(fù)用器(復(fù)用器),放大器和模擬到數(shù)字轉(zhuǎn)換器(ADC)組成。
圖8顯示了申請(qǐng)程序轉(zhuǎn)移的驅(qū)動(dòng)程序。驅(qū)動(dòng)程序可以在模擬通道讀取由復(fù)用器,那么幾微秒的延遲,以便使信號(hào)通過(guò)多路開(kāi)關(guān),并使其穩(wěn)定。然后,當(dāng)轉(zhuǎn)換開(kāi)始時(shí),ADC被觸發(fā),并且驅(qū)動(dòng)程序在一個(gè)周期內(nèi)等待ADC的觸發(fā),直到完成轉(zhuǎn)換。當(dāng)?shù)却倪M(jìn)展,該驅(qū)動(dòng)程序檢測(cè)ADC的狀態(tài)信號(hào)。如果等待時(shí)間比規(guī)定的時(shí)間越長(zhǎng),周期應(yīng)該結(jié)束。在等待的周期時(shí)間,如果轉(zhuǎn)換完成ADC的信號(hào)被檢測(cè)到,驅(qū)動(dòng)程序應(yīng)改為轉(zhuǎn)換的結(jié)果,然后將結(jié)果返回給應(yīng)用程序。
圖9顯示了緩沖區(qū)和信號(hào)量的序列接收?qǐng)D。由于外圍串行設(shè)備的存在CPU的運(yùn)行速度匹配,一個(gè)緩沖區(qū)是必要的,當(dāng)數(shù)據(jù)發(fā)送到序列,它必須被寫(xiě)入緩沖區(qū),然后通過(guò)串行逐一地被發(fā)送出去。當(dāng)從串行端口收到數(shù)據(jù),這些數(shù)據(jù)將不會(huì)被處理直到收到一些字節(jié),因此先前的數(shù)據(jù)可以存儲(chǔ)在緩沖區(qū)中。在實(shí)踐中,兩個(gè)緩沖區(qū),一個(gè)接收緩沖區(qū)和一個(gè)發(fā)送緩沖區(qū),它們是需要從內(nèi)存開(kāi)放出來(lái)。在這里緩沖區(qū)像循環(huán)隊(duì)列數(shù)據(jù)結(jié)構(gòu)一樣被定義。
由于uC/OS-II提供額外時(shí)間等待機(jī)制的信號(hào),串口也具有額外的閱讀和寫(xiě)作能力。如
蘇州大學(xué)本科生畢業(yè)設(shè)計(jì)(論文)
果收到的數(shù)據(jù)信號(hào)初值為0,它表示循環(huán)緩沖區(qū)是空的。在中斷收到后,ISR從UART接受緩沖區(qū)中讀到收到的數(shù)據(jù),并投入接收緩沖區(qū)域,最后通過(guò)收到的數(shù)據(jù)開(kāi)始用戶執(zhí)行讀操作的的任務(wù)。在整個(gè)過(guò)程中,變量?jī)r(jià)值目前字節(jié)在存儲(chǔ)緩沖區(qū)中的字節(jié)的變量值是可以被詢問(wèn)的,這能夠表明接收緩沖區(qū)是否已滿。為了降低數(shù)據(jù)丟失的可能性和避免浪費(fèi)存儲(chǔ)空間應(yīng)合理地設(shè)置緩沖區(qū)的大小。
結(jié)論
隨著工業(yè)過(guò)程控制領(lǐng)域的快速發(fā)展和網(wǎng)絡(luò),智能,數(shù)字化分布式控制系統(tǒng)廣泛應(yīng)用,有必要發(fā)展對(duì)數(shù)據(jù)準(zhǔn)確性和控制可靠性要求更高的系統(tǒng)。由于較差的實(shí)時(shí)性和可靠性基于單片機(jī)數(shù)據(jù)采集系統(tǒng)已逐步被淘汰。隨著嵌入式ARM處理器的迅速普及,ARM處理器替代單芯片實(shí)現(xiàn)數(shù)據(jù)采集與控制成為了一種新的趨勢(shì)。嵌入式ARM系統(tǒng)能夠適應(yīng)數(shù)據(jù)采集系統(tǒng)的嚴(yán)格要求,如功能,可靠性,成本,大小,耗電量等等。
在本文中一種基于ARM的嵌入式遠(yuǎn)程I / O數(shù)據(jù)采集系統(tǒng)已被研究和開(kāi)發(fā),其硬件平臺(tái)采用32位嵌入式ARM處理器和軟件平臺(tái)的使用開(kāi)源的RTOS uS/ OS-Ⅱ核心。該系統(tǒng)可廣泛應(yīng)用于電力,石油,化工,冶金,鋼鐵,交通運(yùn)輸?shù)确矫妗_@是主要用于收集和監(jiān)測(cè)各種電氣和熱信號(hào),如電壓,電流,熱電阻,生產(chǎn)過(guò)程中的熱電偶數(shù)據(jù)。然后通過(guò)RS485或以太網(wǎng)接口將這些數(shù)據(jù)發(fā)送到遠(yuǎn)程的DAS,DCS控制系統(tǒng)的監(jiān)測(cè)系統(tǒng)。該系統(tǒng)具有雙冗余網(wǎng)絡(luò)和長(zhǎng)途通信功能,它可以確保干擾抑制和通信網(wǎng)絡(luò)的可靠性。
第三篇:基于嵌入式ARM的遠(yuǎn)程視頻監(jiān)控系統(tǒng)研究.
基于嵌入式ARM的遠(yuǎn)程視頻監(jiān)控系統(tǒng)研究
隨著科技的進(jìn)步,視頻監(jiān)控系統(tǒng)正在向嵌入式、數(shù)字化、網(wǎng)絡(luò)化方向發(fā)展。嵌入式視頻監(jiān)控系統(tǒng)充分利用大規(guī)模集成電路和網(wǎng)絡(luò)的科技成果,實(shí)現(xiàn)了體積小巧、性能穩(wěn)定、通訊便利的監(jiān)控產(chǎn)品。本文以S3C2410為核心硬件平臺(tái)開(kāi)發(fā)了基于嵌入式的遠(yuǎn)程視頻監(jiān)控系統(tǒng),并對(duì)關(guān)鍵技術(shù)進(jìn)行了論述和研究。首先給出了系統(tǒng)總體軟硬件設(shè)計(jì)方案,針對(duì)本系統(tǒng)硬件對(duì)vivi進(jìn)行了修改和移植,對(duì)編譯和移植Linux內(nèi)核以及制作YAFFS文件系統(tǒng)也做了深入的研究,重點(diǎn)討論了在嵌入式Linux操作系統(tǒng)下開(kāi)發(fā)USB接口攝像頭驅(qū)動(dòng)程序和利用linux提供的Video4Linux API函數(shù)實(shí)現(xiàn)視頻數(shù)據(jù)采集,其次采用背景差法實(shí)現(xiàn)了對(duì)視頻圖像中運(yùn)動(dòng)目標(biāo)的檢測(cè),然后通過(guò)MJPEG壓縮算法實(shí)現(xiàn)了視頻數(shù)據(jù)壓縮,接著介紹了在Linux下基于TCP/IP協(xié)議的socket編程,實(shí)現(xiàn)了視頻數(shù)據(jù)的網(wǎng)絡(luò)發(fā)送。最后著重論述了嵌入式Web服務(wù)器的設(shè)計(jì),編寫(xiě)了視頻監(jiān)控主界面程序,并實(shí)現(xiàn)了基于B/S模式的視頻監(jiān)控系統(tǒng)結(jié)構(gòu)。本系統(tǒng)采用模塊化設(shè)計(jì)方法,使得設(shè)計(jì)更加簡(jiǎn)潔、高效,具有良好的擴(kuò)展性和易用性,有利于系統(tǒng)升級(jí)。另外采用嵌入式的方法,系統(tǒng)成本較低,易于推廣使用。
【關(guān)鍵詞相關(guān)文檔搜索】: 控制理論與控制工程;ARM;嵌入式Linux;USB攝像頭;Video4Linux;嵌入式Web服務(wù)器
【作者相關(guān)信息搜索】: 南京理工大學(xué);控制理論與控制工程;陳青林;李保國(guó);
第四篇:嵌入式生產(chǎn)數(shù)據(jù)采集系統(tǒng)研究論文
摘要:當(dāng)今社會(huì),科學(xué)技術(shù)不斷發(fā)展,不斷改變,不斷創(chuàng)新,同一個(gè)行業(yè)的企業(yè)之間的競(jìng)爭(zhēng)也越來(lái)越激烈。在如此強(qiáng)烈的競(jìng)爭(zhēng)環(huán)境下,企業(yè)如果想要獲得更多的利益,想要有更好的社會(huì)地位,就必須不斷改革創(chuàng)新,獲得先進(jìn)的科學(xué)技術(shù),將先進(jìn)技術(shù)應(yīng)用到企業(yè)的各個(gè)方面。企業(yè)建立相應(yīng)的管理部門(mén),對(duì)技術(shù)人員進(jìn)行管理,讓企業(yè)的生產(chǎn)能夠順利開(kāi)展。
關(guān)鍵詞:RFID的嵌入式;生產(chǎn)數(shù)據(jù)采集;研究與設(shè)計(jì)
一、對(duì)RFID技術(shù)的理解
RFID技術(shù)就是一種自動(dòng)識(shí)別技術(shù),讀寫(xiě)器和電子標(biāo)簽是基本部件,不管是好的環(huán)境還是壞的的環(huán)境都能夠使用RFID技術(shù),而且不用很多人都看著這個(gè)技術(shù)進(jìn)行,甚至都不用人工操作這項(xiàng)技術(shù)。RFID技術(shù)的識(shí)別速度非常快,操作起來(lái)也不難,每個(gè)步驟都很容易操作,而且RFID技術(shù)的應(yīng)用也越來(lái)越廣泛,成本不斷降低,能夠被大部分人接受這個(gè)價(jià)格。RFID技術(shù)的使用壽命相對(duì)于其它的技術(shù)來(lái)講也比較長(zhǎng),不僅減少了資源的浪費(fèi),而且也為企業(yè)帶來(lái)了更多的利益。
二、數(shù)據(jù)采集終端硬件的主體設(shè)計(jì)
(一)電源電路。在設(shè)備運(yùn)行過(guò)程中,一般情況下,工作電壓是1。8伏特,和其他的設(shè)備不太一樣,數(shù)字電源和模擬電源之間有什么不一樣,該設(shè)備就不能準(zhǔn)確的識(shí)別出來(lái)。在實(shí)際應(yīng)用過(guò)程中,要多設(shè)計(jì)幾條電路線,很有可能會(huì)出現(xiàn)多種應(yīng)用電源的情況,也要應(yīng)對(duì)一些突發(fā)事件,避免出現(xiàn)突發(fā)事件的時(shí)候,手忙腳亂,以至于連最基本的問(wèn)題都無(wú)法順利解決。電源電路多線路的設(shè)計(jì)特點(diǎn),提高了生產(chǎn)的質(zhì)量,也促進(jìn)了企業(yè)的發(fā)展[1]。
(二)系統(tǒng)時(shí)鐘電路。在實(shí)際應(yīng)用數(shù)據(jù)采集系統(tǒng)的時(shí)候,要合理的利用LPC2210ARM7微控器,在使用過(guò)程中,可以通過(guò)兩種不同的電路進(jìn)行合理的使用,一種是外部晶振電路,還有一種是外部時(shí)鐘源電路,而且內(nèi)部的電路還是可以調(diào)節(jié)的,以便提高設(shè)備的運(yùn)行速度,運(yùn)行速度也是有限制的,最大的不能超過(guò)60赫茲。在使用系統(tǒng)時(shí)鐘電路的時(shí)候,要嚴(yán)格按照要求進(jìn)行生產(chǎn)數(shù)據(jù)的采集。
(三)建立復(fù)位電路。復(fù)位電路芯片的選擇十分重要,任何的選擇都可能影響企業(yè)的日常運(yùn)行操作,供電電壓要保持在一定的范圍內(nèi),不要太低,也不要太高,保持在正常的范圍內(nèi)就行[2]。復(fù)位電路的電壓最高是2.93伏特,如果超過(guò)2.93伏特,就不能正常進(jìn)行,要是想要正常的運(yùn)行設(shè)備,必須嚴(yán)格控制電壓,只有電壓低于2.93伏特的時(shí)候,設(shè)備才能正常的運(yùn)行。
三、數(shù)據(jù)采集終端的外圍設(shè)計(jì)
(一)圖形液晶模塊接口的電路設(shè)計(jì)。這類電路設(shè)計(jì)主要應(yīng)用的是點(diǎn)陣圖形,最大的優(yōu)點(diǎn)就是可以容闊其他的模塊。使用點(diǎn)陣圖形液晶模塊接口的電路設(shè)計(jì)時(shí),如果輸入正確的指令,在點(diǎn)陣圖形模塊中就可能同時(shí)出現(xiàn)中文和英文。而且點(diǎn)陣圖形模塊接口的電路設(shè)計(jì)可以降低設(shè)備的操作難度,符合大眾的需求,讓幾乎每一個(gè)人都能體會(huì)到該設(shè)計(jì)的應(yīng)用。
(二)鍵盤(pán)輸入電路設(shè)計(jì)。一般的工作都會(huì)應(yīng)用到電腦,用電腦就會(huì)用到鍵盤(pán),每一個(gè)技術(shù)人員對(duì)于電腦鍵盤(pán)的操作都不陌生,可以用鍵盤(pán)輸入數(shù)據(jù),統(tǒng)計(jì)數(shù)據(jù),制作數(shù)據(jù)報(bào)表,計(jì)算工程利益預(yù)估的價(jià)格等,這就是人和機(jī)器很好結(jié)合的表現(xiàn)。在設(shè)計(jì)電路的時(shí)候,鍵盤(pán)輸入電路的設(shè)計(jì)最為普遍,很多人能夠充分的了解該項(xiàng)設(shè)計(jì)內(nèi)容,也能很好的接受鍵盤(pán)輸入電路設(shè)計(jì),并且應(yīng)用到實(shí)際的工作生產(chǎn)過(guò)程中。而且現(xiàn)在學(xué)校中計(jì)算機(jī)的教育會(huì)先教學(xué)生使用鍵盤(pán),隨著人們不斷的學(xué)習(xí),鍵盤(pán)的使用已經(jīng)扎根在人們的腦子里了。
四、結(jié)語(yǔ)
目前,我國(guó)的經(jīng)濟(jì)發(fā)展非??欤舶l(fā)展的非常好,生產(chǎn)數(shù)據(jù)的采集還有很多不足之處,需要各個(gè)企業(yè)不斷改革創(chuàng)新,爭(zhēng)取建立最適合我國(guó)經(jīng)濟(jì)發(fā)展的生產(chǎn)數(shù)據(jù)采集系統(tǒng)。各個(gè)企業(yè)的設(shè)計(jì)部門(mén)應(yīng)該在現(xiàn)有電路設(shè)計(jì)的基礎(chǔ)上不斷完善電路設(shè)計(jì)內(nèi)容,相關(guān)技術(shù)人員對(duì)于所使用的電路設(shè)計(jì)也要熟練的掌握其基本要領(lǐng)。在當(dāng)今社會(huì)中,通過(guò)解決工作過(guò)程中不斷出現(xiàn)的一個(gè)又一個(gè)的問(wèn)題,不斷完善電路設(shè)計(jì)。企業(yè)也要經(jīng)常召開(kāi)會(huì)議,對(duì)于技術(shù)的改革創(chuàng)新進(jìn)行不斷探討。在實(shí)際生產(chǎn)過(guò)程中,企業(yè)要建立相關(guān)的部門(mén),專門(mén)負(fù)責(zé)生產(chǎn)過(guò)程中的設(shè)計(jì)問(wèn)題,如果出現(xiàn)什么問(wèn)題,要及時(shí)的解決問(wèn)題,不要累積問(wèn)題,讓問(wèn)題的危害擴(kuò)大。企業(yè)的相關(guān)部門(mén)也要對(duì)技術(shù)人員進(jìn)行培訓(xùn),很多技術(shù)在不斷改革創(chuàng)新,就需要專業(yè)的技術(shù)人員對(duì)新技術(shù)做到熟悉了解,能夠把新技術(shù)熟練的應(yīng)用到生產(chǎn)過(guò)程中,推動(dòng)企業(yè)的發(fā)展,避免企業(yè)在社會(huì)日益發(fā)展的潮流中被淘汰下去。
參考文獻(xiàn)
[1]張開(kāi)生,石瑞華,薛楊。基于RFID技術(shù)的服裝生產(chǎn)過(guò)程管理系統(tǒng)設(shè)計(jì)[J]。單片機(jī)與嵌入式系統(tǒng)應(yīng)用,2018,18(04):43—48。
[2]嘉丹丹,蔣高明,叢洪蓮,吳志明,焦洋。應(yīng)用ZigBee技術(shù)的緯編生產(chǎn)數(shù)據(jù)實(shí)時(shí)采集系統(tǒng)[J]。紡織學(xué)報(bào),2016,37(12):129—133。
第五篇:基于ARM嵌入式的遠(yuǎn)程監(jiān)控系統(tǒng)設(shè)計(jì)
基于ARM嵌入式的遠(yuǎn)程監(jiān)控系統(tǒng)設(shè)計(jì)
摘要:基于ARM 內(nèi)核的嵌入式系統(tǒng)在遠(yuǎn)程監(jiān)控報(bào)警系統(tǒng)中的設(shè)計(jì)實(shí)現(xiàn)與應(yīng)用。核心部分主要包 括 ARM 嵌入式平臺(tái)設(shè)計(jì)及 μC-OS 嵌入式實(shí)時(shí)操作系統(tǒng)移植;人機(jī)交互界面 μCGUI 的設(shè)計(jì)與實(shí)現(xiàn);遠(yuǎn)程通訊及自動(dòng)報(bào)警等;系統(tǒng)的設(shè)計(jì)還考慮到了擴(kuò)展性和通用性以及與其他監(jiān)控設(shè)備無(wú)縫連接等問(wèn)題。
關(guān)鍵詞: ARM;μC/OS-II;μCGUI;遠(yuǎn)程監(jiān)控 引言
監(jiān)控系統(tǒng)現(xiàn)已成為現(xiàn)代化生產(chǎn)、生活中不可缺少的重要組成部分。目前,監(jiān)控系列產(chǎn)品 種類繁多,大部分廣泛應(yīng)用于交通、醫(yī)院、銀行、家居、學(xué)校等安防領(lǐng)域。
隨著嵌入式系統(tǒng)的出現(xiàn),尤其是基于 ARM 內(nèi)核芯片的嵌入式系統(tǒng)的出現(xiàn),使得監(jiān)控系統(tǒng)的應(yīng)用領(lǐng)域更為廣泛。本文設(shè)計(jì)的遠(yuǎn)程監(jiān)控報(bào)警系統(tǒng)除了作為安防功能外,還可以應(yīng)用于以下領(lǐng)域:通訊領(lǐng)域:遠(yuǎn)程通訊、視頻會(huì)議和視頻點(diǎn)播、證券、遠(yuǎn)程教育等。醫(yī)療領(lǐng)域:病房監(jiān)護(hù)、遠(yuǎn)程診斷等。工業(yè)領(lǐng)域:遠(yuǎn)程設(shè)備診斷、維護(hù)、維修,遠(yuǎn)程生產(chǎn)監(jiān)控等。家用領(lǐng)域:家用電器遠(yuǎn)程維護(hù);電、氣、火等重大事故自動(dòng)報(bào)警等。
系統(tǒng)設(shè)計(jì)
2.1系統(tǒng)組成
本文設(shè)計(jì)的遠(yuǎn)程監(jiān)控系統(tǒng)主要由中心控制器、數(shù)據(jù)終端、傳感器模塊、通訊模塊、接口模塊等幾部分組成。系統(tǒng)組成圖(如圖 1)。
2.2中心控制器 系統(tǒng)核心負(fù)責(zé)數(shù)據(jù)采集判斷處理。為了提高系統(tǒng)工作效率,這里使用的是三星公司的 S3C2410芯片作為處理器。S3C2410 芯片是一款高性價(jià)比的 ARM 芯片,非常適合作手機(jī)、PDA 等手持設(shè)備。主要特性包括: ARM920T 內(nèi)核,最高工作頻率 203MHz,LCD 控制器:可直接驅(qū)動(dòng)真彩液晶屏,最高支持 2048×1024 真彩液晶屏,2 個(gè) USB Host端口,1 個(gè)USB Device端口,支持 Nand flash 啟動(dòng)模式,SD 卡接口,UART、IIC、SPI、IIS 等多種類 型串行接口,4 通道DMA。
本文的監(jiān)控系統(tǒng)的 CPU 核心部分使用的是標(biāo)準(zhǔn)的 SO-DIMM200 金手指接口,便于后期維護(hù)和升級(jí)。如果該監(jiān)控系統(tǒng)的使用環(huán)境較為苛刻,可以將 CPU替換為S3C2440芯片。S3C2440完全兼容S3C2410全部特性(注意:芯片引腳不完全兼容)。與S3C2410芯片相比,S3C2440的性能更為優(yōu)越:最高工作頻率可達(dá)500MHz,內(nèi)部集成CMOS攝像頭接口,但價(jià)格較昂貴。
圖1 監(jiān)控系統(tǒng)組成框圖
2.3數(shù)據(jù)終端 數(shù)據(jù)終端的主要功能是對(duì)監(jiān)控?cái)?shù)據(jù)進(jìn)行分析、處理,及時(shí)將數(shù)據(jù)匯報(bào)給監(jiān)控人員。同時(shí),監(jiān)控人員可以根據(jù)現(xiàn)場(chǎng)情況,使用數(shù)據(jù)終端對(duì)監(jiān)控的設(shè)備進(jìn)行遠(yuǎn)程控制。數(shù)據(jù)終端最大優(yōu)勢(shì) 就是安全、可靠、便于攜帶。一般情況下為了節(jié)約成本,可以將手機(jī)、PDA 等移動(dòng)通訊設(shè)備作為數(shù)據(jù)終端使用。但是如果作為對(duì)高危環(huán)境或精密儀器的監(jiān)控系統(tǒng),數(shù)據(jù)終端需要專業(yè)定制。這里使用的是中心控制器的作為數(shù)據(jù)終端,即中心控制器既作為數(shù)據(jù)采集發(fā)送中心,也可數(shù)據(jù)接收處理中心使用。
2.4通訊模塊
通訊模塊主要負(fù)責(zé)遠(yuǎn)程數(shù)據(jù)通訊。帶有 RS232/485、GPRS、CDMA 等一種或多種通訊 方式。需要根據(jù)現(xiàn)場(chǎng)環(huán)境和用戶需要進(jìn)行定制。通訊模塊與控制器通過(guò)接口總線連接,連接 方式為 TTL/RS232/RS485 等。
2.5傳感器模塊
傳感器模塊的主要功能是感知外部環(huán)境,對(duì)外部環(huán)境進(jìn)行實(shí)時(shí)監(jiān)測(cè)。由人體紅外傳感器、振動(dòng)傳感器、超聲波傳感器、可燃?xì)怏w傳感器、溫度傳感器、濕度傳感器等一種或多種傳感 器組成。可根據(jù)現(xiàn)場(chǎng)監(jiān)測(cè)環(huán)境不同進(jìn)行定制。
2.6接口模塊
接口模塊主要作為系統(tǒng)擴(kuò)展功能使用,將控制器的 A/D 轉(zhuǎn)換、I2C、SPI 等多種接口進(jìn)行 外部擴(kuò)展。接口模塊沒(méi)有特定的功能,但可以根據(jù)需要與其他設(shè)備連接,例如可以與工業(yè)儀 器儀表或設(shè)備連接,實(shí)時(shí)對(duì)儀器或設(shè)備進(jìn)行監(jiān)控。
接口模塊雖然不是監(jiān)控系統(tǒng)的主要部分,但是對(duì)于整個(gè)系統(tǒng)來(lái)說(shuō)卻是不可缺少。因?yàn)楸疚牡谋O(jiān)控系統(tǒng)主要考慮到了系統(tǒng)的可擴(kuò)展性和與其它系統(tǒng)無(wú)縫連接。通過(guò)接口模塊可以很方 便的對(duì)監(jiān)控系統(tǒng)進(jìn)行升級(jí),并且可以實(shí)現(xiàn)與其他系統(tǒng)或設(shè)備的無(wú)縫連接。這也是本系統(tǒng)區(qū)優(yōu) 于其他監(jiān)控系統(tǒng)的主要功能。軟件設(shè)計(jì)
3.1工作軟件
系統(tǒng)的軟件設(shè)計(jì)較為復(fù)雜,這里只給出了整個(gè)工作軟件流程(如圖 2)。
圖2 軟件流程圖
3.2操作系統(tǒng)移植
S3C2410 芯片支持多種嵌入式操作系統(tǒng),如 WINCE、uCLinux 等。但考慮到監(jiān)控系統(tǒng) 的實(shí)時(shí)性要求,這里使用的是 μC/OS-II 嵌入式實(shí)時(shí)操作系統(tǒng)。μC/OS-II 是一個(gè)源碼公開(kāi)、可移植、可固化、可裁剪、占先式的實(shí)時(shí)多任務(wù)操作系統(tǒng)。其絕大部分源碼是用 ANSI C 寫(xiě)的。整個(gè)嵌入式系統(tǒng)分為兩大層:硬件層和軟件層。這里主要研究軟件層的架構(gòu)。軟件層主要分為四個(gè)部分:實(shí)時(shí)操作系統(tǒng)內(nèi)核,與處理器相關(guān)部分,與應(yīng)用程序相關(guān)部分,用戶的應(yīng)用程序。移植 μC/OS-II 系統(tǒng)需要修改的文件有:應(yīng)用程序相關(guān)文件: OS_CFG.H INCLUDE.H; 處理器相關(guān)文件: OS_CPU.H、OS_CPU_A.ASM、OS_CPU_C.C。
3.2.1 與處理器相關(guān)的代碼
這是移植中最關(guān)鍵的部分。內(nèi)核將應(yīng)用系統(tǒng)和底層硬件有機(jī)的結(jié)合成一個(gè)實(shí)時(shí)系統(tǒng),要 使同一個(gè)內(nèi)核能適用于不同的硬件體系,就需要在內(nèi)核和硬件之間有一個(gè)中間層,這就是與 處理器相關(guān)的代碼。處理器不同。這部分代碼也不同。我們?cè)谝浦矔r(shí)需要自己移植這部分代 碼。
a)OS_CPU.H
包括了用#define 定義的與處理器相關(guān)的常量,宏和類型定義,有系統(tǒng)數(shù)據(jù)類型定義,棧 增長(zhǎng)方向定義,關(guān)中斷和開(kāi)中斷定義,系統(tǒng)軟中斷的定義等等。
b)OS_CPU_A.ASM
這部分需要對(duì)處理器的寄存器進(jìn)行操作,所以必須用匯編語(yǔ)言來(lái)編寫(xiě)。包括四個(gè)子函數(shù): OSStartHighRdy(),OSCtxSw(),OSIntCtxSw(),OSTickISR()。OSStartHighRdy()在多任務(wù)系統(tǒng)啟動(dòng)函數(shù) OSStart()中調(diào)用。完成的功能是:設(shè)置系統(tǒng)運(yùn)行標(biāo)志位 OSRunning = TRUE;將就緒表中最高優(yōu)先級(jí)任務(wù)的棧指針 Load 到 SP 中,并強(qiáng)制中斷返回。這樣就緒的最高優(yōu)先級(jí)任務(wù)就如同從中斷里返回到運(yùn)行態(tài)一樣,使得整個(gè)系統(tǒng)得以運(yùn)轉(zhuǎn)。OSCtxSw()在任務(wù)級(jí)任 務(wù)切換函數(shù)中調(diào)用的。任務(wù)級(jí)切換是通過(guò) SWI 或者 TRAP 人為制造的中斷來(lái)實(shí)現(xiàn)的。ISR 的向 量地址必須指向 OSCtxSw()。這一中斷完成的功能:保存任務(wù)的環(huán)境變量(主要是寄存器的值, 通過(guò)入棧來(lái)實(shí)現(xiàn)),將當(dāng)前 SP 存入任務(wù) TCB 中,載入就緒最高優(yōu)先級(jí)任務(wù)的 SP,恢復(fù)就緒最高優(yōu)先級(jí)任務(wù)的環(huán)境變量,中斷返回。這樣就完成了任務(wù)級(jí)的切換。OSIntCtxSw()在退出中斷 服務(wù)函數(shù) OSIntExit()中調(diào)用,實(shí)現(xiàn)中斷級(jí)任務(wù)切換.由于是在中斷里調(diào)用,所以處理器的寄存器入棧工作已經(jīng)做完,就不用作這部分工作了。具體完成的任務(wù);調(diào)整棧指針(因?yàn)檎{(diào)用函數(shù)會(huì)使任務(wù)棧結(jié)構(gòu)與系統(tǒng)任務(wù)切換時(shí)堆棧標(biāo)準(zhǔn)結(jié)構(gòu)不一致),保存當(dāng)前任務(wù) SP,載入就緒 最高優(yōu)先級(jí)任務(wù)的 SP,恢復(fù)就緒最高優(yōu)先級(jí)任務(wù)的環(huán)境變量,中斷返回。這樣就完成了中斷級(jí)任務(wù)切換。OSTickISR()系統(tǒng)時(shí)鐘節(jié)拍中斷服務(wù)函數(shù),這是一個(gè)周期性中斷,為內(nèi)核提供
時(shí)鐘節(jié)拍。頻率越高系統(tǒng)負(fù)荷越重。其周期的大小決定了內(nèi)核所能給應(yīng)用系統(tǒng)提供的最小時(shí) 間間隔服務(wù)。一般只限于 ms 級(jí)(跟 MCU 有關(guān)),對(duì)于要求更加苛刻的任務(wù)需要用戶自己建立中斷來(lái)解決.該函數(shù)具體內(nèi)容:保存寄存器(如果硬件自動(dòng)完成就可以省略),調(diào) OSIntEnter(),調(diào)用 OSTimeTick(),調(diào)用 OSIntExit(),恢復(fù)寄存器,中斷返回。
c)OS_CPU_C.C
該文件中共定義了 6 個(gè)函數(shù),但是最重要的是 OSTaskStkInit().其他都是對(duì)系統(tǒng)內(nèi)核的擴(kuò)展 時(shí)用的.OSTaskStkInit()是在用戶建立任務(wù)時(shí)系統(tǒng)內(nèi)部自己調(diào)用的,對(duì)用戶任務(wù)的堆棧進(jìn)行初始化。使建立好的進(jìn)入就緒態(tài)任務(wù)的堆棧與系統(tǒng)發(fā)生中斷并且將環(huán)境變量保存完畢時(shí) 的棧結(jié)構(gòu)一致。這樣就可以用中斷返回指令使就緒的任務(wù)運(yùn)行起來(lái)。
3.2.2與應(yīng)用相關(guān)的代碼
這部分包括兩個(gè)文件:OS_CFG.H, INCLUDES.H。用戶根據(jù)自己的應(yīng)用系統(tǒng)來(lái)定制合適 的內(nèi)核服務(wù)功能。OS_CFG.H 來(lái)配置內(nèi)核,用戶根據(jù)需要對(duì)內(nèi)核進(jìn)行定制,留下需要的部分,去掉不需要的部分,設(shè)置系統(tǒng)的基本情況。比如系統(tǒng)可提供的最大任務(wù)數(shù)量,是否定制郵箱服務(wù),是否需要系統(tǒng)提供任務(wù)掛起功能,是否提供任務(wù)優(yōu)先級(jí)動(dòng)態(tài)改變功能等等。INCLUDES.H 系統(tǒng)頭文件,整個(gè)實(shí)時(shí)系統(tǒng)程序所需要的文件,包括了內(nèi)核和用戶的頭文件。
3.3用戶圖形接口
雖然 μC/OS-II 操作系統(tǒng)具有很高的實(shí)時(shí)性,但不像 WINCE、uCLinux 等操作系統(tǒng)那樣 有良好的圖形界面支持。所以,在使用液晶和觸摸屏的情況下需要移植用戶圖形接口程序。這里使用的是 μC/GUI。μC/GUI 是一個(gè)軟件模塊集合,通過(guò)該模塊可以在我們的嵌入式產(chǎn)品 中加入用戶圖形接口(GUI)。μC/GUI 具有很高的執(zhí)行效率,并且與處理器和 LCD 控制器相 獨(dú)立。該模塊可以工作在單任務(wù)或者多任務(wù)環(huán)境,可以支持不同大小的顯示方式。
通過(guò) μC/GUI 我們可以很方便的在液晶屏繪制圖形和界面。如果需要多種字體支持,必 須自己將相應(yīng)的字體字庫(kù)加入到 μC/GUI 中。為了避免出現(xiàn)亂碼,盡量使用 GB2312 國(guó)標(biāo)字庫(kù)。
3.4關(guān)于字庫(kù)的兼容性問(wèn)題
我們國(guó)內(nèi)通常使用的漢字字庫(kù)是 GB 碼,但國(guó)際上使用的是 UNICODE 碼,所以如果數(shù)據(jù)終端使用的是手機(jī)、PDA 等移動(dòng)通信設(shè)備,那么在數(shù)據(jù)發(fā)送前必須進(jìn)行字碼轉(zhuǎn)換,即 GB 碼 轉(zhuǎn)換為 UNICODE 碼或者 UNICODE 碼轉(zhuǎn)換為 GB 碼。由于 GB 碼與 UNICODE 碼在排列組合上沒(méi)有任何規(guī)律,所以通常字碼轉(zhuǎn)換的方法就是 查表法。
4結(jié)束語(yǔ)
基于 ARM9 嵌入式系統(tǒng)的遠(yuǎn)程監(jiān)控系統(tǒng)與以往的監(jiān)控系統(tǒng)不同,高性能的處理器芯片大大提高了系統(tǒng)的性能。使監(jiān)控系統(tǒng)能夠工作在比較惡劣的環(huán)境中。并且在設(shè)計(jì)上充分考慮到了系統(tǒng)的可擴(kuò)展性和兼容性問(wèn)題,實(shí)現(xiàn)了本系統(tǒng)與其他系統(tǒng)的無(wú)縫連接。以滿足不同工作環(huán) 境的需要。
作者創(chuàng)新觀點(diǎn):本文設(shè)計(jì)的遠(yuǎn)程監(jiān)控系統(tǒng)應(yīng)用范圍更廣,更靈活、方便。通過(guò)各個(gè)功能模塊 的不同組合,可以十分方便快速的應(yīng)用于各個(gè)領(lǐng)系域,真正實(shí)現(xiàn)智能化、自動(dòng)化且具有較高 的性價(jià)比。