LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Conditional loop for calculation of discharge coefficient

Solved!
Go to solution

Hello Everyone,

 

I have question related to the conditional loops. The problem that I am trying to solve is as follows.

I am trying to calculate a discharge coefficient. In order to be clear I am going to use hypothetical equation. Let's say I have an equation of  1-1/x which I am trying to calculate but I should initialize x before starting the loop.

1) I initialize x by 0,6, let's say then

2) I give conditional, if  |x-0,6|<0,001 then go to the next step

3) if |x-0,6| > 0,001 then go back to the calculation and plug new value

And the loop continuous until the condition met and after this, it will proceed to the next loop.

Thanks in advance. Any help greatly appreciated.

0 Kudos
Message 1 of 15
(4,037 Views)
Solution
Accepted by topic author Aeros08

Hi Aeros,

 

you need a while loop with a shift register to store your "x" value…

check.png(according to your description)

This is pretty basic LabVIEW stuff: have you taken the free courses?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 15
(4,017 Views)

Thank you for your response GerdW,

Nope, I did not but I will check that now.

I read about shift register but in some point I stuck, I could not realize how to compare the values and feed to the beginning of the calculation.

0 Kudos
Message 3 of 15
(4,007 Views)

This is what I did until now.

0 Kudos
Message 4 of 15
(3,993 Views)

Hi Aeros,

 

and what was the problem with your VI?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 15
(3,989 Views)

It seems that it does not go back and update as I intend. The thing that I am trying to do is in the attachment.

0 Kudos
Message 6 of 15
(3,983 Views)

Hi Aeros,

 

It seems that it does not go back and update as I intend.

You wired the "C_calculated" into the shift register, so it will be used in the next iteration (like in your requirement).

As I don't have your DAQ hardware you need to debug your VI with real values on your own.

Is the iteration condition met?

 

Btw. I miss the root(1-beta^4) term in your VI…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 15
(3,979 Views)

Since beta is a constant value, I directly wrote constant value to the vi instead of root(1-beta^4).

Condition did not met but I guess there is a problem with calculation. Unfortunately, I can check that tomorrow because I left the lab. Thank you very much for the help.

0 Kudos
Message 8 of 15
(3,971 Views)
Solution
Accepted by topic author Aeros08

@Aeros08 wrote:

This is what I did until now.


 

I don't know if this is a problem, but can the Formula Express VI handle a "," as the decimal point?

 

express.PNG

 

The formula is (X1)**0,75 and when I run it, it ALWAYS returns "1". It appears to ignore everything after the "," so for me, it evaluates (X1)**0

 

Why not just use the native LV exponential function Power of X? Seems much simpler than hiding the formula in an express VI.

 

exponent_.png

Message 9 of 15
(3,950 Views)

Thank you for your help jamiva, I will check that.

0 Kudos
Message 10 of 15
(3,938 Views)