LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to provide Data from Queue as a input to Multisim file in LabVIEW?

Hello,

I am trying to develop an application that performs continuous operation on Data read from queue through a Multisim module in LabVIEW,

Currently I am unable to perform both write & read data from queue's, please find an example of the same in the attachment.

 

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

You've chosen a pretty high-level Example from MultiSim.  It is not clear if the problem is buried in the MultiSim code, or in the Queue structure.

 

Do you know about Queues, how to use them, how to program them?  If not, it might benefit you to learn about them first.  There are multiple examples in LabVIEW (use the LabVIEW Help, or do a search for Producer/Consumer Design Pattern, which is what MultiSim is probably using).

 

Do you know enough about MultiSim to get something to work, without worrying about Queues?  If not, learn more MultiSim.

 

Once you understand Queues, and understand MultiSim, putting the two together should be easy.

 

Bob Schor

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

Hello Bob_Schor,

In the example code,

- both Multisim & LabVIEW files are properly working without any issues when tested individually without any involvement of one & other,

-the example is also similar to producer/consumer design pattern, except each producer loop & consumer loop are implemented in different VI's,

The issue with my example is, I am unable to read from the queue's until I run & stop the producer loop(VI_1). This issue might be occurring due to inclusion of Multisim module or co-simulation loop.

So Is there an example to solve such issues or any other suggestions?

Thank You 

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

The trouble with having two "isolated" VIs, one for the Producer and one for the Consumer, is that there's no control of the "life" of the Queue.  Both VI1 and VI2 create and destroy the Queue independently, so if VI 1 starts first, it might Enqueue and then destroy the Queue, then VI 2 starts, re-creates the Queue (empty), and never gets anything.

 

Try making VI1 and VI2 have Queue Control inputs.  Have a top-level VI create the Queues and pass them as inputs to VI1 and VI2.  Now there is a single point of Create, and when VI1 and VI2 are called, the Queue is already defined (and it doesn't matter which VI comes first, the Queue already exists).  Stopping the two is a little trickier.  In your example, I'm not sure what causes the structure-that-looks-like-a-Timed-Loop to stop (sorry, don't know MultiSim), but the important point is that the Producer should stop first, but not destroy the Queue, and should send a signal to the Consumer to let the Consumer destroy the Queue.

 

One way to do this is to use a Sentinel, a "unique" value that you put on the Queue to mean "That's All, Folks".  For example, if you enqueue an Array, you could use an Empty Array as a Sentinel.

 

Here's how Stop would work (assuming that the Producer and Consumer are both in loops):  The Producer Loop would have a Stop control that, when True, causes the Producer to stop looping.  Instead of destroying the Queue on loop exit, the Producer enqueues the Sentinel (e.g. puts an empty Array on the Queue), and then exits.  The Queue still exists, so the data go to the Consumer.  As the Consumer dequeues the data, it checks to see if it is the Sentinel.  If not, it processes the data normally, but if it is the "Time-to-Quit" Sentinel value, it simply exits its own loop, and the Consumer destroys the Queue.  Note that this is perfectly safe -- the Producer had to exit its "Producing" loop in order to create the Sentinel, so the Consumer can, when it sees the Sentinel, safely Destroy the Queue (since the Producer has already stopped).

 

There are a lot of words there, but if you try it out in some Demo code, I think it will become clear.

 

Bob Schor 

Message 4 of 5
(2,055 Views)

Thank You Bob_Schor for your valuable suggestions.

After trying out with lots of examples, I have found the following,

- Named Queue can be used between two VI's, without any help of references.

- The main issue in my application is due to use of Co-Simulation Loops.

 

Following are the observations made while trying various solutions,

- Co-Simulation loop of VI_1 that generates certain signals is working, however Co-simulation loop of VI_2 which consumes signals to generate different output is not working.

- I tried to run VI_1 & VI_2 without any interdependencies, i.e, by use of independent Multisim function(one which only produces output, without any inputs) in Co-Sim loop, In this case, both the VI's are working fine.

Thus, I need a solution to configure co-simulation loops, In-order to run dependent multisim functions in different Co-Sim Loops.

Lastly may know a detailed example of how to create references for queues.

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