LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Coding with valve and water circulator

I am trying to implement a two-loop automated control sequence in LabVIEW, involving multiple valves, a vacuum pump, and a water circulator (chiller).
Each loop corresponds to a specific operation mode, and I want to be able to switch modes as needed.
Here is what I want the control logic to do:

Loop 1 (Mode 1)

  1. Open the valve of device A, start the vacuum pump.

  2. When the pressure of device A reaches the target value (1.7 kPa), close valve A.

  3. Open valve B.

  4. When device B reaches its target pressure (1.82 kPa), close valve B and turn off the vacuum pump.

  5. Open and activate device C for 10 seconds, then close valve C.

  6. Start the water circulator (this should also be controlled by code).

  7. Open valve D, keep it open for 5 minutes, then close valve D and stop the water circulator.


Loop 2 (Mode 2)

  1. Open valve A, start the vacuum pump.

  2. When device A reaches its new target pressure (4.24 kPa), close valve A.

  3. Open valve B.

  4. When device B reaches its target pressure (3.78 kPa), close valve B and turn off the vacuum pump.

  5. Start the water circulator (controlled by code).

  6. Open valve E, keep it open for 5 minutes, then close valve E and stop the water circulator.


I plan to implement both loops and switch between them using a mode selector in LabVIEW.

However, I am struggling with:

  • How to properly connect and organize the block diagram to execute these sequences step by step,

  • How to manage timing and pressure conditions between each step (e.g., using Case Structures, Sequence Structures, or State Machines),

  • And how to ensure that valves, pumps, and the water circulator are synchronized correctly.

Could you please explain how to structure this logic in LabVIEW,
and whether it would also be possible to simulate for verification before hardware implementation?

0 Kudos
Message 1 of 12
(475 Views)

If mode 1 and mode 2 are two different states, you only need one loop and a simple state machine architecture. States change as a function of mode and the various threshold comparisons.

 

Is the user allowed to switch modes in the middle of the current mode or is switching only possible when a mode has completed all steps? The two states are very similar, differing only in some threshold and one valve.

 

What have you tried?

0 Kudos
Message 2 of 12
(467 Views)

Thank you for your response.
Currently, I am planning to allow switching to another mode even if the current mode has not yet been completed.
So far, I have been working on setting up the system based on an example I found.
As this is my first time attempting this, I would greatly appreciate any guidance or support you can provide.
Thank you very much.

0 Kudos
Message 3 of 12
(455 Views)

@jhkjhk424 wrote:

Currently, I am planning to allow switching to another mode even if the current mode has not yet been completed.
So far, I have been working on setting up the system based on an example I found.
As this is my first time attempting this, I would greatly appreciate any guidance or support you can provide.
Thank you very much.


If you switch to a new state in the middle of the other state, should the new state start from step 0 or from a similar state?

 

I currently cannot open VIs saved in version 2025. I recommend to do a "save for previous" (LabVIEW 2020 or below) and attach again.

0 Kudos
Message 4 of 12
(396 Views)

Thank you for your additional reply!

  1. You should start from the very first step.

  2. As shown in image 1, there is a problem that prevents saving with Save for Previous. However, although the setup I’ve put together is very incomplete, I will show it to you in the image.
    Best regard

jhkjhk424_0-1760882821089.png

jhkjhk424_1-1760883150373.png

 

 

0 Kudos
Message 5 of 12
(392 Views)

You did not select a proper file name for the save for previous.

 

(Showing a truncated picture with a broken wire going outside the visible area is pointless.)

0 Kudos
Message 6 of 12
(387 Views)

Thank you for reply!
I renamed the file and save previous version.
If it doesn't work, please...check the image...

Best regard..!

 

jhkjhk424_1-1760950623266.png

 

0 Kudos
Message 7 of 12
(325 Views)

If you hover over the broken boolean wire with the mouse, it will tell you that the wire has no source. Where should it's value come from?

 

The rest of the code seems rather incomplete.

0 Kudos
Message 8 of 12
(297 Views)

I understand that the code looks incomplete — that’s actually why I’m asking for help.
It would be really helpful if you could show me how to fix or complete the missing parts.... 😞 

Thank you for your understanding.

Best regard

0 Kudos
Message 9 of 12
(223 Views)

Hi jh,

 


@jhkjhk424 wrote:

I understand that the code looks incomplete — that’s actually why I’m asking for help.
It would be really helpful if you could show me how to fix or complete the missing parts.... 😞 


Christian Altenbach already told you you only need ONE loop to create your statemachine.

Have you started to implement this ONE statemachine in ONE loop?

 


@jhkjhk424 wrote:

However, I am struggling with:

  • How to properly connect and organize the block diagram to execute these sequences step by step,

  • How to manage timing and pressure conditions between each step (e.g., using Case Structures, Sequence Structures, or State Machines),

  • And how to ensure that valves, pumps, and the water circulator are synchronized correctly.


  • ONE loop to bundle them all. ONE big case structure inside to implement your statemachine.
  • You manage conditions using comparisons. Once you made your comparison you can decide which state to call next in your statemachine.
  • This "syncing" comes with your statemachine for free…

There are 5 valves (outputs) and 2 pressures (inputs).

Additionally there are 2 pressure limits (config inputs) and a mode selector (user input). Some states should handle time measurement by evaluating timestamps.

Your statemachine needs to:

  • read input values (DAQmx task1)
  • evaluate the inputs (according to the mode selector) using the limits/timestamps
  • create the output values from evaluation results
  • output the new DO values (DAQmx task2)
  • select the next state based on evaluation results

When creating statemachines it often helps to draw their flow chart on a sheet of paper. Really!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 12
(216 Views)