LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding a boolean control into a state machine

Is there a way to use a Boolean control and a timer to switch in between states? The state machine will be going through several states and will need to choose either the timer control or the Boolean control for at least one of the states. I'm trying to make an endurance test and I'm stuck on how to make one of my state machines. Basically I'm trying to use two proximity switches to switch in between certain states (so 2 Boolean controls, one being valve open and one being valve closed), and using a timer during certain states for one machine. I am also using 2 while loops in the same program (I'm pretty green to labview and don't know of a better way).  For a better explanation of my test see below. The lower state machine in my software called Data Acquisition is the one in question. Also if you have any suggestions on how I could do like a subVI control to separate these while loops easier I'd appreciate it. Also I only have Labview 2012 so if you could please send a pic along with anything you suggest. Thanks in advance.

 

I am trying to make a VI that controls and takes data on a spool valve for an endurance test. The test is going to bias a valve back and forth repeatedly, cycling back and forth is one cycle and I need it to cycle 1050 time. It'll bias the valve in sets of 25 cycles and wait 5 minutes in between each cycle. After every 25 cycle the test will stop, wait 5 minutes, and open a relief valve to take leakage data from a flow meter. After every set of 250 cycles the test will (after taking a flow reading) wait 24 hours and will then continue to bias normally. The reason why I am using 2 while loops is because I need the data acquisition to occur right in between every open and close of the valve. I'm doing a force reading on the valve, but to not bore you with the details basically it needs to read just after the valve begins to bias and just before it stops biasing this is where the proximity switches will be used.

 

0 Kudos
Message 1 of 3
(2,525 Views)

Is there a way to use a Boolean control and a timer to switch in between states? The state machine will be going through several states and will need to choose either the timer control or the Boolean control for at least one of the states. I'm trying to make an endurance test and I'm stuck on how to make one of my state machines. Basically I'm trying to use two proximity switches to switch in between certain states (so 2 Boolean controls, one being valve open and one being valve closed), and using a timer during certain states for one machine. I am also using 2 while loops in the same program (I'm pretty green to labview and don't know of a better way).  For a better explanation of my test see below. The lower state machine in my software called Data Acquisition is the one in question. Also if you have any suggestions on how I could do like a subVI control to separate these while loops easier I'd appreciate it. Also I only have Labview 2012 so if you could please send a pic along with anything you suggest. Thanks in advance.

 

I am trying to make a VI that controls and takes data on a spool valve for an endurance test. The test is going to bias a valve back and forth repeatedly, cycling back and forth is one cycle and I need it to cycle 1050 time. It'll bias the valve in sets of 25 cycles and wait 5 minutes in between each cycle. After every 25 cycle the test will stop, wait 5 minutes, and open a relief valve to take leakage data from a flow meter. After every set of 250 cycles the test will (after taking a flow reading) wait 24 hours and will then continue to bias normally. The reason why I am using 2 while loops is because I need the data acquisition to occur right in between every open and close of the valve. I'm doing a force reading on the valve, but to not bore you with the details basically it needs to read just after the valve begins to bias and just before it stops biasing this is where the proximity switches will be used.

0 Kudos
Message 2 of 3
(2,471 Views)

There are several problems with these state machines.

  • States should be typedef'd to make it easier to change state enum later.
  • States should not wait for an extended period of time. The state should instead check a timer to see if the time has elapsed or not, and then transition based on that information. It should not take the user longer than ~300ms to interrupt it.
  • Your stop button is not inside a loop. It gets read once at the start of the run, and the same constant value is used for loop iteration.

To answer your original question, you can use a boolean control to trigger a state by using an event structure. Please see the JKI state machine for an example of this. You can use a timer as described above.

0 Kudos
Message 3 of 3
(2,446 Views)