06-19-2012 03:16 AM
Hi,
I am trying to continuously measure data (i.e. a voltage signal) using DAQmx and storing the data.
In an old setup, I stored the data to an array, and whenever this array reached a certain size, I saved it to a file. However, this caused a loss of data during the storage.
So I read about using queues, had a look at the examples, read some tutorials and thought I understood the principle.
However, I can't get my example to work.
Thanks for any help.
Regards,
Jack
Solved! Go to Solution.
06-19-2012 03:36 AM
What is the problem you are facing with the code. I see you are always reading the queue but writing to the file conditionally so you will loose the data whenever you boolean is false. So for conditional writing you should not read the queue continously. Check the attached code.
06-19-2012 03:46 AM
Thanks.
The problem is, that the data from my device is not stored in the file.
I see the sine wave I want to save in the chart, so the producing loop works fine.
But when I put a probe at the array I want to store, it is "not executed".
Thanks for any further hints.
Regards
Jack
06-19-2012 03:52 AM
If the 2nd while loop is not executed then it means that the local variable is still holding the same old true value so whenever you run the code the local variable stops the 2nd while loop. Clear the local variable at the beginning of the code and run it and check with the vi I attached.
06-19-2012 03:55 AM
I would also suggest that you put a delay in both the loops or else it act as a greedy loop.
Regards
Javed
06-19-2012 04:15 AM
Thanks again.
This solved the problem with the second loop.
Now, the data stored in the file is not one nice column anymore though...sort of a different issue.
Could you explain why my way of logging was not really good? choosing between logging and not logging could be chosen before running the program.
Anyway, working the cues did not solve my main problem: When I sample a 1 kHz sine wave with 2.5 kHz using the VI attached (the first version I attached in this case), I still get some problems in my sine wave around amp=0, as shown in the graph. This is the same problem I had before, which I hoped to solve using cues.
06-19-2012 06:58 AM
Problem solved, thanks for the help!
Cheers
06-19-2012 10:35 AM
@Javed H wrote:
I would also suggest that you put a delay in both the loops or else it act as a greedy loop.
Regards
Javed
This is not necessary when you have a dequeue/enqueue in the loops. They will allow the scheduler to check a context switch as well as prevent the loops from being greedy loops.
06-19-2012 01:34 PM
Hello Mark
Thank you for the correcting me. This is something new I learnt today.
Regards
Javed
06-19-2012 01:41 PM
@Javed H wrote:
Hello Mark
Thank you for the correcting me. This is something new I learnt today.
Regards
Javed
There are other items that will allow the scheduler to check for a context switch as well. Notifies, queues, communication VIs (VISA, TCP, etc). Basically anything that has a timeout will allow a context switch and prevent a greedy loop.