LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Alter program execution structure based on input file

Solved!
Go to solution

I have a program that takes some parameters from an input file then runs a visual acquisition, using IMAQ, controlling some other hardware at the same time.  The parameters control the duration of various steps in this process. 

 

There is a stacked sequence structure to control reading in the input file, initialisation of the hardware and then a while loop on the final frame to do the actual acquisition.

 

The user of the program would now like the capability of having multiple sets of acquisition within the same run, possibly with different duration parameters.  This would mean various iterations of the final while loop, based upon the parameters in the input file.  There might be 5 acquisition sets on one occasion, 3 on another etc., within one run of the program.

 

The VI structure already seems a little baroque and I don't want to make it even more complicated.

 

I would welcome any advice as to the best way to proceed, as I'm very much a LabView novice.

0 Kudos
Message 1 of 8
(3,296 Views)
Solution
Accepted by topic author verdurin

If you use a 'State Machine' architecture, you can do just that.

Instead of having a stacked sequence structure, it is essentially a case structure within a while loop.

Each case represents a state.

 

So in your case you would have a state for:

- reading input file

- hardware initialization

- data aquisition

 

You can have the user control how many iterations of the DAQ state you would like to run. 

Cory K
Message 2 of 8
(3,294 Views)
Change your architecture to a Queued Message Handler where the states are blocks of code i.e. Acquire data, Analyze dat, Display Data, Save Data.  With this type of architecture it is possible to program the Message handler from an external file.
Visualize the Solution

CLA

LabVIEW, LabVIEW FPGA
Message 3 of 8
(3,293 Views)

Now that I think about it, there are several architectures you could use for this setup.
However, none of them use a stacked sequence structure.

In general, a stacked sequence should be avoided just because it hides code and isnt generally necessary for data flow. 

Cory K
Message 4 of 8
(3,291 Views)

Dear Verdurin

 

With reference to Cory K's earlier post the most practical and efficient method to achieve acquistion would indeed be to use a Standard State Machine VI sequence structure. This structure executes set code (your own code) and determines which state to transition to. I agree with Cory K's 3 states within the sequence. Using the iterations loop you can define how many iterations of each acquistion you require. In LV, click File > New > From Template > Frameworks > Design Patterns > Standard State Machine. This automatically creates the VI for you to use where you can create the 3 states required.

 

Within the 3 states input your code into the relevant states to achieve acquistion. Use timing to achieve different duration parameters within the case structure. After you have read from the input file, select the next state as initialisation, then after that is complete, select the next state as acquistion. Repeat this loop as many time as you need for each acquistion.

 

I hope this clarifys your question. If you have any problems please do not hesitate to contact me and thanks for using the NI forums.

 

 

 

Kind regards

 

David

 

Applications Engineer

National Instruments UK

 

 

 

Many thanks for using the NI forums and I look forward to your reply.

Kind regards

David

Applications Engineer
National Instruments UK
Message 5 of 8
(3,246 Views)

Thanks everyone for your comments.

 

I'll refactor the program along the lines you suggest.

 

 

0 Kudos
Message 6 of 8
(3,231 Views)
Mark a "Solution"!
Richard






0 Kudos
Message 7 of 8
(3,228 Views)
{{ off topic }} Congratulations on 1000 posts Cory!
Richard






Message 8 of 8
(3,224 Views)