From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is declaring functions still not supported in LabView?

I see some very old posts that function declaration is not supported in formula nodes.  Is this still the case?  Are there any work-arounds besides a sub-VI?

 

Thanks,

Justin 

0 Kudos
Message 1 of 6
(2,917 Views)

Hi Justin,

 

Are there any work-arounds besides a sub-VI?

Why do you call the creation of LabVIEW subVIs a "workaround"? 😉

 

What exactly do you want to achieve with LabVIEW? Why do you think you need a formula node to reach this goal?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(2,913 Views)

GerdW,

 

Thanks for the quick reply.  I think I used the term "work-around" because it was used in an earlier post, but this is not really the case since the function declaration and the sub-VI are 2 different things (at least in my mind).

 

I routinely use formula nodes when I'm doing a whole bunch of algebra.  I find it cleaner and easier to interpret and comment than wiring up the math.  I also routinely drop them into a sub-VI to keep the parent block diagram neat.  I would never look at this as an analog for a function declaration within the formula node full of algebra though.  But I do see how it can be interpreted that way.  

 

It would be nice to be able to declare a function inside the formula node for the same reason it's nice to be able to do it in C code.  It just makes doing some math more efficient.  It's really no different than the efficacy of using the built-in functions when appropriate.  For example if I want to pick the maximum between 2 numbers I'd just us the max(x,y) function instead of writing my own conditional everytime.  

 

Anyways, I can do the tedious, repetitive math just fine without the ability to declare a function in the formula node, but like I said, it would be nice if I could.

 

Thanks,

Justin 

0 Kudos
Message 3 of 6
(2,883 Views)

Think of a VI as declaring a C function.  Each VI is assigned to do a specific task and when combined with other "functions", they accomplish your end goal.  Don't try to throw all of the code into one VI because you are right, it would be difficult to interpret what is happening.  But when split up and properly documented, the code should be easy to understand. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 4 of 6
(2,875 Views)

@jbarber wrote:

For example if I want to pick the maximum between 2 numbers I'd just us the max(x,y) function instead of writing my own conditional everytime.  

 


Here's Max and Min of two numbers:  Max and Min.png

 

Bob Schor

0 Kudos
Message 5 of 6
(2,868 Views)
Point taken. Don't get me wrong, I've been using LabVIEW off and on for 15 years to solve all sorts of engineering problems--and mostly not with formula nodes. I'm a big fan of what and how LabVIEW does what it does.

That said, well, there's a time and place for everything. Given the problem and what you have to work with (which perhaps includes some code), formula nodes can be an expeditious option. Actually the ability to drop a blob of existing functional code (C or something else) into a "box" within a VI and run it would be pretty slick.

Then again, the external code could be compiled to a DLL and called from LabVIEW to achieve the same result...several ways to approach the problem.

0 Kudos
Message 6 of 6
(2,854 Views)