LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

writing to spreadsheet excel problem

Hi Guys , I have a problem with my VI , it is working well , i am measuring Temp from my devices.

The problem is that I want to save the measurements in excel file on c:\data.xls (writing too) , while i am running the VI , it writes to my excel file but when I stop the VI , my .xls file is 1 kb (has no data only header info channel 1 , channel 2 , channel 3.....)

why is that ? 

LV 8.2
0 Kudos
Message 1 of 12
(3,749 Views)

Your Untitled5 subVI is missing, perhaps the problem is in there.

 

I would guess that the way you have things written, the Untitled5 subVI is running 1 more time after you stop the inner most loop, because the Exit button would have already been read in the outer loop as False.  So the outer loop runs one more time, the subVI runs again, it probably is not set for appending data.  The inner loop doesn't restart because you are not starting again.  Then the Exit button gets read as True and stops the outer loop.

Message Edited by Ravens Fan on 08-28-2008 12:14 PM
0 Kudos
Message 2 of 12
(3,739 Views)
When the acquisition stops, you are still calling the VI that creates the headers each and every iteration. I don't understand why you need to do this at all but obviously something in this VI is creating a new file and overwriting your data. You have no provided that subVI. Why don't you just move it out of the while loop?
Message 3 of 12
(3,735 Views)

Ravens Fan wrote:

Your Untitled5 subVI is missing, perhaps the problem is in there.

 

I would guess that the way you have things written, the Untitled5 subVI is running 1 more time after you stop the inner most loop, because the Exit button would have already been read in the outer loop as False.  So the outer loop runs one more time, the subVI runs again, it probably is not set for appending data.  The inner loop doesn't restart because you are not starting again.  Then the Exit button gets read as True and stops the outer loop.


No, the boolean from the inner loop is "OR'd with the outer termination condition, so the outer loop should stop just fine after pressing "exit", however the "pause" button would force a rewriting of the header and possibly clearing of the data.

 

Overall, the writing of the header is in the wrong place. Currently, you rewrite the header with every iteration of the outer loop, even if no DAQ takes place. This is pumping a lot of hot air.

 

You have not shown us the missing subVI, but a quick and dirty solution would be to add some logic to it so it only writes the header if the file does not exist or has zero size.

 

 

There are also better ways to slice out a few rows or colums than going the detour over dynamic data. Think "index array".

Message Edited by altenbach on 08-28-2008 09:32 AM
0 Kudos
Message 4 of 12
(3,734 Views)

This is My SubVI....

Dennis was right I just put my Subvi outside the loop and Data still there , did not overwrite it 🙂

it is working now 🙂 but still is that a good thing ? I am happy with the output file i am getting my values.

Thank you GUYS

LV 8.2
0 Kudos
Message 5 of 12
(3,730 Views)

Note that the code in your subVI is flawed.

 

You are

  1. writing to the file and
  2. opening the same file in parallel

... without any control what (1 or 2) occurs first. SInce the "write to text file" does a "replace or create" automatically, you should delete the "open/create/replace file". It has no purpose or function and only clutters the code.

 

Of course any good subVI should also have a reasonable name, e.g. "writeHeader.vi" in this case or similar.. 😉

Message Edited by altenbach on 08-28-2008 11:35 AM
0 Kudos
Message 6 of 12
(3,701 Views)

yes LOL i am gonna change the name of my VI 🙂

I removed the open/create/replace file......it is working well , btw what a difference will be made if i use the arrow to the left ? i wanna add 4 more channels (total 8 ) !!!

LV 8.2
0 Kudos
Message 7 of 12
(3,691 Views)

kmous wrote:

... btw what a difference will be made if i use the arrow to the left ?


Sorry, what arrow????

0 Kudos
Message 8 of 12
(3,682 Views)
the pink arrow in my subvi that goes into Concatenate strings. 🙂
LV 8.2
0 Kudos
Message 9 of 12
(3,675 Views)

Ah, you mean the TAB diagram constant. 😄

 

The arrow seperates your strings by tabs so excel can correctly interpret the fields (remember, you are not writing a native excel file, but just a plain ASCII table with tabs separating columns and newlines seperating rows).

 

An easier way would be to write the headers as a 1D spreadsheet. Less code and more scalable.

 

SImply change N for the desired number of channels.

 

Message Edited by altenbach on 08-28-2008 12:47 PM
Message 10 of 12
(3,669 Views)