LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

best practice for code structure to control multiple devices in a 2 stage-sequence

Solved!
Go to solution

I have a question about code architecture and getting multiple devices controlled and sychronized for one experiment. This is an "architecture"-type inquiry, so I am hoping for some suggestions on how to proceed.

 

I run an experiment in which I control 2 NI PCI-6733. I am soon to add a Tektronix AFG 3022B, and have long been putting off an opportunity to rewrite my labview code from the ground up. I inherited it from an earlier research, and while functional, I would like to make it easier to modify and break up into subVi's and such. Link to the current program (labview 8.6.1) is here if you would like to see the code that is currently used, and the subvi's are in a zip file. The current version of the experiment consists of just one stage, all the writing of the data to the PCI cards is saved for the end. I need to change this in my new setup though. 

 

The new experiment consists of 2 stages. The first will run (looping an output array to the PCI cards) until it hears a "true" from another computer (connected via TCP). At that point, it should switch to stage 2 and run a sequence (usually 10^5 timeunits in length, where the time unit is 0.1 ms) that outputs to the two PCI cards, the AFG 3022B, and with the flexibility to add more devices in the future.

 

Most appreciated would be structural advice. How to arrange the VIs, if it's good to use a "master" VI that would control the two subVi's of stage 1 and 2, etc...  Feel free to ask for more details if it would help clarify my question. Thanks!

0 Kudos
Message 1 of 2
(2,503 Views)
Solution
Accepted by topic author ajolson

Programs of this type usually use a state machine of some sort.  You can find many tutorials on LabVIEW state machines in these forums or the LAVA forums.  If you are doing a rewrite, I would also recommend you consider LabVIEW classes.  They help modularize your code and make the subparts more reuseable.  You may end up with less to maintain, as a result.

 

<shamelessPlug>You may also want to consider TestStand.  It was designed to run sequences of tests, so may make your life easier.  It could also be gross overkill.</shamelessPlug>

 

Let us know if you run into issues with state machines or classes.

0 Kudos
Message 2 of 2
(2,475 Views)