LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Occurences

I have a situation where i am trying to use occurences to synchronise two while loops.  When the 'Threshold' controlvalue is changed, i observe the occurence being set and i think i can see the occurencereaching the second (lower) loop but for some reason the second loop doesn't execute.  It gets 'stuck' at the first for loop.  I have attached the section of code where my problem occurs (see picture).

 

Please advise as to what i may be doing wrong, or if there is a better way of initiating/activating the second loop (it only executes once per occurence).

 

Thank you.

 

James

 

Message Edited by James Mamakos on 06-01-2009 07:12 PM


Never say "Oops." Always say "Ah, interesting!"

0 Kudos
Message 1 of 10
(3,980 Views)

Its hard to tell but your wait an occurance has no dataflow dependant code after it,  essentially all the code in the bottom loop will execute since it is not dependant of the occurance but the loop will block the second itteration until the occurance is set.

 

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 2 of 10
(3,960 Views)
Can you show the entire code?
0 Kudos
Message 3 of 10
(3,943 Views)

hi james,

 

I have tried same logic with two while loops.I am attaching my vi for you. I have taken 2 while loops and using occurence tried to run for loop (no event structure).

check if it is helpful to you..if not then please attach  your code.

 

 

Best of luck

Gaurav kSmiley Happy

Gaurav k
CLD Certified !!!!!
Do not forget to Mark solution and to give Kudo if problem is solved.
0 Kudos
Message 4 of 10
(3,930 Views)

Different question - same topic...

With a while loop that is waiting on an occurrence to execute, what's the best way of terminating the loop without running all the code inside it?

Should I set an occurrence when the 'stop' button is pressed, and the enclose all the code in the above-mentioned while loop in a case statement so nothing executes when I'm trying to end the program? ...or is there a better way to achieve this?
  Actually, even this won't work because if the stop value is changed to false, the whole code in the while loop will execute unwantedly.  Any ideas?


Message Edited by James Mamakos on 06-02-2009 10:00 AM


Never say "Oops." Always say "Ah, interesting!"

0 Kudos
Message 5 of 10
(3,912 Views)

I think i've discovered my problem, (i feel rather silly now). Smiley Sad

 

In my VI, i've got an empty 2D constant wired and indexed into the for loop.  This can easily be sorted by using a non-array constant, but it's made me think...

 

Is there a way of selecting which indexed input of a for loop is the one that controls the number of iterations other than finding the array size of the intended input and wiring that to the count (N) terminal?

Message Edited by James Mamakos on 06-02-2009 10:27 AM


Never say "Oops." Always say "Ah, interesting!"

0 Kudos
Message 6 of 10
(3,898 Views)

For several reasons (passing data, error wires), it might be of an advantage to use notifiers instead of occurances. In the 7.1. help there is a note from NI to prefer notifiers...

 

Felix 

0 Kudos
Message 7 of 10
(3,893 Views)

James Mamakos wrote:

In my VI, i've got an empty 2D constant wired and indexed into the for loop.  This can easily be sorted by using a non-array constant, but it's made me think...

 

Is there a way of selecting which indexed input of a for loop is the one that controls the number of iterations other than finding the array size of the intended input and wiring that to the count (N) terminal?


I think you still have some misconceptions. The number of iteration of a FOR loop is determined by the smallest of all following numbers: (1) the value wired to N, (2) the sizes on all autoindexing arrays.

 

So, if you autoindex on an empty array, you loop will iterate exactly zero times, even if you have a million wired to N.

0 Kudos
Message 8 of 10
(3,867 Views)

To be honest I have not seen your code but for information, in some cases you can use "Reshape Array" function before passing that array into the loop.

 

Hope this helps...

0 Kudos
Message 9 of 10
(3,858 Views)

krsone wrote:

To be honest I have not seen your code but for information, in some cases you can use "Reshape Array" function before passing that array into the loop.


krsone,

 

We cannot tell which post you are replying to and it would be important to know, so always quote a small, but relevant part.

 

Also the "reshape" answer is a bit too vague: Reshape into what?? 😉

0 Kudos
Message 10 of 10
(3,847 Views)