LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

write to excel file slows down reading voltage channels

Hi all,
 
I read in input voltage data using PCI 6143 throught finite sampling. This VI is supposed to, for example, after acquiring 240 samples, I write all collected voltages to an excel file. Before I write the data into excel, I need to re-arrange the data array. This re-arranging task takes up quite a significant amount of time (about ~30ms). Hence, the 2nd batch of 240 samples collected is only done after arranging data and writing to file.
 
Hence the process will be like, 0.9milli sec of data, wait 30milli sec, 0.9milli sec of data, wait 30milli sec and so on.
 
So is it possible to pass this huge chunk of data to another VI, specifically doing the data manipulation and writing to file while the main VI continue collecting the voltage data without data losses?
 
Does anyone have any suggestion by which mean am I able to do this?
 
I saw a nice example in LV 7.1 example finder-> optimizing applications synchronizing tasks->Pass Data with Notifiers.vi
 
Is this notifier method the solution to my problem or is there some other means to achieve the results?
 
Thanks everybody!
 
Best regards,
Dick
0 Kudos
Message 1 of 12
(3,845 Views)
Hi Dick

I encountered similar problems. Thats why I changed my programs into writing to *.csv files. This is a semicolon or comma separated textfile. You can write in such file without the activeX overhead you need to write in excel. And the files will also be much smaller.

Regards

Yves
0 Kudos
Message 2 of 12
(3,839 Views)
Could you show some code of the rearranging, I can't imagine any operation on 240 datapoints take more than one ms!

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 3 of 12
(3,835 Views)

Hi Ton,

I know my data manipulation takes out a bit of time, okay, quite a lot of time. I attached my vi (finitie looping test.vi) with the sub vis. The sub vis are the data arranging stuff. Please point out any mistake in the program or if the data manipulation is doing something wrong. I have also attach my excel file result.

Thanks for your reply!

Regards,

Dick

Download All
0 Kudos
Message 4 of 12
(3,832 Views)
Hi Yves,
 
Thanks for your suggestion! I will try it out and see if it improves my situation. 🙂
 
Thanks again!
 
Regards,
Dick
0 Kudos
Message 5 of 12
(3,831 Views)
Hi Dick,

I have some question you set the Sample Mode to Finite samples, why. If you do this you will miss samples!
You start and stop the tasks every iteration, this will cause great wait times
You can move the constat vi's outside the while loops.
If you use continious samples you have to wire up the samples per channel to the ai read vi.

If i profile the VI I see that voltage data-constants takes 3.6 ms of time (average).

Also you should open the file outside the while loop and use the array to to spreadsheet string vi and write to text file to write the data. Successfully close the file after the while loop.

In general opening/starting/closing/ending should not be done inside a repetative loop.

It looks to me that 'voltage data constants.vi' generates an spreadsheet string from the data with a time column added.:
this can be done like this:

EDIT:Also you'r vi will 'remember' all the previous string and adds these together. If you don't want this initialize the shift register with an empty string, i missed the 'firstrun' case, but it is still better to initialize the shift register correctly, or you can connect the iteration number straight to the switch case
Ton

Message Edited by TonP on 09-28-2006 11:34 AM

Message Edited by TonP on 09-28-2006 11:45 AM

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 6 of 12
(3,828 Views)
Hi Ton,
 
Thanks for your reply!
 
You mean I should set voltage read's sampling to continuous or counter output's or both of them to continuous?
Previously, there's some kind of buffer overflow problem when I used continuous sample cause I took too long to process the data and the buffer became too full of data.
 
The start task is that I want the digital output to send a reset signal to the address (back to 00000) everytime before I read the data again.
 
I will try to move the constant string headings and the file i/o out of the string.
 
Thanks for your answers!
 
Regards,
Dick
 
 
0 Kudos
Message 7 of 12
(3,800 Views)
Hi Dick,

on my PC I saw that the voltage data constants VI took 3 ms. to process, the whole loop ran at 70 ms.
So the time consuming is in starting and stopping the task over and over again.

Ton

PS if you use continious sampling don't put anything on the samplecount at the daqmx timer vi
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 8 of 12
(3,793 Views)

Hi Ton,

Thanks for verifying this timing problem for me. I tried placing the start tasks outside the loop and ended up with error -200284. some or all of the sample have not been acquired.

I attached my simplifed vis, one with the start tasks out of the loop and the other with the start tasks inside the loop (basically is the old vi). I searched my Labview example and couldn't really find a vi that shows how to synchronize a voltage input read with a counter output frequency. Hope you can take a look at my vi and point out the problem.

Thanks again, you've been a great help!

Regards,

Dick

0 Kudos
Message 9 of 12
(3,791 Views)

Hi Dick,

Regarding synchronizing the counter operation with Analog Input. Looking at the code, I see that you are starting the Analog Input Task before Counter Task. Because of this even before the counter task is started, the analog input task will try to acquire. Because of this analog input task cannot find the sample clock for smaller duartion and will be timeout.

I rearranged the tasks so that the countertask starts before analog input task. This should fix the problem hopefully. Please post back if you still get the error.

Thanks,

Kalyan

Kalyanramu Vemishetty
Automated Test Systems Engineer
National Instruments
0 Kudos
Message 10 of 12
(3,762 Views)