LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Communicating Between Two Parallel Loops

Hi everyone, I am trying to get more information on how to communicate between two parallel loops.  I am running two while loops in parallel in my VI.  While Loop 1 has an event structure in it that will stop the loop when Boolean control ComError in While Loop 2 changes value.  While Loop 2 just sets the ComError boolean to True and is connected to the Stop control of the loop.  When I run the VI, I expect when While Loop 2 sets ComError Boolean = True that then While Loop 1 event structure ComError changed value event would trigger and stop While Loop 1 but it does not.

 

I have attached my VI.  What am I doing wrong?

 

Thanks so much for everyone's help. 

0 Kudos
Message 1 of 7
(3,907 Views)

That VI isn't going to work like you think it is.

 

The Value change event fires whenever the user changes the value of the control, or when a value is sent to the Value(Signalling) property node of that control.

 

Wiring a value to a local variable will NOT fire a value change event.

Message 2 of 7
(3,889 Views)
RavensFan, so if I change the local variable of that control to a value (signaling) property node that should resolve the issue? Is this the most efficient method or is there another way around this? Thanks!
0 Kudos
Message 3 of 7
(3,885 Views)

Try it.

 

I don't know if it would be the most efficient method because what you have is a simplified VI to test out a concept.  What is best is going to be determined by the rest of your application.

Message 4 of 7
(3,878 Views)
The thing to consider is what is really needed. If you need to pass some data and that data is important enough to interrupt whatever else the receiver was doing just to get it, use an event.

If on the other hand is all you need to know is what the current value is the next time you go to use it, use a FGV or something.

Mike.

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 5 of 7
(3,867 Views)

Thanks everyone for their input.  My While Loop2  is reading a com port using VISA read function.  My While Loop 1 has an event structure in it that has different event cases dependent on user input on the front panel.  The STOP control of While Loop 1 is controlled by boolean output from each of the events.  All of these events will keep While Loop 1 running except for one event which is when the User hits the done button.  I want While Loop 1 to shutdown if there is a VISA read function error.  

 

Taking the advice of RavensFan, I created a boolean variable called "ComError." In the While Loop 1 event structure, I created an Event Case called "ComError" (value change) which shuts down While Loop 1 whenever this variables signal changes.  Then I passed the While Loop 2 error cluster "status" to "ComError" property node value (signaling).  This seems to work and it effectively shuts down While Loop 1 when While Loop 2 has a ComError.

 

This seems to be the best method for my application but maybe there are more efficient methods of doing this?  Thanks so much!

0 Kudos
Message 6 of 7
(3,815 Views)

In your described design, the user interface handling stops along with While Loop 1 when a VISA read function error occurs.  I assume that would probably also mean that your application is entirely finished.  This is often not what you want - instead, consider a VISA read function error being reported to the user in some way and allow the user a way to stop or recover.

 

Also, you did not create a Boolean variable called "ComError", you created a Boolean control or indicator.  Controls and indicators are user interface elements and should not be used for purely programmatic operations.  A better solution would be a User Event.  A User Event allows you to define your own event, register it for your Event Structure, and then raise it in your While Loop 2 when the error occurs.



Message 7 of 7
(3,800 Views)