LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatically add steps to a VI

Solved!
Go to solution

I am writing a code to control a bank of valves via cDAQ/DAQmx. I need to figure out how to allow the user to build a macro or something similar that will allow them to programmatically change the order and number of the steps in a sequence. For example, one time he might want to have 5 different steps where he activates valves 1, 2, 1, 3, 1, 5. The next time he might need 8 steps alternating back and forth between 2 and 6. A sequence would only run one time.

With each step there are only two variables, the address of the valve on an ni9472 and the length of time the step is active, both of which could be expressed numerically. The code for each step will be the same, just these two variables change.

Thank you

0 Kudos
Message 1 of 8
(2,667 Views)

Can you post what you have so far?

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 2 of 8
(2,660 Views)
Solution
Accepted by topic author LlywusB

How about a For loop based on an array of a cluster with two numerics in it for each of the values?

 

The cluster is controllable for the valve and time. Index the for loop on the array so it does only the steps in the array. In the loop split out the cluster, set the valve at the address to active, then wait length of time before completing the loop. If you want this to be run continuously, then a case and while loop might be all you need to add.

 

The downside to a for loop is that it will tie up the program - no easy options for cancelling the sequence (although it can be done). If you want something more interactive, look at the producer/consumer loops and queues. (the help files are a good start for those)

0 Kudos
Message 3 of 8
(2,655 Views)

You are correct, it can be done, but it is fairly easy to stop a For Loop based on conditional entries or values.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 4 of 8
(2,647 Views)

Right now I have nothing for this issue. I have the code to operate the valves manually but I haven't begun anything to automate them. I can post that if you like.

0 Kudos
Message 5 of 8
(2,638 Views)

Yes.  That would be fine.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 6 of 8
(2,627 Views)

Hi LlywusB,

 

You might try to go about parsing a string constant (and later control) into separate numbers and feed that into a case structure.  This will give you the option to control up to 10 valves each with a different address and different timing.  Take a look at the VI attached

 

Anthony F.

Anthony F.
Staff Software Engineer
National Instruments
0 Kudos
Message 7 of 8
(2,584 Views)

I use a (JKI) string-based queued State Machine (cough, cough).  My current project reads a sequence from a file when the program starts so I can modify the execution without modifying my executable.  It would work in your case, if you don't have the common aversion to string-based queued (cough) State Machines.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 8 of 8
(2,569 Views)