LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

High CPU usage during 15 acquiring analog input and write to file (suggestion needed)

Helllo everybody,

 

      I have a problem about the usage of CPU now i am using a realtime target (PXI-8186) with Daq (PXI-6259) to get 15 analog signals at the rate of 10kHz

at first i try to get signal at different rate but i found out that all of the channels share the same clock so i get the highest frequency that i desired  after that i do 

some data manipulation with displaying charts  and use shift register to stack data in array of string  finally i write the data to spreadsheet every  5 second, by doing this the CPU usage

is always 100% and reduce by the time the file is recordedto 71% or so and then start to increase to 100% again. I think  the things that make CPU usage too high are

 

1. Time loop: because i set the period to be 10ms maybe this is too low.

 

2. The shift registered: may be it use too much overhead memory but i do not know other method to stack data before writing to a file 

 

3. RAM too low: The RAM of PXI is only 256mb

 

4. Poor program arrangement: Because i am new to labview the program is not arranging correctly or i may use some inappropriate structure.

 

My program is very messy sorry about it because i avoid using SubVI and i am new to labview. Please help any suggestion is apperciated. Thanks in advance.

 

Best regard

Wuttikrai

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

You defenetly have to put some effort to restructure your code.

 

Thing to avoid

 

Build Array: This will lead to memory leak when you use it un conditionally. You are building the array and keeping them in the shift register, which consumes your RAM a lot

Data Acquisition: Unless you don't have any specifi requirement don't acquire the data as a waveform as it packs additional data along with the real data you need. You can simply acquire the data as a DBL value and write that to a file.

Formula Node: You have all the mathematical functions available with LabVIEW so there is no need to use this.

Graph Display: Don't do this in RT itself, bring the data to the host and display it.

File Writing: Best method as always suggested is, put a queue and transfer the data to another loop but in your case you can send the data to the host and save it there. Also when you are using continous Read/Write operation in file use the Write to text file primitive along with Array to Spreadsheet function. Write to spreadsheet VI opens and closes the file everytime you execute.

-----

The best solution is the one you find it by yourself
Message 2 of 5
(2,751 Views)

 

 

 

 

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

It looks like you are writing your data to disk every so often.  For that reason, I recommend making it based on the number of samples you have instead of the time.  With that you can preallocate your arrays with constants going into the shift registers.  You then use Replace Array Subset to update your arrays.  When you write to the file, make sure you go back to overwriting the beginning of your array.  This will greatly reduce the amount of time you spend reallocating memory and will reduce your memory usage.


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 4 of 5
(2,715 Views)

@greed wrote:

 

 

 

 


Crossrulz already has given a good advice.

 

If you still struggle to initialize your array and use replace array subset, run the loop at 1KHz with "1" as dt and acquire single sample/channel. Here you can define the array size as 15 and use replace array subset and pass the data to another loop and pack the data send it to host. I believe 1KHz data is good enough to analyze the data.

-----

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