04-27-2010 01:46 PM
04-27-2010 01:51 PM - edited 04-27-2010 01:54 PM
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?
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.
04-27-2010 01:59 PM - edited 04-27-2010 02:05 PM
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!
04-27-2010 02:24 PM - edited 04-27-2010 02:25 PM
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.
04-27-2010 02:29 PM - edited 04-27-2010 02:31 PM
04-27-2010 02:40 PM
04-27-2010 03:03 PM
04-27-2010 04:34 PM - edited 04-27-2010 04:42 PM
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.
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?
04-28-2010 02:42 AM
04-28-2010 04:09 AM
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