LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

The usage of the multiple "Wait On Occurrence"

Solved!
Go to solution

I've download an example VI demonstratinig how to use the function of occurrence.

When I tested that VI, it is "sometimes" not triggered in all wait on occurrence.

20150408001.PNG

I have no idea how to explain it...

Cound anyone give me some suggestion?

Thanks a lot!

0 Kudos
Message 1 of 8
(4,857 Views)
Solution
Accepted by topic author William1225

What exactly is your question? Are you asking why sometimes a timeout condition occurs? You are triggering the occurrence every 100ms, and you have a 100ms timeout on the Wait on Occurrence. The timing isn't that precise. The Wait (ms) function sets a lower bound on the wait but does not dictate absolute timing, so that loop will often take slightly longer than 100ms. On a desktop operating system (such as Windows) there is no way to guarantee absolute timing - you need a real-time operating system for that. Since the occurrence will sometimes not be set within 100ms, the Wait on Occurrence will occasionally time out. Use a longer timeout on the Wait on Occurrence and you'll see this much less frequently, with little effect on the overall system timing.

Message 2 of 8
(4,839 Views)

Also try setting "ignore previous" to FALSE (default is TRUE).

Message 3 of 8
(4,835 Views)

Very thanks nathand and altenbach's suggestioins, it helps a lot.

I agree that the jitter has influence on it.

I'd like to figure out more detailed thinking, like the following image as the last attached image

 

20150409003.PNG

 

It is "often" both Couter and Timeout increased by 1 in one loop than the other.

How to realize it?

After thinking after your suggestions, there're two images in my brain,

(I like to upload image to express my thoughts, since it show my thinking clearly,

and hope you may not be confused with my poor English expression)

 

20150409001.png

While the jitter happened, say timeout of LOOP 2 exceeds the LOOP 1, and a trigger just goes between the timing,

and then LOOP 1 get one more timeout, and the "Counters" remain the same.

 

20150409002.png

There's a increment function after the wait on occurrence, say "math".

If LOOP 2 is doing the math, and the trigger just happened, and then LOOP 2 miss a counter.

 

Is my above thoughts correct? Is there other possible situation?

I still can not figure out how does the "Timeout" and "Counter" usually increment or decrement together.

Hope I don't go too far away to the discussion...

0 Kudos
Message 4 of 8
(4,779 Views)

William1225 wrote:

I still can not figure out how does the "Timeout" and "Counter" usually increment or decrement together.


Let's say the loop that sets the occurrence takes just slightly longer than 100ms. This causes the timeout to increment. Then, on the next cycle of the timeout/counter loop, the occurrence is set immediately (because the loop that set it took just barely longer than the timeout time), so the counter increments immediately. This is exactly what you'd expect.

0 Kudos
Message 5 of 8
(4,769 Views)
The issues are more visible if you would place a 50ms wait in the two loops on the right. If the occurrence is set right after it timed out, but before it is waiting again in the next iteration, it makes a difference if it is discarded or not.
0 Kudos
Message 6 of 8
(4,767 Views)

@William1225 wrote:
 

20150409001.png


The situation shown in LOOP 1 in this image never happens! You won't ever have the same "Wait On Occurrence" waiting for the occurrence twice in the same loop cycle. Your drawing should show that as soon as the occurrence happens the first time, it goes on to the next loop cycle.

0 Kudos
Message 7 of 8
(4,759 Views)

I should say sorry to nathand & altenbach...

It's my misunderstanding to the code, mistake the "Timeout" doing the same action(increment while timeout) as the "Counter", the Timeout is just the index of the while loop...

No wonder you are not surprised at the increment of both Counter and Timeout.

So stupid I am, but I still make something clear. Thanks nathand and altenback's suggestions again!

0 Kudos
Message 8 of 8
(4,715 Views)