外文文獻(xiàn)翻譯-基于μC OS-Ⅲ的多路數(shù)據(jù)采集設(shè)計(jì)與實(shí)現(xiàn)【中文2062字】【PDF+中文WORD】
外文文獻(xiàn)翻譯-基于μC OS-Ⅲ的多路數(shù)據(jù)采集設(shè)計(jì)與實(shí)現(xiàn)【中文2062字】【PDF+中文WORD】,中文2062字,PDF+中文WORD,外文文獻(xiàn)翻譯-基于μC,OS-Ⅲ的多路數(shù)據(jù)采集設(shè)計(jì)與實(shí)現(xiàn)【中文2062字】【PDF+中文WORD】,外文,文獻(xiàn),翻譯,基于,OS,路數(shù),采集,設(shè)計(jì),實(shí)現(xiàn),中文,2062
Design and Implementation of Multi-channel Data Acquisition Based on μC/OS-Ⅲ
Abstract. This paper achieves task scheduling of the multi-channel data acquisition based on the operating system of μC/OS-ⅢIt realizes transplanting the operating system of μC/OS-Ⅲ on DSPIC30F6014 to acquire the data of the voltage current temperature and power through )The experiment shows that it can acquire and process multi-data
timely, then displays the information on the LCD
Key words: μC/OS-Ⅲ, data acquisition, DSPIC30F6014
Introduction
The multi-channel data acquisition is information processing module commonly used in the industrial control. The data it acquired is the parameter often used in industrial production. So the module of multi-channel data acquisition based onμC/OS-Ⅲ in this
paper is main functional module of the electrical regulator. It can control the conduction angle of SCR(silicon controlled rectifier) to regulate the voltage current temperature power and so on to reach the technical parameter in the industrial production according to the list of the parameter and multi-channel data timely. The processing method of multi-channel information is portable and can be used in every embedded device to acquire the multi-channel information with wide application prospect.
The hardware design
The description of dsPIC30F6014 chip. dsPIC30F6014 is the digital signal controller made by the world leading provider of microcontroller and analog semiconductor (Microchip).It uses high-performance modified RISC integrates with MCU and DSP seamlessly, and the CPU module uses 16-bit (data) and 24-bit(instruction) modified Harvard architecture with an enhanced instruction set including significant support for DSP. The dsPIC30F6014 has MCU and DSP double engine, so its instruction set has two classes of instructions: MCU and DSP. These two instruction classes are seamlessly integrated into a single and execute from one execution unit. The whole data space of
11
processor is 64K, because the chip itself contains a DSP engine, and many DSP operations are executed in parallel, thus data space is split into two blocks, referred to as X and Y data memory. Each of the memory blocks have their own independent address generating unit ( Address Generation Unit, AGU ).The instructions of MCU class operates solely through the X memory AGU, which accesses the entire data space as one linear data space. Certain DSP instructions operate through the X and Y AGU to support read operation of dual operand at the same time, which splits the data space into two parts. dsPIC30F6014 also has abundant peripherals which allow devices to exchange the information with the outside world. The peripheral feature of dsPIC30F6014 is high-current sink/source I/O pins, five 16-bit timers/counters and 16-bit timers can be optionally configured as two 32-bit timers, 3-wire SPI modules, two addressable UART module with FIFO buffer and conversion rate with 200Kips, 12-Bit Analog-to-Digital Converters(A/D) with 16 input channels
Configuration of A/D module. The dsPIC30F6014 A/D converter is convenient for acquisition data. The main job is the configuration relevant registers according to the sampling rate of acquisition signal and numerical format after quantified[2] .Follow the following steps to perform an A/D module.
1. Select source voltage to match the expected of analog input
2. Select the clock to match desired data rate with processor clock
3. Determine how sampling will happen
4. Determine how inputs will be allocated to the S/H channel
5. Determine how the conversion results will appear in the buffer
6. Select interrupt rate
7. Switch on A/D module
The software design
Device configuration.The user can use the device configuration register to customize certain aspects of the device. The device configuration registers are nonvolatile memory locations in the program memory. It can save dsPIC6014 configurations during power-off. The configuration registers save global configuration information of devices, such as the source of oscillator, the mode of watchdog timer, code protection and so on. FOSC(CSW_FSCM_OFF); // turn off failsafe
_FWDT(WDT_OFF); // turn off watchdog
_FBORPOR(PBOR_OFF); //power-up timer disable
_FGS(CODE_PROT_OFF); //user program memory isn’t code-protected Configuring A/D module.This system mainly uses AN3-AN6 channel to acquire voltage, current, temperature and power, then stores the data to ADCBUF and transfers these data to the microprocessor. The microchip displays the data on the LCD
Perform an A/D conversion according to the following steps ADCON2=0X042C; // V REFH = AVDD VREFL = AVSS ADCON3=0X000F; //Tad=8Tcy
ADCON1=0X0044; //compare end sampling using timer3 ADCSSL=0X00F0; //scan input select from AN3, AN4, AN5, AN6 ADCON1bits.ADON=1; //turn on A/D
Fig 1 The interrupt service flow diagram
Porting μC/OS-Ⅲ. There are two main jobs of μC/OS-Ⅲ transplant, One thing is the design of the interrupt handler program, the other thing is the design of the time program .1. The design of the interrupt handler is an important part of hardware
abstraction layer in the embedded operating system. ForμC/OS-Ⅲ, every interrupt
handler must be written in assembly language. In addition handling the interrupt is not
the same in different compilers. The dsPIC compiler retains a interrupt vector for each interrupt. When the interrupt occurs it will automatically jump to the interrupt vector. The first step is saving the interrupt scene, if this is not interrupt nesting, then saves the pointer of the task stack, clears the interrupt flag status, calls the C interrupt service function, interrupt exits).if this is interrupt nesting, then not saves the pointer of the task stack, calls and processes the C interrupt service function. 2. The design of the system
time. μC/OS-Ⅲ, like other computer operating systems, uses the hardware time to
realize the system time with a millisecond time interrupt. The design uses timer 1 for system time. The step of initializing timer is that: 1 clear TM R1 bit2 setup Time1 interrupt for desired priority level 3 clear the Time1 interrupt status flag 4 enable Time1 interrupts 5 starts Time1 with prescaler settings and clock source set.2 select internal clock source. 3 set the frequency demultiplication, interrupt cycle (10 ms), the interrupt priority. 3 clear interrupt flag bit and enable interrupt. 4 start a timer.
μC/OS-Ⅲ architecture: (1) APP.C and APP.H are the main the application file. (2)
*.h and *.c are library files provided by the manufacturer of CPU. (3) BSP.H and BSP.C are interface functions to peripherals in the aim circuit board. (4) OS_CFG_APP.C and other files are files that are processor-independent and μ C/OS- Ⅲ . (5) OS_CPU.H
and other files are files that are processor-dependent and make modification when you transplant μC/OS-Ⅲ. (6) CPU.H and other files summarize main function of CPU, for
example disable and enable interrupts. (7) μC/LIB is a series of source that provide common functions such as the operation of the string.(8) 0S_CFG.H and OS_CFG_APP.H define mainlyμC/OS-Ⅲ features such as idle task stack size ,tick rate,
etc.
Fig 2 : μC/OS-Ⅲ architecture
Conclusions
The paper explains in detail the design and implementation of multi-channel data acquisition based onμC/OS-Ⅲ. The paper realizes 4-channel data acquisition with the dsPIC30F6014. The experiment shows that this system can acquire and process timely multi-channel data and schedule multi-task withμC/OS-Ⅲ operating system. Then it
meets the need of the electrical regulator. This design has the very strong versatility, just to replace the system’ microprocessor--- dsPIC30F6014A by other processor chip, can be realize real time signal acquisition and storage processing through appropriate modifications in accordance with the method described in this paper, with a very broad application prospects.
Figure 3 The running system
References
[1] Microchip Technology Inc. dsPIC30F Enhanced Flash 16-Bit Digital Signal Controllers General Purpose and Sensor Families Data Sheet
[EB/OL].www.microchip.com,2006.
[2] Wang fang.High-speed signal acquisition and processing system and its application.
Northwestern polytechnic university .2006
[3] Wen xia Design and Implementation of the signal acquisition circuit [4] information on www.micrium.com
[5] Jean J.Labrosse μC/OS-Ⅲ The Real-Time Kernel[M] Micriμm 2011
基于μC/ OS-Ⅲ的多路數(shù)據(jù)采集設(shè)計(jì)與實(shí)現(xiàn)
摘要
本文實(shí)現(xiàn)了基于μC/ OS-Ⅲ操作系統(tǒng)的多通道數(shù)據(jù)采集任務(wù)調(diào)度,實(shí)現(xiàn)了μC/ OS-Ⅲ操作系統(tǒng)在 DSPIC30F6014 上的移植,獲取電壓電流溫度和功耗數(shù)據(jù)。) 實(shí) 驗(yàn)表明,它可以及時(shí)采集和處理多種數(shù)據(jù),然后在 LCD 上顯示信息。 關(guān)鍵詞:μC/OS-Ⅲ;數(shù)據(jù)采集;DSPIC30F6014
介紹
多通道數(shù)據(jù)采集是工業(yè)控制中常用的信息處理模塊。 它獲得的數(shù)據(jù)是工業(yè)生 產(chǎn)中經(jīng)常使用的參數(shù)。 因此本文基于μC/ OS-Ⅲ的多路數(shù)據(jù)采集模塊是電氣調(diào)節(jié) 器的主要功能模塊。 它可以根據(jù)參數(shù)表和多通道數(shù)據(jù)及時(shí)地控制 SCR(可控硅) 的導(dǎo)通角來調(diào)節(jié)電壓電流溫度功率等,以達(dá)到工業(yè)生產(chǎn)中的技術(shù)參數(shù)。 多通道信 息的處理方法是便攜式的,可用于各種嵌入式設(shè)備中獲取具有廣泛應(yīng)用前景的多 通道信息。
硬件設(shè)計(jì)
dsPIC30F6014 芯片的說明:dsPIC30F6014 是世界領(lǐng)先的微控制器和模擬半導(dǎo)體
(Microchip)供應(yīng)商制造的數(shù)字信號(hào)控制器。它采用高性能改良的 RISC 與 MCU 和 DSP 無縫集成,CPU 模塊使用 16 位(數(shù)據(jù))和 24 位(指令)修改的哈佛架構(gòu), 并增強(qiáng)了指令集,包括對(duì) DSP 的重要支持。 dsPIC30F6014 具有 MCU 和 DSP 雙 引擎,因此其指令集有兩類指令:MCU 和 DSP。這兩個(gè)指令類無縫地集成在一個(gè) 單獨(dú)的執(zhí)行單元中執(zhí)行。處理器的整個(gè)數(shù)據(jù)空間為 64K,因?yàn)樾酒旧戆粋€(gè) DSP 引擎,并且許多 DSP 操作是并行執(zhí)行的,因此數(shù)據(jù)空間被分成兩個(gè)塊,稱為 X 和 Y 數(shù)據(jù)存儲(chǔ)器。每個(gè)存儲(chǔ)器塊都有自己的獨(dú)立地址生成單元(地址生成單元 AGU).MCU 類的指令僅通過 X 存儲(chǔ)器 AGU 操作,它將整個(gè)數(shù)據(jù)空間作為一個(gè)線 性數(shù)據(jù)空間訪問。某些 DSP 指令通過 X 和 Y AGU 操作,以同時(shí)支持雙操作數(shù)的 讀操作,將數(shù)據(jù)空間分成兩部分。 dsPIC30F6014 還具有豐富的外設(shè),可讓設(shè)備與 外界交換信息。 dsPIC30F6014 的外設(shè)功能是高電流灌入/源 I / O 引腳,5 個(gè) 16 位 定時(shí)器/計(jì)數(shù)器和 16 位定時(shí)器可以選擇配置為兩個(gè) 32 位定時(shí)器,3 線 SPI 模塊, 兩個(gè)可尋址 UART 模塊具有 200 Kips 的 FIFO 緩沖器和轉(zhuǎn)換速率,具有 16 個(gè)輸入 通道的 12 位模擬數(shù)字轉(zhuǎn)換器(A / D)。
A / D 模塊的配置:dsPIC30F6014 A / D 轉(zhuǎn)換器便于采集數(shù)據(jù)。 根據(jù)采集信號(hào)的采 樣率和量化后的數(shù)值格式[2],主要工作是配置相關(guān)寄存器。按照以下步驟執(zhí)行 A /
D 模塊。
1.選擇電源電壓以符合模擬輸入的預(yù)期要求
2.選擇時(shí)鐘以使期望的數(shù)據(jù)速率與處理器時(shí)鐘匹配
3.確定如何采樣
4.確定如何將輸入分配給 S / H 通道
5.確定轉(zhuǎn)換結(jié)果將如何出現(xiàn)在緩沖區(qū)中
6.選擇中斷率
7.打開 A / D 模塊 軟件設(shè)計(jì) 設(shè)備配置
用戶可以使用設(shè)備配置寄存器來自定義設(shè)備的某些方面。 器件配置寄存器是 程序存儲(chǔ)器中的非易失性存儲(chǔ)單元。 它可以在斷電期間節(jié)省 dsPIC6014 配置。 配 置寄存器保存設(shè)備的全局配置信息,如振蕩器的來源,看門狗定時(shí)器的模式,代 碼保護(hù)等。
_FOSC(CSW_FSCM_OFF); // turn off failsafe
_FWDT(WDT_OFF); // turn off watchdog
_FBORPOR(PBOR_OFF); //power-up timer disable
_FGS(CODE_PROT_OFF); //user program memory isn’t code-protected
配置 A / D 模塊:該系統(tǒng)主要使用 AN3-AN6 通道獲取電壓,電流,溫度和功率, 然后將數(shù)據(jù)存儲(chǔ)到 ADCBUF 并將這些數(shù)據(jù)傳輸?shù)轿⑻幚砥鳌?微芯片在 LCD 上顯 示數(shù)據(jù)。
根據(jù)以下步驟執(zhí)行 A / D 轉(zhuǎn)換。
ADCON2=0X042C; // V REFH = AVDD VREFL = AVSS ADCON3=0X000F; //Tad=8Tcy
ADCON1=0X0044; //compare end sampling using timer3 ADCSSL=0X00F0; //scan input select from AN3, AN4, AN5, AN6 ADCON1bits.ADON=1; //turn on A/D
A/D ISR
清除T3 IF位
清除AD IF位
計(jì)數(shù)器<16
將轉(zhuǎn)換結(jié)果寫入A/D轉(zhuǎn)換區(qū)
否
是
返回
圖 1 中斷服務(wù)流程圖
移植μC/ OS-Ⅲ:μC/ OS-Ⅲ移植有兩個(gè)主要的工作,一個(gè)是中斷處理程序的設(shè)計(jì), 另一個(gè)是時(shí)間程序的設(shè)計(jì)。1.中斷處理程序的設(shè)計(jì)是嵌入式操作系統(tǒng)中硬件抽象層 的重要組成部分。對(duì)于μC/ OS-Ⅲ,每個(gè)中斷處理程序必須用匯編語言編寫。另外 處理中斷在不同的編譯器中是不一樣的。dsPIC 編譯器為每個(gè)中斷保留一個(gè)中斷向 量。當(dāng)發(fā)生中斷時(shí),它會(huì)自動(dòng)跳轉(zhuǎn)到中斷向量。第一步是保存中斷場(chǎng)景,如果這 不是中斷嵌套,則保存任務(wù)堆棧的指針,清除中斷標(biāo)志狀態(tài),調(diào)用 C 中斷服務(wù)函 數(shù),中斷退出)。如果這是中斷嵌套,則不會(huì)保存任務(wù)堆棧的指針,調(diào)用并處理 C 中斷服務(wù)函數(shù)。 2.系統(tǒng)時(shí)間的設(shè)計(jì)。與其他計(jì)算機(jī)操作系統(tǒng)一樣,μC/ OS-Ⅲ使 用硬件時(shí)間以毫秒時(shí)間中斷來實(shí)現(xiàn)系統(tǒng)時(shí)間。該設(shè)計(jì)在系統(tǒng)時(shí)間使用定時(shí)器 1。初 始化定時(shí)器的步驟如下:1 清除 TM R1 位 2 設(shè)置時(shí)間 1 中斷為所需優(yōu)先級(jí) 3 清除 時(shí)間 1 中斷狀態(tài)標(biāo)志 4 啟用時(shí)間 1 中斷 5 啟動(dòng)帶預(yù)分頻器設(shè)置和時(shí)鐘源設(shè)置的時(shí)
間 1.2 選擇內(nèi)部時(shí)鐘源。 3 設(shè)置分頻,中斷周期(10 ms),中斷優(yōu)先級(jí)。 3 清除
中斷標(biāo)志位并使能中斷。 4 啟動(dòng)一個(gè)計(jì)時(shí)器
μC/ OS-Ⅲ架構(gòu):(1)APP.C 和 APP.H 是主要的應(yīng)用程序文件。 (2)* .h 和* .c 是 CPU 制造商提供的庫(kù)文件。 (3)BSP.H 和 BSP.C 是目標(biāo)電路板中外設(shè) 的接口功能。 (4)OS_CFG_APP.C 和其他文件是獨(dú)立于處理器且μC / OS-Ⅲ的 文件。 (5)OS_CPU.H 和其他文件是移植μC/ OS-Ⅲ時(shí)依賴于處理器并進(jìn)行修改 的文件。 (6)CPU.H 和其他文件總結(jié) CPU 的主要功能,例如禁用和啟用中斷。
(8)μS/ CFG.H 和 OS_CFG_APP.H 主要定義μC/ OS-Ⅲ的特性,如空閑任務(wù)堆棧 大小節(jié)拍率,等等。
圖 2:μC/ OS-Ⅲ架構(gòu)
結(jié)論
本文詳細(xì)闡述了基于μC/ OS-Ⅲ的多通道數(shù)據(jù)采集的設(shè)計(jì)與實(shí)現(xiàn)。 本文實(shí)現(xiàn)了 dsPIC30F6014 的 4 通道數(shù)據(jù)采集。 實(shí)驗(yàn)表明,該系統(tǒng)可以及時(shí)采集和處理多路數(shù) 據(jù),并可以通過μC/ OS-Ⅲ操作系統(tǒng)調(diào)度多任務(wù)。 然后它符合電氣調(diào)節(jié)器的需要。 這種設(shè)計(jì)具有很強(qiáng)的通用性,只要用其他處理器芯片代替系統(tǒng)的微處理器--- dsPIC30F6014A,就可以通過根據(jù)本文描述的方法進(jìn)行適當(dāng)修改來實(shí)現(xiàn)實(shí)時(shí)信號(hào)采 集和存儲(chǔ)處理, 應(yīng)用前景廣闊。
圖 3 運(yùn)行系統(tǒng)
參考文獻(xiàn)
[1] Microchip Technology Inc. dsPIC30F Enhanced Flash 16-Bit Digital Signal Controllers General Purpose and Sensor Families Data Sheet
[EB/OL].www.microchip.com,2006.
[2] Wang fang.High-speed signal acquisition and processing system and its application.
Northwestern polytechnic university .2006
[3] Wen xia Design and Implementation of the signal acquisition circuit [4] information on www.micrium.com
[5] Jean J.Labrosse μC/OS-Ⅲ The Real-Time Kernel[M] Micriμm 2011
收藏