09-04-2008 08:12 PM
I've constructed a simple, 1-D boolean array showing comparison results between expected and actual values, read over the serial port. I want to have a single LED indicator on the Front Panel that turns ON when all of the array elements are True. If only a single array element is False, I want the front-panel LED indicator to turn OFF.
This would be straightforward in a traditional programming language: set an initial, global boolean scalar variable to "False", then sequentially test every array element (via a 'for' loop). If any of the boolean array elements is "False", then set the global scalar to "False" as well.
But I can't visualize how to implement this For loop in LabView. How to search the boolean array for any "False" value, and if found, set a Front Panel indicator to turn off?
I have attached a short program that attempts to illustrate the issue. Most of the program can be ignored: the "For" loop on the far right actually sets the value of each boolean array element. I would think that the global scalar value could somehow be checked somewhere in that "For" loop, also ....
I would also welcome any suggestion for how I could avoid hard-wiring the loop-count in that "For" loop to a constant (in this case, to the value '12'). Shouldn't the "For" loop be able to deduce the size of the array automatically?
Thanks.
09-04-2008 08:27 PM - edited 09-04-2008 08:31 PM
I don't think your text based solution is very simple and I know it's simple in LabVIEW. Look on the array palette.
p.s. You really want to keep similar posts like this to the LabVIEW board. It has nothing to do with Instrument Control.
You also don't need to wire any value to the 'N' terminal of a for loop when you pass in an array. You might also want to check out the free LabVIEW training
09-04-2008 08:46 PM
09-05-2008 12:08 PM
Thanks, Dennis. I wasn't aware of the "boolean palette" until you pointed it out. This contained the perfect function. Regarding my reference to the "serial port", you are correct that my test case was poorly identified. This was a consequence of the test case itself: the actual application I'm working on involved serial port communication, and I should have removed the reference since it was not part of the test case.
I appreciate the quick feedback.
- Eric
09-05-2008 02:13 PM - edited 09-05-2008 02:14 PM
09-05-2008 05:20 PM
Albert -- thank you for the additional reply. Yes, your proposal is closer to the traditional algorithm I had in mind. I appreciate the insight. My LabView learning curve continues to climb ...
Regards,
- Eric Means