LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Formula Node Code Syntax

Hello all,

I have a bit of a problem and was hoping someone with more knowledge than me would be willing to help. We acquired a program written in LabVIEW for a specialized piece of test equipment. We were told that it wouldn't be a problem but when I received the program I had to rewrite most of it (there was only 1 sub-vi and over a hundred local variables). My rewrite works better than the original but there were certain key calculations within the program that I didn't want to change; these were written in Formula Nodes. I understand, outside of the node, what is suppose to be calculated. However, I've never written anything in C so I can't fully understand the syntax of the node. I know that there must be something wrong because there are certain instances where the calculations are obviously incorrect (infinity or negative results). I was hoping that someone here would have a look at the code within the node and reveal any issues with it. I am also sending this back to the original programmer to have him fix it but I now have doubts that he knows what he's doing.

 

I have attached the VI that contains the Formula Node, and it's sub-vi, with a few changes to hopefully make it easier for others to open. The inputs are times when certain events in the test occur and the outputs are F, Q, and I. Q and I are easily calculated and I am confident that the code is correct but F is more complicated. Depending on the rate at which the events happen, some events are skipped and the formula used for the calculation of F changes. As I understand the code, the node calculates all possible Fs and then limits which one it outputted based on changes in rate and the number of events that occurred. I am not sure that the syntax that is being used for selecting the required F value is correct but with my lack of C knowledge I can't prove it or fix it. I think all the individual calculations of F are correct just not how the F is selected. If I still don't feel confident in the original programmer's fix I can of course rewrite it in 'real' LabVIEW but would rather have him do what we paid him for. I will also post his fix for forum review.

 

Thanks for helping out a LabVIEW only programmer.

Tessa

Download All
0 Kudos
Message 1 of 2
(4,186 Views)

I don't think anyone on the forums are going to be able to help you.  We don't know what that formula node is supposed to do to have any idea whether something would be right or wrong.

 

If it was a syntax error, then we might be able to find it.  But you are basically asking us to figure out the logic.  The problem and is various oddly named variables, and deeply embedded case structures mean nothing to us.

 

It might be possible to clean up that code some by eliminating unneeded line breaks in the case structure to make it easier to read.  Many of the commands are just single line, but wrapped with curly braces on the lines before and after.  There winds up being 4, 5, 6 curly braces in a row closing at the bottom of the deep case structures.  By elminating extra line breaks when not needed, and having a more substantial indentation, it could greatly shorten up the formula node and make it easier to read.

 

If you understand what the formulas are supposed to do, it looks like there is a lot of repeated calculations in there that could be handled in pure LabVIEW code with appropriate array indexing, looping, and subVI's.  However, for complicated algorithms that can be adequately expressed in text code, then the formula node is not a bad way to go.

 

I'm afraid your going to have to rely on your original programmer to step up and make sure that it is working the way it is supposed to.

0 Kudos
Message 2 of 2
(4,170 Views)