Confirm that you have a physical DAQ device connected, the compatible N-DAQmx driver installed and you can see the device in NI MAX or have created simulated NI-DAQmx device available in MAX.
NI-DAQmx API
When using the NI-DAQmx API, it is recommended to use the framework available through a shipping example.
Starting with an Example (recommended)
- Launch LabVIEW
- Navigate to Help >> Find Examples... which will launch the NI Example Finder
- Confirm you are in the Browse tab and navigate through the folders Hardware Input and Output >> DAQmx
- Navigate to the folder for you application needs
- Double click the the example you want to use
- DO NOT edit this example. Any changes will overwrite the original example.
- Click File >> Save As
- Choose the option that suits your needs. Recommendation is to choose Duplicate Hierarchy to new location
- Choose the location and click Save
- Close out for the example and open Example in the new location
- Once the local copy of the example is opened, you can change the configuration and the channel used in the example. You can use real and simulated devices and channels to run the application
Note: Most examples start with
DAQmx Create Virtual Channel and will create an unnamed task automatically. Most examples will also only have 1 channel and 1 device listed. You can
channel expand by modifying one instance of the
DAQmx Create Virtual Channel VI to incorporate more channels or devices or by adding more than one
DAQmx Create Virtual Channel VI to the same task. If you are adding more devices, be sure they can share a timing resource for the task.
- Edit the example as you need
Starting from Scratch A good resource is
Learn 10 Functions in NI-DAQmx and Handle 80 Percent of Your Data Acquisition Applications. It will walk-through the main functions you may require in an NI-DAQmx Data Acquisition application.
Use NI MAX Task
Creating tasks in MAX to use in LabVIEW allows to set up multiple channels, scales, timing and triggers outside of LabVIEW which can help with cluttered code. It is easier to port task information between different VIs. In comparison with using the DAQ Assistant is giving more control when the task starts and stops, can easily use the same channel setup in multiple instances/VIs, and can edit some aspects of the task for a particular instance/VI without changing the setup of the task.
- Follow the steps to Create Tasks for NI-DAQmx Devices in NI MAX
- To use this task created in NI MAX you need to use a DAQmx Task Name (Task Constant), you have 2 options on how to create this:
- Drag the Task:
- Open NI MAX and the Block Diagram in LabVIEW
- Hover over the task in NI MAX
- Click and drag over to the Block Diagram
- A Task Constant is now created in LabVIEW and will reference the task configurations in NI MAX
- You can update the task you want to use in LabVIEW by clicking on the arrow of the constant and clicking Browse. This will create a popup with the list of saved tasks available for use.
- Place the DAQmx Task Constant (Task Constant) in LabVIEW
- Open the Block Diagram in LabVIEW
- Open the Functions Pallet (Right-Click on the Block Diagram)
- Navigate to Measurement I/O » NI-DAQmx and click Task Constant. Place where you want it.
- You can update the task you want to use in by clicking on the arrow of the constant and either choosing a task available in the drop down or clicking Browse. Clicking Browse will create a popup with the list of saved tasks available for use.
- You now have a few options on how to use this:
DAQ Assistant
Using DAQ Assistant for your application packages the entire DAQmx Task from creation to start to stop, therefore, you do not have to use the DAQmx API components. It's a configuration based tool that walks you through the steps to acquiring simple measurements in LabVIEW. It is great for getting simple measurements, triggering and data logging set up in a short time but has limitations for lower level control.
- Open the Block Diagram in LabVIEW
- Open the Functions Pallet (Right-Click on the Block Diagram)
- Navigate to Measurement I/O » NI-DAQmx and click DAQ Assistant. Place where you want it.
- Once placed,it will begin initializing and a Create New... window will pop up
- The functionality of creating the task will be very similar to NI MAX - Follow Step 5 and onward of Create Tasks for NI-DAQmx Devices in NI MAX .
- Once you have configured the task, click OK. This will build the task VI to be used. Note: You can update any configuration information by double-clicking the DAQ Assistant
- (Optional) You can use the DAQ Assistant as is.
- Right-Click the DAQ Assistant and click Convert to NI-DAQmx Task which will create a DAQmx Name Constant (Task Constant). This will save the task in NI MAX.
- You now have a few options on how to use this: