LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Basic question on case structures

Hi,

I have been using a boolean case structure to handle two different cases (if a measured value is higher or lower then a threshold value), but now I need to add a third case (if the value is in a range in the middle).
I cant figure out how to do this and the LV help and examples dosent give me any ideas, so if you have any examples in store it would be much appreciated.

/Mathias
0 Kudos
Message 1 of 9
(2,836 Views)
I'm new to LabView and thought the help index on this subject was well written and clear. Did you find this?:
 
 
Creating Case Structures
"4. For each case, use the Labeling tool to enter a single value or lists and ranges of values in the case selector label at the top of the Case structure. For lists, use commas to separate values. For numeric ranges, specify a range as 10..20, meaning all numbers from 10 to 20 inclusively. You also can use open-ended ranges. For example, ..100 represents all numbers less than or equal to 100, and 100.. represents all numbers greater than or equal to 100. For string ranges, a range of a..c includes all strings beginning with a or b, but not c. A range of a..c,c includes the ending value of c."
0 Kudos
Message 2 of 9
(2,821 Views)

Enum is best way to control case statements.  Best if used in custom control type def.


http://zone.ni.com/reference/en-XX/help/371361B-01/lvconcepts/custom_cont_ind_type/

0 Kudos
Message 3 of 9
(2,810 Views)
Hi,

gchristi1: I looked at the case structure help file and it does explain it well, but i do not understand how to go from having measured values into the enumerated case structure.

So the question is how I based on a numeric value pick a enum value for the case structure.

centerbolt : As far as I can tell the custom controls are about cosmetc changes of controls?

Thanks,
Mathias
0 Kudos
Message 4 of 9
(2,801 Views)

Mathias,

If you go to the next step of creating the strict type def custom control, you can now use the custom control several places in your design and have all those instances referenced back to the custom control.  The idea being that if you need to edit the items in the enum, you only have to edit the custom control and those changes will be reflected in all the instances of the custom control in your code. 

 

0 Kudos
Message 5 of 9
(2,792 Views)
Hello,

The answer of gchristi1 offers you a solution with which you can select a case for different range of numerial values.

If your measured value is floating point, then you can determine the significant decimals and multiply by a factor that makes the value integers.

The integer values can be entered in the case selectors as descirbed by the NI help posted by gchristi1.

Regards,

André
Regards,
André (CLA, CLED)
0 Kudos
Message 6 of 9
(2,787 Views)
Hello,

The strict type def definition is primarily for front panel items, to prevent them from changing shape after changing the content. The normal type def defintion is sufficient and allows to resize the control/indicator/constants.

The type def could be a solution but you would have to create a sub VI to convert the measured value into a enum value. The use of the subVI allows you to, when required to add more ranges, change the code required in one place.

Regards,

André
Regards,
André (CLA, CLED)
0 Kudos
Message 7 of 9
(2,781 Views)
Andre, good suggestion, that seems to be working. Multiplying by a thousand right away would have saved me some hours Smiley Happy

gchristi, that seems to be a good solution for a wider usability, but I will stick to what works as fast as possible right now, I will look closer at it later,

Thanks all for your input.
0 Kudos
Message 8 of 9
(2,771 Views)

If you have multiple ranges, one easy way would be to use threshold array on a sorted array as e.g. shown here. Modify as needed.

(see also http://forums.ni.com/ni/board/message?board.id=170&message.id=232911#M232911)

0 Kudos
Message 9 of 9
(2,754 Views)