07-22-2011 10:14 AM
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
Solved! Go to Solution.
07-22-2011 10:42 AM
Can you post what you have so far?
07-22-2011 10:52 AM
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)
07-22-2011 11:24 AM
You are correct, it can be done, but it is fairly easy to stop a For Loop based on conditional entries or values.
07-22-2011 12:13 PM
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.
07-22-2011 12:46 PM
Yes. That would be fine.
08-02-2011 09:28 AM
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.
08-02-2011 11:14 AM
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.