From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DaqMx create channel lines

I am using DaqMx create channel to collect a sequence of boolean data from four cDAQ9181 modules. I want to be ab le to select the lines at run-time from four controls, one per cDAQ.

I read Labview does not necessarily execute the code left to right.

I attach the vi. It starts the acquisition from the pre-set lines, but I would like to have the possibility to change them. How should I change the code to make it possible?

Thanks

0 Kudos
Message 1 of 6
(2,585 Views)

@DavideB wrote:

I read Labview does not necessarily execute the code left to right.


LabVIEW uses the Principle of Data Flow to determine code execution order.  Look at any function (or VI) -- it has 0 or more Inputs, it "does something", and it produces 0 or more Outputs.  The Principle of Data Flow says:

  1. The function (or VI) will not start until all of its Inputs have data on them.
  2. The function will execute everything "inside it" at least once before it exits.
  3. Until the function exits, none of its outputs will have data on them.
  4. If two functions (or VIs) share no common input (or, indeed, have no inputs), their order of execution is undetermined.

Some comments:

  • Many LabVIEW Functions (and most well-written sub-VIs) have Error In and Error Out terminals.  Connecting Functions/VIs via their Error Lines defines their order of execution.  The LabVIEW convention is that Inputs are wired to Terminals on the left, Outputs to Terminals on the right, which imposes a general left-to-right order of execution.
  • There are some "asynchronous" elements in LabVIEW (Channel Wires, reference-based structures such as Queues) that are exceptions to Principle #3 above.  But you don't need to worry about (or know about) them until you've mastered the Basics.
  • Inside a While Loop, a "free-floating" Wait (ms) function can "clock" the Loop (as it must "tick" at least once for the Loop to exit).
  • Similarly, if a While Loop takes a few seconds to "do its thing", pressing the Stop button will probably not stop the current loop (as the Stop button, being not connected to anything, was probably read and acted on when the loop was entered and the value "False" wired to the Stop Indicator, so the changed value to True won't register until the next iteration of the loop).

Now, dealing with your question, you have two things you want to do (and in this order):

  1. Set up the DAQmx Channels hat you want to use.
  2. Acquire data using these Channels.

If you want Task 1, defining the DAQmx Channels, to be "interactive", i.e. you want to see and change them at Run Time, I would recommend that you write a sub-VI that lets you choose the Channels and their configuration.  Once you have it the way you want, exit the sub-VI, passing the settings out as its output, to be used in the rest of the code.  Note that if you are doing multi-channel DAQ acquisition, it is much simpler to set up sequential channels (0, 1, 2 ...) and set up N-channel acquisitions.

 

Bob Schor

Message 2 of 6
(2,409 Views)

Thanks a lot Bob,

I realised though that if one of the chassis goes off for some reason (eg momentary lack of power), the vi will crash. How can I modify it in order that it will keep collecting data from the modules which are still on line?

0 Kudos
Message 3 of 6
(2,035 Views)

What do you mean by crash? Do you get an error code then crash? If so you need to handle the error code. Stop and restart the system once the error clears.

Tim
GHSP
0 Kudos
Message 4 of 6
(2,029 Views)

If a momentary power loss causes problems for your test, then I recommend you invest in an uninterruptible power supply for it.

0 Kudos
Message 5 of 6
(2,012 Views)

@RavensFan wrote:

If a momentary power loss causes problems for your test, then I recommend you invest in an uninterruptible power supply for it.


A UPS should be in every real test system.  The only real question is how large.  I will state that I have had a lot of luck with this UPS from Eaton.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 6
(1,994 Views)