LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Change Part of sequence in loop as a result of Boolean Value

I have a DAQ I/O that I am using a sequence loop to control. I want to make it so that the second DAQ box is initiated when the boolean [10] (converted to number 1) is measured. I would then like it to return to the first box in the sequence when [01] (numerical 2) is measured. I'd like this loop to occur indefinitely until the stop command is initiated. Any help is appreciated.

Download All
0 Kudos
Message 1 of 6
(1,727 Views)

Okay, so you have a bit of unnecessary in your code.  Let's first start with some questions and you can better explain what's happening.

 

1) Does your code work at all on your end?

2) How many physical DAQ boxes are there?

3) Are you inputting the pressure values?

4) How many total physical relays?

 

0 Kudos
Message 2 of 6
(1,719 Views)

1) Does your code work at all on your end?

I've gotten it to work fine if I have a single case structure. I am trying to add a second one, because during increasing and decreasing pressure intervals, the sensor will be reading the same pressure output, but I will need the opposite I/O state.

 

2) How many physical DAQ boxes are there?

There are 3 states and 2 DAQ I/O ports. 

State 1

Relay 1 On, Relay 2 off

State 2

Relay 1 Off, relay 2 on

Boolean to numerical outputs will give me:

In first case structure

0 - State 1

1 - State 2

2- State 1

Second case structure

0 - State 2

1 - State 2

2 - State 1

 

3) Are you inputting the pressure values?

The current pressure input value is just a placeholder, I will be replacing it with an SPI sensor readout.

 

4) How many total physical relays?

2

0 Kudos
Message 3 of 6
(1,701 Views)
  • The mechanical action of your stop button is wrong (typically latch when released) and your loop termination condition is a poor choice. (Stop if true is more typical).
  • Your while loop is floating above the sequence structure, so it runs in parallel with it. Notice the shadow? You need to place it so the shadow disappears.
  • If you would line up all your relevant functions with the error wire, none of you sequence structures are needed.
  • I can't really tell how your express tasks are configured, but aren't they basically all the same, just with different data depending on the state? How long does each take?
  • I think it would be significantly better to use lower level functions.
  • What hardware is this running on (windows? embedded?)

 


@jd555 wrote:

 I'd like this loop to occur indefinitely until the stop command is initiated. Any help is appreciated.


Simplify it into a simple state machine. One loop. One case structure, one state variable in a shift register.

0 Kudos
Message 4 of 6
(1,651 Views)

I haven't figured out how to reduce this to a single case structure, because my issue is that I need a 0 value to result in a different state as a result of the same pressure measurement. I am making a pressure chamber to create a pressure waveform, so if (for instance) I measure 1 PSI, I will need this to be either state 1 or 2 depending if I am in the ascending or descending slope of my waveform. How would you recommend accomplishing this with a single case? I'm sure I could create a boolean function that could give me 4 possible integers readouts, but I have minimal experience am completely new to logic and controls.

0 Kudos
Message 5 of 6
(1,606 Views)

You could just use a feedback node and compare the current and previous pressure to see which direction it is currently going and react accordingly. 

0 Kudos
Message 6 of 6
(1,591 Views)