LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

100% CPU Usage Problem

I am using Labview 7.1.  My system is a 2.26GHz Pentium 4 with 1GB of RAM.
 
My program is using GPIB data acquisition from two sources:
1) Keithley Instruments 238 High Current Source Measure Unit 
2) Agilent 8164A Lightwave Measurement System
 
My program is pegging CPU usage at 100%.  I'm not sure exactly what the cause is, but from the search I performed prior to this post I think it might be from too large of arrays.  Sometimes the program works for small range sweeps and my best results seem to come right after restarting both the Keithley Instrument and Labview.   However, it is not consistent even for small ranges and regardless I need operation over a large range. 
 
I've attached my .vi and would appreciate any help or suggestions you may have.  Please let me know if you require any further information.
 
Dave
0 Kudos
Message 1 of 6
(3,432 Views)
anyone with any suggestions?
0 Kudos
Message 2 of 6
(3,404 Views)
Dave,

1. Building data arrays by autoindexing at the output of a for loop is not the best way to manage memory, especially if the arrays can get large. Using Initialize array, a shift register and Replace Array Element is more efficient.

2. The sequence structures can be eliminated by using dataflow. Error clusters are very useful for this.

3. Calculating the number of iterations by subtracting and dividing nano scale numbers to get an integer does not seem like the best way. I would do the multiply by 1e-9 only on the values which need that scale.

4. Look at the state machine architecture as an alternative approach. It is more flexible and adaptable to change.

5. Can you use the Write to Spreadsheet File VIs rather than writing data points one at a time? Also, you do not need to wire to N on a for loop which has one or more arrays autoindexing at the input.

6. Look at the style guides. Most experienced LV programmers try to limit diagrams to one screen in size. Creating subVIs can help.

Having said all this, I am not sure why you CPU usage goes to 100%. Does it do it as soon as the program starts to run or only at a certain point in the program?

Lynn
Message 3 of 6
(3,394 Views)
Thank you very much for your response Lynn.  Admittedly I am neither a programmer or experienced with Labview so I am sure that code looked like a disaster to you.  I will look into your suggestions immediatly.
 
The frustrating part is that it works perfectly sometimes but other times it freezes up anywhere from immediatly to well into the sweep.  I ran it in the lightbulb stepper mode which took forever, but I seem to get a error #6 off of the GPIB Write blocks in frames 2 and 7 which seems to indicated a timeout.  Again it seems that this error only occurs once the CPU locks in at 100% usage.
0 Kudos
Message 4 of 6
(3,387 Views)
Dave,

The "lightbulb stepper mode" is called "Highlight execution." When a program works fine with it on and fails without it, it is usually an indication of a timing problem.

Can your instrument respond to the commands as fast as they are being sent? Some instruments have a command buffer and others do not. If the instrument is in the middle of e measurement, how quickly will it respnd to an incoming command (does it finish what it is doing first)? The instrument manual usually tells these things, but sometimes it is quite obscure.

Putting in some indicators showing what the program is doing can be useful. An iteration count indicator will tell you how many times the loop has run.

Lynn
0 Kudos
Message 5 of 6
(3,368 Views)

Dave,

Lynn is right, if it seems to be working in highlighted execution then the problem is with the timing in the VI. 

I noticed that some GPIB writes in your vi dont have any data dependencies (this is when different parts of your vi depend on another to execute thus thus determining when they will execute.)  For instance in your VI when you set the Input power and Laser State, there is no way to tell when these will execute because they are just "floating" on your diagram, they could even run after everything else thus causing timing problems and possibly the problems you are seeing.  If you add a data dependency to these GPIB writes it may help in the VI running more consistantly.

Brian

Message Edited by BrianPack on 06-21-2006 05:06 PM

0 Kudos
Message 6 of 6
(3,362 Views)