NI-DAQmx Simulated Devices

本文介绍了NI-DAQmx模拟设备,它为DAQ系统开发者提供高性能驱动和测量服务。教程涵盖了模拟设备的创建、使用方法,以及使用时的注意事项,如数据写入无限制、不模拟定时和触发等。还提及了所需软件版本及相关帮助文档。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

NI-DAQmx not only provides DAQ system developers a high-performance driver, it also includes many measurement services designed to increase productivity. One of the newest and most exciting measurement services added to NI-DAQmx is NI-DAQmx simulated devices. A simulated NI-DAQmx device is a replica of a device created using the NI-DAQmx Simulated Device option in the Create New menu of MAX for the purpose of operating a function or program without hardware. An NI-DAQmx simulated device behaves similarly to a real device. Its driver is loaded, and programs using it are fully verified.

This tutorial explains the basics of NI-DAQmx simulated devices, including how to create them, how to use them, as well as some considerations when using NI-DAQmx simulated devices.

Follow this tutorial using an installed copy of NI-DAQmx 7.4 or later and National Instruments application development software LabVIEW 7.x or later or VI Logger Lite. If you do not own National Instruments LabVIEW 7.x or higher, VI Logger Lite is available for download and installation to help you complete this tutorial.

Most of this information is also available in the Measurement & Automation Explorer Help for NI-DAQmx. Additional information about NI-DAQmx simulated devices is in the NI-DAQmx Help and the DAQ Quick Start Guide.

Table of Contents:
invis.gif
 How to Create an NI-DAQmx Simulated Device

To create an NI-DAQmx simulated device, NI-DAQmx 7.4 or later must be installed.
  • 1. Open Measurement & Automation Explorer (MAX). NI-DAQmx simulated devices are created within MAX. Unless you unchecked the feature during installation, MAX was installed when NI-DAQmx was installed. If MAX is not installed, you must reinstall NI-DAQmx.

    2. Right-click
My System>>Devices and Interfaces and select Create New... In the subsequent dialog, select NI-DAQmx Device>>NI-DAQmx Simulated Device. The Choose Device window prompts you to select a device.

31.4AEC?OpenElement&FieldElemFormat=gif
Figure 1. Create an NI-DAQmx simulated device in MAX.

3. Select the device you want to create as an NI-DAQmx simulated device. With this list, you can browse the lhundreds of devices supported by NI-DAQmx supports. You can create an NI-DAQmx simulated device of any NI-DAQmx-supported device, with the exception of the SCXI-1600.
53.3698?OpenElement&FieldElemFormat=gif
Figure 2. Choose from hundreds of NI-DAQmx supported devices.

  • 4. Click
OK in the Choose Device window to close the window. The NI-DAQmx simulated device appears in MAX. The icon color of the NI-DAQmx simulated devices differs from real devices. Real devices are green, and simulated devices are yellow.
105.3F0C?OpenElement&FieldElemFormat=gif
Figure 3. NI-DAQmx simulated devices listed in MAX have yellow icons.
invis.gif
 How to Use an NI-DAQmx Simulated Device

An NI-DAQmx simulated device works just as a real device. You can use NI-DAQmx simulated devices to create NI-DAQmx tasks either through the DAQ Assistant or the API. Because a real device is no longer required to create an NI-DAQmx task, NI-DAQmx simulated devices allow developers to do the following: Begin application development and logic before without hardware Develop application logic on a machine other than the target system Evaluate acquisition functionality of National Instruments software without owning any hardware
This section of the tutorial describes how to create an NI-DAQmx task using the DAQ Assistant, then use the task to acquire simulated data in VI Logger Lite or LabVIEW.
  • 1. Complete the previous section to create an NI-DAQmx simulated device in MAX.

    2. Create an NI-DAQmx task in the DAQ Assistant.
    • a. Right-click
My System>>Data Neighborhood>>NI-DAQmx Tasks and select Create New NI-DAQmx Task. A window prompts you to select the measurement type.
52.2CB0?OpenElement&FieldElemFormat=gif
Figure 4. Step 1 of the DAQ Assistant: Select a measurement type

    • b. Select
Analog Input>>Voltage as the measurement type for this task. A window prompts you to select the physical channels.

c. Select one or more channels from the NI-DAQmx simulated device. Both real and NI-DAQmx simulated devices are available for creating NI-DAQmx tasks, and that the DAQ Assistant makes no distinction between them. If you do not remember which device is a simulated device, refer to the color of the device icon in MAX. Green icons indicate a real device, and yellow icons indicate an NI-DAQmx simulated device.
113.2CB0?OpenElement&FieldElemFormat=gif
Figure 5. Step 2 of the DAQ Assistant: Select the physical channel(s).

    • d. Click
Next. The DAQ Assistant prompts you to give the task a descriptive name.
173.2CB0?OpenElement&FieldElemFormat=gif
Figure 6. Assign a descriptive task name.

    • e. Click
Finish. A window opens prompting you to add timing and synchronization information to the task as well as add custom scaling, add or delete virtual channels, view a connection diagram, and so on. To learn more about the DAQ Assistant, refer to the DAQ Assistant Help.

f. Configure the task as shown.
244.3408?OpenElement&FieldElemFormat=gif
Figure 7. Configure your task in the DAQ Assistant.

    • g. Click
Test in the toolbar at the top of the page. Both NI-DAQmx simulated devices and real devices have test panels in the DAQ Assistant. Notice the noisy sine wave being returned as simulated data on the channels of the DAQ task.
272.3D64?OpenElement&FieldElemFormat=gif
Figure 8. You can test NI-DAQmx tasks for NI-DAQmx simulated devices for errors and view simulated data.
Note: NI-DAQmx simulated devices create a noisy sine wave for all analog input channels. Configuration of other simulated data is not available at this time.

Note: NI-DAQmx tasks for NI-DAQmx simulated devices are verified just as they are on real devices. If a property is set to an invalid value, the error returned for an NI-DAQmx simulated device will be identical to the error returned for a real device. All resources necessary for the task, such as RTSI lines, PXI Trigger lines, DMA channels, counters, and so on, are counted and reserved for NI-DAQmx simulated devices just as they are on real devices.

h. Exit the test panel.
  • 3. Use the NI-DAQmx Task in VI Logger Lite to complete a data logging application.
    • a. Open VI Logger Lite.
If you do not have VI Logger Lite, download it or request a free CD.

b. Right-click My System>>VI Logger Tasks and select Create New.

c. Select Using NI-DAQmx and click Finish.

d. Select the NI-DAQmx task for the NI-DAQmx simulated device. Leave all settings in the defaults, and click Run task in the toolbar.
328.29A4?OpenElement&FieldElemFormat=gif
Figure 9. VI Logger Lite data logging task.

    • The data logging task begins. Data from the NI-DAQmx simulated device is displayed in the Real Time Data viewer.

      e. Click
Stop task.
384.29A4?OpenElement&FieldElemFormat=gif
Figure 10. VI Logger Lite logging data using an NI-DAQmx simulated device.

    • f. Explore additional features of the VI Logger Lite software. Click the
View in Excel button in the toolbar to export the data currently in the viewer to Microsoft Excel. Right-click the task name to the left in the configuration tree and select Generate example VI in LabVIEW to create an example program in LabVIEW, which allows for customization of the analysis of the acquired data.
  • 4. Use the NI-DAQmx simulated device in LabVIEW. In this step we will not use the previously created NI-DAQmx task but will use a reference to the device and channel instead.
    • a. Open LabVIEW 7.x or higher.

      b. Open the Example Finder by clicking
Help>>Find Examples.

c. Open the Cont Acq&Graph Voltage-Int Clk VI found at Hardware Input and Output>>DAQmx>>Analog Measurements>>Voltage. This application uses physical channels explicitly entered in the physical channel control.

d. Use MAX to determine the device number for the simulated device you created. The device number is in quotes next to the NI-DAQmx simulated device listed in Device and Interfaces.
393.49FC?OpenElement&FieldElemFormat=gif
Figure 11. The device number is listed next to the device

e. Change the value in the Physical Channel control to Dev x /ai0:4 where x is the device number from the previous step. Although we used the Physical Channel control for this example, some slight modifications to this particular example would also allow us to use the task previously created.
404.36AC?OpenElement&FieldElemFormat=gif
Figure 12. Update the Physical Channel control using the NI-DAQmx simulated device number

f. Run the VI.

435.341C?OpenElement&FieldElemFormat=gif
Figure 13. Acquiring data from an NI-DAQmx simulated device in LabVIEW
invis.gif
 Considerations for Using NI-DAQmx Simulated Devices

Reading Data
All simulated devices return analog input data in the form of a full-scale sine wave with three percent of full-scale noise. When multiple channels are in the task, the data for each channel is offset slightly in time. Digital data is returned as if each 8-bit port were counting up. Counter data is always returned as 0. Since simulated devices do not simulate timing, data is always immediately available for reading.
Writing Data
  • Other than verifying the data is within limits, the data written to an NI-DAQmx simulated device has no restrictions.

Timing and Triggering
  • Simulated devices do not simulate timing and triggering.
  • Finite input operations always complete immediately.
  • Reads never have to wait for data.
  • Writes always occur immediately.
  • Triggers always occur immediately.
  • An NI-DAQmx simulated device never issues a software event or causes a timed loop to execute.
  • Watchdog timers never expire.

Non-Task Operations
  • Operations such as self-test, calibration, and reset always succeed.
  • Data that is normally stored on the physical device, such as serial number, is always returned as 0.

Device Is Simulated Property
To discover during the execution of a program whether a device is simulated, use the DeviceIsSimulated property on the NI-DAQmx Device property node. Open the All Functions>>NI Measurements>>DAQmx>>DAQmx Advanced>>DAQmx System Setup subpalette to find this property node. The property returns true if the device is simulated.
0.3FE6?OpenElement&FieldElemFormat=gif
Figure 14. Use DeviceIsSimulated property to programmatically determine if a device is simulated.

Importing an NI-DAQmx Simulated Device Configuration onto a Physical Device
To import the configuration of an NI-DAQmx simulated device onto a physical device, use the MAX Import and Export functions. Select File >>Export and follow the prompts to export the desired NI-DAQmx simulated device as an .nce file stored on the computer. Select File >>Import and follow the prompts to import the previously created .nce file. Importing requires a physical device of the same type as the NI-DAQmx simulated device.

Importing a Physical Device as an NI-DAQmx Simulated Device
To import a physical device configuration as an NI-DAQmx simulated device, use the MAX Import and Export functions. Select File>> Export and follow the prompts to export the desired physical device as an .nce file stored on the computer. Select File>>Import and follow the prompts to import the previously created .nce filep. Be sure to designate the imported device as simulated.

Alternative Strategy for Converting Physical and NI-DAQmx Simulated Devices
Assume a device number “Dev x” for the NI-DAQmx simulated device, “Dev y” for the physical device, and Dev x and Dev y are the same model of National Instruments DAQ hardware. After developing code using “Dev x,” there is now a need to use the physical device. You can rename the physical device “Dev x” and rename the NI-DAQmx simulated device “Dev y (or z)”. This allows the application code to remain unchanged, but the application uses a physical device instead of a simulated one.
invis.gif
 Want More NI-DAQmx Information?

NI-DAQmx driver software includes tools introduced in this document in addition to many other software tools and features. To learn more about NI-DAQmx visit some of these additional resources:

转载于:https://www.cnblogs.com/Qia_sky/archive/2005/04/17/139089.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值