I would like to take the data from DAQ. However, I am encountering small problem. I would like to do these two things at the same time :
1. Taking data and displaying that data in (almost) real-time with relative fast sample rate around 10 KHz from a Ni-DAQ => I am able to do this using a while loop
2. Having another display of data from 1 in a specified time interval (for example, display data from 1 each 10s) ==> I am able to do this using a timer loop. This task is depended on task 1
The problem is I cannot do these two things at the same time by A. puting the timer loop inside while loop or B. timer loop and the while loop seperatedly . I believe the problem in A because the timer loop in number 2 affects the while loop and in B because the data from the while loop (taken from DAQ) is not sent to the timer loop. How could I fix this?
Solved! Go to Solution.
A simple VI example would probably explain it much better that 20 more paragraphs of the same.
There seems to be some code with red numbers, blue sections and dark red uppercase letters in your post, but it makes little sense to an outsider. How do you "send" data to the timer loop?
Thank you for suggestion. To simplify the idea of what happen I use the two below instead (Sample rate 1000, Number of Sample is 1000). Case number 1: Waveform Graph and S2 will display each 10 second but I would like waveform Graph continuously display the data while S2 shows the reading each 10s. Case 2: Waveform Graph 2 continuously displays the data but S2 3 display nothing each 10s.
Both of your code fragments make no sense in terms of dataflow:
Left: The outer loop acquires one set of data, displays it on the graph. Then the code gets trapped in the inner loop until "stop 2" is pressed, at which point we grap another dataset and get trapped again inside the inner loop.. In the inner loop will update s2 with stale data every 100 seconds, no new data will get acquired while it is running.
Right: The loop on the right cannot start until the loop in the middle has stopped. It relies on data from the loop in the middle.
Why don't you design your program with a data simulator, then use execution highlighting to better understand dataflow.
In summary: You could use two independent loops, one for DAQ and one for the rare display event. Let them communicate with e.g. a queue or similar. You can also use a single loop. Place the second graph inside a case structure, and enable it only every n seconds.