LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Notifier - for loop

Solved!
Go to solution

Hi Gerd,

 

You are right, I didn't notice the deadlock loop. But I need to stop the FOR loop in each iteration, so how can I do that? inserting a event structure inside the for can be used but it will not retain the FOR iteration.

 

I tried to use shift registers but the values where not transfer properly outside the loop.

 

- Get the notifier reference once before the loop, close it once after the loop!

but I need to stop in each iteration!and in addition, wait until a trigger to continue iterating...

 

How can I arrange the structures in an optimal way?

0 Kudos
Message 11 of 60
(1,572 Views)

Hi Stavros,

 

But I need to stop the FOR loop in each iteration, so how can I do that?

As told before…

 

inserting a event structure inside the for can be used but it will not retain the FOR iteration.

Yes, it will. If done correctly…

 

I tried to use shift registers but the values where not transfer properly outside the loop.

 We don't know what you tried and in which way you tried…

 

but I need to stop in each iteration!and in addition, wait until a trigger to continue iterating...

So what's the problem here? Get the notifier once before the loop. Wait for notification in the loop. Close the notifier once after the loop!

 

How can I arrange the structures in an optimal way?

Handle the event structure in a parallel loop!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 12 of 60
(1,568 Views)

Your description is very confusing and your code isn't helping to describe what it is you are trying to do.  Why don't we backtrack and have you explain your problem as a set of requirements?  I think then we'd be better able to help you.  🙂

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 13 of 60
(1,532 Views)

Ok, what about now....

 

 

any tips?

0 Kudos
Message 14 of 60
(1,519 Views)

Hi Stavros,

 

you still have your deadlock due to executing the event structure before the case structure!

Even worse: the event loop will only execute once. You either "start" or "ready", but not both!

 

Have your event structure run in a parallel loop!!!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 15 of 60
(1,510 Views)

Is this what you are trying to do?

 

EDIT: Not sure what is wrong with the snippet and event structure.  That's not what my code looks like.

 

snip.png

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 16 of 60
(1,493 Views)

 

Billko,

The requirements:

-Have a button to START the process (there is a initializing process and then wait until start is pressed)
-There is a file with coordinates ( number, x coordinate, Y coordinate, diameter), where using a FOR loop iteration a row is readed and the parameters are "extracted" to be used in another process.
-Because it is needed to wait until the other process is finished, I am replacing that with a READY button to make sure that the next line of the file can be readed (continue with the FOR loop after a "pause" has been done.

At that's it.


Gerd,

I create the event structure before because I need both, a waiting to START and then a READY that is an unpause button for the FOR loop.
You were right, the event was executed once, that was wrong.
it could be nice to have some structure ideas....


Aputman,

Your snippet was very handy. I did not understand why you release the notifier before it entered the event structure....I imagine in that case it will never enter there!!

 

I have made another modification taking in account the example gave by Aputman.

But I still can't figure out how can I introduce a "Pause" in my FOR.


please, more recommendations or examples are very welcome!!!

 

notifier2.png

0 Kudos
Message 17 of 60
(1,463 Views)

The easiest and simpler method to use it in my FOR loop is this(and it works perfectly):

 

pauseForLoop.png

where the first iteration is done, and then it waits until Ready is pressed for the next one. And whenever STOP is pressed, then the program stops.

 

Now I need to add that the Ready button should come in form of a trigger signal (i thought using a notifier from an external parallel event), and the STOP should be used as a general STOP of the program as well....

 

Furthermore, a START button should be added to this program......I was thinking on states machines (event structure inside an case structure) but maybe there's a simpler way.

 

any suggestions?

0 Kudos
Message 18 of 60
(1,430 Views)

@aputman wrote:

Is this what you are trying to do?

 

EDIT: Not sure what is wrong with the snippet and event structure.  That's not what my code looks like.

 

 


LabVIEW's built-in Snippets don't work well with Event Structures or Property Nodes.

 

Use the Code Capture Tool.  It works much, much better.

0 Kudos
Message 19 of 60
(1,426 Views)

@Stavrosyt wrote:

 

Aputman,

Your snippet was very handy. I did not understand why you release the notifier before it entered the event structure....I imagine in that case it will never enter there!!

 


I did not release the notifier "before it entered the event structure."  The notifier is released after the top loop exits.  When the notifier is released, the "Waiting on Notifier" returns an error because it can't find the reference so it kills the bottom loop.  In your picture, you reversed everything and it is not going to exit.

 

You are way to cavalier with your use of event structures.  I have yet to come across a case where you need more than one.  But if you do use more than one, you better know what you're doing.  

 

If you need to "pause" a for loop, you need to think about your design more.  Why are you writing to a file and then pausing your for loop waiting for that write to complete, only to read the data back from the file again.  At least that is what I understand from your requirements.

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 20 of 60
(1,393 Views)