08-28-2008 10:31 AM
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 ?
08-28-2008 11:10 AM - edited 08-28-2008 11:14 AM
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.
08-28-2008 11:16 AM
08-28-2008 11:29 AM - edited 08-28-2008 11:32 AM
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".
08-28-2008 11:59 AM
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
08-28-2008 01:34 PM - edited 08-28-2008 01:35 PM
Note that the code in your subVI is flawed.
You are
... 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.. 😉
08-28-2008 02:07 PM
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 ) !!!
08-28-2008 02:20 PM
kmous wrote:... btw what a difference will be made if i use the arrow to the left ?
Sorry, what arrow????
08-28-2008 02:31 PM
08-28-2008 02:46 PM - edited 08-28-2008 02:47 PM
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.