02-11-2013 05:30 PM
I need to acquire the DAQ values every x seconds. The wait in the DAQ loop is set so that next N samples are acquired after x seconds. When the stop is pressed the DAQ consumer loop stops after the x sec that is wired to Wait function.
1. How to stop the inner loop immediately when a stop is pressed?
Also need to write the acquired samples after doing some math on the samples.
1. Plan to queue sample to pass to file consumer loop. Is there any other recomendation such that file loop does not miss any samples? How much of data can a queue hold?
Thanks.
Solved! Go to Solution.
02-11-2013 11:20 PM
Use 'stop all' local variable & with OR condition give it to outer while loop also.
It will be great if your post your code with 2011 compatibility.
Thanks
02-12-2013 12:43 AM
Ranjeet,
That will not work. The local variable in the inner loop is probably read as soon as the iteration starts. Any changes will not have any effects until the next iteration.
sonotk,
We cannot tell from your image but I am presuming that the value wired to the circled Wait (ms) function is 1000*x. If you need rapid termination response, it is better to make the wait much shorter. For example if the desired time between acquisitions is 1000*x, make the wait 100 ms. Keep a counter and when the count value exceed 10*x, then do an acquisition and reset the counter. With such a method your system will respond to a stop command in no more than 100 ms.
Lynn
02-12-2013 01:08 AM
Hi johnsold,
See if the is no delay between two iteration then there will not be any time for outer loop to read the value.
Agree ?
02-12-2013 01:31 AM
No! The outer loop will always "read" the value.
This is basic dataflow, the fundamental paradigm of LabVIEW. Any node can begin execution only when data is available at all its inputs and it will complete execution after all nodes internal to it have completed their execution.
In the case of the code image posted in this thread the inner loop will not complete one iteration until all the code inside has finished. Let's assume that the Is List Empty subVI executes in 1 ms and the DAQ Actions subVI takes 100 ms. Let the value coming in to the Wait ms be 1000 ms. The the loop starts its iteration: The Wait starts. The Stop All local is read. The Is List Empty subVI starts. One ms later Is List Empty ends and DAQ Actions starts.The OR gate has both its inputs and executes, generating the value which will stop the loop or allow it to continue. One hundred ms later (~101 ms after starting the iteration) DAQ Actions ends. The new values are placed on the indicators. After 1000 ms the Wait ends and the iteration ends. If the OR gate output was False a new iteration begins immediately. If it was True, the loop stops, the rest of the code in the case executes and then the outer loop completes its iteration. For this case the outer loop will always do at least one more iteration because a default value is wired to the stop terminal. The outer loop will only take nanoseconds or microseconds to get to the next case. But the outer loop DOES read the value of the boolean coming from the case structure (always False in this case) to determine whether to continue or to stop.
Lynn
02-12-2013 02:16 AM
Hi johnsold,
Thanks for the wonderful reply. What i mean to say is attached in image file.
See once user presses stop all then after ~101 ms outer loop will read the stop all boolean which is true. Hence it will stop the outer loop also (Agree that not immediately).
Hence the outer loop will terminate when either stop all boolean is presses from the front panel OR list is empty.
Hope i am right to some extent.
02-12-2013 09:45 AM - edited 02-12-2013 09:46 AM
No, the outer loop will read the value of the Stop local variable as soon as the iteration starts. There is no data dependency (data input) to the Stop local variable therefore it will execute immediately. So if the stop is set while in the inner loop the outer loop will execute one more iteration. You need to force the read of the stop button to ovvur after the case statement has completed.
02-12-2013 10:37 AM
Hello Lynn,
The input to wait function is 5secs. It is read from a file. Sample needs to be acquired every 5 secs. How will this be achived with a counter? The counter will have to count till 5000 and the stop response will be slow, or am I missing the point?
02-12-2013 10:50 AM
sonotk,
You missed the point. Rather than having a 5000 millisecond Wait, use a 100 ms Wait and count the number of times you have waited 100 ms. When the count reaches 50, take a sample and restart the counter.
The counter is just as shift register containing an integer. Inside the while loop you have a case structure. Test the count shift register to see if it is 50. If True, use the True case of the case structure. Inside there is everything in your loop except the Wait and the stop logic. In the false case you add 1 to the shift register and wait 100 ms.
In looking at your code image again it appears that the shift regsiters with TempData and VoltData are not needed because you never use the previous iteration data at the left side.
Ranjeet,
Make a simple VI with two loops and some Waits. Run it with Execution Highlighting turned on to see what happens. It is a good learning tool.
Lynn
02-12-2013 07:29 PM
Thanks Lynn, that worked.
You are rght I should have removed the shift registesr for volt and temp, these are replaced with queue to send the data to file loop.
thanks again!!