LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Evaluate multiple conditions.

Solved!
Go to solution

Hi,

I have three sets of routine developed in LabVIEW. I need to execute these blocks when certain condition is met, For example,

If condition 1 is true

      execute block 1

 

else if condition 2 is true

         execute block 2

 

else condition 3 is true

         execute block 3

 

Inputs and outputs are similar in each block. I was hoping to utilize state machine architecture but still not getting idea how to do it. 


Regards.


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

To make any state machine you need to define the states and the conditions which determine the transitions between states.

 

You have not defined all the possible states for your system.

 

              Condition 1

 

True -> Block 1                                    False -> Test condition 2

        What happens after Block 1?                             

                                                                         True -> Block 2           False  -> Test Condition 3

                                                              What happens after Block 2?

                                                                                                                True -> Block 3        False ????

                                                                                                             What happens after Block 3?

 

 

So you would need several states. The first one would obtain the inputs necessary to test Condition 1.  There will be states for each Block. Testing of Condtion 2 appears to only occur in the state where Block 2 occurs and similarly for 3. There may be other states for the undefined situtations.

 

Lynn

0 Kudos
Message 2 of 5
(6,249 Views)

I have a following scenario. please note that inputs travelling to all three functions are same (a, b, c) and outputs too (x, y, z)

If a number (c) is greater than zero,

          than there is a function 1 which executes and outputs results.

If a number (c) is greater than zero and less than one

           function 2 executes

 

else

          Forward the inputs to the outputs as it is.

Just a LabVIEW version of IF, ELSE IF statements.

For instance, I need to add two numbers if condition 1 goes true, subtract two numbers if condition 2 goes true, turn an LED on  if condition 3 is met. This is the simple analogy I could give. Just a concept and architecture of how to do this problem would suffice. 

 

Regards.


0 Kudos
Message 3 of 5
(6,245 Views)
Solution
Accepted by topic author NapDynamite

Your problem can be handled with a triply-nested Case structure.  Evaluate Condition 1.  The True case is "Execute Block 1".  The False case is another Case structure, Evaluate Condition 2, True = Execute Block 2, False = another Case structure, Evaluate Condition 3, True = Execute Block 3, False = do nothing.

 

If you want to make this into a State Machine, you could proceed as follows:  Define the following States -- Evaluate 1, Execute 1, Evaluate 2, Execute 2, Evalute 3, Execute 3.  The Evaluate 1 State does "Evaluate 1", and if True, calls State Execute 1, else it calls State Evaluate 2.  You fill in the rest.  Note that you should probably have another State, "Continue", that all of the Execute States (and the False case of Evaluate 3) call when they are done, so you don't "get stuck".  On the other hand, if the State Machine is a sub-VI, you could just exit (which is another "pseudo-State").

 

Bob Schor

Message 4 of 5
(6,239 Views)

I guess the former architecture is best considering small application.

Thanks a million. Smiley Happy

 

Regards. 


0 Kudos
Message 5 of 5
(6,225 Views)