LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Errors with formula node

Solved!
Go to solution

I have a formula node which gives me an error called.Error on line 1 is marked by a '#' character: "constant#=(Pi*f/c) Einsta=constant*sqrt("

 

I created a constant, but i gives me an error. wham I doing wrong?

0 Kudos
Message 1 of 13
(4,596 Views)

It would be easier to help if you would attach a simplified version of the VI instead of a picture.

 

My first guess is that "pi" is a reserved word. (You don't need to define it and wire pi to the terminal.) Check the help. There might be other problems, but I don't typically debug images. Where do you define "constant"?

Message 2 of 13
(4,591 Views)
Solution
Accepted by topic author shivik89

The formulas are all the same except for the input value.  So why not bundle the inputs into an array (using Labview primitives of course), auto-index the array for each input and calculate the output.  Throw all of this into a subVI and get rid of that formula node. 

 

Example_VI_BD.png

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

Hi shivik,

 

one more question: why do you need a formula node here for those simple formulas? Use plain G…

 

Edit:

@aputman: What's the purpose of the FOR loop?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 13
(4,562 Views)

@GerdW wrote:

 

 

Edit:

@aputman: What's the purpose of the FOR loop?


Yeah you're right.  I forget that the primitives can operate on arrays.  Smiley Frustrated

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

@aputman wrote:

The formulas are all the same except for the input value.  So why not bundle the inputs into an array (using Labview primitives of course), auto-index the array for each input and calculate the output.  Throw all of this into a subVI and get rid of that formula node.

 


As GerdW stated, no FOR loop required.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 13
(4,545 Views)

As others have said, try to use LV primitives, if possible.  The less typing a human has to do, the better.  😉

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 7 of 13
(4,530 Views)

While I agree with everyone saying use the primitives over the formula node, the reason you are getting an error is because constant is undefined. Add constant as an output if you want it to work the way you have it set up

Message 8 of 13
(4,520 Views)

@OEM_Dev wrote:

Add constant as an output if you want it to work the way you have it set up


Or just declare it before that line.

float constant;
constant=pi*f/c;
Einsta=constant*sqrt(480*(Pinsta./G));
Eavg=constant*sqrt(480*(Pavg./G));
Epeak=constant*sqrt(480*(Ppeak./G));

GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 9 of 13
(4,514 Views)

@OEM_Dev wrote:

While I agree with everyone saying use the primitives over the formula node, the reason you are getting an error is because constant is undefined. Add constant as an output if you want it to work the way you have it set up


And the root cause?  Typing.  I have to admit that I have this bias against typing because I so thoroughly SUCK at it.  😉

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 10 of 13
(4,487 Views)