LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Be careful with formula node!

Colleagues,

 

As "LabVIEW-oriented" engineers we are more and more far away from text-based programming languages. LabVIEW is cool, but sometimes you can get some "side effects", like I've got today.

 

So, for saving few wiring I have programmed simple formula node:

 

fn1.png

 

Looks simple, isn't? But result was not expected, because this was interpreted as V_mm = Offset + Cal * ( 5 * Size);

The problem occur because the Formula Node accepts only the period (.) as a decimal separator.

 

No errors, warnings, etc!

 

Correct syntax should be:

 

fn2.png

Take a note, that on the BD constants looks like "0,2", not "0.2".

 

Well, technically both code above are OK.

Here another discussion about this.

 

Just for fun I checked this with CVI:

 

ccode.png

 

No warnings, and results absolutely the same as above:

 

V_mm 14950.800000

V_mm 15992.000000

 

And the Intel C compiler only said me, that

 

TEST.c - 2 warnings
 55, 1   (55): remark #174: expression has no effect
 55, 1   V_mm = Offset + Cal * (V_pix - 0,5 * Size);

 

Just would like to share this "very basic knowledge", because you may get the same trouble, which can't be easily recognized immediately...

 

with best regards, 

Andrey

Message 1 of 36
(4,264 Views)

Let's convince our countries to make a trade. We'll adopt the metric system and you guys switch over from the comma to the period decimal separator.  Smiley Happy

PaulG.

LabVIEW versions 5.0 - 2020

“All programmers are optimists”
― Frederick P. Brooks Jr.
Message 2 of 36
(4,238 Views)

It's a fair deal...  😉

 

That's how it works in Canada...

 

23.8 deg C

 

🙂

Message 3 of 36
(4,231 Views)

I don't think a trade is needed.  How did some countries come into the habit of doing something as stupid as making a comma the decimal separator.

 

It is known as a decimal "point".  I've never heard anyone say "decimal comma".

 

By the way, is it the same countries that when they write the numeral one (1), it always looks like a seven (7)?

Message Edited by Ravens Fan on 06-11-2009 03:57 PM
0 Kudos
Message 4 of 36
(4,211 Views)
See here for the rest of the story.  http://en.wikipedia.org/wiki/Decimal_point
Message 5 of 36
(4,198 Views)

Neener neener neener, we have metric AND decimal point......

 

3.14 is really spoken "three comma one four" in german ("Drei comma eins vier" to be exact).

 

Shane.

0 Kudos
Message 6 of 36
(4,192 Views)
You nailed it Ravens Fan. The first time I saw a comma as a seperator I said to myself "WT_?" Smiley Very Happy
PaulG.

LabVIEW versions 5.0 - 2020

“All programmers are optimists”
― Frederick P. Brooks Jr.
Message 7 of 36
(4,197 Views)

PaulG. wrote:
You nailed it Ravens Fan. The first time I saw a comma as a separator I said to myself "WT_?" Smiley Very Happy

 

The Metric system has only 7 basic measures, plus a substantial number of measures using various combinations of these base measures. The imperial system (prior to the UK converting to metric) and the USA system have over 300 different measures which many are ambiguous. For example, there are eight different definitions of ton (including the 'short ton' and the 'long ton'), all of which differ in weight. There are also eight different definitions of barrel, five different definitions of bushel, three different definitions of mile (international, nautical, and US Survey). The USA gallon is smaller than the Imperial gallon, and all measures which are multiples or subdivisions of the gallon (e.g.. pint, quart) likewise are inconsistent between the USA and the UK. Not only are the USA and UK pints different in size, but there are also differences between 'dry pints' and 'liquid pints'.  All the units in the metric system are multiplied by 10 (to make larger units) or divided by 10 (to make smaller units). For example a kilometer is 1000 meters (10 * 10 * 10). It's nearest equivalent is a mile which is 5280 feet (8 * 10 * 22 * 3; based on the calculation that a mile is 8 furlongs, 10 chains to a furlong, 22 yards to a chain, 3 feet to a yard). ( At this point I actually gave a huge yawn) Although complex calculations can be done using the Imperial or USA system, almost all calculations can be done easier and faster in the metric system.

 With the exception of the USA, all major countries have converted to the metric system (although in some countries, such as the UK, the conversion to metric is not yet complete). Consequently, for any international communication (trade, science, etc.) the metric system is the most widely used and accepted.

So let us have our to you strange decimal point. And as last nail in the coffin. Why do you Americans name a national sports league hardly noticed by other than Americans for the "World Series" That is spooky if you ask me;)



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
Message 8 of 36
(4,189 Views)

Ravens Fan wrote:

 

It is known as a decimal "point".  I've never heard anyone say "decimal comma".

 


Well, but again, for me "decimal comma" is fully OK. Used everywhere here. "EUR 1,49", not "EUR 1.49". Comma is just standard in Germany. On the Block diagram all constants - with comma separator, and I just typed comma in the formula node and got slightly incorrect result.

 

But sometimes such mistyping may cause big troubles...

What may happened if you will type "DO 5 K = 1. 3" instead of "DO 5 K = 1, 3"? — Mariner 1 crash

 


PaulG. wrote:

Let's convince our countries to make a trade. We'll adopt the metric system and you guys switch over from the comma to the period decimal separator.


 

Well, some of us measuring vodka in litres, another people measuring whisky in gallons... When both things are mixed, then the Gimli Glider incident may happened. Also Mars Climate Orbiter was crashed my metric/imperial mixup...

 

What I would like to say - just one warning message from LabVIEW (like Intel compiler does) may save lot of time. In my case that was no messages, and I was absolutely sure that the given code is correct. And result was nearby correct, but I was more than hour in hard debug session before figuring out what is wrong. Also be very careful and accurate.

 

Andrey.

Message 9 of 36
(4,182 Views)
so the Montreal and Toronto teams feel accepted

"Should be" isn't "Is" -Jay
Message 10 of 36
(4,183 Views)