03-23-2012 08:01 AM
The sequence structure is not helping you.
The reading of the boolean and the execution of the case selector can all happen before, after or concurrently with the sequence frame. And I think the fast majority of the time, it will wind up executing before the data gets written to inside the sequence frame. The only the sequence frame is doing is making sure the addition doesn't occur before everything inside the frame finishes.
In order to prevent the global from being read until after the stuff in the sequence frame executes is to add another frame to the sequence structure and put it inside that 2nd frame.
03-23-2012 10:02 AM - edited 03-23-2012 10:02 AM
@Grant_C wrote:
Do you have an alternative solution?
Try somethings as described here.
or in the post following it. You can easily make it more universal to work for your problem.
@Grant_C wrote:
I added the flat sequence in order for the global to be written to prior to being read by the case selector. Could this not work. Basically, i am toggling a switch when it reaches -100 or 0 in order to change the increment between 0.5 and -0.5. It seems to work ok. Do you have an alternative solution? I take your advise on the floating point. What is the alternative to using floating point?
Best Regards,
Why do you even need the global variable? All you need is a stack of two case structures that handles both comparisons and outputs a boolean wire to be fed to the select node (if you really need the global to see the state elsewhere, wire it to this wire). You never need to read from the global in the same VI. Instead of the equal comparisons, use a "greater or equal" to catch it soon after if the floating point comparison fails due to binary rounding.