LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Run a Loop multiple times with only single input from queue

Solved!
Go to solution

Hi There,

Following on from another question which was solved, I am trying to run a loop multiple times with just one output from a queue.

I am outputting a boolean array which represents heater state into a queue which is then read by a consumer loop.

I would like the consumer loop to continuously run once this array is recieved rather than running once and waiting another value from the queue, this is as once the heaters are selected on/off the PID will take over on the on states.

Is this completly the wrong way to use an event structure queue?

Any help is appreciated.

Download All
0 Kudos
Message 1 of 4
(2,472 Views)

I can't open your VI, but when I've needed to do this in the past I use a shift register wired to the "timeout" input of "dequeue element."

I initialize it to -1, and when it gets a message that needs to keep looping, it sets the value to 0. When a new command comes in it'll process it. If it gets the Stop message, I set the value back to -1.

 

You can also re-enqueue a message into the queue from the state that needs to keep looping, but you can end up with some weird conditions if you're not careful.

0 Kudos
Message 2 of 4
(2,456 Views)
Solution
Accepted by topic author Alex.902

Hi Alex!

 

Using File » Save for Previous Version you save your VIs compatible to older versions of LabVIEW. Not everybody has access to LabVIEW 2018, especially on the Forum it makes sense to save a VI in e.g. LabVIEW 2014 format.

 

Apart from what Bert said, I'd underline as well that this is mainly a question about the architecture of your application. I assume this is what you want to achieve:

- Call your ovens' PIDs regularly, e.g. once a second.

- In case an oven is enabled, send the related PID's value to it, otherwise send a 0.

- Be able to change the enabled/disabled state per oven any time.

 

There are several possible solutions to this. All have specific dis-/advantages; which one you want to pick depends on your requirements. Just two ideas:

  1. Put the PIDs into a Functional Global Variable (FGV). It shall have at least two main modes: Update and Switch. Call "update" once per second to calculate new values and update the outputs. Call "switch" when you received a new heater array from your queue.
  2. Have he PIDs in a loop that has a wait function. Use a local or global variable to store the latest received "heater enable array". (Basically you need to uncouple the de-queuing from the PID-updating.)

Apart from that two small comments on your code:

  • Use a Shift Register on the Event Handler loop for your Block Array data in case you are going to add another case. This way you can maintain the current value, but can still overwrite them in the cases you want to:
    (Wired through in all cases that don't change the Block Heater data)(Wired through in all cases that don't change the Block Heater data)
  • Nice use of the Notifier, however you don't need it here (except you planned to to more with it). You can achieve the same behavior using e.g. the Get Queue Status node - as soon as the Queue is released (use the Force Destroy!) it will generate an error in your Producer loop and therefore end it.

Ingo – LabVIEW 2013, 2014, 2015, 2016, 2017, 2018, NXG 2.0, 2.1, 3.0
CLADMSD
0 Kudos
Message 3 of 4
(2,413 Views)

Hi Bert & ikaiser,

Thank you both for your replies. Yes that is essentially what I am trying to do.

Berts way seems simple even though I havent managed to make it work yet, I will have to wire a compound arithmetic OR to the Boolean array so that it loops whenever any block is enabled.

 

I Do like the FGV option as it seems like the more programatic way of doings things possibly? however I have never used them and don't quite understand the exmple yet. Would using  FGV mean that I dont need the Queue for the Boolean Array?

 

Thank you for your comments regarding the notifier, I was just trying to use a standard way of stopping all loops as in the end the program will have the following loops not driven by the event structure,

Data Producer Loop - (Main)

Data Manipulation Loop - Queue from (Main)

Write to Front Screen Loop - Queue from (Data Manipulation Loop)

Save Data Loop - Queue from (Data Manipulation Loop)

PID Loop - Driven by Event Structure to initiate then Queue from (Data Manipulation Loop)

Thanks

 

P.s files re-uploaded to v2014

Download All
0 Kudos
Message 4 of 4
(2,406 Views)