LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems when comparing arrays

Solved!
Go to solution

I know this is a really simple subject and I had it working about 30 minutes ago but I then made the VI into a subVI and implemented it into another program and now it seems to not be comparing all the elements.  The basic idea for the subVI is to compare the max temperature measurement, the voltage setting, and the current setting in an experiment and make sure they are not too high. A simple psuedo code would be:

 

-Bring in array of temperature measurements

 

-Bring in voltage setting

 

-Bring in current setting

 

-Calculate max temperature measurement

 

-Create array of max temp, voltage, and current

 

-Compare this to an array of comstants (my limits) in compare agregate mode

 

-If any value is larger it returns true and turns program off.

 

This seems to work fine for temperature and voltage but the program seems to ignore current now. Any help is much appreciated.

 

- Kyle

0 Kudos
Message 1 of 5
(2,235 Views)
Solution
Accepted by topic author kgould

Set it to "compare elements" followed by "or array elements".

Message 2 of 5
(2,227 Views)

Hi Kyle,

 

When I ran your VI, I found that your comparison function returned a "T" was when the temperature exceeded the set limit.  So it seems to ignore both voltage and current.

 

The reason for this is because of the way "compare aggregates" works.  It compares sequential elements until a decision can be made.  In your case, I believe that what is happening is that a "greater than" decision can be made based on the 0th element of your arrays, thus obviating the need for the function to compare the rest of the elements.  Perhaps I am misunderstanding the way "compare aggregates" works for a "greater than" function, but it certainly seems to describe what is happening.

 

I think it makes more sense to use "compare elements" mode and OR the resulting array.  See attached.

Diane

 

EDIT:  I should have known Altenbach would beat me to it!

Message 3 of 5
(2,226 Views)

You say "If any value is larger than it returns true".  Does that mean if the Temp. is too large but the others are not, then it should be true?

 

Right now you have it programmed that all of the values must be larger in order to return a True.  (Though upon further testing, the comparisons seem to be flakier than that.)  That is what the compare aggregates mode is doing.

 

If you turn off compare aggregates, you will get an array of booleans (a true or false for each comparison).  The you can use the OR Array Elements from the boolean palette to determine if one or more elements is true.

Message 4 of 5
(2,224 Views)

Thanks a lot.  Worked perfectly.  I misunderstood how compare agregate mode worked.  The "OR array function" is great to leatn and will come in very handy.  Thanks again and I am sure I will be back.

 

- Kyle

0 Kudos
Message 5 of 5
(2,211 Views)