LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need to convert a String to Ring Control's numerical value.

Hi all.

 

I have this requirement, and need some help.

 

In the screenshot below you can see that a Ring Control is going into the TIming block. As in the detailed help, you can see that when "Falling" is selected the block in fact sees the number 10171.

 

In my application I cannot use the ring control, and instead I have a string "Falling". I want to convert this string to the precise value 10171 using programming.

 

I tried type casting, but as you see its not helping.

 

Can anyone please assist?

 

I appreciate it.

 

Thanks.

 

Capture.PNG

0 Kudos
Message 1 of 8
(7,062 Views)

You will need to explain a bit more. Is “Falling” the only string that you will have to convert to an integer? Is the string always going to say “Falling” or will it be dynamic?

 

The first though that comes to mind might be to use the “Equal?” and “Select” functions. The equal function would compare the incoming string to the string "Falling" then output a Boolean to the select function and then that would output the correct integer value.

 

I would post a picture of my thought process, but I don’t have access to LV on this computer.

0 Kudos
Message 2 of 8
(7,049 Views)

Hi B-Lac

 

Thanks for your reply.

 

There will be two cases Falling or Rising. But that will be decided dynamically.

 

And thanks for your suggestion. That is similar to one of the methods I had in mind.

 

But I prefer to understand how they get that number from the ring control, and implement that using a string input.

 

If there is absolutely no way, I will do the equal and select method or similar, but I want it to be more "logical" rather than "manipulative" if you know what I mean.

 

Thanks.

0 Kudos
Message 3 of 8
(7,043 Views)

You can only do this using a property node, which means you'll need to have an instance of the ring on your front panel, and at that point it might be easier just to use the ring.  However, if you want to have a string input and leave the ring control hidden, you could do something like this:

String to Ring Value.png

Message 4 of 8
(7,025 Views)

Try with combo box.

Anand kumar SP
Senior Project Engineer
Soliton Technologies Pvt Ltd
0 Kudos
Message 5 of 8
(7,018 Views)

Hi razor,

 

it might be so simple:

check.png

(It's a German LabVIEW, so they used German names for those constants. 😞 )

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 8
(7,013 Views)

Hi all. Thanks for all the replies!

 

In the end, I had to implement equal,select and case.

 

I used the case because if I use only "Select" then even if there is a String "Rising2" Falling will be selected. To make it error proof, I seperated the execution.

 

 

But still, if any one knows how to really "convert" that String to the (Ring Control equivalent) number, I will be interested to know that.

 

Anyways, thanks for your inputs.

0 Kudos
Message 7 of 8
(6,985 Views)

razor149 wrote:

But still, if any one knows how to really "convert" that String to the (Ring Control equivalent) number, I will be interested to know that.


Again, the only way to do this is with a property node as I demonstrated in an earlier reply.  This is the difference between a Ring and an Enumeration.  The list of strings in an Enumeration is part of the data type, so it is possible to get the corresponding string value.  A Ring is a simple numeric value and the strings are purely cosmetic.

0 Kudos
Message 8 of 8
(6,983 Views)