03-05-2015 01:01 AM
While using a case structure, I got a problem with the case structure. I need the case structure to change a vlue depending on the case input provided.
however, the case inputs( boolean) i want to give to the case stucture are '<0' , '=0', '>0'.here I can only provide the case structure with >0 or <0.
How can I include the condition '=0' in the case input so that the case structure
1. decreases the value of the parameter if the case is '<0' ,
2. does not change the value of parameter if the case is '=0' ,
3. increases the value of parameter if the case is '>0.
I have included the VI that I am working on for illustration.
P.S- The VI has a knob to vary the input variable, and has a numerical indicator to view the output variable from the case structure. so, the numerical indicator should be constant if the input variable is not varied.
Thank You in advance.
Solved! Go to Solution.
03-05-2015 01:19 AM
I cannot open your VI, but you could use '..-1', '0' and '1..' (instead of true/false) if the values are integer values or can be converted to integer.
03-05-2015 01:39 AM
HI,
Unable to view your code as it is developed in LV 2014.
Find the attached snippet.
Hope it resolve your issue.
Regards,
Bijay
03-05-2015 06:01 AM
As other have said, you can wire the numeric directly to the case selector and create ranges. Since you will get wierd rounding when you use the floating point data types, use the Sign function (in the numeric palette) to convert your difference into [-1,0,1] and then use that result for the case structure.
03-05-2015 06:06 AM
03-05-2015 02:48 PM
The comparison operators (=, <, etc.) are binary -- they give you yes/no answers. Your question is ternary, three possible outcomes. If you want to use binary comparisons, you need two of them (which gives you 4 choices, so you throw one away). Note that a "mapping" strategy suggested earlier is probably better when dealing with more than three cases, but if you are just learning LabVIEW, sometimes the "simple way" is easier to grasp. Note this is a Snippet, so you should be able to paste the image in LabVIEW 2014 and see the other cases (though they should be obvious -- the inner "False" says ">0 Case") and the outer "False" says "<0 Case").
BS
03-05-2015 03:24 PM - edited 03-05-2015 03:26 PM
I would go with the sign function directly. No case structure needed!
Here's how your code would look like.
03-05-2015 07:51 PM
Thank you crossrulz. I have converted the binary decision in to three numbers Using the following method. And thanks for all the replies.
03-05-2015 08:15 PM - edited 03-05-2015 08:22 PM
That is Rube Goldberg Code . Why do it that way when you can use the Sign function Altenbach shows which does it in a single node?
Heck, the middle of your construct there is completely pointless because it adds 0 whether the original number is equal to zero or not equal to zero.
Here is Altenbach's code saved as a vi.
03-05-2015 11:28 PM
@altenbach wrote:
I would go with the sign function directly. No case structure needed!
I need to spend more time searching the functions palette aimlessly. It amazes me that there was a function I had never seen in the middle of the Numeric palette.