摘 要
本系统介绍USB接口波形发生器的设计。它采用直接数字频率合成(DDFS)技术,实时将USB接收到的数据转换成各种频率的波形输出,所使用的USB传输方式为全速同步传输。它可以输出正锯齿波、反锯齿波、三角波、方波和正弦波5种波形。其硬件电路由以USB控制芯片AN2131QC为核心的USB接口单元、以可编程逻辑器件EPM7064为核心的DDFS单元、以数模转换器TLC7524和DAC0832为核心的波形输出单元三大部分构成。其中,USB接口单元负责完成硬件系统和PC机之间的数据传输,DDFS控制单元负责控制系统输出波型的频率,波形输出单元负责对波形数据进行DA转换,并负责控制输出波形幅度峰峰值。它的系统软件包括Keil C51语言编写的AN2131QC芯片固件程序、Visual C++语言编写的USB设备驱动程序和Win32应用程序。其波形频率范围是0.5Hz~15999.5Hz,步进值为0.5Hz,幅度范围是0V~+5V,步进值为20mV。
关键词: USB接口;任意波形;DDFS;波形发生器;Visual C++语言
ABSTRACT
This system introduces the design of USB interface wave form generator. It uses direct digital frequency synthesizer (DDFS) techniques, real-time will be received USB data into various frequency waveform output, used for full-speed USB transfer mode asynchronous transfer. It can output is sawtooth, anti-aliasing wave, triangle wave, square wave and sine wave . The hardware circuit to USB controller chip by AN2131QC at the core of the USB interface unit to EPM7064 programmable logic device as the core unit DDFS to DAC TLC7524 and the DAC0832 output waveform at the core constitute the majority of unit three. Which, USB interface unit is responsible for the completion of the hardware systems and PC data transfer between machines, DDFS control unit control system is responsible for the frequency of the output waveform, waveform output unit is responsible for the waveform data DA conversion, and is responsible for control of output waveform peak-to-peak amplitude. Its system software, including the Keil C51 language AN2131QC firmware chip, Visual C + + language prepared USB device drivers and Win32 applications. It’s frequency adjustment range is 0.5Hz ~ 15999.5Hz, step value of 0.5Hz and amplitude of the adjustment range of 0V ~ +5 V, step value of 20mV.
Key words: USB interface; Arbitrary Waveform; DDFS; waveform generator; Visual C+ + Language
目 录
1 引言………………………………………………………………………………………………………………….. 3
1.1课题背景及意义………………………………………………………………………………………… 3
1.2课题的主要任务和技术指标………………………………………………………………………. 4
2 系统总体设计和工作原理………………………………………………………………………………….. 5
2.1方案设计与论证………………………………………………………………………………………… 5
2.2工作原理…………………………………………………………………………………………………… 5
2.2.1 USB主机………………………………………………………………………………………… 5
2.2.2 USB设备………………………………………………………………………………………… 6
2.3 USB接口芯片…………………………………………………………………………………………….. 7
2.3.1 USB主控制器芯片………………………………………………………………………….. 8
2.3.2 USB集线器芯片……………………………………………………………………………… 8
2.3.3 USB功能设备芯片………………………………………………………………………….. 8
2.4 USB信号…………………………………………………………………………………………………… 9
2.4.1 USB信号的发送……………………………………………………………………………… 9
3 系统硬件电路的设计………………………………………………………………………………………… 11
3.1主控制器——单片机AN2131QC的特点……………………………………………………… 11
3.1.1芯片结构……………………………………………………………………………………….. 11
3.2系统硬件模块电路的设计………………………………………………………………………… 13
3.2.1 电路总体方框图…………………………………………………………………………… 13
3.2.2 USB接口单元……………………………………………………………………………….. 14
3.2.3 DDFS控制单元……………………………………………………………………………… 14
3.2.4 波形输出单元………………………………………………………………………………. 15
4 软件的设计与实现…………………………………………………………………………………………… 17
4.1软件功能及作用………………………………………………………………………………………. 17
4.1.1主函数………………………………………………………………………………………….. 17
4.2上位机程序设计………………………………………………………………………………………. 17
4.2.2上位机程序功能和界面…………………………………………………………………. 18
4.3设备驱动程序………………………………………………………………………………………….. 19
4.3.1 固件程序……………………………………………………………………………………… 19
4.3.2 波形功能程序………………………………………………………………………………. 19
结 论…………………………………………………………………………………………………………….. 21
参 考 文 献……………………………………………………………………………………………………….. 22
附录1:原理图…………………………………………………………………………………………………… 23
附录2:程 序(主函数部分)………………………………………………………………………….. 26
致 谢…………………………………………………………………………………………………………….. 35