LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to search for specific match from an array?

Hi Mike,
 
Thanks for the reply.

I am reading a position of switches whether ON/OFF. It is nothing but the digital inputs status from the field. I am Indexing that array, and connect it to the LED indicators to show the relevant status. Also I want to raise an alarm  once, for the ON switches.  By using Search 1D array, I got the first TRUE match index from the array. But if I want to know all the occurrences of ON condition (TRUE from an array of booleans) from an array of switches. How to do that?
 
Hope this clarifies.

Thanks
 
Kousy
0 Kudos
Message 1 of 3
(2,366 Views)


@Kousy wrote:
...By using Search 1D array, I got the first TRUE match index from the array. But if I want to know all the occurrences of ON condition (TRUE from an array of booleans) from an array of switches.

Use the "search array" in a loop and keep the last found index (plus one) in a shift register to be used as start index for the next iteration. Loop until the index is -1.
 
The attached (LabVIEW 7.1) shows one possible implementation. There are many ways to do this. 😉
0 Kudos
Message 2 of 3
(2,361 Views)

I almost missed this message because you started a new thread.

In any case, the code altenbach posted will give you an array of the indexes that are set to true. So it sounds like that is at least part of what you want. The alarm you mention, is that one "master" alarm if any of them are true, or is it a separate alarm for each bit?

If it is one "master" alarm for all of them the logic menu has a function for ORing all the elements in a boolean array. Also when you say "alarm" what is the nature of this alarm? A dialog box? a flashing light (real or on the applications's front panel)? message in a status display?

The attached code shows one possible direction by adding onto altenbachs code the ability to accumulate a single error message based on the states of individual bits. (BTW: The other alternative that you might see would be to pass the array into a loop and use a case to append a message of the bit is true. The advantage of the one in the combined VI is that the loop only iterates for the number of true bits +1. Where as the other approach would have to look at all the bits one at a time.)

In a sense this is why I asked for clarification because there are a lot of things you can do when parsing an array like this.
 
Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 3 of 3
(2,348 Views)