LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Comparing array values

Solved!
Go to solution

I'm trying to create a VI that monitors temperature and flow data and issues a warning when it's slightly out of spec and shuts off when it's really out of spec. I have attached my VI, but I'm having a problem with comparing arrays of data for the logic flow. It seems that only the first value in the index ever gets looked at because when I crank the 2nd or 3rd value higher than the limit, nothing happens. 

 

I used the compare aggregate feature since I would like 1 boolean operator to serve as an input to my case structure.

 

Any advice would be appreciated, I attached my VI below. 

 

Thanks

0 Kudos
Message 1 of 16
(3,550 Views)

Your VI has a password, so we cannot inspect it.

0 Kudos
Message 2 of 16
(3,547 Views)

Forgot about that - it's re-uploaded now without a password, thanks

0 Kudos
Message 3 of 16
(3,539 Views)

Well, can you give a truth table on what LEDs should be on depending on the inputs?

Are the two input arrays (temp, flow) guaranteed to be the same size?

 

You really need to compare with scalars, not arrays. You can always use "OR array elements" later.

 

Here is one possibility (assuming the arrays have same size. If not, the "OR array elements" need two copies and to be moved right after the comparisons).

 

(Note that this code is most likely not right, because I don't know the truth table and your code is apparently incorrect. Still, it should point you in the right direction.)

 

compare.png

0 Kudos
Message 4 of 16
(3,518 Views)

@altenbach wrote:

Well, can you give a truth table on what LEDs should be on depending on the inputs?


Given the following diagram, which LEDs should be lit depending on the nine possible conditions (A..I)?

 

TheTruth.png

 

 

0 Kudos
Message 5 of 16
(3,508 Views)

Sure, so when the temperature is below the warning level (25) and the flow is above (3), the interlock satisfied light should be on. If the temperature is between 25 and 30 or the flow is between 3 and 4, the interlock is still satisfied but now the warning light is on. When the temp is greater than 30 or the flow is less than 3, the interlock is not satisfied.

 

The temp and flow are always the same size (3 values). Eventually I will be gathering the data from a DAQ but I'm trying to get the logic correct first. 

 

I'm trying to understand your code, what comparison mode are they using? I'm assuming elements because of the OR array elements. Also, what function is at the output of the for loop? I'm fairly new to labview (my first week) so I appreciate all your help. 

0 Kudos
Message 6 of 16
(3,506 Views)

Sorry, posting by phone. When comparing an array and a scalar, you cannot use aggregate mode.

The loop does both comparisons, resulting in two elements, extracted using index array later.

I am sure all this could be simplified even much more.

0 Kudos
Message 7 of 16
(3,496 Views)

@gregb7 wrote:

Sure, so when the temperature is below the warning level (25) and the flow is above (3), the interlock satisfied light should be on. If the temperature is between 25 and 30 or the flow is between 3 and 4, the interlock is still satisfied but now the warning light is onWhen the temp is greater than 30 or the flow is less than 3, the interlock is not satisfied.


So far you have defined the squares, but there are overlaps and inconsistencies:

 

A, 😧  I=On, W=Off

B,D, E, F, H: :I=On, W=On

C, F, I, G,H, I=Off, W=On

 

As you can see, there are conflicting settings for cases F and H, for example. Watch for the logical difference between OR and AND when defining things. It would be much easier to define the LED states for all cases A..I.

 

 

 

TheTruth.png

 

0 Kudos
Message 8 of 16
(3,480 Views)

I created a truth table with the desired values:

 

truth table.JPG

 

How would I attempt to simplify this? I'll try to implement this using the example code you provided in the meantime

 

Thanks

0 Kudos
Message 9 of 16
(3,442 Views)

I created this VI but I seem to have the same issue as before, where the indicators only react to the first value of the array. I played around with it and the truth table is correct but for only the first value. How can I make labview look at all values concurrently? 

0 Kudos
Message 10 of 16
(3,437 Views)