外文文献翻译-基于μC OS-Ⅲ的多路数据采集设计与实现【中文2062字】【PDF+中文WORD】
外文文献翻译-基于μC OS-Ⅲ的多路数据采集设计与实现【中文2062字】【PDF+中文WORD】,中文2062字,PDF+中文WORD,外文文献翻译-基于μC,OS-Ⅲ的多路数据采集设计与实现【中文2062字】【PDF+中文WORD】,外文,文献,翻译,基于,OS,路数,采集,设计,实现,中文,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-Ⅲ的多路数据采集设计与实现
摘要
本文实现了基于μC/ OS-Ⅲ操作系统的多通道数据采集任务调度,实现了μC/ OS-Ⅲ操作系统在 DSPIC30F6014 上的移植,获取电压电流温度和功耗数据。) 实 验表明,它可以及时采集和处理多种数据,然后在 LCD 上显示信息。 关键词:μC/OS-Ⅲ;数据采集;DSPIC30F6014
介绍
多通道数据采集是工业控制中常用的信息处理模块。 它获得的数据是工业生 产中经常使用的参数。 因此本文基于μC/ OS-Ⅲ的多路数据采集模块是电气调节 器的主要功能模块。 它可以根据参数表和多通道数据及时地控制 SCR(可控硅) 的导通角来调节电压电流温度功率等,以达到工业生产中的技术参数。 多通道信 息的处理方法是便携式的,可用于各种嵌入式设备中获取具有广泛应用前景的多 通道信息。
硬件设计
dsPIC30F6014 芯片的说明:dsPIC30F6014 是世界领先的微控制器和模拟半导体
(Microchip)供应商制造的数字信号控制器。它采用高性能改良的 RISC 与 MCU 和 DSP 无缝集成,CPU 模块使用 16 位(数据)和 24 位(指令)修改的哈佛架构, 并增强了指令集,包括对 DSP 的重要支持。 dsPIC30F6014 具有 MCU 和 DSP 双 引擎,因此其指令集有两类指令:MCU 和 DSP。这两个指令类无缝地集成在一个 单独的执行单元中执行。处理器的整个数据空间为 64K,因为芯片本身包含一个 DSP 引擎,并且许多 DSP 操作是并行执行的,因此数据空间被分成两个块,称为 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],主要工作是配置相关寄存器。按照以下步骤执行 A /
5
D 模块。
1.选择电源电压以符合模拟输入的预期要求
2.选择时钟以使期望的数据速率与处理器时钟匹配
3.确定如何采样
4.确定如何将输入分配给 S / H 通道
5.确定转换结果将如何出现在缓冲区中
6.选择中断率
7.打开 A / D 模块 软件设计 设备配置
用户可以使用设备配置寄存器来自定义设备的某些方面。 器件配置寄存器是 程序存储器中的非易失性存储单元。 它可以在断电期间节省 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 模块:该系统主要使用 AN3-AN6 通道获取电压,电流,温度和功率, 然后将数据存储到 ADCBUF 并将这些数据传输到微处理器。 微芯片在 LCD 上显 示数据。
根据以下步骤执行 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转换区
否
是
返回
图 1 中断服务流程图
移植μC/ OS-Ⅲ:μC/ OS-Ⅲ移植有两个主要的工作,一个是中断处理程序的设计, 另一个是时间程序的设计。1.中断处理程序的设计是嵌入式操作系统中硬件抽象层 的重要组成部分。对于μC/ OS-Ⅲ,每个中断处理程序必须用汇编语言编写。另外 处理中断在不同的编译器中是不一样的。dsPIC 编译器为每个中断保留一个中断向 量。当发生中断时,它会自动跳转到中断向量。第一步是保存中断场景,如果这 不是中断嵌套,则保存任务堆栈的指针,清除中断标志状态,调用 C 中断服务函 数,中断退出)。如果这是中断嵌套,则不会保存任务堆栈的指针,调用并处理 C 中断服务函数。 2.系统时间的设计。与其他计算机操作系统一样,μC/ OS-Ⅲ使 用硬件时间以毫秒时间中断来实现系统时间。该设计在系统时间使用定时器 1。初 始化定时器的步骤如下:1 清除 TM R1 位 2 设置时间 1 中断为所需优先级 3 清除 时间 1 中断状态标志 4 启用时间 1 中断 5 启动带预分频器设置和时钟源设置的时
间 1.2 选择内部时钟源。 3 设置分频,中断周期(10 ms),中断优先级。 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-Ⅲ的特性,如空闲任务堆栈 大小节拍率,等等。
图 2:μC/ OS-Ⅲ架构
结论
本文详细阐述了基于μC/ OS-Ⅲ的多通道数据采集的设计与实现。 本文实现了 dsPIC30F6014 的 4 通道数据采集。 实验表明,该系统可以及时采集和处理多路数 据,并可以通过μC/ OS-Ⅲ操作系统调度多任务。 然后它符合电气调节器的需要。 这种设计具有很强的通用性,只要用其他处理器芯片代替系统的微处理器--- dsPIC30F6014A,就可以通过根据本文描述的方法进行适当修改来实现实时信号采 集和存储处理, 应用前景广阔。
图 3 运行系统
参考文献
[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-Ⅲ的多路数据采集设计与实现
摘要
本文实现了基于μC/ OS-Ⅲ操作系统的多通道数据采集任务调度,实现了μC/ OS-Ⅲ操作系统在 DSPIC30F6014 上的移植,获取电压电流温度和功耗数据。) 实 验表明,它可以及时采集和处理多种数据,然后在 LCD 上显示信息。 关键词:μC/OS-Ⅲ;数据采集;DSPIC30F6014
介绍
多通道数据采集是工业控制中常用的信息处理模块。 它获得的数据是工业生 产中经常使用的参数。 因此本文基于μC/ OS-Ⅲ的多路数据采集模块是电气调节 器的主要功能模块。 它可以根据参数表和多通道数据及时地控制 SCR(可控硅) 的导通角来调节电压电流温度功率等,以达到工业生产中的技术参数。 多通道信 息的处理方法是便携式的,可用于各种嵌入式设备中获取具有广泛应用前景的多 通道信息。
硬件设计
dsPIC30F6014 芯片的说明:dsPIC30F6014 是世界领先的微控制器和模拟半导体
(Microchip)供应商制造的数字信号控制器。它采用高性能改良的 RISC 与 MCU 和 DSP 无缝集成,CPU 模块使用 16 位(数据)和 24 位(指令)修改的哈佛架构, 并增强了指令集,包括对 DSP 的重要支持。 dsPIC30F6014 具有 MCU 和 DSP 双 引擎,因此其指令集有两类指令:MCU 和 DSP。这两个指令类无缝地集成在一个 单独的执行单元中执行。处理器的整个数据空间为 64K,因为芯片本身包含一个 DSP 引擎,并且许多 DSP 操作是并行执行的,因此数据空间被分成两个块,称为 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],主要工作是配置相关寄存器。按照以下步骤执行 A /
D 模块。
1.选择电源电压以符合模拟输入的预期要求
2.选择时钟以使期望的数据速率与处理器时钟匹配
3.确定如何采样
4.确定如何将输入分配给 S / H 通道
5.确定转换结果将如何出现在缓冲区中
6.选择中断率
7.打开 A / D 模块 软件设计 设备配置
用户可以使用设备配置寄存器来自定义设备的某些方面。 器件配置寄存器是 程序存储器中的非易失性存储单元。 它可以在断电期间节省 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 模块:该系统主要使用 AN3-AN6 通道获取电压,电流,温度和功率, 然后将数据存储到 ADCBUF 并将这些数据传输到微处理器。 微芯片在 LCD 上显 示数据。
根据以下步骤执行 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转换区
否
是
返回
图 1 中断服务流程图
移植μC/ OS-Ⅲ:μC/ OS-Ⅲ移植有两个主要的工作,一个是中断处理程序的设计, 另一个是时间程序的设计。1.中断处理程序的设计是嵌入式操作系统中硬件抽象层 的重要组成部分。对于μC/ OS-Ⅲ,每个中断处理程序必须用汇编语言编写。另外 处理中断在不同的编译器中是不一样的。dsPIC 编译器为每个中断保留一个中断向 量。当发生中断时,它会自动跳转到中断向量。第一步是保存中断场景,如果这 不是中断嵌套,则保存任务堆栈的指针,清除中断标志状态,调用 C 中断服务函 数,中断退出)。如果这是中断嵌套,则不会保存任务堆栈的指针,调用并处理 C 中断服务函数。 2.系统时间的设计。与其他计算机操作系统一样,μC/ OS-Ⅲ使 用硬件时间以毫秒时间中断来实现系统时间。该设计在系统时间使用定时器 1。初 始化定时器的步骤如下:1 清除 TM R1 位 2 设置时间 1 中断为所需优先级 3 清除 时间 1 中断状态标志 4 启用时间 1 中断 5 启动带预分频器设置和时钟源设置的时
间 1.2 选择内部时钟源。 3 设置分频,中断周期(10 ms),中断优先级。 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-Ⅲ的特性,如空闲任务堆栈 大小节拍率,等等。
图 2:μC/ OS-Ⅲ架构
结论
本文详细阐述了基于μC/ OS-Ⅲ的多通道数据采集的设计与实现。 本文实现了 dsPIC30F6014 的 4 通道数据采集。 实验表明,该系统可以及时采集和处理多路数 据,并可以通过μC/ OS-Ⅲ操作系统调度多任务。 然后它符合电气调节器的需要。 这种设计具有很强的通用性,只要用其他处理器芯片代替系统的微处理器--- dsPIC30F6014A,就可以通过根据本文描述的方法进行适当修改来实现实时信号采 集和存储处理, 应用前景广阔。
图 3 运行系统
参考文献
[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
收藏