LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to record data after time delay / transfer data between while loops


@austin_okstate wrote:

Thank you for the responses, but why can't I just take the readout from my channel and place it in a different loop and wait 5 seconds or so, and get the time delay number of pulses? Would placing the Ticks after time delay in a for loop solve the issue? 


So what you are really after here is a loop that just reads the counter at some rate and another loop that uses the latest value that was read.

 

Two options I will throw at you:

1. If using LabVIEW 2016 or newer, use a Tag Channel Wire.  The Channel Wire is not a normal wire in that it enforces data flow.  It instead shows a parallel relationship between loops.  Since you only care about the latest value, use that Tag version.

2. Use a Global Variable.  Quick. Simple.  Work extremely well as long as you only have 1 writer.  And a shameless plug: Are Global Variables Truly Evil?


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
0 Kudos
Message 11 of 14
(414 Views)

@crossrulz wrote:

@austin_okstate wrote:

Thank you for the responses, but why can't I just take the readout from my channel and place it in a different loop and wait 5 seconds or so, and get the time delay number of pulses? Would placing the Ticks after time delay in a for loop solve the issue? 


So what you are really after here is a loop that just reads the counter at some rate and another loop that uses the latest value that was read.

 

Two options I will throw at you:

1. If using LabVIEW 2016 or newer, use a Tag Channel Wire.  The Channel Wire is not a normal wire in that it enforces data flow.  It instead shows a parallel relationship between loops.  Since you only care about the latest value, use that Tag version.

2. Use a Global Variable.  Quick. Simple.  Work extremely well as long as you only have 1 writer.  And a shameless plug: Are Global Variables Truly Evil?


Why a global variable when OP is trying to access data within one VI? Isn't that a normal variable?

And again, OP would have to ensure that the loops are synchronized, repeatedly checking the variable only after a new value is added, then store the value until the expected time is reached. Your solution would lead to repeated values.

Using Labview 2022, Windows 10
0 Kudos
Message 12 of 14
(409 Views)

@austin_okstate wrote:

The Producer/Consumer loop seems to work, but I'm curious if you set the Prod/Con loop to run continuously? This function would have me click the Enqueue Element button each time I want a readout.  


Yes, You can continuously run two loops with prod/con coninuously.

One loop (produder) will continuously enqueue data when it is received.

The other loop (consumer) will, when the timer value is reached, flush the queue. By flushing the queue, you will have an array of all the data enqueued since the last flush. This way, you can get an array of values each time the timer tick value is reached, evaluate that set of values, and wait for the next one. 🙂

Using Labview 2022, Windows 10
0 Kudos
Message 13 of 14
(407 Views)

@AllisonSCJ wrote:

Why a global variable when OP is trying to access data within one VI? Isn't that a normal variable?


You mean a Local Variable?  The Local Variable requires a front panel control/indicator.  I just recommend the Global Variable since I have a tendency of putting my parallel loops into separate VIs.

 


@AllisonSCJ wrote:

And again, OP would have to ensure that the loops are synchronized


No.  In the second loop, the OP only cares about the value at time X and then Y seconds later.  We do not care one iota about the data in between.  So since we only care about the value at the time we happen to check, tags (ie Global or Local Variable) are perfect.

 


AllisonSCJ wrote:  Your solution would lead to repeated values.

Again, no.  Read value from tag, wait Y time, read value from tag, do math.  The only way repeated values will happen here is if the wait is really short and/or the acquisition loop is not updating the tag.


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
0 Kudos
Message 14 of 14
(401 Views)