6. Generate Code

Taking an NI-DAQ™mx Measurement in LabVIEW™

Edition Date: February 2012

Part Number: 370689M-01

»View Product Info
Download Help (Windows Only)

Using the DAQ Assistant, you have three options for generating code in LabVIEW from a task or channel:

Example—Generates all the code necessary to run the task or channel, such as VIs needed to read or write samples, VIs to start and stop the task, loops, and graphs. Choose this option if you want to run the task or channel you created to verify that it works or to use your configuration in a simple application. In LabVIEW, this option adds to the VI you are working in. The generated code is a simple NI-DAQmx example that you can then modify for your application.

Configuration—Generates the code that replicates the configuration of the tasks and channels. LabVIEW replaces the DAQmx task name control with a subVI that contains VIs and property nodes used for channel creation and configuration, timing configuration, and triggering configuration used in the task or channel. Choose this option if you want to deploy your application to another system. Refer to Deployment in the NI-DAQmx Help located at Start»All Programs»National Instruments»NI-DAQ for more information.

When you generate Configuration code, the link between the application and the DAQ Assistant is lost. Any changes you make to the configuration code are not reflected in the DAQ Assistant. You can regenerate Configuration code from the DAQ Assistant, but the regenerated code does not incorporate previous changes that you made to the code.

Caution  Although generated configuration code includes code to create virtual channels and tasks, it does not include code to create scales. If you generate configuration code for deployment of applications that include scales, you must ensure that the scales are configured in the target computer. Refer to Deployment in the NI-DAQmx Help located at Start»All Programs»National Instruments»NI-DAQ for more information.

Configuration and Example—Generates both Configuration code and Example code for the task or channel in one step.

Tip  If you configure a task using the DAQ Assistant Express VI, you can right-click the VI and select Generate NI-DAQmx Code to generate configuration and example code. The code replaces the DAQ Assistant Express VI.

Complete the following steps to generate code to run the voltage task.

  1. Right-click the DAQ Assistant Express VI on the block diagram, and select Generate NI-DAQmx Code from the shortcut menu.
  2. The DAQ Assistant generates all the code necessary to run the task, as shown in the following block diagram.

  3. Save the VI as MyVoltageTask.vi.
  4. Display the front panel. Click the Run button to start the application.
Note  Any changes you make to the generated code apply only to the VI and are not saved into the task configuration stored in MAX.
Previous: 5. Edit the Task Next: What's Next

WAS THIS ARTICLE HELPFUL?

Not Helpful