From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

create case structure using mutilple boolean conditions

girish_jadhav_0-1598277647869.png

1. Is it possible to build enum type of control using boolean conditions and then connect it to a case structure?

2. I got it partially working using a formula node (only when the second condition is removed, i.e., x>=100 & x<=200), but when it is present I am getting an error.

girish_jadhav_1-1598278117327.png

 

Edit: y = -0-01*x+91; y = -0.01*x + 91;

0 Kudos
Message 1 of 13
(1,649 Views)

Case structures can take integers as their case selectors if you didn't already know. Take your setpoint, round it down and convert it to an integer, and build a case structure with that as the selector.

Redhawk
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

0 Kudos
Message 2 of 13
(1,634 Views)

Hi girish,

 

might be simpler to use Threshold1DArray:

You can use the "index" value to select one of several cases in a case structure. Or just use it with IndexArray to index the corresponding result from another array constant…

 

Btw. be aware of possible problems when comparing floating point numbers for equality!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 13
(1,622 Views)

Since the 2nd solution basically loops/checks through your comparisons until one is found, i'd make a while loop with a case structure that does the same. (Case 0 is the 1st X=100 case and so on)

Multiple cases.png

 

(I Think you must use 'AND' in your formula node, '&' is a bitwise AND i Think, thus the integer requirement)

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 13
(1,614 Views)

@girish_jadhav wrote:

girish_jadhav_0-1598277647869.png

Case structures can use I32 as inputs. You can use ranges for each case "..100" will give below 100. "100..200" will select 100 to 199. See the detailed help for a case structure for additional details on ranges.

 

Norm

0 Kudos
Message 5 of 13
(1,562 Views)

@Viper wrote:
Case structures can use I32 as inputs. You can use ranges for each case "..100" will give below 100. "100..200" will select 100 to 199. See the detailed help for a case structure for additional details on ranges.

I did not know about this option! Thanks for the reply 🙂

0 Kudos
Message 6 of 13
(1,531 Views)

You have 2 solutions for X=100, which one is correct?

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 13
(1,523 Views)

Since you used a Double for X, i assumed you'd have values as 100.12. In that case, the case selectors option of 100..200 isn't really an option. 🙂 That only works for integers.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 8 of 13
(1,521 Views)

@Yamaeda wrote:

You have 2 solutions for X=100, which one is correct?


I confused how character ranges work with the integer cases. That's why I said read the detailed help.

 

Type of Values Description of Type of Values
Numeric ranges Specify a range as 10..20, meaning all numbers from 10 to 20 inclusively.
Open-ended numeric ranges Specify a range ..100, meaning all numbers less than or equal to 100, and 100.. represents all numbers greater than or equal to 100.
Lists and ranges Use commas to separate values, for example ..5, 6, 7..10, 12, 13, 14. When you enter values that contain overlapping ranges in the same case selector label, the Case structure redisplays the label in a more compact form. The previous example redisplays as ..10, 12..14.
String ranges A range of a..c includes all strings beginning with a or b, but not c. String ranges are case sensitive. For example, a range of A..c behaves differently than a..c because LabVIEW uses ASCII values to determine a string range.
Enumerated values The values display in quotation marks, for example "red", "green", and "blue". However, you do not need to type the quotation marks when you enter the values unless the string or enumerated value contains a comma or range symbol ("," or ".."). In a string value, use special backslash codes for non-alphanumeric characters, such as \r for a carriage return, \n for a line feed, and \t for a tab.
0 Kudos
Message 9 of 13
(1,518 Views)

@Yamaeda wrote:

Since you used a Double for X, i assumed you'd have values as 100.12. In that case, the case selectors option of 100..200 isn't really an option. 🙂 That only works for integers.


For your example I would multiply X by 100 then cast it to an I32. Then I would adjust my case selectors as well to account for the multiplication.

 

Norm

0 Kudos
Message 10 of 13
(1,517 Views)