LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

fixed point as case selector value solution?

Solved!
Go to solution

Hey all so I'm very new to LabVIEW and I'm trying to do a simple program.

 

Right now I'm have a numeric control which controls my analog input voltage on my sbRIO 9636 board(from the evaluation kit). Depending on the voltage I want to display a message onto the LCD screen. I know that you cannot use FXP values as case selector values. Is there any way around this? I was thinking about converting it into string, but I want to have a case where any voltage between 0-1 displays a message, then 1-2 displays a different message and so on and so forth up until 10.

 

 

0 Kudos
Message 1 of 10
(3,417 Views)

Hi butter,

 

well, integers are allowed for case structure selector input. So the easy way would be to convert your FXP to an integer (with some rounding applied)...

Best regards,
GerdW


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

Yeah I figured it out once I got on my computer that had LabVIEW on it..

 

I have another problem.

 

I have a case structure with a bunch of cases and an integer case selector.

 

I want to be able to display a message for each value. Between 0 to 1 volts would display "zero" and between 1 to 2 volts will display "one" etc. But the case structures rounds up my values, so anything that is >=1.5 will be automatically thought of as 2. >=0.5 is thought of 1. How can I get around this?

0 Kudos
Message 3 of 10
(3,392 Views)
Solution
Accepted by butterwaffle

The rounding in the case selector is built-in and cannot be changed by the programmer.  You will need to do the logic externally and create the integer selectors you need.  One way to do this is to create a constant array with the values where you want to switch cases. Then do a comparsion to the variable value. Search the resulting boolean array for the first True. The Index coming form the search goes to the case selector.

 

Lynn

 

DBL to Case.png

Message 4 of 10
(3,383 Views)

@butterwaffle wrote:

I want to be able to display a message for each value. Between 0 to 1 volts would display "zero" and between 1 to 2 volts will display "one" etc. But the case structures rounds up my values, so anything that is >=1.5 will be automatically thought of as 2. >=0.5 is thought of 1. How can I get around this?


If you are keeping with the integer numbers as the limits, just use Round to -Infinity to round down to the nearest integer and wire the result into the case selector.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 10
(3,372 Views)

I knew there was an easier way I was missing!

 

Lynn

0 Kudos
Message 6 of 10
(3,368 Views)
0 Kudos
Message 7 of 10
(3,341 Views)

Hi butter,

 

didn't I mention "with some rounding applied" in my previous post?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 8 of 10
(3,327 Views)

@johnsold wrote:

I knew there was an easier way I was missing!

 

Lynn


The next simplest way I was thinking was using the Threshold 1D Array and then round the resulting index to -Infinity.  That would work well if the limits are not integers.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 10
(3,305 Views)

Yep I found the Round to -Infinity in the numeric pallete! Thanks for the help all.

0 Kudos
Message 10 of 10
(3,287 Views)