LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why do very few programmers use LabVIEW unit labels

I've been developing code for 8 years and once I discovered unit labels I fell in love with them and have used them consistently ever since.  And I have to say, I have never smashed a spaceship into Mars!  However, other coders at my company avoid them and I've never seen example code or instrument drivers that use them.  For instance, if a company has a laser power measurement instrument and provide instrument drivers to return the measured power, why don't they add power units to the output?  It seems so obvious and simple.  Does anyone know why these are not used?
Message 1 of 26
(9,299 Views)

Hi Wise Owl,

 

I use them from time to time...

 

But:

The use of unit labels increases the time needed for testing your app. Not all [math] functions support units. Some even give wrong results...

Ever tried to calc the square of "1m" using the square function?

SquareMeter.png

The result is: 1m. Yes, (1m)^2=1m. (Length)^2=Length. Simple physics, eh?

 

Atleast in LabVIEW. Using a basic MKS-system/SI unit. Using a simple square function.

Message Edited by GerdW on 04-27-2010 08:53 PM
Message Edited by GerdW on 04-27-2010 08:54 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 26
(9,295 Views)

Wise Owl wrote:
I've been developing code for 8 years and once I discovered unit labels I fell in love with them and have used them consistently ever since.  And I have to say, I have never smashed a spaceship into Mars!  However, other coders at my company avoid them and I've never seen example code or instrument drivers that use them.  For instance, if a company has a laser power measurement instrument and provide instrument drivers to return the measured power, why don't they add power units to the output?  It seems so obvious and simple.  Does anyone know why these are not used?

 

Some people may think you need an extra label, caption, or free text - and avoid it due to the fuss involved (alignment, font, forgetting to display it, moving it accidentally, etc).

 

If more people knew how to format unit labels into indicators, I think more people would use it. You can do it pragmatically with a property node (this is great when the unit may change, such as going from seconds to minutes), or you can just edit the Properties of an indicator in Advanced Editing Mode and put it there. Easy!

 

Message Edited by Broken Arrow on 04-27-2010 02:05 PM
Richard






Message 3 of 26
(9,273 Views)

Broken Arrow wrote:

 

Some people may think you need an extra label, caption, or free text - and avoid it due to the fuss involved (alignment, font, forgetting to display it, moving it accidentally, etc).

 

If more people knew how to format unit labels into indicators, I think more people would use it. You can do it pragmatically with a property node (this is great when the unit may change, such as going from seconds to minutes), or you can just edit the Properties of an indicator in Advanced Editing Mode and put it there. Easy!


That is a good tidbit for formatting a string.  But adding "Amps" to the format string is not really the same thing as associating the indicator with the units of Amps.

 

I can do this where the conversion of the scalar made the value in Watts, but the numeric format of the indicator tells it to show "Amps".  And if I hid the unit label for the indicator, all you'd see is amps, but that is just a word in the format, while the actual units for the indicator are Watts.

 

Message Edited by Ravens Fan on 04-27-2010 03:25 PM
Message 4 of 26
(9,229 Views)
Ravens, Thanks! I began to think that just as I posted that response. Smiley Surprised So my reply is a bit OT. Sorry Wise Owl!
Message Edited by Broken Arrow on 04-27-2010 02:31 PM
Richard






0 Kudos
Message 5 of 26
(9,216 Views)
Yes, I've never seen that, but I've never used that function, or the raise to the power of n (which doesn't work correctly either).  But this isn't typical of math functions.
0 Kudos
Message 6 of 26
(9,198 Views)
I first discovered how to add units years ago when I first switched from Visual Basic to LabVIEW.  I used it for a few months, then I was bit in the rear by a bug related to units.  Badly burned, I swore off units completely.  To me, this is a key failing of LV.  Units are vitally important in test & measurement, and yet there is no elegant way to associate them with numbers.  You would think that of all languages LV would be able to do that...
-------------------
Greg
Certifed LabVIEW Developer
Message 7 of 26
(9,177 Views)

I often choose to use units, though you do need to be careful.  For one program that I wrote to compute oxygen diffusion, they were extremely useful simply to ensure that the equations were coded correctly - if the units don't match, then something is wrong!

 

It's certainly a bug that the Square function doesn't convert units correctly, and moreso as the Square Root function does preserve units - though as LabVIEW doesn't support fractional units, the input needs to have unit powers that are multiples of two. However it's very simple to code around by wiring to both inputs of a Multiply function. It's not as surprising that the Power of X function doesn't support units, given that the power may be fractional.

 

Unit Example

 

Also, it's very helpful that the Trig routines support inputs with angular units, however it would be nice to be able to tell the inverse functions to provide outputs with angular units - perhaps a right-click option?

 

Message Edited by GregS on 04-28-2010 09:42 AM
Message 8 of 26
(9,147 Views)

Hi Wise Owl,

 

did you read the latest Nugget by Darren? Coincidence?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 26
(9,099 Views)

I use LV 7.1 and there is a bug, don't know if it is fixed in a newer version (might be a win problem). If you use unit lables and a system control -> crash.

 

Felix 

0 Kudos
Message 10 of 26
(9,083 Views)