第一篇:基于嵌入式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 嵌入式系統的遠程監控系統與以往的監控系統不同,高性能的處理器芯片大大提高了系統的性能。使監控系統能夠工作在比較惡劣的環境中。并且在設計上充分考慮到了系統的可擴展性和兼容性問題,實現了本系統與其他系統的無縫連接。以滿足不同工作環 境的需要。
作者創新觀點:本文設計的遠程監控系統應用范圍更廣,更靈活、方便。通過各個功能模塊 的不同組合,可以十分方便快速的應用于各個領系域,真正實現智能化、自動化且具有較高 的性價比。