LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simple sequence VI

I know sequence structures are looked down on here, but I don't need anything too fancy.

 

What I'm trying to do is:

 

1) Read in analog signal

2) Compare to desired signal

3) If desired is larger than actual, trigger relay 1 (digital out)

4) Read in analog signal

5) Compare to desired signal

6) If desired signal is larger than actual, trigger relay 2

 

I would like to do this for about 12 relays.  

 

I would also like for the VI to work in the reverse case (i.e., if desired signal is smaller than actual signal, turn relay 12 off (work in reverse here)).

 

Can anyone get me started?

0 Kudos
Message 1 of 3
(2,142 Views)

I don't know why sequence structures are "looked down on".  They are useful tools.

 

It's not clear from your description whether you have 12 different signals (12 channels) or you're reading the same signal sequentially. 

 

If you have 12 separate channels, be aware that you can run an array of 12 signals into one side of a COMPARE operation, 12 constants (your limits) into the other side, and you get out 12 BOOLEAN values, to drive 12 relays.

 

Other than that, please explain more about your situation, and why sequences don't do what you need. 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 2 of 3
(2,135 Views)

Sequence structures are only needed if the execution order is important and cannot be determined from dataflow alone.

 

You seem to only have 3 steps (1:read-2:compare-3:trigger) that you want to repeat 12 times. So use a FOR loop with 12 wired to N.

 

Inside the FOR loop, do the three steps. Execution order is clear, no seuqnce needed. The comparison cannot take place until you have data from step 1, and the case structure containing step 3 depends on the comparison. Things will go in order automatically due to dataflow. Do some logic that translates the loop counter to relay number. or do whatever needed so the correct relay is sleected based on iteration.

 

For the reverse, you might want to keep the state of all relays in a shift register so you can decide if it needs to be turned on or off.

 

This all looks quite simple. The code shouldn't take more that the area of half a postcard. 😉

 

See how far you get. Please show us your code if you get stuck. 😉

0 Kudos
Message 3 of 3
(2,133 Views)