LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I Strip units from a number without changing the value?

Solved!
Go to solution

Hi,

 

I am trying to make an applicaiton that the user can select the units on the controls/indicators. I will be logging data from those indicators to a data file. I want to give them the freedom to select any units they want (as long a LabVIEW supports them) and then based on that unit selection the save data file will reflect that unit selection. I realize I could do this using case structures but it would be a huge ordeal dealing with all the different types of unit selections possible. I've attached a vi which is close to what I want to do but for some reason the units get converted to meters even though my constant has no units.

 

Thanks!

0 Kudos
Message 1 of 5
(2,937 Views)
Solution
Accepted by topic author Ryman

LabVIEW stores the value of a number with attached unit always in the base unit and only converts to the selected unit and back when displaying/entering the value.

 

However you may be able to use VI Server properties of the control to read the actual text value of the control and store that to the file.

Rolf Kalbermatter
My Blog
Message 2 of 5
(2,920 Views)

Welcome to the spooky world of LabVIEW units.  Many of the developers here have tried using them for a while, then got burned by some ugly bugs and caveats.

 

Check out this thread for a small dose of things to look out for.

 

Here's a snippet of a classic.

 

units squared - oops.png

 

 Note the units on the indicators!

 

 

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 3 of 5
(2,898 Views)

Hi Ryman,

If you want the user to select the units and that unit selection should be a part of control/indicator,then you have to create a xcontrol which is another way to creating an advanced controls/indicators.

For more information on xcontrols refer:  http://www.ni.com/white-paper/3198/en/

 

Regards,

SrikrishnaNF

Regards,
Srikrishna


0 Kudos
Message 4 of 5
(2,879 Views)

Awesome rolfk that worked. I tried that before except I fed it the value not the number.text property. Thanks!

 

Thanks for all the others who posted I will be careful I have worked with units before with only a little bit of trouble hopefully things will go smoothly from here on out.

0 Kudos
Message 5 of 5
(2,857 Views)