From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

User-defined sequence to control valves

Hi all - 

 

I'd like some direction in the best way to code a valve sequence structure in Labview 2011. I have six valves. On the front panel, I'd like the user to be able to program in events for a sequence. For each event, the user selects a valve, a start, and a stop time. It would look something like this:

 

Valve 1, 3 sec, 5 sec (this means the valve is open from second 3 to second 5)

Valve 2, 4 sec, 6 sec

Valve 1, 7 sec, 8 sec 

Valve 3, 1 sec, 2 sec 

 

As you can see, this allows there to be multiple events for each valve and the events do not have to be chosen in sequential order. After entering in as many events as the user likes, they click the go button. The sequence then plays through and opens up the valves for the times requested. 

 

Could you please point me in the right direction for how to code this? A link to a tutorial or example would be a helpful starting point. I've read through a few forum posts about similar things, and my initial thought is to use a state machine. I read through the tutorial on that, and I understand the concept. But I can't figure out how to apply it to my specific objective. In the state machine, is every event it's own case? 

 

Any tips are appreciated. Thank you very much!

 

 

0 Kudos
Message 1 of 4
(2,556 Views)

You could do this with a state machine but I would suggest instead a producer consumer architecture. 

 

I would suggest an array of clusters. When you press run (or start, or whatever) you should parse the array for all of the start and stop times and put them in order. Using your example, that would become

1,3,open

2,3,close

3,1,open

4,2,open

5,1,close

...

 

Or similar. This parsing is two steps - break the cluster element into two steps, then sort by time.

 

Then, you can enqueue this series of events to the consumer, either at the time required, or at the start. In the first case, the producer has a clock and sends messages as needed, in the latter the consumer has a clock and checks if time is reached yet. I would probably choose the former, but I'm not sure which is better for you.

 

Then, your consumer has a VI with a small number of simple inputs - which valve, open or close?

 

 


GCentral
0 Kudos
Message 2 of 4
(2,525 Views)

Below is a VI (saved to 2015) that shows splitting and sorting the array. Note that the time is before the value in the cluster and the boolean indicates if you should open or close.

 

Take care if the inputs might not be all in agreement - if you want Valve 1 opening at 1s, closing at 10s, and you also write Valve 1, 3s, 4s, then the valve will be open from 1s to 3s with this idea. If you need to handle that kind of conflict, you'll need to use more complicated logic.

 

sortCluster.png


GCentral
0 Kudos
Message 3 of 4
(2,520 Views)

Did this help at all? Let me know how it's going.


GCentral
0 Kudos
Message 4 of 4
(2,488 Views)