LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to trigger multiple producer consumer loop simutaneously

Solved!
Go to solution

Hi,

I am working on a VI that should acquire 2 images and 1 data (from a spectrophotometer) simultaneously. They are organized in 3 different producer/consumer loops.

What I want to do is to trigger the 3 Producer Loops synchronized every few minutes.

I thought about making the 3 producer loops into Event Cases that are triggered by a single loop with a timing function, but I don't know a practical way to do it. 

If you can give an idea of how to pull it off I, or give me an example I would be already very pleased.

 

Thanks in Advance for your help,

Oscar

 

0 Kudos
Message 1 of 13
(4,649 Views)

Unless your three P.C. loops are in separate VIs you could instead have one Producer handling three Consumers, and when you want all three consumers to trigger together it becomes a much easier task.

 

Alternatively, yes, make the Producer loops trigger of User Events, and fire a custom UE from another source.

Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 2 of 13
(4,627 Views)

So my question is more of how to fire this UE. Could you help me ?

0 Kudos
Message 3 of 13
(4,599 Views)
Solution
Accepted by topic author Liepo
0 Kudos
Message 4 of 13
(4,593 Views)

I didn't quite understood how to addapt this method of Custom Event to my VI.

I'm sending my VI and a picture of my block diagram for you.

Please help.

Download All
0 Kudos
Message 5 of 13
(4,574 Views)

Looking at the picture of your block diagram, it won't be so simple to introduce user events to your architecture. It would be easier to simply synchronise the start of your producer loops. Perhaps ntroduce a step between your hardware initialisation and the producer loops.

 

BTW, I think there might be a race condition in your Image capture code. You share a reference to the IMAQ image through a queue, but use the same reference for all your image captures. If the Write PNG does not occur before the next image capture than you'll lose the previous image. Think of the Image datatype as a reference, not data.

Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 6 of 13
(4,548 Views)

Hey Thoric,

Thanks for your help, but i'm having quite difficulty.

I tried to bundle all the queues from Producer/Consumer loops into one queue. It kinda works.

But I'm still having problems, and I think is about that race condition you told about. But I can't figure out how to fix it, could you tell me a more direct instruction? I already tried putting the IMAQ Create inside the loop but it didn't work. And tried linking the error ends of the IMAQdx Grab, with no results.

The error keeps repeating sistematically on the IMAQdx Grab, with a green arrow that freezes the screen.

I am sending the new logic on the VI below, tell me if you think that's the way to go.

 

Please, please. Help me one more time

Thanks in advance,

Oscar

0 Kudos
Message 7 of 13
(4,512 Views)

This is the green arrow that shows in highlight mode after the program freezes.

0 Kudos
Message 8 of 13
(4,504 Views)

I feel there are lot of things are not configured correctly. Let's go one by one

-You are using two cameras. How these cameras are triggered?

-The Grab fucntion is set to wait for next buffer mode, read the help then you will get why it is waiting.

-Do you want to grab images from both cameras same time or one after another?

-Like closing queue, you should be using dispose image after your writing finishes after consumer loop other wise you might loose that.

-Why are you using IMAQ write to PNG with vision info instead of IMAQ write to PNG when there is no info you are adding to image?

Thanks
uday
0 Kudos
Message 9 of 13
(4,472 Views)
Hi udka, thanks for the help.
-You are using two cameras. How these cameras are triggered?
They are USB Cameras, i'm triggering them at the producer loop .
-The Grab fucntion is set to wait for next buffer mode, read the help then you will get why it is waiting.
You think I shoul change it?
-Do you want to grab images from both cameras same time or one after another?
At the same time would be better, but I can stand a few seconds of difference.
-Like closing queue, you should be using dispose image after your writing finishes after consumer loop other wise you might loose that.
You are right in that, maybe it helps. But the race condition happens even in the first acquisition of the VI (unless it is in Highlight Mode).. So I think it will not solve it
-Why are you using IMAQ write to PNG with vision info instead of IMAQ write to PNG when there is no info you are adding to image?
You are quite right in that too, but I don't see how that would make a difference..

The main problem is the race condition.. ans yet it has not been solved. If you could focuse on that I would be very thankful.

Thanks in advance.
Oscar
0 Kudos
Message 10 of 13
(4,453 Views)