LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to put multiple inputs to a Case or event structure?

Solved!
Go to solution

I want to use the output from polling a VI which will be boolean T/F, also a timer and a value of the loop iteration of a while loop. I have never used  a  case or event structure before and the help I have looked at seems to assume knowledge I dont have. The timer has boolean output also but you apparently cannot have three boolean inputs to a case structure so I tried to convert the timer to numeric and add that as a case but it is not accepted. 

In the case of using an event structure I couldnt work out how to descriminate between a T and F input value. Can somone say something to help me get started with this please?

 

 

0 Kudos
Message 1 of 5
(1,221 Views)

I'm on LabVIEW 2021 so I can't open your VI to look at it, so this is general advice with a best guess from your description.  If you can do a "Save as previous" back to 2018 or so then more people can look at it and offer help.

 

A case structure has multiple frames and must run one and exactly one of them when all dataflow gets to it.  

 

Only a small amount of data types can be used as a selector and have some restrictions on the cases they can support:

  • Boolean
    • Must have exactly 2 cases
  • Integer
    • Can have any number of cases up to the integer limit
    • Must have either a default case, or a case for every possible integer.
  • Enum
    • Must either have one case per enum value (with the option to put multiple values in one case) or have a default option for all cases without values
    • Max cases is the number of possible enum values
  • Error wire
    • Must have at least 2 cases (Error, no error)
    • Can have additional cases matching specific error numbers as integers, but always needs a default case for unexpected error numbers
  • String
    • Must have a default case
    • Can have any number of cases
    • Can be set to be case-insensitive optionally

If you want a case structure to handle more than just a Boolean, you need to either convert your selections into something that is one of the above data types and use that, or use nested cases:

 

Kyle97330_0-1702082438205.png

Extremely basic example of how you might turn two Booleans into a string, and use that to make a case structure:

Kyle97330_1-1702082633559.png

Message 2 of 5
(1,208 Views)

Thanks, I have tried your code example which tends to work but in my case for some reason the While Loop gets stuck at the first iteration. I have tried it with the timer and the output from the iteration counter connected up but adding all three presumably requires three letter combinations in the selector label which gets a bit cumbersome and makes me think there must be a better way. I have tried the code without the timer in case that is stalling the while loop but that makes no difference. In fact it looks like the timer is useless as wired as it is shown not executed. I want it to start the code if its not the first iteration and polling via modbus hasn't resulted in a true.

 

0 Kudos
Message 3 of 5
(943 Views)
Solution
Accepted by topic author EdHarris

No need for a case structure or event structure. It can be done with the boolean pallet. 

 

 

0 Kudos
Message 4 of 5
(446 Views)

For integers, ranges are also possible:

 

..1 means all values less than or equal to 1

 

2..8 means all values between (and including) 2 and 8

 

9.. well, you got it

 

Same is valid for enums, though barely used by hand. But a case with subsequent values of an enum is displayed as "firstEnumValue".."lastEnumValue"

 

 

Message 5 of 5
(402 Views)