LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Case structure

Hello!

I am using a case structure with true/false and  I want to add a new case, but there is the next error: Some of the selector values specified for cases in the Case structure could not be converted to the same type as the selector.

I have to compare 3 numbers and in the end to display a message using String, and if the number,  which i have entered is between the others 2 numbers( limits), i have to use a boolean.

0 Kudos
Message 1 of 10
(2,968 Views)

I'm afraid your description of your problem is too confusing to know what you are trying to do.  Now if you had attached an actual VI, we might be able to understand.

 

You talk about a case structure with true/false.  That means you can only have two cases and never 3 or more.  Booleans are either True or False.

 

Perhaps you are looking for a case structure embedded inside a case structure?

 

 

0 Kudos
Message 2 of 10
(2,960 Views)

I would use my psychic powers to look at your code, but I don't have any psychic powers.  Just kidding.  Even if I had psychic powers, I wouldn't bother using them to try to search for your code.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 3 of 10
(2,954 Views)

here it is what i tried

0 Kudos
Message 4 of 10
(2,931 Views)

Use In Range and Coerce to determine wither it is in range.  If in range,  (True case), then do your in range message.  In the False case, do a comparison with upper limit and determine if it is high.  Otherwise it is low.

0 Kudos
Message 5 of 10
(2,916 Views)

True/False can only have two cases.

 

So what exactly did you wire to the case selector now? (There are many possibilities: Boolean, integer, String, enum, etc.)

 

It seems you only have two possibilities (A) Values in range, (B) Value is NOT in range. So all you need is two cases with the selector wired to the output of the "in range and coerce function" Since you seem to only have two possible strings, a simple "select" could be used instead of a case structure..

 

Note that you need to decide to include or exclude the boundaries. I am using integers, because DBL comparisons can be tricky.

 

altenbach_0-1606952255390.png

 

0 Kudos
Message 6 of 10
(2,871 Views)

Hello, my sister have a homework, as limit testing. Can you help me or us:)) thank you in advance.

1. The user should be able to enter the date via a slider, ranging from -10 to 10

2. to be 2 numerical controls

3. There should be an LED that lights up if the input value is out of range

4. a.there is a string indicator, which shows a. (Always): "the current value is ...

   b. (if the value is above \ below the range): "and this is above \ below the range of Y", where X is the current input value, and Y. represents the difference between the input value and the given range.

She must use case structure and comparison palette.

0 Kudos
Message 7 of 10
(2,841 Views)

The easier tool for limit testing would probably be In Range and Coerce, but since this is homework with a specific method in mind, it sounds like you have pretty good instructions.

Where are you having trouble?

 

  • Did you manage to add a slider?
  • Have you set the range of the slider inputs? Should the range be +-10, or larger? Do the "2 numerical controls" set the limits?
  • Assuming the range is +-10, and the limits are given by the 2 separate controls, have you added the controls? Can you use a function from the Comparison palette to determine if the slider value is Greater Than, Less Than etc the numeric controls?
  • Can you find a formatting function to convert the slider value to a string, and add the necessary preceding text ("The current value is ")?
  • Probably you want to use your case structure to append a string if needed to the initial output.

GCentral
0 Kudos
Message 8 of 10
(2,830 Views)

Hi J.Julia,

 

even if J.MATT may not be your sister you question seems to be the very same as his/her question.

Use the answer given in this thread…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 10
(2,827 Views)

@J.Julia wrote:

Hello, my sister have a homework, as limit testing. Can you help me or us:)) thank you in advance.

1. The user should be able to enter the date via a slider, ranging from -10 to 10

2. to be 2 numerical controls

3. There should be an LED that lights up if the input value is out of range

4. a.there is a string indicator, which shows a. (Always): "the current value is ...

   b. (if the value is above \ below the range): "and this is above \ below the range of Y", where X is the current input value, and Y. represents the difference between the input value and the given range.

She must use case structure and comparison palette.


OK, your sister should start with going over the class notes. Most likely all that's needed has been covered. If there are remaining doubts, there are quite a few learning resources listed on the top of the forum.

 

Now start looking at the requirements and place everything required on the front panel:

 

  • One slider control, two numeric controls, one LED indicator, one string indicator.
  • Decide on the data type (representation). Do you want only integers or also allow fractional values?
  • Edit their labels to intuitive names related to their function. Change the scale range.
  • Arrange everything nicely for good usability.
  • Change all values to reasonable defaults so next time you don't get all zeroes, which is not really interesting.
  • A running program also needs to be stopped, so add a stop button.

Now switch to the diagram. At this point you should see the terminals of all the front panel elements you just placed. Some are controls (i.e. data sources) and some are indicators (i.e. data sinks). A running program should read the controls at regular intervals, do the comparison, and output the result to the indicators. This means that you should surround everything with a while loop. Wire the stop button terminal to the stop terminal.

Since it does not really make sense to spin the loop millions of times per second, place a small wait (e.g. 50ms) to make it a million times slower and better allow your computer to also focus on other things.

 

Now how do you check if a value is in range? Yes, there is a function in the comparison palette that has already been mentioned. It has three inputs, exactly what you need! So wire the controls to its inputs. It has two outputs and you only need the boolean output at the bottom right. Wire the LED to it. Run the program to see hat happens. You are almost there (!) except for some flaws: the string always shows blank and the LED is lit when in range instead of when out of range. Bummer! If only there was a function to flip the value in a boolean wire.

 

Now about the string. Look into the formatting operations already mentioned. Still, first you need to clarify point #4. Not sure what the "difference between input value and range" really means. Do you mean how far outside the range it is, i.e. the distance to the closes boundary? See how far you (and she) gets.

Message 10 of 10
(2,783 Views)