01-04-2013 04:27 AM
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
01-04-2013 04:51 AM
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.
01-04-2013 05:08 AM - edited 01-04-2013 05:09 AM
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.
01-04-2013 05:55 AM
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.
01-04-2013 06:15 AM
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.
01-04-2013 10:58 AM
I need a VI to run a motor continuously can u please help me??
01-04-2013 11:07 AM
You'll probably need the producer/consumer architecture (ques) but if you want help you'll have to provide information
01-04-2013 11:13 AM
@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.
01-04-2013 03:20 PM
@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?
01-04-2013 03:23 PM
@AJAYKUMAR wrote:
I need a VI to run a motor continuously can u please help me??
Continued here.