From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to access value inside loop from outside

Hello,

I am working on a electrical measurement project in which I've "for" loop in which the measurement module is running and I wanted to access the variables inside loop from outside. Here I am depicting my problem using simple example. Please provide solution suppose if I want to access current value of "i" inside loop from outside.

 

Thanks

Raghav

ni.JPG

 

0 Kudos
Message 1 of 10
(3,095 Views)

You should have a parallel loop running to monitor the loop continously otherwise it will be a one time read. Try to have a while loop parallel to the for loop and keep the local variable and the indicator inside it and check, it will work.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 10
(3,085 Views)

In addition, if you have too many variables in the actual code, for which you want to monitor values, then, take the references of all those variables to be monitored and use their Value propery node to continuously see their values.

 

 

Regards
Freelance_LV
TestAutomation Consultant
0 Kudos
Message 3 of 10
(3,080 Views)

I don't know your specific application but if synchronization and/or data loss is a concern you might want to get rid of the locals. Switching to a producer/consumer architecture is then the best option, check the example finder/help for more information.

 

 

0 Kudos
Message 4 of 10
(3,070 Views)

HI,

 

If you want to read only data and not worried about the data loss then you can go with other parallel loop and can use property node as suggested above.

 

But if your application is concerned about data loss then you can use queues , notifiers to monitor the data in other loop.

It will be better if you explain your application here so that  you will get better solutions.

0 Kudos
Message 5 of 10
(3,065 Views)

I need a VI to run a motor continuously can u please help me??

0 Kudos
Message 6 of 10
(3,034 Views)

You'll probably need the producer/consumer architecture (ques) but if you want help you'll have to provide information Smiley Wink

0 Kudos
Message 7 of 10
(3,027 Views)

@AJAYKUMAR wrote:

I need a VI to run a motor continuously can u please help me??


It's rude to hijack someone else's thread.  Please start your own.

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 8 of 10
(3,021 Views)

@Raghav_Nilearner wrote:

Hello,

I am working on a electrical measurement project in which I've "for" loop in which the measurement module is running and I wanted to access the variables inside loop from outside. Here I am depicting my problem using simple example. Please provide solution suppose if I want to access current value of "i" inside loop from outside. 


You have an indicator inside the loop, that's not a "variable". There are plenty of way to get the current value of that indicator elsewhere in the code, and a local variable is probably easiest.

 

However, your code currently reads the local variable exactly once at the start of the progran, and in parallel to starting the FOR loop, so you'll only get a single value, or even a stale value from an earlier run. Can you specify what you mean by "access"? I assume you simply want some other code to read it occasionally, so that other code needs to be in a polling loop as already mentioned.

 

As a first step, I recommend some tutorials about dataflow in general. Then try to run your code in execution highlighting mode to get a better understanding how things execute.

 

Obviously your real problem is probably a bit more complicated. Can you show is the real code instead? Who needs that value?

0 Kudos
Message 9 of 10
(3,000 Views)

@AJAYKUMAR wrote:

I need a VI to run a motor continuously can u please help me??


Continued here.
0 Kudos
Message 10 of 10
(2,994 Views)