LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Express VI's with DAQmx Blocks

Solved!
Go to solution

Problem: I'm trying to use Express VI's with DAQmx blocks so that I can change the device that the DAQmx block uses, but DAQmx blocks return errors when connected this way

Why: we have multiple identical testing units, with their own NI hardware, and would like our software to work automatically with any of them. We also use a variety of laptops, so it would be preferable for the task information to be self-contained in the Labview software (so that we don't need to add/create the tasks anytime a new laptop wants to use a new testing unit)

 

In the help window to the Express VI's, "Task out" can be connected to DAQmx blocks (the relevant section included at the bottom of this post for convenience).

However, when I try to do this, the DAQmx blocks give a "invalid task" error. I've made a simplified VI to show this, attached to this post. I've also attached a screenshot after running, with relevant probes showing the error. To my understanding, The "task out" of the Express VI is blank, and is not passing the task it creates to the DAQmx blocks.

 

How can I fix this?

or, alternatively, Is there a better way to accommodate automatically switching devices, without needing to manage tasks in NI MAX and/or not needing discrete tasks for each set of NI hardware?


Block Diagram Outputs

Parameter Description
data Contains samples read from the task. data is an output for measurement tasks and an input for analog and digital output tasks. data does not appear for counter output tasks.
error out Contains error information. If error in indicates that an error occurred before this Express VI ran, error out contains the same error information. Otherwise, it describes the error status that this Express VI produces.
stopped Indicates whether the task stopped. The task stops if the stop input is set to TRUE or an error occurs. This output appears for continuous or hardware-timed single-point tasks only.
task out Contains a reference to the task after this VI completes execution. Wire this output to other NI-DAQmx VIs to perform other operations with this task.
0 Kudos
Message 1 of 4
(1,182 Views)
Solution
Accepted by topic author tuckjohn

Hi Tuck,

 


@tuckjohn wrote:

Problem: I'm trying to use Express VI's with DAQmx blocks so that I can change the device that the DAQmx block uses, but DAQmx blocks return errors when connected this way

Why: we have multiple identical testing units, with their own NI hardware, and would like our software to work automatically with any of them. We also use a variety of laptops, so it would be preferable for the task information to be self-contained in the Labview software (so that we don't need to add/create the tasks anytime a new laptop wants to use a new testing unit)

Problems:

  • You use ExpressVIs when there are simple DAQmx functions to use. Stick with plain DAQmx!
  • You have a problem with your VI, but you don't attach that VI!
  • There's an error returned from DAQmx (which function), but you don't tell which error you got…

Solution:

Stick with plain DAQmx functions. Read this and skip the ExpressVI paragraph!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 4
(1,160 Views)

Oop! Turns out if you fail the CAPTCHA it removes your attached files. They're attached here.

 

I'll check out that link.

Download All
0 Kudos
Message 3 of 4
(1,155 Views)

Hi Tuck,

 


@tuckjohn wrote:

Oop! Turns out if you fail the CAPTCHA it removes your attached files. They're attached here.


Did you read the error explanation?

Error -200088 means "task is invalid or non-existant"! One (of many) bad thing of the DAQmx-ExpressVI: it opens and closes the DAQmx task with each call.

 

Again I recommend to stick with plain DAQmx functions - as are explained in ALL those example VIs about DAQmx in the LabVIEW example finder!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 4
(1,137 Views)