LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Functions in Formula Node

Hello:
I have written a simple formula node in the VI in annex. It uses two functions that should be called for R, G and B. Because I do not know how to implement functions (the way I implement C functions) I had to repeat 3 times the same code (for R, G and B) which makes the code not so readable and maybe I loose on performances? Could you correct the formula node by implementing functions, please? I was not able to find this tip in the various documentation that I have nor on the net. Thank you very much in advance,
Chris
0 Kudos
Message 1 of 6
(4,121 Views)
The way to do functions in LabVIEW is to create subVIs. Implement the repeated math by either using a formula node or LabVIEW math functions in the subVI and call that three times.
0 Kudos
Message 2 of 6
(4,121 Views)
Wow Chris!

That is one impressive formula node! In terms of computational efficiency, I wouldn't expect there to be a lot of difference between the formula node and separate VIs. Stll, I have attached two sub VIs that I think implement the two repeated areas of the formula node code.

Something to do though is change the type of all the outputs to doubles. The calculation is being done in double precision anyway, so you might as well preserve it. Also, the single frame sequence around the whole thing isn't performing any function so it can be deleted.

As far as readability goes, remember that readability (like beauty) is in the eye of the beholder. If you can read the code and know intuitively what it does, I wouldn't worry too much about it...


Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Download All
0 Kudos
Message 3 of 6
(4,121 Views)
Had a little more time so I have created a version of your original VI showing both the formula node and the "subVI version" using the two subVIs I posted earlier. According to my (admittedly limited) testing the two versions give the same results.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 4 of 6
(4,121 Views)
Mike:
Thanx but what I am trying to do is _not_ to use VIs because it makes the process too slow. On the VI you sent your version takes 3 times more time to execute than the formula node VI version.
Chris
0 Kudos
Message 5 of 6
(4,121 Views)
Ok;

I guess I misunderstood what you meant by making functions of parts of it. As I said in another post, if the formula node you have works and you can understand what its doing--don't sweat it. You're done.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 6 of 6
(4,121 Views)