LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

use notification to stop parralle loop

Solved!
Go to solution

Hi

Every one

I have created multiple producer/connsumer loops.

 

One producer loop is event case which wait from  control value change from FP and then send queue to consumer loop (control solenoid valve)

The other separate producer loop is for NI 9213 to display Temp data, I use other consumer loop to acquire data from NI9213

 

I am not sure if I can use notification to stop both pair of loops.

 

I hope when I click Stop The whole Process Button in FP, then, True value is send to Nofication. Then NI 9213 Producer loop get this message to stop loop. Right now stop process button only control solenoid loop since this button is in event structure.

 

I tried notification. When I put wait on notification in NI 9213 loop, this loopkeep waiting any notification and doesnot monitor the temp data

 

Thanks

0 Kudos
Message 1 of 17
(5,301 Views)

Sounds like you need to set the timeout value for Wait on Notification, since the default is to wait forever.  Then you need to check if the wait timed out, and only do something (exit the loop) if timed out is false, meaning a new notification is available.  You might also want to check for errors coming out of the Wait on Notification, since if one loop destroys the notifier it will cause an error in any Wait on Notification loops that use that notifier.

 

If this doesn't answer your question, please attach your VI to your reply.

0 Kudos
Message 2 of 17
(5,297 Views)

OHOH...

 

yes . It works

Thank you so much

 

0 Kudos
Message 3 of 17
(5,287 Views)

Hello

Now I have a new question. I also need to send message to other 3 consumer loops to begin save data . For example, when NI 9213 Temp is higher than 35 degree C. I can send msg to notifier in producer loop.  Other consumer loops will wait notification(time out 10ms). When they received " True" which  is coming from producer loop and then start to save data in a file. 

 

Right now I put wait on notification (time out 10ms)in consumer loop, which is connected to case structure , true for saving data and false for not saving data. 

In producer loop, once I send  "T" to notifier, consumer loop start to save but on next loop, It will stop saving it seems to output False to case selector. 

 

Is there other way to keep saving until I send false to notifier?  I may use time out terminal ??

 

 

 

0 Kudos
Message 4 of 17
(5,243 Views)

Have you considered using a queued message (often caled a queue state machine) rather than using a notifier? Also, I generally try to use explicit messages to control consumer loops rather than simply using a boolean. Explicit messages are more explicit and if you use a general message construct (a cluster with a message type (string or ENUM) and a variant) you can pass any type pf data specific to a particular message. If no data is required then the data portion will be empty. The one down side with using queues is that you will need to send the message to each queue rather than broadcast via a notifier. In your case it is inefficient to check the notifier every iteration because it only has meaning once.

 

Alternatively you can use a tradiitional state machine in the consumer with one of your states that will simply wait on the start notification. Once received you transition to another state and only return to the start if required.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 5 of 17
(5,236 Views)

One simple solution is to save the most recent notification in a shift register, and use that value when timeout is true (a Select node makes this easy).

0 Kudos
Message 6 of 17
(5,235 Views)

 

Thanks.

I made like this

When I click save ,consumer loop will start save immediately

But When I click stop saving , after one loop it will stop. because the SR value is still true, so saving data loop will run one more loop then stop

Is there other methods to improve this?

Thanks

save data notifier.png

 

0 Kudos
Message 7 of 17
(5,199 Views)

@MYLONG wrote:

 

Thanks.

I made like this

When I click save ,consumer loop will start save immediately

But When I click stop saving , after one loop it will stop. because the SR value is still true, so saving data loop will run one more loop then stop

Is there other methods to improve this?

Thanks

save data notifier.png

 


you are stopping the second loop on "error" only...if you want to stop, you wire a stop local to the second loop or send a messege "stop" to a "stop" case with a true bool wired directly to your 2nd loop stop

Message 8 of 17
(5,195 Views)

try queues as mark had suggested...queue.png

 

also look at Caveats and Recommendations when Using Events and LabVIEW Error Handling Best Practices , enforce data flow by using error clusters and dont forget to merge errors

0 Kudos
Message 9 of 17
(5,188 Views)

I would go with what Mark suggested... 

The advantage of the queue over Notifier is that the queue has a buffer; whereas the notifier is like a single element queue.

 

On the other hand, you can also wire a cluster to the notifier which would do more than simply sending a boolean or a string message, or an enum (although enums are quite useful).  You can send combinations thereof..  You could use the enum to select a state and the boolean could be to pick choice(s) within that state.  The message could provide additional information. 

 

It all depends on how you design the solution.  And how you want the software to behave...

Message 10 of 17
(5,187 Views)