取消
显示结果 
搜索替代 
您的意思是: 

fixed point as case selector value 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 项奖励
1 条消息(共 10 条)
3,822 次查看

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 项奖励
2 条消息(共 10 条)
3,810 次查看

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 项奖励
3 条消息(共 10 条)
3,797 次查看
解答
接受人 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

4 条消息(共 10 条)
3,788 次查看

@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.



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
5 条消息(共 10 条)
3,777 次查看

I knew there was an easier way I was missing!

 

Lynn

0 项奖励
6 条消息(共 10 条)
3,773 次查看
0 项奖励
7 条消息(共 10 条)
3,746 次查看

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
8 条消息(共 10 条)
3,732 次查看

@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.



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 项奖励
9 条消息(共 10 条)
3,710 次查看

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

0 项奖励
10 条消息(共 10 条)
3,692 次查看