NI Home > Community > NI Discussion Forums

LabVIEW

Showing results for 
Search instead for 
Do you mean 
Reply
Trusted Enthusiast
Darren
Posts: 2,900

Darren's Weekly Nugget 04/26/2010

The Convert Unit function is an easy way to convert data from one unit value to another:

 

convert_unit.png

 

If you're not sure what the symbol for a particular unit is, you can right-click the Convert Unit function and choose Build Unit String....

 

build_unit_string_dialog.png

 

Here, you can pick from a variety of categories (time, distance, etc.) to find the symbols for the units you wish to convert. And as you can see in the screenshot, you can also combine units...for example, I have created a unit string that will generate an accelleration value (in km/s^2).

Darren Nattinger, CLA
LabVIEW Artisan and Nugget Penman
Member
RandyP
Posts: 38

Re: Darren's Weekly Nugget 04/26/2010

[ Edited ]

Thanks, Darren. I've been befuddled as to how to use this function. The fog is beginning to clear. Question for you: Why does this work:

 unit_math_ok.png

But this doesn't:

 unit_math_broken.png

 

?

 

 

It seems unit math is a bit lacking. I'm can understand arbitrary exponents not working since the power wouldn't be known until runtime, but it seems functions like x^2 should handle converting the units.

 

Message Edited by RandyP on 04-27-2010 09:32 AM
-Randy
-=--=-=-=-=-=-=-
Nothing like a good dose of LabVIEW to cure what ails ya'.
Knight of NI
Knight of NI
Ben
Posts: 16,154

Re: Darren's Weekly Nugget 04/26/2010


RandyP wrote:

Thanks, Darren. I've been befuddled as to how to use this function. The fog is beginning to clear. Question for you: Why does this work:

 unit_math_ok.png

But this doesn't:

 unit_math_broken.png

 

?

 

 

It seems unit math is a bit lacking. I'm can understand arbitrary exponents not working since the power wouldn't be known until runtime, but it seems functions like x^2 should handle converting the units.

 

Message Edited by RandyP on 04-27-2010 09:32 AM

 

There are bugs in the unit functions that prevents it from handling squaring a unit like you did.

 

So far as using the unit functions...

 

Since my apps typically monitor many different types of physical units and the data is acquired as arrays, the unit functions are of little use since all elements in an array can differ only in value. If the units for an array could be specified on a element by element basis they could be useful, but that would require a major re-write of arrays.

 

Ben

Ben Rayner
I am currently active on.. MainStream Preppers
Rayner's Ridge is under construction
Knight of NI
RavensFan
Posts: 16,018
0 Kudos

Re: Darren's Weekly Nugget 04/26/2010

[ Edited ]
Message Edited by Ravens Fan on 04-27-2010 09:52 AM
Active Participant
_Bryan
Posts: 461

Re: Darren's Weekly Nugget 04/26/2010

I showed this to someone this morning and grabbed an expression node by mistake.  It looks exactly the same as the convert unit function and even has the build unit string option.  But it does not work with the example.  The expression node is probably looking for a variable, which is why it did not work (LV 2009, no service pack).

 

Why do they look the same, yet do 2 different things?    

Trusted Enthusiast
Darren
Posts: 2,900
0 Kudos

Re: Darren's Weekly Nugget 04/26/2010


_Bryan wrote:
I showed this to someone this morning and grabbed an expression node by mistake. 

You know, if you used Quick Drop, that mistake wouldn't happen... :smileywink:

 

Seriously, though, I agree that they need some sort of visual differentiator.  I also don't know why we show the "Build Unit String..." right-click menu option on an Expression Node.  I filed CAR# 223245 on these issues.

Darren Nattinger, CLA
LabVIEW Artisan and Nugget Penman
Member
gchristi1
Posts: 50
0 Kudos

Re: Darren's Weekly Nugget 04/26/2010

The praise first. I've never used convert unit and I can see where this can clean up some of my code. I took the basic, intermediate and advanced classes and this function was never covered, so thanks.

 

The negative: It took me way too long to duplicate your examples by clicking on help.  I really had to hack around to get the BUILD UNIT STRING menu to come up. Maybe a future nugget will give a walk through from step A on how to use this function. I've figured it out, but there are probably other users that have skipped this thread because they can't get past step A.

 

Trusted Enthusiast
Darren
Posts: 2,900
0 Kudos

Re: Darren's Weekly Nugget 04/26/2010

Did you accidentally drop the Expression Node instead of the Convert Units function?  See my latest post above...they look identical in the palettes, but they don't work the same.  As I mentioned, I filed a CAR on this issue.
Darren Nattinger, CLA
LabVIEW Artisan and Nugget Penman
Member
tstahl
Posts: 32

Re: Darren's Weekly Nugget 04/26/2010

The converting of units is a neat idea.  But...  My attempts at using them in a generic test system were very short lived.  I can see where they could work well in a specific application, but it's not possible to array numerics of different units, so a simple array of test metrics generates broken wires.

 

Tim

 

Active Participant
Posts: 241
0 Kudos

Re: Darren's Weekly Nugget 04/26/2010

I have wanted to use this for years.

 

I am scared away by the reports of bugs and the limited unit choices (why no percent (%)).

 

I think this tool could be enhanced if you could create you own units.