LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can you have multiple nested DAQmx Write VI?

Solved!
Go to solution

Hello everyone. I am pretty new to Labview, and am trying to figure out the best way to handle several "if" statements using an array of clusters, and outputing to various pins on a DAQ module. Will it work to have a dozen or so DAQmx Write VIs in nested case statements, or will this result in errors? 

 

The objective is to take the inputs from the front panel and control outputs based on the timings and values of the user inputs. Any suggestions would be appreciated.

 

Thank you very much in advance!

James

Download All
0 Kudos
Message 1 of 4
(2,857 Views)
Solution
Accepted by topic author jamesbe

Sure you can have multiple DAQmx Write VI's.

 

Here is a tip that will save you programming time:

The Index Array function is resizable!  You don't need to break an array wire and use 4 Index Arrays and wire up constants to each one to get the individual elements.  Just drop one and drag the bottom of the node downwards until you get 4 outputs.  By default, they will start at 0 and increment by 1 as you go down.  You'll get elements 0, 1, 2, and 3 without having to wire up any of the constants to the index input.

 

I would also recommend that instead of using local variables, you keep the array of boolean in a wire that goes across all cases in a shift register.  Just replace array element for whichever array elements you are changing in a particular case.

 

I would also restructure the code so you don't need dozens of nested case statements.  For instance, you have an ON and OFF case inside one of the nests.  I'm assuming the only difference is that you are either wiring a True or a False.  Just wire the boolean in.  Other the other code is duplicated between each case.  Likewise for the higher levels of the nest.  If you are writing to the DAQ in all cases, move that outside the case structure and just control which boolean values get changed inside the case structures.

Message 2 of 4
(2,847 Views)

Thank you very much Sir RavensFan!

I'm not sure why I wasn't doing a couple of the suggestions you made already. I am a little confused on the shift registers, but will let you know if I can't figure it out.

Thanks again!

0 Kudos
Message 3 of 4
(2,837 Views)

Shift registers just pass a value from one iteration to the next.  Whatever you wire into the output side of the loop will be read in at the input side on the next iteration.  It's an easy way to update values between each iteration.

0 Kudos
Message 4 of 4
(2,821 Views)