LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with Occurrence

Solved!
Go to solution

I have this simple occurence, and I need to know why the value of a, and b are not equal. Afterall, the while loop on the right is suppose to iterate before the while loop on the left.

 

So I expect to see the same value. Thanks for any explanation. I have attached the picture file.

0 Kudos
Message 1 of 5
(3,276 Views)

Works just fine here.

 

What is your LabVIEW version? Can you attach your code?

0 Kudos
Message 2 of 5
(3,268 Views)

I admit from the picture I don't see what's happening, but I'll throw in a general suggestion that could be related.

 

Always consider using Notifiers instead of Occurrences. My biggest complaint about occurrences is that an instance of the Generate Occurrence function on a diagram will output the same occurrence reference every time it executes, not a new reference. This means it's possible that the Wait on Occurrence function could accidentally get triggered from an old occurrence if Ingore Previous is not true. And if it is true, then you run the danger of missing the occurrence in the first place due to race conditions.

 

Notifiers have all the functionality of occurrences and more, and they avoid this problem because you have the control over opening and then closing separate references as needed.

Jarrod S.
National Instruments
Message 3 of 5
(3,260 Views)

Thanks guys, I have attached the file. I use LabVIEW 8.6, but I am not getting the same value for the two while loop iteration.

 

Actually, I am trying to learn occurrrences, that is why I am running the program.

 

I have attached the code

0 Kudos
Message 4 of 5
(3,256 Views)
Solution
Accepted by topic author ade77

What you are seeing here has nothing weird to do with occurrences at all. They are performing exactly as they should. You can verify that by placing a breakpoint before the Set Occurrence function as shown below. You can then control exactly when the occurrence is set by unpausing the VI. You'll see then that both loops are at the same iteration.

 

The iteration counts merely appear to be different because the loop that waits on the occurrence has a shorter wait, so it is at least trying to run faster more often than the slow loop that sets the occurrence. This means it will start its iteration sooner and update the Iteration indicator before it waits for the Occurrence to be set, which then resynchronizes the loops.

 

 

Message Edited by Jarrod S. on 05-01-2009 10:44 PM
Jarrod S.
National Instruments
Message 5 of 5
(3,252 Views)