09-06-2017 09:16 AM
I have different elements on my front panel and would like to update them after different amounts of time have elapsed. (This example uses multiples of 250 because I'm not original, but assume arbitrary times.)
KISS Method
Is there a better way to combine these three loops while maintaining timing independence and keeping an intuitive back panel?
Solved! Go to Solution.
09-06-2017 09:30 AM
Once you also have other events, the use of an event structure for this purpose us not good, because any other event will reset the timeout. Also, your button belongs inside one of the stop events, else it will not reset.
In this case I would recommend a single loop running at 250ms (GCD), then you can do some simple math based in the iteration terminal to decide what the boolean value should be for each.
For an LED it does not matter how often it is updated with the same value, but if you write to e.g. a digital output, you can use case structures to only do so if a change occurs.
09-06-2017 09:32 AM
Hi ATE,
it seems you want to set indicators at multiples of 250ms: set the timeout to 250ms and count the timeouts…
Or: Use a state machine - it's also KISS… (States like "do something1", "wait some time", "do something2", "wait some time")
09-06-2017 09:44 AM
I would also look at using the Elapsed Time VI. You can have a different one for each indicator and use a case structure to conditionally write to them.
09-06-2017 09:52 AM - edited 09-06-2017 01:55 PM
Here's a simple draft of what I had in mind.
As you can see it shows the same behavior (and even resets correctly when the program starts. (your code will show stale values until the first update).
Also note that arrays make everything simpler. No need for all these loose terminals cluttering the diagram. 😄
09-06-2017 01:58 PM
09-06-2017 02:23 PM - edited 09-06-2017 02:38 PM
@ATE-EGNE wrote:
Considering that I want my Stop button inside the event producer loop, is there a better way than a dedicated event structure to end the ticker loop?
Why would you need the stop button terminal in the producer loop?? All you need is the stop event . Since the button is latch action, a value change is necessarily a TRUE (very few exceptions*), so you can simply wire the "new val" event data node (or even a TRUE constant!) to the stop condition from inside that event (... and also add code to shutdown the consumer via the queue, etc.). This allows you to place the stop terminal in the bottom loop, eliminating the event structure there.
*one exception would be if the default value of the latch action button is TRUE. In this case it would turn FALSE until it is read by the code and returns back to the default TRUE value.
09-06-2017 03:20 PM - edited 09-06-2017 03:21 PM
ATE-EGNE wrote:Here's what I have implemented:
It does not work correctly because you have connected to the lower "IQ" output instead of the upper "R" output of Q&R. Be careful there! 😮 (compare with my VI above)
09-06-2017 06:29 PM
@ATE-EGNE wrote:
I like the use of the NOR gate (wouldn't have thought of that)
It is actually an XOR (exclusive OR). A XOR TRUE = NOT(A)
09-06-2017 07:05 PM
Yes, I am using an XOR (you could also just use a "not equal" :)). You replaced it with a "not XOR" for some unknown reason. Notice the little circle on the output of yours!