LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to switch in case structure

Solved!
Go to solution

hi everyone i have some question. i want to makes a 3 condition about temperature.

for example when the temperature condition is "less than equal to 30" then the string status "cold", then if the temperature condition is "more than equal to 30" and "less than equal to 100" the string status "normal" and when the temperature condition is "more than equal to 100" then it appears state string "hot". here I use the comparison function "select" how to move to the next case when the current condition is false ? I feel this is the wrong function. I beg your help for the correct use of this case. thank you

 

mamprat_0-1628609288295.png

 

0 Kudos
Message 1 of 12
(4,064 Views)

You can probably implement this more easily with the Select node (as you've found), but without the Case Structure.

 

Is this the actual problem, or do you need the Case Structure for more code in the real case?

 

You're comparing a string to the "30", which probably won't do what you want.

If the pink wire from the left is a string giving the temperature (e.g. "28", "27.4", "95.1") then you can use one of the conversion functions to get a number instead, and then compare to a number. This will compare in the manner that you want.

 

For example:
Example_VI.png

 

By doing a series of different comparisons (here they are all > 30?) you can wire a series of Select nodes into each other and get the string you want out.

 

Another option is to use Threshold 1D Array, but I often find that function more complicated to understand and have to check the context help (Ctrl+H) every time...


GCentral
0 Kudos
Message 2 of 12
(4,053 Views)

the reason I made it into a case, this string will display the status of the detection and will also display an indicator lamp as well. I think it would be more concise if it was made into a case.

 

 

0 Kudos
Message 3 of 12
(4,048 Views)

Comparisons with string will not do it numerically, but alphabetically, so 1000 < 2, for example (because "1000" would be before "2" in a dictionary). You need to do this using a numeric datatype.

 

Easiest would be to threshold into a sorted array of limits and then index into an array of strings.

0 Kudos
Message 4 of 12
(4,042 Views)

Hmm, then perhaps you can do the same conversion to number, and comparisons to produce a set of booleans.

 

Then you can build these into an array and use Boolean Array to Number, and then work out the relevant ranges to use in the Case Structure:

cbutcher_0-1628611719374.png

cbutcher_1-1628611736954.png

 

 


GCentral
0 Kudos
Message 5 of 12
(4,040 Views)
Solution
Accepted by topic author mamprat

@mamprat wrote:

the reason I made it into a case, this string will display the status of the detection and will also display an indicator lamp as well. I think it would be more concise if it was made into a case.


Still no need for a case. Here's what I had in mind earlier. (I use a colorbox as indicator lamp.)

 

altenbach_0-1628613650226.png

 

 

 

Message 6 of 12
(4,025 Views)

if now i makes the system like that, its efective or not ?

 

mamprat_0-1628616024018.png

 

0 Kudos
Message 7 of 12
(4,010 Views)

Hi mamprat,

 


@mamprat wrote:

if now i makes the system like that, its efective or not ?


No, it's not effective. Infact it's mostly Rube-Goldberg…

 

Why don't you follow Christians (Altenbach) suggestion? His advice almost always is considered "effective"!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 8 of 12
(4,006 Views)

sorry i missed your post, i applicated your the way you do it is very effective and I was helped by that thank you for the help 

0 Kudos
Message 9 of 12
(3,997 Views)

sir i try to makes your own. i have some question why the bundel name not display ?

why its happen ? thanks

 

mamprat_0-1628626466666.png

 

0 Kudos
Message 10 of 12
(3,949 Views)