LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Logging Data using Queues

Solved!
Go to solution

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

0 Kudos
Message 1 of 11
(2,918 Views)

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.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 11
(2,912 Views)

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

0 Kudos
Message 3 of 11
(2,909 Views)
Solution
Accepted by Jack_W

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.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 4 of 11
(2,906 Views)

I would also suggest that you put a delay in both the loops or else it act as a greedy loop.

 

Regards

 

Javed

0 Kudos
Message 5 of 11
(2,902 Views)

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.

 

 

 

0 Kudos
Message 6 of 11
(2,896 Views)

Problem solved, thanks for the help!

 

Cheers

0 Kudos
Message 7 of 11
(2,872 Views)

@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.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 8 of 11
(2,845 Views)

Hello Mark

 

Thank you for the correcting me. This is something new I learnt today. Smiley Happy

 

Regards

 

Javed

0 Kudos
Message 9 of 11
(2,826 Views)

@Javed H wrote:

Hello Mark

 

Thank you for the correcting me. This is something new I learnt today. Smiley Happy

 

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.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 10 of 11
(2,824 Views)