外文文獻翻譯-基于μC OS-Ⅲ的多路數據采集設計與實現(xiàn)【中文2062字】【PDF+中文WORD】
外文文獻翻譯-基于μC OS-Ⅲ的多路數據采集設計與實現(xiàn)【中文2062字】【PDF+中文WORD】,中文2062字,PDF+中文WORD,外文文獻翻譯-基于μC,OS-Ⅲ的多路數據采集設計與實現(xiàn)【中文2062字】【PDF+中文WORD】,外文,文獻,翻譯,基于,OS,路數,采集,設計,實現(xiàn),中文,2062
Design and Implementation of Multi-channel Data Acquisition Based on C/OS-Wang xiaokai,Guo gaizhi,Wang zhonghua College of Computer and Information Engineering,Inner Mongolia Normal University China , Key words:C/OS-,data acquisition,DSPIC30F6014 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.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 onC/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 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 channels1.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 quantified2.Follow the following steps to perform an A/D module.Advanced Engineering ForumOnline:2012-09-26ISSN:2234-991X,Vols.6-7,pp 796-799doi:10.4028/ 2012 Trans Tech Publications Ltd,SwitzerlandThis is an open access article under the CC-BY 4.0 license(https:/creativecommons.org/licenses/by/4.0/)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 isnt 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 LCD3 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.ForC/OS-,every interrupt handler must be written in assembly language.In addition handling the Advanced Engineering Forum Vols.6-7797interrupt 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 timer4.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 mainlyC/OS-features such as idle task stack size,tick rate,etc5 Fig 2:C/OS-architecture Conclusions The paper explains in detail the design and implementation of multi-channel data acquisition based onC/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 withC/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 798Information Technology for Manufacturing Systems IIIby 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 Acknowledgment The project is Supported by the Inner Mongolia Natural Science Foundation(2010MS0918),the High Education Science Research Program of Inner Mongolia(NJ09038)and the Youth Foundation of Inner Mongolia Normal university(ZRYB09013).References 1 Microchip Technology IncdsPIC30F Enhanced Flash 16-Bit Digital Signal Controllers General Purpose and Sensor Families Data SheetEB/OL,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 5 Jean J.Labrosse C/OS-The Real-Time KernelM Micrim 2011 Advanced Engineering Forum Vols.6-7799
基于μC/ OS-Ⅲ的多路數據采集設計與實現(xiàn)
摘要
本文實現(xiàn)了基于μC/ OS-Ⅲ操作系統(tǒng)的多通道數據采集任務調度,實現(xiàn)了μC/ OS-Ⅲ操作系統(tǒng)在 DSPIC30F6014 上的移植,獲取電壓電流溫度和功耗數據。) 實 驗表明,它可以及時采集和處理多種數據,然后在 LCD 上顯示信息。 關鍵詞:μC/OS-Ⅲ;數據采集;DSPIC30F6014
介紹
多通道數據采集是工業(yè)控制中常用的信息處理模塊。 它獲得的數據是工業(yè)生 產中經常使用的參數。 因此本文基于μC/ OS-Ⅲ的多路數據采集模塊是電氣調節(jié) 器的主要功能模塊。 它可以根據參數表和多通道數據及時地控制 SCR(可控硅) 的導通角來調節(jié)電壓電流溫度功率等,以達到工業(yè)生產中的技術參數。 多通道信 息的處理方法是便攜式的,可用于各種嵌入式設備中獲取具有廣泛應用前景的多 通道信息。
硬件設計
dsPIC30F6014 芯片的說明:dsPIC30F6014 是世界領先的微控制器和模擬半導體
(Microchip)供應商制造的數字信號控制器。它采用高性能改良的 RISC 與 MCU 和 DSP 無縫集成,CPU 模塊使用 16 位(數據)和 24 位(指令)修改的哈佛架構, 并增強了指令集,包括對 DSP 的重要支持。 dsPIC30F6014 具有 MCU 和 DSP 雙 引擎,因此其指令集有兩類指令:MCU 和 DSP。這兩個指令類無縫地集成在一個 單獨的執(zhí)行單元中執(zhí)行。處理器的整個數據空間為 64K,因為芯片本身包含一個 DSP 引擎,并且許多 DSP 操作是并行執(zhí)行的,因此數據空間被分成兩個塊,稱為 X 和 Y 數據存儲器。每個存儲器塊都有自己的獨立地址生成單元(地址生成單元 AGU).MCU 類的指令僅通過 X 存儲器 AGU 操作,它將整個數據空間作為一個線 性數據空間訪問。某些 DSP 指令通過 X 和 Y AGU 操作,以同時支持雙操作數的 讀操作,將數據空間分成兩部分。 dsPIC30F6014 還具有豐富的外設,可讓設備與 外界交換信息。 dsPIC30F6014 的外設功能是高電流灌入/源 I / O 引腳,5 個 16 位 定時器/計數器和 16 位定時器可以選擇配置為兩個 32 位定時器,3 線 SPI 模塊, 兩個可尋址 UART 模塊具有 200 Kips 的 FIFO 緩沖器和轉換速率,具有 16 個輸入 通道的 12 位模擬數字轉換器(A / D)。
A / D 模塊的配置:dsPIC30F6014 A / D 轉換器便于采集數據。 根據采集信號的采 樣率和量化后的數值格式[2],主要工作是配置相關寄存器。按照以下步驟執(zhí)行 A /
5
D 模塊。
1.選擇電源電壓以符合模擬輸入的預期要求
2.選擇時鐘以使期望的數據速率與處理器時鐘匹配
3.確定如何采樣
4.確定如何將輸入分配給 S / H 通道
5.確定轉換結果將如何出現(xiàn)在緩沖區(qū)中
6.選擇中斷率
7.打開 A / D 模塊 軟件設計 設備配置
用戶可以使用設備配置寄存器來自定義設備的某些方面。 器件配置寄存器是 程序存儲器中的非易失性存儲單元。 它可以在斷電期間節(jié)省 dsPIC6014 配置。 配 置寄存器保存設備的全局配置信息,如振蕩器的來源,看門狗定時器的模式,代 碼保護等。
_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 通道獲取電壓,電流,溫度和功率, 然后將數據存儲到 ADCBUF 并將這些數據傳輸到微處理器。 微芯片在 LCD 上顯 示數據。
根據以下步驟執(zhí)行 A / D 轉換。
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位
計數器<16
將轉換結果寫入A/D轉換區(qū)
否
是
返回
圖 1 中斷服務流程圖
移植μC/ OS-Ⅲ:μC/ OS-Ⅲ移植有兩個主要的工作,一個是中斷處理程序的設計, 另一個是時間程序的設計。1.中斷處理程序的設計是嵌入式操作系統(tǒng)中硬件抽象層 的重要組成部分。對于μC/ OS-Ⅲ,每個中斷處理程序必須用匯編語言編寫。另外 處理中斷在不同的編譯器中是不一樣的。dsPIC 編譯器為每個中斷保留一個中斷向 量。當發(fā)生中斷時,它會自動跳轉到中斷向量。第一步是保存中斷場景,如果這 不是中斷嵌套,則保存任務堆棧的指針,清除中斷標志狀態(tài),調用 C 中斷服務函 數,中斷退出)。如果這是中斷嵌套,則不會保存任務堆棧的指針,調用并處理 C 中斷服務函數。 2.系統(tǒng)時間的設計。與其他計算機操作系統(tǒng)一樣,μC/ OS-Ⅲ使 用硬件時間以毫秒時間中斷來實現(xiàn)系統(tǒng)時間。該設計在系統(tǒng)時間使用定時器 1。初 始化定時器的步驟如下:1 清除 TM R1 位 2 設置時間 1 中斷為所需優(yōu)先級 3 清除 時間 1 中斷狀態(tài)標志 4 啟用時間 1 中斷 5 啟動帶預分頻器設置和時鐘源設置的時
間 1.2 選擇內部時鐘源。 3 設置分頻,中斷周期(10 ms),中斷優(yōu)先級。 3 清除
中斷標志位并使能中斷。 4 啟動一個計時器
μC/ OS-Ⅲ架構:(1)APP.C 和 APP.H 是主要的應用程序文件。 (2)* .h 和* .c 是 CPU 制造商提供的庫文件。 (3)BSP.H 和 BSP.C 是目標電路板中外設 的接口功能。 (4)OS_CFG_APP.C 和其他文件是獨立于處理器且μC / OS-Ⅲ的 文件。 (5)OS_CPU.H 和其他文件是移植μC/ OS-Ⅲ時依賴于處理器并進行修改 的文件。 (6)CPU.H 和其他文件總結 CPU 的主要功能,例如禁用和啟用中斷。
(8)μS/ CFG.H 和 OS_CFG_APP.H 主要定義μC/ OS-Ⅲ的特性,如空閑任務堆棧 大小節(jié)拍率,等等。
圖 2:μC/ OS-Ⅲ架構
結論
本文詳細闡述了基于μC/ OS-Ⅲ的多通道數據采集的設計與實現(xiàn)。 本文實現(xiàn)了 dsPIC30F6014 的 4 通道數據采集。 實驗表明,該系統(tǒng)可以及時采集和處理多路數 據,并可以通過μC/ OS-Ⅲ操作系統(tǒng)調度多任務。 然后它符合電氣調節(jié)器的需要。 這種設計具有很強的通用性,只要用其他處理器芯片代替系統(tǒng)的微處理器--- dsPIC30F6014A,就可以通過根據本文描述的方法進行適當修改來實現(xiàn)實時信號采 集和存儲處理, 應用前景廣闊。
圖 3 運行系統(tǒng)
參考文獻
[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
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-Ⅲ的多路數據采集設計與實現(xiàn)
摘要
本文實現(xiàn)了基于μC/ OS-Ⅲ操作系統(tǒng)的多通道數據采集任務調度,實現(xiàn)了μC/ OS-Ⅲ操作系統(tǒng)在 DSPIC30F6014 上的移植,獲取電壓電流溫度和功耗數據。) 實 驗表明,它可以及時采集和處理多種數據,然后在 LCD 上顯示信息。 關鍵詞:μC/OS-Ⅲ;數據采集;DSPIC30F6014
介紹
多通道數據采集是工業(yè)控制中常用的信息處理模塊。 它獲得的數據是工業(yè)生 產中經常使用的參數。 因此本文基于μC/ OS-Ⅲ的多路數據采集模塊是電氣調節(jié) 器的主要功能模塊。 它可以根據參數表和多通道數據及時地控制 SCR(可控硅) 的導通角來調節(jié)電壓電流溫度功率等,以達到工業(yè)生產中的技術參數。 多通道信 息的處理方法是便攜式的,可用于各種嵌入式設備中獲取具有廣泛應用前景的多 通道信息。
硬件設計
dsPIC30F6014 芯片的說明:dsPIC30F6014 是世界領先的微控制器和模擬半導體
(Microchip)供應商制造的數字信號控制器。它采用高性能改良的 RISC 與 MCU 和 DSP 無縫集成,CPU 模塊使用 16 位(數據)和 24 位(指令)修改的哈佛架構, 并增強了指令集,包括對 DSP 的重要支持。 dsPIC30F6014 具有 MCU 和 DSP 雙 引擎,因此其指令集有兩類指令:MCU 和 DSP。這兩個指令類無縫地集成在一個 單獨的執(zhí)行單元中執(zhí)行。處理器的整個數據空間為 64K,因為芯片本身包含一個 DSP 引擎,并且許多 DSP 操作是并行執(zhí)行的,因此數據空間被分成兩個塊,稱為 X 和 Y 數據存儲器。每個存儲器塊都有自己的獨立地址生成單元(地址生成單元 AGU).MCU 類的指令僅通過 X 存儲器 AGU 操作,它將整個數據空間作為一個線 性數據空間訪問。某些 DSP 指令通過 X 和 Y AGU 操作,以同時支持雙操作數的 讀操作,將數據空間分成兩部分。 dsPIC30F6014 還具有豐富的外設,可讓設備與 外界交換信息。 dsPIC30F6014 的外設功能是高電流灌入/源 I / O 引腳,5 個 16 位 定時器/計數器和 16 位定時器可以選擇配置為兩個 32 位定時器,3 線 SPI 模塊, 兩個可尋址 UART 模塊具有 200 Kips 的 FIFO 緩沖器和轉換速率,具有 16 個輸入 通道的 12 位模擬數字轉換器(A / D)。
A / D 模塊的配置:dsPIC30F6014 A / D 轉換器便于采集數據。 根據采集信號的采 樣率和量化后的數值格式[2],主要工作是配置相關寄存器。按照以下步驟執(zhí)行 A /
D 模塊。
1.選擇電源電壓以符合模擬輸入的預期要求
2.選擇時鐘以使期望的數據速率與處理器時鐘匹配
3.確定如何采樣
4.確定如何將輸入分配給 S / H 通道
5.確定轉換結果將如何出現(xiàn)在緩沖區(qū)中
6.選擇中斷率
7.打開 A / D 模塊 軟件設計 設備配置
用戶可以使用設備配置寄存器來自定義設備的某些方面。 器件配置寄存器是 程序存儲器中的非易失性存儲單元。 它可以在斷電期間節(jié)省 dsPIC6014 配置。 配 置寄存器保存設備的全局配置信息,如振蕩器的來源,看門狗定時器的模式,代 碼保護等。
_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 通道獲取電壓,電流,溫度和功率, 然后將數據存儲到 ADCBUF 并將這些數據傳輸到微處理器。 微芯片在 LCD 上顯 示數據。
根據以下步驟執(zhí)行 A / D 轉換。
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位
計數器<16
將轉換結果寫入A/D轉換區(qū)
否
是
返回
圖 1 中斷服務流程圖
移植μC/ OS-Ⅲ:μC/ OS-Ⅲ移植有兩個主要的工作,一個是中斷處理程序的設計, 另一個是時間程序的設計。1.中斷處理程序的設計是嵌入式操作系統(tǒng)中硬件抽象層 的重要組成部分。對于μC/ OS-Ⅲ,每個中斷處理程序必須用匯編語言編寫。另外 處理中斷在不同的編譯器中是不一樣的。dsPIC 編譯器為每個中斷保留一個中斷向 量。當發(fā)生中斷時,它會自動跳轉到中斷向量。第一步是保存中斷場景,如果這 不是中斷嵌套,則保存任務堆棧的指針,清除中斷標志狀態(tài),調用 C 中斷服務函 數,中斷退出)。如果這是中斷嵌套,則不會保存任務堆棧的指針,調用并處理 C 中斷服務函數。 2.系統(tǒng)時間的設計。與其他計算機操作系統(tǒng)一樣,μC/ OS-Ⅲ使 用硬件時間以毫秒時間中斷來實現(xiàn)系統(tǒng)時間。該設計在系統(tǒng)時間使用定時器 1。初 始化定時器的步驟如下:1 清除 TM R1 位 2 設置時間 1 中斷為所需優(yōu)先級 3 清除 時間 1 中斷狀態(tài)標志 4 啟用時間 1 中斷 5 啟動帶預分頻器設置和時鐘源設置的時
間 1.2 選擇內部時鐘源。 3 設置分頻,中斷周期(10 ms),中斷優(yōu)先級。 3 清除
中斷標志位并使能中斷。 4 啟動一個計時器
μC/ OS-Ⅲ架構:(1)APP.C 和 APP.H 是主要的應用程序文件。 (2)* .h 和* .c 是 CPU 制造商提供的庫文件。 (3)BSP.H 和 BSP.C 是目標電路板中外設 的接口功能。 (4)OS_CFG_APP.C 和其他文件是獨立于處理器且μC / OS-Ⅲ的 文件。 (5)OS_CPU.H 和其他文件是移植μC/ OS-Ⅲ時依賴于處理器并進行修改 的文件。 (6)CPU.H 和其他文件總結 CPU 的主要功能,例如禁用和啟用中斷。
(8)μS/ CFG.H 和 OS_CFG_APP.H 主要定義μC/ OS-Ⅲ的特性,如空閑任務堆棧 大小節(jié)拍率,等等。
圖 2:μC/ OS-Ⅲ架構
結論
本文詳細闡述了基于μC/ OS-Ⅲ的多通道數據采集的設計與實現(xiàn)。 本文實現(xiàn)了 dsPIC30F6014 的 4 通道數據采集。 實驗表明,該系統(tǒng)可以及時采集和處理多路數 據,并可以通過μC/ OS-Ⅲ操作系統(tǒng)調度多任務。 然后它符合電氣調節(jié)器的需要。 這種設計具有很強的通用性,只要用其他處理器芯片代替系統(tǒng)的微處理器--- dsPIC30F6014A,就可以通過根據本文描述的方法進行適當修改來實現(xiàn)實時信號采 集和存儲處理, 應用前景廣闊。
圖 3 運行系統(tǒng)
參考文獻
[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
收藏