LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Lagging Data Acquisition

Solved!
Go to solution

Hi All,

I have an issue with my code (relevant section image shown below) and I am hoping you guys can help me understand why I am experiencing the problem that I am.  The problem experienced has to do with the acquisition rate wired to the daqmx sample clock.  When my VI is running, there is no prblem with the data displayed on the waveform initially regardless of the acquisition rate I specify.  However, when the true case is initiated inside the case 1 structure and I reinitialize my daqmx task, I experience extreme data lagging problems (the waveform chart, data logging, and user inputs lag way behind data changes) if I set the acquisition rate above 400Hz.  As long as I keep the acquisition rate below 400 everything seems to work fine but once I go above that rate, I experience the problem only when the true condition is met inside the case 1 structure and so I switch to acquiring and reading the data in the while loop that is inside the case structure.  I hope my explanation of the problem is clear enough and I would appreciate any insight as to what might be going on here.  Thanks.

problem code.PNG

0 Kudos
Message 1 of 4
(3,558 Views)
Solution
Accepted by topic author crockengineer

I think your major lag is due to that property node.  A property node is HORRIBLY slow to write to.  The simple solution could be to replace it with a local variable.

 

A better solution would be to use a Producer/Consumer architecture.  Since it looks like you only care about logging the data when above 300, you could just enqueue the data when above 300 and then your logger just sits there and waits for data to come in when you are lower than 300.  This will help since you will not have to destroy and recreate your task and have duplicate code.  This is one of the few times I would recommend not to use the DAQmx Logging capability.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 4
(3,531 Views)

You were exactly right crossrulz.  I switched the poperty node to a local variable and the lag went away.  I had no idea that a property node would create such a drastic slow down.  Thank you.

0 Kudos
Message 3 of 4
(3,480 Views)

@crockengineer wrote:

I had no idea that a property node would create such a drastic slow down.


Let me put it this way, the last time I did the benchmark, the property node was about 10,000x slower than the local variable.  The local variable was slightly slower than writing to the terminal.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 4
(3,466 Views)