11-08-2017 06:09 AM
@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?
11-08-2017 07:17 AM
@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.
11-08-2017 07:21 AM
@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. 🙂
11-08-2017 08:28 AM
@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.