01-20-2014 06:13 PM
Hi everyone.
I’m new to Labview, so I’m sorry if this is very elementary or if I have overlooked an earlier question and solution regarding the same.
I would like to use a Boolean value to switch between different numerical values. The Boolean value switch each 60 second, and I would like to pass through the following numerical values in the order they are written: 300, 800, 1500, 300, 1500. The program shall then start again from the beginning of this cycle and continue running through this cycle.
I have considered case structures, stacked sequence and so on, but can’t find a solution that can handle more than two states and will continue to run through this cycle infinitely. Perhaps some kind of state machine, but I have no experience with this…?
Hope that one of you experts can help me. Thanks in advance.
Solved! Go to Solution.
01-20-2014 06:27 PM
When the boolean is true, increment a number that is passed around a shift register. Use this value as an index to index the array containing your values 300, 800, 1500, 300, 1500. If the index becomes bigger than the array size, et it back to zero.
01-21-2014 06:38 AM
Hi Chris
I've attached a file for you
One loop does what you are asking, switch between the numbers when a boolean changes
Second loop does the same as the first loop but much simpler using the wait functions instead of the watch.
Best Regards
Anders
01-21-2014 06:44 AM - edited 01-21-2014 06:44 AM
@ToeCutter wrote:
When the boolean is true, increment a number that is passed around a shift register. Use this value as an index to index the array containing your values 300, 800, 1500, 300, 1500. If the index becomes bigger than the array size, et it back to zero.
It is easier for the reset if you use the Quotient & Remainder to get the remainder of your index divided by the number of items in your array. Just do this when you increment. So your process should really be 1) check value, if FALSE, go back to 1, 2) increment value, divide by array size to get remainder, 3) use Index Array with the remainder value to get the value you want to output.
01-21-2014 07:12 AM
Tim, You know I got nothing but love for you brother.
Tools>>Options
Just check the boxes.
01-21-2014 08:09 AM - edited 01-21-2014 08:12 AM
Jeff·Þ·Bohrer wrote:
Tools>>Options
Just check the boxes.
I always have those on. What are you trying to get at?
EDIT: Whoa. What? Why isn't the constant folding working inside of the case structure? Or is it just not showing that it is really constant folding?
01-22-2014 03:52 PM
Thank you all very much for your input and solutions.
@A.Rohde the reason why I would like to use the watch instead of the wait function, is that I'm going to use it as a part of larger producer-consumer structure program. Here I have experienced some difficulties controlling the time correctly, as it is acquiring both analogue signals and digital signals with a changing frequency, so it varies how often there are values to write to the queue. This problem might be due to bad programming (probably is ) but the watch solves this problem - it's definitely precise enough for me with the watch.
Again thank you all.