04-06-2009 11:06 AM
Hello,
I'm trying to build a vi that reads in boolean true/false values, then correspondingly disables the false ones on a ring. The problem I'm having is that I can't build the array for the disabled items indices correctly. I've looked over the attached file several times and tried to do some error checking, etc. (which explains some parts of the vi), but I can't figure out why it isn't working correctly. Any help on the matter would be much appreciated.
Scott
04-06-2009 11:18 AM
The problem in your VI is the loop condition. Your condition states that the loop should stop if the size of the array is greater than the current index. Since the current index ('i') starts at 0, your 16 element array of booleans will always be greater than it.
You can either change your loop condition terminal to a loop on true, or change your comparison statement.
04-06-2009 11:40 AM - edited 04-06-2009 11:43 AM
OK, first you should learn some basics, because your code is very bad.
Here's a quick draft for some of your code snippets. See if they make sense. (... and don't use the "continuous run" button!)
04-06-2009 11:41 AM
Your real problem is that you're trying to write LabVIEW code as if it were VB code. LabVIEW code does not execute top to bottom or left to right. You are using local variables where you should be using wires. LabVIEW is a dataflow language, not a linear/procedural language. Thus, you cannot write code in the same way as you with text-based languages. None of your local variables are necessary. Plus, since you have three independent loops, there is no control as to which one executes first because you are using local variables. This is a classic race condition.
Also, your use of the uninitialized shift register will cause problems as with subsequent runs it will use the contents of the shift register from the previous run.
As to the premise, an easier solution would be to use a cluster of Booleans rather than individual Booleans. You also only need one loop, not three.
04-06-2009 11:41 AM - edited 04-06-2009 11:42 AM
(duplicate due to site issues. Ignore)
04-06-2009 12:27 PM
Thanks for the input. The posted code is a good starting point for further discussion. First, how did you make the array of push buttons? Second, if you have a loop, does the next event "down the wire" wait until the loop executes? I presume it does...
Thank you,
Scott
04-06-2009 12:36 PM - edited 04-06-2009 12:36 PM
SAMullin wrote:First, how did you make the array of push buttons?
Drop an array container on the front panel, drop the button in it, resize the container, click on the last element to define the array size, make current values default. save VI.
SAMullin wrote:Second, if you have a loop, does the next event "down the wire" wait until the loop executes? I presume it does...
Yes. It's called dataflow. A structure cannot execute until it recevied data on all inputs and a structure only outputs data when all of it has finished. Everything wired to the output of a loop for example will wait until the loop has completed. Isn't it great! 😄