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: 

modifying my consumer producer pattern with different types of commands

Solved!
Go to solution

Hi,

I have a VI working using the producer / consumer pattern.

I have a set of liquid pumps controlled by an Arduino. Labview sends commands through serial port (VISA) to the Arduino, and this Arduino actuate the pumps.

The producer loop produces the commands. Stuff like "use pump 1 at speed 50 to absorb 10ml". It is a sequence of actions, and I am using a state machine. There are 4 or 5 steps, where in every step different pumps are actuated. All these commands are place in a queue.

The consumer reads the queue, and executes the commands. It basically sends the parameters to the Arduino, and waits for its OK.

This is 100% working. As expected the loops run in parallel. The producer loop is done like in 1 second, while the consumer loop takes like five minutes.

You can see the VI here:

http://imgur.com/6qDCC28

In the producer all the steps are very similar to the one you can see. In the consumer, there's a wait state which waits until there's something in the queue, and then execute 4 steps, as the one you can see, to actuate the plunger and valve within the valve.

The problem I have, is that as described, my VI is simply producing pump commands, and executing them. At the moment I need to do other actions that are not pump related, or even Arduino related. For example, something as simple as wait like 1 minute between some states, or execute any other action. I need the producer to produce this, and then in the consumer, do something else than just actuating the pumps (but I still need how to actuate them)

Any help or guidance would be very helpful. I have been writing code for years, but just started with Labview.

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

Hi,

 

maybe expanding the content of the queue is the answer. You could add an enum that specifies whether the current command is for Arduino, a waite command or something else entirely.

 

Best regards

Florian

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

Hi, thank you for your answer.

 

What do you mean by expanding the content of the queue? At the moment I have the queue to accept cluster type commands, where the cluster are the paramenters that the pump needs.

0 Kudos
Message 3 of 5
(2,583 Views)
Solution
Accepted by topic author juanmanuelparrilla

Right,

 

sorry I wasn't clear about that. I meant adding the enum I mentioned to the cluster.

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

that looks like a good idea, thank you!

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