LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to optimize data logging in my code?

I have my program working well enough to have it run some trials in the lab. It was run under some 'extreme' conditions to make sure data acquisiton and logging is working well.

 

With frequency being 1000Hz, he requirements are that the relay goes ON for 20ms and and stays off for 250ms. This 250ms should equate to 250samples gathered.

 

After a run, the saved files range from 240 to 280 samples for a 250ms setting, but some are as little as 150 samples. I need to ensure that the correct number is logged, a +/- 5% variation is 'OK' but when the samples gathered are close to half of the desired is unacceptable.

 

I need the graphs wired to 'data[0]' and 'data[1]' to update in real time, to be smooth.

 

Any suggestions? Every time my consumer loop executes, how many samples does my DAQmx Read, at current, receive? I do not think it's an issue w DAQmx setup, but I am not 100% sure..

 

Capture.JPG

0 Kudos
Message 1 of 5
(2,641 Views)

I should add that my logging happens when the "injecting?" is FALSE  and RelayPower boolean is TRUE and 'SAVE' is TRUE so it is dependent on that.

I imagine that is my main issue?

0 Kudos
Message 2 of 5
(2,636 Views)

You should move the writeing to file to a seperate while loop.

File operations, write or read, are slow and take some time to complete.

 

Displaying data should also be in a seperate loop.

 

Then you should be left with only DAQmx read functions in that loop.

 

 

 

0 Kudos
Message 3 of 5
(2,592 Views)

You should also clean up the wiring.  It is difficult to tell where some of those boolean wires are going.

 

Also, it is a Rube Goldberg construct where you are converting your array of waveforms to a cluster, then unbundling.  You should just use Index Array.

0 Kudos
Message 4 of 5
(2,572 Views)

Is there any reason you're not using compound arithmatic to get into the logging loop?  What happens in those false cases?  If you're just wiring everything through, you'd be better served to only use one case structure.  Feed all three boolean values into a single compound arithmatic set to AND.  If all three are true, after the NOT used to invert the false value, it will enter the true case.  Otherwise, it'll enter the false case.  It's the same logic, but it's handled better.

 

You might consider taking a look at Producer/Consumer or Queued Message Handler.  You can use these to send a message to an external while loop.  If you have multiple cores, this makes it easy to split the task to read data on one core and leave it mostly unaffected by the logging process done on another core.

0 Kudos
Message 5 of 5
(2,555 Views)