LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Notifier - for loop

Solved!
Go to solution

@aputman wrote:

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.


Now I understand what did you do with the Notifier, but considering that, even when top event structure is not addressed, I think the "wait on Notifier" will return an error because the released is outside the window, doesn't it?

 

It is true I am making lots of events structures, but it's maybe because I have not very clear how to make the optimal structure (otherwise I wouldn't be here posting).

 

You understand wrong my requirements, I have a txt file that have tabulated values (same form as an excel array).

I need to read each row with each FOR loop iteration. But I need to wait for each row because I need to use those values to execute another process.

When the process is done, I continue reading the second row and "extract" the next values, and so on....

 

I think is shouldn't be very complicated, but I am creating a mess between the creation of Events structures and the Notifiers together....

0 Kudos
Message 21 of 60
(2,100 Views)

I don't understand why you need to pause the reading of the file?  How many data points (rows) are you talking about?  How long does the secondary process run for each row? 

aputman
0 Kudos
Message 22 of 60
(2,084 Views)

Sounds like this is all you need.  

capture.png

aputman
0 Kudos
Message 23 of 60
(2,080 Views)

@aputman wrote:

I don't understand why you need to pause the reading of the file?  How many data points (rows) are you talking about?  How long does the secondary process run for each row? 


 

I need to pause the reading because otherwise I "lose" my parameters and the next row reading.

Rows? not many, sometimes 24, or 44.

The secundary process can be maximum 10 seconds.

 

You were right, that what I need, and that's what I was using as you can see in one of the pictures I posted before.

 

I put it here again....updated.png

0 Kudos
Message 24 of 60
(2,048 Views)

Here's a LabVIEW tip for you.

 

Index Array is expandable.  You don't need to make 4 copies and have the array wire splitting and going to each of  them.  Drag the bottom of one downwards and you'll get extra Index inputs.  You don't need to wire up any of the index inputs because by default it will give you index 0, 1, 2, 3, ......

Message 25 of 60
(2,016 Views)

My problem is reduced to this: I have a FOR loop where is needed to be paused until the present values are used. A signal that the first iteration is done trigger another process,and when it finishes trigger another signal to let the FOR loop to continue.

 

I was making some examples and this is what I did....but of course, it doesn't work..... I thought to use 2 notifiers, one called "Motor ready" and other "Laser ready".

 

When the first proces is done (motor process), then the laser process begins and when it finishes, return to the FOR loop that is in the motor process.

 

I think can be used the Producer/consumer (events) template....but I am missing something in the dataflow of a WHILE loop inside a FOR loop to be used as "row reading pause".

 

notifer-example.png

 

suggestions?

0 Kudos
Message 26 of 60
(1,967 Views)

Hi Stavros,

 

suggestions?

Use Ctrl-U (autocleanup tool) to have "nice" wires going from left to right!

 

You have a dead-lock: the FOR loop may run for one iteration, but then it will wait forever on notifications!

 

And get rid of sequences by using proper DATAFLOW: use error wires!

 

Next time attach a VI instead of some images…

Best regards,
GerdW


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

Ok, I modified the program to have instead of a WHILE loop, a EVENT structure,but the FOR loop is never reached!!!!

 

how can I do it in a right way?

 

(VI attached)

0 Kudos
Message 28 of 60
(1,927 Views)

Have you tried to run your vi in Highlight Execution?

That will show you how your vi is runing and why it is stuck.

 

You need to understand DATAFLOW and you need to learn how to debug code.

 

And final, by now you need to give us a bigger picture of your program.
I'm 99% sure it can be done in another way, that does not require a loop to wait.

What is the motor process and what is the Laser process. How are they designed and programmed.

 

I could think of a simple statemashine could do the job.

0 Kudos
Message 29 of 60
(1,910 Views)

@dkfire wrote:

Have you tried to run your vi in Highlight Execution?

That will show you how your vi is runing and why it is stuck.

 

You need to understand DATAFLOW and you need to learn how to debug code.

 

And final, by now you need to give us a bigger picture of your program.
I'm 99% sure it can be done in another way, that does not require a loop to wait.

What is the motor process and what is the Laser process. How are they designed and programmed.

 

I could think of a simple statemashine could do the job.


Hello dkfire,

 

Yes, i run it in highlight executation, and after doing the notification never enters the for loop, consequently never reaches the while loop either.

 

My motor process is:

 

  • initialize
  • wait for start button
  • if start, then read first row of the file andobtain the parameters.
  • with a subVI, run the motors from the parameters obtained.
  •  once finished (knew by reg event callback), go to laser process
  • wait for laser process to finish
  • finally, read the next row of the file and repeat the process until the EOF is find.

 

Laser process is:

 

  • initialize
  • wait for motor process to begin
  • execute
  • let the motor process know is finished by a event (reg event callback)

 

And that's it.

 

I have all the program executed, but when it comes to wait for the parameters to be read and create a Pause in the FOR loop and begin to be messy in the DATAFLOW.

Even more, when I need to come back where the FOR loop was paused, and continue with the iterations....

0 Kudos
Message 30 of 60
(1,900 Views)