From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

PXI

cancel
Showing results for 
Search instead for 
Did you mean: 

Optimize vi - Using PXI 8185

Looking on suggestions to make my code more efficient.  Monitoring my CPU usuage while the program is running I'm dangerously close to 100% and with the code as it is I'm only about 40% complete.  I'm not sure if the memory upgrade availible for the 8185 will be enough to get things handled or if I should recommend a stronger platform.  Any suggestions?
LabVIEW 2016 - Windows 7

CLAD
0 Kudos
Message 1 of 7
(3,732 Views)
Also note that I'm using the PXI-4461 and PXI-4462.
LabVIEW 2016 - Windows 7

CLAD
0 Kudos
Message 2 of 7
(3,725 Views)

Hi MeCoOp,

Whenever you have a loop, it is good practice to include a wait function (found in the Timing Palette) within it.


Otherwise the computer will execute the code within the loop as quickly as it can, thus consuming all your computer’s resources.

 

Message Edited by Mark E on 10-22-2007 09:12 PM

Mark E.
Precision DC Product Support Engineer
National Instruments

0 Kudos
Message 3 of 7
(3,716 Views)
Mark, I was under the impression that a timing function was not needed since the loop only reads when the cache is full.  With my settings of 25000 Hz and 5000 samples I calculated an iteration time of 0.2 seconds.  Is this correct?
LabVIEW 2016 - Windows 7

CLAD
0 Kudos
Message 4 of 7
(3,709 Views)

MeCoOp,

Do you want to achieve a specific timing of the loop or just process samples as quickly as possible? The loop will wait for all of the samples specified by the DAQmx Read VI before passing its output to the rest of the loop. Without a wait function inside the loop, it will go right into the next iteration of the loop without giving the processor any rest. This will make your processor run at 100% no matter how efficient your code is inside. It also makes your process prone to timing inconsistencies when Windows decides to run a different process instead of your VI.

Your code looks lean to me. I suggest adding one extra error handling step: make your VI stop if it encounters and error, rather than waiting until you stop it. I’ve done this in the code (by unbundling the error status and OR-ing it with the stop button) and posted it back so you can see it. I’ve also added a function that will show you the time delay between loops. Feel free to take it out.

Mark E.
Precision DC Product Support Engineer
National Instruments

0 Kudos
Message 5 of 7
(3,697 Views)

Mark, thanks very much for your help!  I've been hesitant to load LV 8.5 on my computer because of some of the problems some of the board members have run into.  Can anyone save the "tweaked.vi" in 8.2.1 so I can view it?

Thanks.

LabVIEW 2016 - Windows 7

CLAD
0 Kudos
Message 6 of 7
(3,692 Views)
There you go. Let me know if there's more I can do.

Message Edited by Mark E on 10-25-2007 08:41 AM

Mark E.
Precision DC Product Support Engineer
National Instruments

0 Kudos
Message 7 of 7
(3,687 Views)