LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VI running very slow!!

Solved!
Go to solution

 

LabView Gurus,
I acquire two signals with 20ms time window, perform my calculations, plot the result and record data ( which is just one 'double') in a table against time.
Now ideally, I should get 50 results in one second, whereas VI writes about 16-18 results in one second and this number goes down slowly as time increases. I am using Labview 2009 (32-bit), Windows 7 Professional (64-bit), Core i-3 2.27 GHz with 4GB ram on an ASUS laptop. The processor loads up to 30% when VI runs.
To explain the VI operation, data from two signals is acquired every 20 milliseconds which is a sine wave and a pulse  square wave. I calculate the phase difference between the signals by measuring the time difference between their zero crossings and then multiplying by time period and 360. Several 'if' 'else' situations have been addressed... This phase difference is measured and stored in an excel file located in the same directory with every iteration of while loop until the 'SWITCH ON BEFORE LOADING' switch is turned on, after turning this switch ON, the VI reads the same excel file and subtracts the new phase difference from the initially saved one, writes the result in table and plots waveform. All the elements on the front panel need to stay there as we need them for the presentation. However, the 'meter indicator' can be removed which doesn't really made any difference when I tried.
Ideally, VI should write one value in the table every 20ms and clearly the calculations are taking a lot of time.
Any help would be greatly appreciated.
I have attached the zip file with all sub-VIs as well as the single VI with no subs.
Regards,
Awais

 

Download All
0 Kudos
Message 1 of 18
(9,732 Views)

hello,

 

many thing but the mains i see :

 

- There is no time delay (wait) so cpu is always 100%

 

- why opening xls file at each loop iteration couln't you opening once in a table and then picking  up data

 

- a minor why using so many if and not a case selector ?

 

Regards

 

Tinnitus

 

CLAD / Labview 2011, Win Xp
------------------------------------------------------
Mission d'une semaine- à plusieurs mois laissez moi un MP...
RP et Midi-pyrénées .Km+++ si possibilité de télétravail

Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
Don't forget to valid a good answer / pensez à valider une réponse correcte
Message 2 of 18
(9,715 Views)

tinninus,

 

If by replacing 'read from file', you mean making a local variable, I have already tried that where I write to a local variable on the first call after switching on the "SWITCH ...LOAD"  and then in the next flat sequence, I read that variable. But it didn't help. Instead this made the program even slower for some reason.

 

Do you mean a 'case structure' or a case selector? I am using the 'Select' block for 'if' 'else' scenarios. The reason for keeping all of those select blocks is due to the nature of the signal that I am acquiring from a sensor. (I am happy to explain this in detail if you think this is root of the problem).

 

Awais

0 Kudos
Message 3 of 18
(9,707 Views)

As long as you are using the read/write from/to file, you will never achieve that fast a rate. Why don't you operate on the data kept in a shift register?

Message 4 of 18
(9,694 Views)

tried using shift registers as well.. didn't make any difference. One thing I noticed was that removing the graphs from the front panel solves the problem completely. The challenge is to keep the graphs there and still get a faster rate (close to 30 results per second)...

0 Kudos
Message 5 of 18
(9,679 Views)

I think your biggest problem is that you are using a comination of shift registers and building an array, along with the Build Table Express VI.

 

The Build Table Express VI maintains a history of what has already gone to it and adds more data to the array.  So there you have a growing array inside of it.  But you take those results and build that array into another array you are maintaining on the shift register.  So that shift register is growing exponentially on each iteration based on the new larger array coming out of the express VI.

Message 6 of 18
(9,662 Views)

The Build Table VI adds every new element at the bottom of the list whereas I need the new data to be placed at the beginning of the table. I couldn't think of any efficient way of doing this.. possibly because of my limited skills in labview. Is there any better way of reversing table values?

0 Kudos
Message 7 of 18
(9,655 Views)

Swap the order of the inputs into the Build Array function so the new data goes into the upper input and the older data from the shift register goes into the lower input.  Then eliminate the Build Table Express VI since the Build Array function and shift register is already building the table for you.

Message 8 of 18
(9,642 Views)

Just tried this method (replacing table with array using shift-registers)...As I need the time against each value, I had to make a cluster with each element of cluster having time stamp (from get time function) and the result that is a 'double'. Still the same speed (16-18 results per second)...

0 Kudos
Message 9 of 18
(9,636 Views)

Post your latest VI so we can see.

Message 10 of 18
(9,629 Views)