labview基于声卡的数据采集系统
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
实验2 基于声卡的数据采集系统
1 实验目的
(1)学习声卡作为数据采集装置的Labview编程方法;
(2)从设计中深入理解虚拟仪器的组成,理解数据采集,数据分析的重要性,用Labview实现测试系统的优点;
(3)实验的应用:目前的测试实验教学实验中常常要用到A/D采集卡,而A/D采集卡价格不菲,以实验室有限的经费,不能较多第购置以供同学们实验使用,进而考虑计算机中的声卡本身就是一个A/D、D/A 的转换装置,而且造价低廉,性能稳定,在教学实验中完全可以满足实验的需求,可以进一步开发研制一个广泛应用的测试教学实验系统。
2 实验设备、仪器
计算机、声卡、Labview软件,其组成如下图:
3 实验任务
设计一个基于声卡的频谱分析仪,可以采集和分析从麦克风输入的声音。
要求仪器可以调节采样频率、数据缓冲区的大小等,可显示其波形,保存并对波形作幅值频谱分析。
4 实验原理
4.1 声卡简介
声卡是现在计算机中非常常见的一个组件,是多媒体的标准配置。
与声卡声音采集相关的两个专业术语是声音采样和声道。
声音采样,即在模拟声音波形上每一个时间间隔取一个幅度值,把自然界的模拟音转变为数字音时。
声音采样的描述有两个指标:'采样位数'和'采样频率'。
采样位数就是指用来描述波形幅度的细腻程度,8位声卡可以把波形划分为256个级别,而16位声卡就可以划分为64×1024个级别,现在的声卡一般都采用16位的声卡。
'采样的频率'是指录音设备在一秒钟内对声音信号的采样次数,采样频率越高声音的还原就越真实越自然,现在声卡采样频率一般有22.05KHz、44.1KHz、48KHz三个等级,22.05 KHz是FM广播的声音品质,44.1KHz则是理论上的CD音质界限,而48KHz则更加精确一些。
声道,就是声卡处理声音的通道的数目,以前是单声道,后来又发展出立体声、5.1声道、四声道等的标准。
4.2 Labview中有关声卡的函数简介
Labview中提供了一系列使用Windows底层函数编写的与声卡有关的函数。
关于声卡函数的子选板如下表所示:
子选板说明
Sound File VIs Sound File VI用于创建和获取波形文件(.wav)。
Sound Input VIs Sound Input VI用于配置和控制声音输入设备。
Sound Output VIs Sound Output VI用于配置和控制声音输出设备。
声卡输入子选板函数如下表所示:
选板对象说明
SI Clear Closes the sound input device associated with the task ID in input and releases all the resources the device uses.
SI Config Configures a sound device for a sound input operation.
SI Read Reads data from the sound input device. If data has arrived to the sound input device, the device returns that data after buffering. Otherwise, the device waits until data arrives.
SI Start Prompts the sound input device to begin accumulating incoming data. SI Stop Prompts the sound input device to stop accumulating incoming data.
声卡输出子选板函数如下表所示:
选板对象说明
SO Clear Closes the output sound device associated with the task ID in input and releases any resources.
SO Config Configures a sound output device and creates a sound output task ID.
SO Pause Pauses a sound output device associated with the task ID in input.
SO Set Num
Buffers
Sets the number of output buffers associated with the task ID in input.
SO Start Starts a sound output operation associated with the task ID in input.
SO Stop Immediately stops the sound output operation associated with the task ID in input. SO Volume Sets the volume of the sound output device.
SO Wait Waits until the sound output device finishes playing all the data the device has received. SO Write Writes data to the sound output device associated with the task ID in input.
声音文件子选板函数如下表所示:
选板对象说明
Snd Read Wave File Retrieves a wave file (.wav) specified in the wave file path input.
Snd Write Wave File Stores waveform data and its sound format information in a file.
由上面的介绍可以看出,使用Labview构建基于声卡的虚拟仪器思路是相当清晰的。
实际数据采集流程如下图所示,这个流程与一般数据采集卡并无多大差别。
声卡数据采集的流程
5 实验步骤
(1)创建类似下图的前面板,可以设置声音采样频率,启动停止声音采集,能显示所得到声音波形和其幅值频谱。
基于声卡数据采集系统前面板示例
(2)利用While Loop,Case Structure, SI Config, SI Start, SI Read, SI Stop, SI Clear, Build Waveform, Spectrum, Time Waveform等等编写程序框图
(3)运行由1、2步创建的VI程序,对着麦克风轻轻哼一个小调,对VI程序功能进行测试。
6 思考题
声卡能否采集从变送器输出的信号?如果可以请查阅资料,设计相关电路图;如果不行,说明理由。
7 实验报告内容
(1)实验目的、实验设备、实验内容、简述实验步骤、流程图、运行结果的前面板图;(2)回答思考问题;
(3)实验感想。