LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Store value within a loop

Solved!
Go to solution

Dear all,

 

Let's say I am sweeping a voltage source within an infinite while loop via the iteration value "i" and for each voltage "V" I measure the output power "P" from another device.

 

Questions:

1. I would like to store within a variable the value V=Vp when a certain power P=p is read within the loop. How do I store this value for later use?

2.  I would like to stop the loop when the value 2xVp (2 times Vp) is reached (and that's one of the reasons why I want to store Vp). If I can "clamp" or store Vp somewhere, then I can easily program the condition to stop the loop by simple asking

"Is V >  2xVp".

 

I understand shift registers may be useful in these kind of cases but  the values stored there always change with "i".

 

I am new to labview and currently learning by doing. I am sure this is relatively easy to implement but I have tried long time already without success. I have read tutorials and watched videos but I haven't found anything helpful.

 

Thanks a lot in advance for your comments,

Richard

 

0 Kudos
Message 1 of 5
(4,436 Views)

Hi Richard,

 

basic LabVIEW stuff: to store values in loop for use in later iterations you shoul duse shift registers.

 

I understand shift registers may be useful in these kind of cases but  the values stored there always change with "i".

Wrong.

When "the values change with i", then you have programmed it this way!

Mind to attach your VI?

 

Did you take those free resources to learn LabVIEW?

Best regards,
GerdW


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

Hi, thanks for your reply.

 

The value of voltage is connected to the iteration value "i" because I am doing a sweep. Therefore, any shift register linked to the voltage will also change with "i".

 

The example attached illustrates the problem.

 

The questions reamain:

 

How can I store the value of the voltage when the "power" is for the first time greater than, say, 0.8?

And then use this value of voltage (let's call it vp) in order to stop the loop at a later time, say, when voltage = 2 x vp ?

 

Thank you,

0 Kudos
Message 3 of 5
(4,410 Views)
Solution
Accepted by topic author ricardo81

Hi Richard,

 

How can I store the value of the voltage when the "power" is for the first time greater than, say, 0.8?

Now we are getting closer to a question with all the facts needed to develop an algorithm!

You need to put in some more logic:

IF power > 0.8 AND flag THEN
  /* store new values */
vp := current voltage flag := FALSE ELSE
/* keep previous values */
vp := vp
flag := flag
ENDIF

The "variables" flag and vp are stored in shift registers.

"flag" needs to be initialized with TRUE, vp with any value you like to…

Best regards,
GerdW


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

Thank you!

 

0 Kudos
Message 5 of 5
(4,376 Views)