LabWindows_CVI环境下实现实时数据管理的一种方法

合集下载

基于LabWindows_CVI的数据库应用程序开发

基于LabWindows_CVI的数据库应用程序开发
随着测试复杂程度的提高和综合测试管理难度 的增加 ,将涉及到大量的测试信息 ,包括 UUT (Unit Under Test,被测对象 )信息 、测试仪器信息 、测试结果
信息 、测试人员信息等 ,这些数据的维护和管理需要 统一的数据库机制来实现 。而 LabW indow s/CV I开 发环境提供了对数据库的支持能力 ,可以实现多种异 构数据库的访问和维护 。
摘要 : LabW indow s/CV I是测试领域优秀的开发软件 ,用于开发大型 、复杂的测试软件 ,能获得优良的测试性能 ,而 M i2 crosoft Access的数据库开发能力也十分强大 ,两者的结合可以使得需要测试大量指标和处理大量测试数据的自动测试 系统的开发变得更加容易 。本文以某电台信号处理模块的自动测试系统的开发为例 ,详细说明如何在 LabW indow s/CV I 中访问 M icrosoft Access制作的数据库 。结果表明 ,由此给自动测试系统在数据处理和数据存储方面提高了数倍效率 。 关键词 :应用程序开发 ; 数据库 ; LabW indow s/CV I; Access; 自动测试系统 中图分类号 : TP391 文献标识码 : A
本文不一一讲述每个表的制作 ,仅以发通道测试 数据表为例说明如何利用 M icrosoft Access制作数据 库 ,及如何在 LabW indow s/CV I的环境中对数据库进 行查询和访问 。
2 数据库制作
数据库是由组织好的数据集组成 。最新的数据 库管理系统 (DBMS)都将数据存为表的形式 。表的 结构通过记录和字段构成的二维形式来实现 (其中 : 记录称为行 ,字段称为列 ) 。数据库中每个表必须有 一个惟一的名字 ,表中每个字段也必须有一个惟一的 名字 [ 3 ] 。表中每个字段都有各自的数据类型 ,在编 写程序之前一定要搞清楚各字段的数据类型 ,才能在

LabWindows CVI实时模块入门指南说明书

LabWindows CVI实时模块入门指南说明书

October 2008374686A-01Getting Started with theLabWindows /CVIReal-Time ModuleThis document provides an introduction to the LabWindows ™/CVI ™ Real-Time Module. Refer to this document for installation and configuration instructions and information about creating a real-time (RT) project.Installing the Real-Time Module Software on a Host ComputerYou must first install the Real-Time Module software on a host computer. Then you can configure and install software on the RT target.To install and use the Real-Time Module software, you must have the following:•Free Disk Space —In addition to the minimum system requirements for LabWindows/CVI, you must have at least 250 MB of free disk space for the Real-Time Module software. Refer to the LabWindows/CVI Release Notes for minimum system requirements.•RT Target —The LabWindows/CVI Real-Time Module supports NI RT Series PXI controllers and desktop PCs converted to RT targets. Refer to the Using Desktop PCs as RT Targets with the LabWindows/CVI Real-Time Module document for more information about converting a desktop computer to an RT target.Complete the following steps to install the LabWindows/CVI Real-Time Module on a host computer.1.Install LabWindows/CVI. Refer to the LabWindows/CVI Release Notes for information about installing LabWindows/CVI.Note Do not install the device driver software when you are prompted to do so during the LabWindows/CVI installation. Instead, install the device driver software when you are prompted during the LabWindows/CVI Real-Time Module installation.™™2.Insert the LabWindows/CVI Real-Time Module CD into the CD drive. Ifthe CD does not run automatically, open Windows Explorer, right-click the CD drive icon, and select AutoPlay.3.Select Install LabWindows/CVI Real-Time Module on the NationalInstruments LabWindows/CVI screen.4.Follow the instructions on the screen.5.During the installation, use the NI Device Drivers media to install thedevice drivers that you need.Configuring the RT TargetAfter you install LabWindows/CVI and the RT module, you must useNI Measurement & Automation Explorer (MAX) to configure the RT target and to install software and drivers on the RT target. MAX provides access to NI devices and systems and can communicate with networked RT targets, or remote systems, located on the same subnet as the computer running MAX. Complete the following steps to configure the RT target. The following sections describe these steps in more detail.1.Boot the RT target into LabVIEW RT.2.Configure network settings.3.Install software on the RT target.4.Configure system settings.5.Configure I/O.Refer to the Measurement & Automation Explorer Help for a complete tutorial about configuring the RT target. Select Help»MAX Help to access this help file, and then refer to the MAX Remote Systems Help section.LabVIEW Real-Time Module. However, you can apply the sameconcepts when you use the LabWindows/CVI Real-Time Module. Booting the RT Target into LabVIEW RTIf the RT target has only LabVIEW RT installed on its hard drive, the system is already set up to boot into LabVIEW RT, and you can continue to the Installing Software on the RT Target section of this document. If the RT target has LabVIEW RT and Windows installed on its hard drive, your system may have DIP switches or BIOS settings for booting into LabVIEW RT.If the RT target is a PXI system that does not have LabVIEW RT installedand has a floppy disk drive, you can create a boot disk to boot the system intoLabVIEW RT.Getting Started with LabWindows/CVI © National Instruments Corporation 3Getting Started with LabWindows/CVI Real-Time 1.Select Tools»RT Disk Utilities»Create PXI Boot Disk in MAX tocreate a boot disk from the host computer.2.Click Yes in the Measurement & Automation Explorer dialog box andfollow the instructions on the screen to create the boot disk.3.When you finish creating the boot disk, remove the floppy disk from thehost computer and insert it into the floppy drive of the PXI controller you are using as an RT target.4.Power on or reset the controller to boot it into LabVIEW RT.If you are converting a desktop computer to an RT target, refer to the Using Desktop PCs as RT Targets with the LabWindows/CVI Real-Time Module document for information about booting into LabVIEW RT.Configuring Network SettingsNoteTo perform the initial configuration, you must connectunconfigured RT targets to the same network subnet as the host computer from which you launch MAX. Unconfigured targets outside of the subnet do not appear under the Remote Systems item in the MAX configuration tree.1.Connect the RT target to the network and power on the target.unch MAX and expand the Remote Systems item in the MAXconfiguration tree.3.Select the RT target from the Remote Systems item and click theNetwork Settings tab. The RT target appears as 0.0.0.0 under the Remote Systems item.4.Assign an IP address in the Network Settings tab using one of thefollowing options:•Select the Edit the IP settings option and specify an IP address.You also can click Suggest Values to select an IP address suggested by MAX.•Select Obtain IP address from DHCP server to obtain an addressautomatically.5.Click Apply to commit the changes.6.Click Yes to reboot the RT target.If your previously configured RT target is on another subnet and does not appear under the Remote Systems item, you must add the target manually. Complete the following steps to add the RT target:1.Right-click the Remote Systems item and select Create New .2.Select the target type and click Next.Getting Started with LabWindows/CVI Real-Time 3.Enter the host name or IP address of the device. You can obtain the hostname or IP address of the RT target by running MAX from a computer on the same subnet as the target or by connecting a monitor to the target and viewing the information displayed when the target boots.4.Click Finish . MAX adds the device to the Remote Systems list.Installing Software on the RT TargetUse the LabVIEW Real-Time Software Wizard to install software on the RT target. With the LabVIEW Real-Time Software Wizard, you can view the software that is already installed on the target, view the software that is available to install on the target, and change the software that is installed on the target. Click Help in the wizard for more information about installing and uninstalling software on the RT target.1.Expand the RT target under the Remote Systems item in the MAXconfiguration tree, right-click Software , and select Add/Remove Software .2.Select the software you want to install on the RT target.Note If you have multiple software versions installed on the host computer, the most recent version is selected by default. You can choose to install another version.•Ethernet Drivers —MAX automatically selects the appropriate Ethernet driver(s) for the RT target when you install theLabWindows/CVI Run-Time Engine for RT component.•LabVIEW Real Time —MAX selects this item automatically when you install the LabWindows/CVI Run-Time Engine for RTcomponent.•NI RT Extensions for SMP (MultiCore Support)—Install this item to take advantage of parallel processing on a multiple-CPU system.Note Single-CPU systems perform best without the NI RTExtensions for SMP . Also, some applications, such as those that consist mainly of single-point I/O, can achieve lower latency on a multicore system by using a single CPU without the NI RTExtensions for SMP .•LabWindows/CVI Network Variable for RT —Install this item only if your application uses functions from the Network VariableLibrary.•LabWindows/CVI Run-Time Engine for RT—Install this item to add support for LabWindows/CVI RT applications on the RT target.This component is required for all LabWindows/CVI RTapplications.•Language Support for LabVIEW RT—Install this item if you are using strings in your RT application containing ASCII charactersabove 127 or multibyte characters. After installing this item on theRT target, you can configure the locale in MAX by selecting thetarget in the Remote Systems item in the MAX configuration tree,selecting the System Settings tab, and modifying the Locale option.•NI Hardware Drivers—Install the appropriate drivers for any other hardware libraries that you use in your application. For example,install the NI-DAQmx component if your application uses functionsfrom the NI-DAQmx Library.•Network Variable Engine—MAX automatically selects this item when you install the LabWindows/CVI Network Variable for RTcomponent.•USB Support—Install this item to enable support for accessing USB thumbdrives.•Variable Client Support for LabVIEW RT—MAX automatically selects this item when you install the LabWindows/CVI NetworkVariable for RT component.Configuring System Settings1.Select the System Settings tab to configure system-level settings for theRT target.e the Timezone option to configure time zone and daylight savingsettings for the RT target. You can use this setting with time and date functions to provide accurate time information, relative to the time zone setting.3.Configure the Locale option to match the language you use for strings inyour RT application. This option is available only when you install the Language Support for LabVIEW RT component on the RT target.This option determines the code page that LabWindows/CVI uses when processing strings containing ASCII characters above 127 or multibyte characters.Configuring I/OYou must configure any National Instruments I/O devices before you can target them from a LabWindows/CVI RT application. For information about how to correctly configure I/O devices, refer to the documentation for that hardware.© National Instruments Corporation5Getting Started with LabWindows/CVI Real-TimeConfiguring an RT ProjectAfter you configure the RT target, you can create an RT application on the host computer and then run the application on an RT target. The applications that you create with the LabWindows/CVI Real-Time Module are DLLs. Complete the following steps to create a DLL and specify an RT target directly from LabWindows/CVI.1.Create a project in LabWindows/CVI using RTmain instead of main asthe entry point function for the program. Select Edit»Insert Construct»RTmain to insert the RTmain code into the program source.2.Select Build»Configuration»Debug or Build»Configuration»Releaseto specify the active configuration for the project.3.Select Build»Target Type»Dynamic Link Library to configure theproject to generate a DLL.4.Select Build»Target Settings to open the Target Settings dialog box.Select Real-time only in the Run-time support option. If you specify this option, LabWindows/CVI does not link to the entire set ofLabWindows/CVI libraries but instead links to only those librariessupported on an RT system.5.Configure other options in the Target Settings dialog box and click OKto exit the dialog box.6.Select Build»Create Debuggable Dynamic Link Library or Build»Create Release Dynamic Link Library to create the DLL.You also can use a project template to create an RT DLL. The project template includes basic settings for RT projects described in the preceding section. To select a project template, select File»New»Project from Template. In the New Project from Template dialog box, select Real-Time Target Application.Specifying an RT TargetComplete the following steps to select the RT target on which to run your RT application.1.Select Run»Select Execution Target for Debugging to view a list ofpreviously configured RT targets. Select the RT target you want to use from the list, if it is available.2.To configure a new RT target, select Run»Select Execution Target forDebugging»New Execution Target.3.In the New Real-Time Execution Target dialog box, enter the computername or IP address of the RT target in the Hostname/IP Address option and click OK to exit the dialog box.Getting Started with LabWindows/CVI © National Instruments Corporation 7Getting Started with LabWindows/CVI Real-Time Running an RT ApplicationSelect Run»Debug Project to run your RT application.NoteIf you select Run»Configuration»Release ,LabWindows/CVI displays a warning message. Click Continue to download and run the release DLL on the RT target. LabWindows/CVI automatically builds the DLL and downloads the DLL and any DLLs that are statically linked to it onto the specified RT target. LabWindows/CVI places the files that it automatically downloads in the NI-RT\CVI\temp folder. LabWindows/CVI empties the folder when you reset the RT device.While you run your RT application, LabWindows/CVI displays a <<Running on target >> menu in the upper left corner of theLabWindows/CVI environment. The menu contains the following options, which you can use for debugging and for shutting down the RT application:•Toggle Breakpoint —Turn on or turn off a breakpoint on the selected line.•Break Execution —Suspend execution of the program.•Simulate RT Shutting Down —End program execution. This option causes the RTIsShuttingDown function to return 1, giving the RT application an opportunity to run any necessary cleanup code and exit. The RT target does not reboot.•Abort Execution and Reboot Target —End program execution and reboot the RT target. The application cleanup code is not guaranteed to finish running before the RT target reboots.•Disconnect from RT target —Disconnect LabWindows/CVI from the RT target while the RT application continues running on the target. Once you disconnect from the RT target, you cannot reconnect LabWindows/CVI to the RT application that is running.Debugging an RT ApplicationIf you select Build»Configuration»Debug , you can debug the DLL from the LabWindows/CVI environment as you would debug any other application. For example, you can set breakpoints and watch expressions, step through code, view and edit variable values, and so on. For more information about debugging in LabWindows/CVI, refer to the Using LabWindows/CVI»Debugging Tools section of the LabWindows/CVI Help.Using the Real-Time Execution Trace ToolkitThis version of the LabWindows/CVI Real-Time Module includes a 30-day full-featured evaluation of the Real-Time Execution Trace Toolkit.Use the Real-Time Execution Trace Toolkit to analyze the timing and execution of an RT application. Use the Execution Trace functions in the Real-Time Utility Library to capture the timing and execution data of functions and threads in applications running on an RT target. The Real-Time Execution Trace Tool displays the timing and event data, or trace session, on the host computer.In LabWindows/CVI, select Tools»Real-Time Execution Trace Tool to launch the Real-Time Execution Trace Tool. Refer to the LabWindows/CVI Help for more information about using the Real-Time Execution Trace Toolkit to analyze RT applications.Deploying an RT ApplicationWhen you finish developing your RT application, you can deploy it to an RT target. After you deploy the RT application, the RT application runs automatically every time the RT target reboots.Select Run»Install Program to Real-Time Execution Target to deploy your RT application. This option performs the following actions:•Checks that the release configuration of the DLL has been built; if not, LabWindows/CVI prompts you to build the DLL or cancel.•Deploys the release DLL and any statically linked DLLs to the NI-RT\CVI folder on the RT target.•Sets the release DLL as a startup DLL.•Displays a dialog box indicating that the DLL was copied and prompting you to reboot the RT target.If you have additional support files that you need to deploy, complete the following steps:1.Select Run»Manage Files on Real-Time Execution Target to launchthe LabWindows/CVI Real-Time File Copy Utility.2.Click Add Files and browse to any support files that your applicationrequires. The utility immediately copies the files to the NI-RT\CVIfolder on the RT target.3.Click Done when you finish adding support files.Getting Started with LabWindows/CVI Where to Go from HereRefer to the following resources for more information about the LabWindows/CVI Real-Time Module:•The LabWindows/CVI Real-Time Module Help section of the LabWindows/CVI Help includes conceptual information about real-time programming techniques, application architectures, and Real-TimeModule software features you can use to create real-time applications.Select Help»Contents in LabWindows/CVI to access theLabWindows/CVI Help.•Use the NI Example Finder, available by selecting Help»Find Examples in LabWindows/CVI, to browse or search for example programs. You also can access the example programs from the samples\CVIsamples\realtime directory.© National Instruments Corporation9Getting Started with LabWindows/CVI Real-TimeNational Instruments, NI, , and LabVIEW are trademarks of National Instruments Corporation. Refer to the Terms of Use section on /legal for more information about National Instruments trademarks. The mark LabWindows is used under a license from Microsoft Corporation. Windows is a registered trademark of Microsoft Corporation in the United States and other countries. Reliance™ is a trademark of Datalight, Inc. Copyright 1989-2008 Datalight, Inc., All Rights Reserved. Datalight® is a registered trademark of Datalight, Inc. Other product and company names mentioned herein are trademarks or trade names of their respective companies. For patents covering National Instruments products/technology, refer to the appropriate location: Help»Patents in your software, the patents.txt file on your media, or the National Instruments Patent Notice at /patents.© 2007–2008 National Instruments Corp. All rights reserved.374686B-01Oct08。

基于LabWindows/CVI5.0.1开发的远程实时数据采集系统

基于LabWindows/CVI5.0.1开发的远程实时数据采集系统

数据采集网页 , 输入具体的采样参数 , : 如 采样通道 数、 通道号 、 增益、 采样点数 、 采样频率、 扫描频率等 等, 点击采样 键后 , 样参数和执行采样动作的命 采 令便 通过 We 务器传 到 虚拟 仪器 , 动位 于虚拟 b服 启 仪 器 上 的采 样 程 序运 行 ,所 得 的采 样 结果 再 通过 we 务器 返 回到 数据 采集 网页 上 , 样 就 实现 了 b服 这 远 程实 时数据 采集 。 1 实现 系统功 能 的技 术 方案 . 2 Lb no sc I 一个 目前 国内外 使 用 较 为 a widw / V 是 广泛的虚拟仪器开发平台, 具有面向对象的可视化 编程 环境 , 以 A Sc为核 心 , 它 NI 以各 种 丰 富 的库 函 数为基础 , 为仪器控制 、 自动测试和数据采集应用 提供 了一个 功能强大 的开发平台。另外 ,aWi Lb n . dw/ V 的编 译 器 和 Mi oo sa C C 十 编 o sC I c sf Vi l / 十 的 r t u 译 器 兼容 , 直 接在 Mioo sa C 十 可 c sf Vi l 十 的程序 中 r t u 调用 Lb no sC I.1的库 函数 。因此 . aWid / V 50 w . 实现 基 于 Lb no s( I.1开发 的 远程实 时 数 据采 集 aWidw /: 50 V . 系统 功能 的 技 术 方案 的思 想 基 础为 : 用 Lb n 利 aWi- dw/ V501的库 函数进 行 二次开 发 , o sC I.. 以实现远 程 实时 数据采集 。 技术 方 案采 用开 发 和 系统 的三 层 结 构 分 布 式 计算机模式相对应、 适应于在 It e Itn t n m t n ae环境 e / r 下使用 的三层 结 构应 用软件 , 图 2 H ML A P脚 如 。 T +S 本语 言和 自动 化组 件 (oktCi t位 于 We Sce 1 n) e b服务 器上 , ce Sr r 序和 用 Lb l o sC I.. o S kt e e 程 v aWidw/ V501 a 创建的包 含采样 函数的动态链 接库 位于作 为虚拟 仪器的计算机上。程序的执行过程为 : S A P脚本运 行 , Sr t 用 自动 化 组 件 后 , ce 1 n 和 VB i 调 O p O S ktCl t e Sce Sre 之 间进 行 通 信 ,oktSre 接 收 到 okt evr Sce o tr Sce Cin 传 来 的数 据 后 ,调 用 用 Lb no s okt l t e aWid / w

基于LabWindows/CVI的数据库编程

基于LabWindows/CVI的数据库编程

基于LabWindows/CVI的数据库编程董慧群;王福明【摘要】In a complex large-scale test system of software development, facing the large amounts of data storage, management and processing, the database is an indispensable and important component. Open database connectivity (ODBC) specification provides a set of%在复杂的大型测试系统的软件开发中,面对大量数据的存储、管理和处理,数据库是测试系统中不可缺少的重要组成部分。

开放式数据库互联(ODBC)规范提供的一组对数据库访问的标准API为数据库的管理和应用程序开发提供了强大的工具。

基于此介绍了在Labwindows/CVI平台下,应用ODBC和SQLTOOLKIT工具包与Oracle数据库交互的过程和程序实例。

实践证明,此方法简单、可靠,实际开发中可用性比较强。

【期刊名称】《山西电子技术》【年(卷),期】2011(000)004【总页数】2页(P55-56)【关键词】LabWindows/CVI;ODBC;SQL;Toolkit;数据库【作者】董慧群;王福明【作者单位】中北大学,山西太原030051;中北大学,山西太原030051【正文语种】中文【中图分类】TP311在测试系统的应用开发中,测试数据通常是以文件的方式进行组织管理的。

这样的数据存储方式有一定的局限性,特别是远程测试系统,对于大量的数据不能及时的反馈。

要实现方便灵活的管理和访问,数据库是一种必然的选择。

LabWindows/CVI是一个完全的标准C开发环境,用于开发虚拟仪器应用系统[3]。

CVI5.5及以后的版本提供了支持数据库的SQL TOOLKIT工具包,该工具包提供了丰富的数据库操作函数,给开发带来了方便和快捷。

LabVIEW与LabWindowsCVI结合两种开发环境的优势

LabVIEW与LabWindowsCVI结合两种开发环境的优势

LabVIEW与LabWindowsCVI结合两种开发环境的优势在现代科技发展的背景下,软件开发环境的选择对于工程师和科研人员来说至关重要。

LabVIEW和LabWindowsCVI是两种常见的软件开发环境,它们分别有自己独特的特点和优势。

然而,结合使用这两种开发环境可以发挥出更大的优势,为用户提供更强大的功能和更高效的开发体验。

一、LabVIEW的优势LabVIEW是美国国家仪器公司(National Instruments)开发的图形化编程环境,被广泛应用于科学研究、工业控制等领域。

LabVIEW具有以下几个显著的优势:1. 图形化编程界面:LabVIEW采用图形化的编程界面,通过将函数模块拖拽至编程区域并连接,用户可以直观地组织和搭建程序。

相比于传统的文本编程,图形化编程使得程序结构更加清晰易懂,降低了学习和开发的门槛。

2. 丰富的工具箱:LabVIEW提供了一系列丰富的工具箱,涵盖了各种领域的应用需求。

无论是进行数据采集、信号处理、图像处理还是控制系统的设计,LabVIEW都提供了相应的工具箱和函数库,可以方便地实现各种功能。

3. 与硬件设备的无缝集成:LabVIEW可以与各种硬件设备无缝集成,包括传感器、仪器等。

通过其独特的数据采集、控制和监控功能,LabVIEW可以轻松实现与硬件设备的通讯和数据交互,为用户提供高效的实验和控制手段。

二、LabWindowsCVI的优势LabWindowsCVI是一种基于C语言的集成开发环境,也是由美国国家仪器公司开发的工程开发环境。

LabWindowsCVI具有以下几个显著的优势:1. C语言编程:LabWindowsCVI基于C语言开发,对于熟悉C语言的开发人员来说更加友好和熟悉。

C语言作为一种广泛应用的编程语言,具有强大的功能和灵活性,可以满足各种复杂应用的开发需求。

2. 高性能和灵活性:LabWindowsCVI具有高性能和灵活性,可以快速响应和处理复杂的数据处理任务。

LabWindows/CVI在某测试系统软件开发中的应用技术

LabWindows/CVI在某测试系统软件开发中的应用技术
( o p tr ntu , otw s r o t h i l nvri , ia 0 2 C ia C m ue s tt N r et nPl e nc i sy X’l7 7 , hn) I ie h e yc aU e t l1 0
Ab t a t A ts y tm sn i u lisr me t e h oo y i rs ne . h to f o s u t g a t s s se b s d o i u l sr c : e ts s e u ig vr a n tu n c n lg sp e e td T e meh d o n t ci e t y t m a e n vr a t t c r n t
isr me ttc n l ge r m t e h r wae s u t r n ot a e s s m s ito u e . h t o s o e d ie e in t e r a・ nt u n e h oo i sfo h a d r t cu e a d s f r y t i n r d c d T e me h d ft r rd sg , h e l r w e h v
理, 与采集到 的试验数据共 同构成产 品的试验结果 。
程技术 中建立 检测 系统 、 自动测试环境 、 数据采集 系统等首选 的
软件开发工具 。
笔者重点讨论 了 L b n o sC I aWidw/ V 环境 下驱 动程序 开发方 法、 测试数据的实时处理技 术及事 后数据处理 中曲线 的无极 缩
得 Lb n o sC I自身功能更加强 大 , aWi w/ V d 应用 更加 方便 , 成为 工
模 拟量信号、 离散 量信 号 、2 4 9信 号、 53 15 B信号及 R 2 2信号 S3 的测试 任务 ; 信号调理模块 主要完成 对对输 入的信号进 行放大 缩小 、 线性化 、 滤波 、 同步采样保 持 、 隔离 、 消除静态信号 、 扩展等 处理等 ; 试验后 , 试验控制计算机可 以通过局域 网收集仿真计算 机、 设备计算机及 控制 台计算 机 的试验 数据 , 行综 合分 析处 进

labwindows-CVI-教程

l a b w i n d o w s-C V I-教程本页仅作为文档封面,使用时可以删除This document is for reference only-rar21year.MarchLabWindows/CVI基础教程序言LabWindows/CVI是National Instruments公司推出的一套面向测控领域的软件开发平台。

它以ANSI C为核心,将功能强大,使用灵活的C语言平台与数据采集,分析和表达的测控专业工具有机地接和起来。

它的集成化开发平台,交互式编程方法,丰富的控件和库函数大大增强了C语言的功能,为熟悉C语言的开发人员建立检测系统,自动测量环境,数据采集系统,过程监控系统等提供了一个理想的软件开发环境。

本教程面向的是那些从未使用过LabWindows/CVI的读者,但是假设读者以有了C语言的基础并且熟悉Windows 2000/9x/NT操作系统。

在每一章节的学习中,作者都是通过一个具体的实例让读者迅速的掌握本章的知识点;而不是长篇大论,述及边枝细叶,反而使读者望而却步,只见树木,不见森林。

想信通过对本教程的学习,读者可迅速掌握LabWindows/CVI编程思想及步骤,为读者日后进一步学习打下基础。

本书约定:“File>>Page Setup>>Options”File 这一种黑色斜体字是指多级菜单名,按扭名,窗口名或者是关键性词汇。

“>>”是指打开一个多级菜单或对话框。

如:File>>Page Setup>>Options是指你首先打开File 菜单,然后选择Page Setup项,最后从弹出的对话框中选择Options 项。

“说明:通过这种方式你可以修改Panel顶端所显示的名字。

”该种字体所写的文字是值得读者注意并记忆的内容。

“该椭圆形框所框住的内容是读者需修改的地方。

第一部分 CVI快速入门本部分通过编制一个简单的LabWindows/CVI程序,使读者对CVI编程环境,思想及步骤有一初步的认识。

LabWindowsCVI的应用特点(1)

LabWindows/CVI的应用特点摘要:LabWindows/CVI是一个完全的标准C开发环境,用于开发虚拟仪器应用系统。

Labwindows/CVI将源代码编辑、32位ANSI C编译、联结、调试以及标准ANSI C库等集成在一个交互式开发环境中。

编程技术方面主要采用事件驱动方式与回调函数方式,编程方法简单易学。

同时Labwindows/CVI对每一个函数都提供一个函数面板,可进行交互式编程,大大减少了源码语句的键入量,减少了程序语法错误,提高了工程设计的效率和可靠性。

关键字: LabWindows/CVI;ANSI C;事件驱动;回调函数;函数面板一、LabWindows/CVI简介LabWindows/CVI是一个完全的标准C开发环境,用于开发虚拟仪器应用系统。

LabWindows/CVI 提供内置式函数库用于完成数据采集、分析、和显示任务;它还提供简单的拖放式用户界面编辑器以及自动代码生成工具。

利用这些功能,您可以在将代码加入到某项目之前,先对其进行互动式的测试。

可以利用LabWindows/CVI定义和建立用户界面,生成或运行ActiveX组件,及开发多线程应用。

如果把您掌握的C语言编程知识与LabWindows/CVI简单易用的特性结合在一起,您将以不可思议地速度开发出复杂的测量应用系统。

LabWindows/CVI的应用领域极其广泛,涵盖了军工,电讯,工业生产和航天等各种行业。

二、Labwindows/CVI的特点LabWindows/CVI是一个完全集成式的开发环境,特别为建立以GPIB,PXI,VXI和插入式数据采集板卡为基础的测量系统而设计。

该环境将互动性、简单易用的开发方式与ANSI C编译代码所特有的强大编程功能和灵活性有机地结合在一起。

LabWindows/CVI提供了许多实用的特性,使您无需牺牲C代码的运行速度或源代码可管理性,便能引人注目地改进工作效率。

Labwindows/CVI将源代码编辑、32位ANSI C编译、联结、调试以及标准ANSI C库等集成在一个交互式开发环境中。

基于LabWindows CVI和MCU的温度采集系统设计

基于LabWindows CVI和MCU的温度采集系统设计摘要:设计了一种基于LabWindows/CVI和MCU的温度采集系统。

下位机由AT89S51单片机、DS18B20温度传感器、MAX232串口通信模块等组成,上位机采用LabWindows/CVI编程,实现单片机与上位机通信。

能够实现对工作现场实时温度采集,数据传输、实时处理、远程温度显示及存储,具有结构简单、显示直观、性价比高等特点。

关键词:LabWindows/CVI;MCU;温度采集温度是工业生产中常见的被控参数,温度采集与控制广泛应用于冶金、机械、食品、化工等各类工业中,准确、可靠、快速地采集到温度数据可以为工业生产中各类控制系统提供重要的依据。

传统温度采集系统多以热电阻、热电偶等为温度敏感元件,它们基本都是先测出电压,再将其转换成相对应的温度,这就显得较为复杂,需要大量的外部硬件支持;线路上传送的是模拟信号易受干扰,随着测温点数量的增加,信号传输线数量也随之增加,导致布线困难、安装、维护和检修的费用增加,软件调试也复杂。

本文设计了基于LabWindows/CVI和MCU 的多点温度采集系统,多个温度传感器采用单总线连接,大大降低了外部电路的复杂程度,具有节省I/O资源、结构简单、成本低廉、便于总线扩展和方便维护等特点[1]。

1 LabWindows/CVI简介虚拟仪器(Virtual Instruments)是仪器技术发展出的第四代仪器技术,是当前计算机辅助测试领域中一项重要的技术。

随着计算机的发展和各种相关软件的产生、完善,虚拟仪器正在逐渐取代传统的测量仪器而成为测试仪器的主流。

虚拟仪器和传统仪器相比,具有性价比高、开发性好、智能化程度高、界面友好、使用方便等优点[2]。

LabWindows/CVI是一个完全的ANSI C开发环境,将功能强大、使用灵活的C语言平台与用于数据采集、分析和显示的测控专业工具有机结合起来,包含了各种总线、数据采集和分析库,同时提供了国内外三百多种仪器的驱动程序,极大方便了虚拟仪器系统的开发,使用户容易生成各种应用程序,开发程序效率高、可靠性好。

基于LabWindows_CVI的数据库与Matlab混合编程及实现

第5卷 第4期信息与电子工程Vo1.5,No.4 2007年8月INFORMATION AND ELECTRONIC ENGINEERING Aug.,2007文章编号:1672-2892(2007)04-0253-04基于LabWindows/CVI的数据库与Matlab混合编程及实现蒋 薇,夏连胜(中国工程物理研究院 流体物理研究所,四川 绵阳 621900)摘要:为了在Windows/CVI环境下实现基于数据库的复杂算法,讨论了LabWindows/CVI与Matlab混合编程以及LabWindows/CVI对数据库进行访问的几种方法,并在多脉冲电子束测控系统中运用三者混合编程,实现了大量现场数据的计算、管理等功能。

关键词:LabWindows/CVI;Matlab;数据库;多脉冲电子束;测控系统中图分类号:TP206+.1 文献标识码:AMixed Programme and Implementation Based on LabWindows/CVI Databaseand MatlabJIANG Wei,XIA Lian-sheng(Institute of Fluid Physics,China Academy of Engineering Physics,Mianyang Sichuan 621900,China)Abstract: Several methods of mixed programme based on LabWindows/CVI and Matlab are discussed.Some kinds of solution about accessing between LabWindows/CVI and database are also described.The controllingand measuring system of multi-pulsed current beam is designed and implemented under the truss ofLabWindows/CVI+database+Matlab.It can provide a way to implement some complex algorithms basing ondatabase in LabWindows/CVI.Key words: LabWindows/CVI;Matlab;database;multi-pulsed current beam;controlling and measuring system1引言NI公司的LabWindows/CVI(以下简称CVI)开发平台集成了从一般用户应用程序开发所需的界面编程到测试应用开发所需的各种仪器控制、数据获取、信息处理以及对数据库和网络应用开发的软件包,适用于自动测试、自动控制、测试仪器通信、测试硬件控制以及信号分析处理的软件开发。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
*国 家 自 然 科 学 基 金 资 助 项 目 (50675207 )
其中 database.cpp 提供数据库内存管理、hashtab.cpp 执行扩 展 哈 希 表 、localcli.cpp 为 数 据 库 提 供 本 地 c 接 口 服 务 、query. cpp 构建数据库查询报表;同样把 FastDB 目录下的 inc 文件夹 下 的 相 关 头 文 件 cli.h、compiler.h、config.h、database.h、、fastdb.h、hashtab.h、localcli.h 等 添 加 到 Header Files, 其 中 cli.h 提 供 调 用 实 时 数 据 库 FastDB 的 接 口 、compiler.h 提 供 条 件 编 译、config.h 定义 FastDB 的配置。 在 Microsoft Visual C++工 程窗口工具栏中选择 Build,然后找到该工程存储目录下的 Debug 文件夹, 可以看到里 面 生 成 了 一 个 引 入 库 文 件 FastDB.lib 和一 个 动 态 链 接 库 文 件 FastDB.dll。 至 此 ,FastDB 的 动 态 链 接 库文件创建完毕。 3 LabWindows / CVI 环境下实时数据库 FastDB 的应用
int cli_fetch(int statement, int for_update);
/ / 执行选择操作
环境下,我们就可以使用实时数据库 FastDB 了。
在本设计中,实时数据库需要完成以下的功能:
1)数据采集:可以从各子系统采集现场数据;
2)具有滚动存储机制:因为实时数据库的容量是有限的,当
新的数据不断产生的时候,数据库中最老的数据将会被删除;
3)数 据 检 索 机 制 :可 以 以 类 似 于 关 系 数 据 库 的 方 式 检 索 数
LabWindows / CVI 的环境下建立一个项目文件, 然后在该项目
文 件 根 目 录 Include Files 中 添 加 FastDB.lib、FastDB.dll、cli.h
和 config.h。 其中 cli.h 为应用程序提供了 FastDB 的 C 接口服
务,config.h 为 FastDB 配置函数。 这样, 在 LabWindows / CVI
24
LabWindows / CVI 环境下实现实时数据管理的一种方法
LabWindows / CVI 环境下实现实时数据管理的一种方法*
A Method Under LabWindows / CVI Environment to Achieve Real-time Data Management
葛松林 李 伟 邓学博 季上满 任 泉 (浙江理工大学信息电子学院,浙江 杭州 310018)
图 1 LabWindows / CVI 结合 FastDB 的应用框图
《工业控制计算机》2009 年 22 卷第 3 期
下面就在 LabWindows / CVI 环境下应用实时数据库 Fast-
DB 来设计一个工业现场控制液位的实时数据库系统,来说明如
何 在 LabWindows / CVI 中 使 用 实 时 数 据 库 FastDB。 首 先 在
/ / 最小值
cli_real8_t time;
/ / 时间
cli_real8_t Liquidlevel;
/ / 液位
cli_bool Isalarm;
/ / 是否报警
妖 Liquidlevel;
static cli_field_descriptor Liquidlevel _descriptor[] = / / 声 明 结 构
25
int cli_create_table (int session, char const觹 tableName, int
nFields, cli_field_descriptor觹 fields);
/ / 创建一个新表

int cli_drop_table(int session, char const觹 tableName); / / 删除表
FastDB 是一个高效率的内存数据库,又是一个开放源代码 的 实 时 数 据 库 ,从 2.47 版 本 开 始 提 供 了 便 利 的 C 接 口 ,这 为 我 们在 LabWindows / CVI 环境下利用 FastDB 进行数据管理提供 了方便。 FastDB 并不支持客户端 / 服务器架构, 因而所有使用 FastDB 数 据 库 的 应 用 程 序 必 须 运 行 在 同 一 台 主 机 上 。 FastDB 针对应用程序通过控制读访问模式作了优化。 通过降低数据传 输的开销和非常有效的高性能锁机制提供了高速的查询。 FastDB 支持事务、在线备份以及系统崩溃后的自动恢复。 此外, 它还取消了事务日志,改进了系统的整体性能,并且能够更加有 效的使用系统资源。
在一些工业控制现场要求数据能够快速并且实时的处理, 但是 LabWindows / CVI 并没有提供对数据库很好的支持。 虽然 NI 公司同时提供了针对 CVI 的 SQLserver 数据库访问工具包, 但是价格昂贵。 自 6.0 版本开始,LabWindows / CVI 提供了对网 络和自动化的支持, 从而更需要扩展该平台开发数据库应用的 能力。 根据这一要求,本文应用动态链接库技术实现了在 LabWindows / CVI 环境下对实时数据库 FastDB 的应用。 1 实时数据库 FastDB
部分与实时数据库 FastDB 的程序代码如下:
typedef struct Liquidlevel
/ /定义一个关
于液位控制的结构体
邀 char觹
varName;
/ / 设备名
cli_int8_t Nid;
/ / 设备号
cli_real8_t Maxvalue;
/ / 最大值
cli_real8_t Minvalue;
体里各元素的存储结构
邀 邀cli_asciiz, cli_hashed, ″ varName ″妖;
/ /哈希表的结
构存储
邀cli_pasciiz, cli_indexed, ″ Nid ″妖;
/ / 索引形式存储
邀cli_ real8, 0, ″ Maxvalue ″妖;
(cli_ real8, 0, ″ Minvalue ″妖;
据库中的数据。
为了使数据库有效发挥作用, 作为一个关键的环节要考虑
数据组织的问题,通过对工业现场的分析,为现场数据定义了模
拟型和数字型等类型,这样基本上可以把数据分开,按照数据类
型设计的变量表进行定义。这些类型具有一定的通用性。在本设
计中设备名、设备号、最大值、最小值、时间、液位是模拟型变量,
是否报警为数字型变量。
FastDB 是一个面向应用程序的数据库,使用应用程序的类 信息来构建一个数据库的表性能。 FastDB 为从数据库中提取数 据提供了一个灵活而方便的接口,使用类似于 SQL 的查询语言 进行指定的查询。 2 FastDB 的动态链接库文件的构建
在 Microsoft Visual C++ 6.0 环境下, 新建一个动态链接 库的项目文件 FastDB.dsw,然后将实时数据库 FastDB(本文用 的 版 本 是 3.48) 目 录 下 的 src 文 件 夹 下 的 database.cpp、 hashtab.cpp、localcli.cpp、query.cpp 等 添 加 到 Source Files,
if (session < 0) 邀
fprintf(stderr, ″cli_open failed with code %d\n″, session);
return EXIT_FAILURE;

上 面 是 具 体 的 在 LabWindows / CVI 环 境 下 建 立 起 了 该 工
程的数据库。 下面简要介绍一下数据库方面的操作函数。
/ / 数据库名
称和存储路径
char觹 filePath = ″ Liquidlevel.fdb″;
int session;
/ / 创建数据库
session = cli_create(databaseName, filePath, 0, 0, 4觹1024觹1024,
4觹1024觹1024, 512觹1024, 0);
Abstract In view of the deficiency of LabWindows / CVI in reserving and managing timely data,this paper put forward a method based on DLL technique to achive data magagement by using Real-time database FastDB in the platform of LabWindows / CVI.Firstly,Real-time database FastDB and dynamic link library(DLL) were briefly introduced;secondly,how to creat a dynamic link library file of FastDB under Microsoft Visual C++ 6.0 environment was detailed introduced;finally,a set of industry field about liquid leveal control Real-time database sysytem is designed by this method,the application shows that this method is feasible in solving timely data management problem. Keywords:LabWindows / CVI,FastDB,real-time database,DLL,liquid level control
相关文档
最新文档