From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple loops in event structure

Solved!
Go to solution

Hello,

 

I am trying to write a program that uses data from an overhead camera to drive a differentially steered robot around a track. I'm new to LabVIEW and I have a question with getting the event structure and while loops to work like I would like. My code currently has three while loops running in parallel, one to process the image into the needed data, one to use that data to locate the robot and the last one to provide commands to the robot. I am trying to add in a calibration subVI that will recalibrate the camera upon start up and whenever the user clicks the calibrate button. Basically I would like to stop/pause the three while loops then run the subVI, then start the loops back up using the updated data from the subVI. 

 

I was thinking that an event structure would be the best way to accomplish this but I can't seem to get it to work properly. I have provided a dummy version of the main VI. If anyone could point me in the right direction on how to do this and also if anyone knows a good place for tutorials for this kind of thing that would be great.

 

Thanks in advance

~Nick

0 Kudos
Message 1 of 5
(2,672 Views)

Nick,

 

This isn't how you want to handle this. An event structure will handle one event at a time, removing them from a queue.  While your "Race" event is happening, the other events will not be registered.

 

A better method would be to use a producer/consumer architecture, and a queued message handler.  On "Race" value change, send a message which will start or stop the other three loops.

0 Kudos
Message 2 of 5
(2,660 Views)
Solution
Accepted by Carmelroro

Thanks BowenM,

 

I will look into the producer/consumer architecture and see if I can get it to work.

 

~Nick

0 Kudos
Message 3 of 5
(2,642 Views)

Here is one solution to get you pointed in the right direction.

 

Note that I am terminating the other loops on an error when the notifier is destroyed in the event. This isn't always best practice, but it is an easy solution to stopping them.

 

-M

 

Edit: I just noticed that you are using "Mouse Down" events. You likely want to use Value Change for booleans instead.  Also, this is just a rough example. I have an empty string constant wired in to the notifier, but you can wire any data type in to be passed to/from loops with the notifier.

0 Kudos
Message 4 of 5
(2,628 Views)

BowenM,

 

Thank you for wiring up a sample for me. I'm running 2011 and can't open it. Any chance I can get you to revert it. 

 

Thanks again

~Nick

0 Kudos
Message 5 of 5
(2,615 Views)