LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Open spreadsheet on demand and add data

Solved!
Go to solution

Using a cDAQ 9172 and Labview 8.2, I am collecting four channels of noisy pressure and temperature data that are gathered during a product test.  The data are displayed live on strip charts on the front panel after being smoothed by the mean feature of the Sample Compression Express vi.  This all works pretty well. 

 

The data are presented to the test operator so he can see when test conditions have stabilized, which usually takes 3 to 5 minutes.  After stabilization, I want to be able to press a button on the front panel so that a spreadsheet is opened (ideally, with the initial opening time as part of the file name) and one scan of the four channels of data are added to the spreadsheet (along with a timestamp).  Then, as the test progresses for another 1 or 2 minutes, I want to be able to again press the button every 10 or 15 seconds or so to add more scans of data so that we can later see that the conditions had actually stabilized.  The exact timing and number of additional data scans is not critical, I just want to be able to log another 4 to 8 lines of data before ending the test.

 

I have a way to sort of do this, shown on the attached "on demand spreadsheet.vi" below.  The noisy signals are shown here simply as random numbers built into an array (which is how my data is presented to the write to spreadsheet file in my real program).  The problem with this arrangement is that the spreadsheet file is created every time I start the vi, and there are many times when tests are run and data is not collected for whatever reason.  As a result, we would end up with a large number of .xls files with no or meaningless data.  I only want to create the spreadsheet file when I press the button(s) during a successful test after conditions have stabilized.

 

spreadsheet.PNG

 

I tried a slightly different approach in the attached "on demand spreadsheet 2.vi" below where I added a toggle switch to activate a case to open the spreadsheet, along with an additional button to record data.  It seems like this should work, but I do not get any lines of data, just the headers.

 

spreadsheet2.PNG

 

I am still pretty new to all of this and I have spent days trying to figure this out.  Any help is greatly appreciated.

 

 

 

 

 

 

 

 

Download All
0 Kudos
Message 1 of 8
(3,459 Views)

I put a delay inside the loop, 100mS.  You should put a delay inside a loop to avoid chewing up 100% CPU time.  Then I ran the top vi.  It recorded every time I hit the Record Data button.  I don't see a problem.  Maybe the delay is what fixed it.

 

Don't use the second vi.  When the boolean is true (the outer case), it will create the file over and over on every loop iteration.  This is not what you want.

 

Message Edited by tbob on 06-02-2010 04:17 PM
- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 8
(3,447 Views)

Thanks, tbob, good point about the delay, but the problem is not with the first vi not working (it works even without a delay), but the fact that it creates a spreadsheet file even if I don't add any data (and therefore the spreadsheet would only show headers without data, a useless file).  I only want to create the spreadsheet file in the case where I actually push the "record data" button.

0 Kudos
Message 3 of 8
(3,443 Views)

Do you want to create a new spreadsheet file everytime you push the button, or do you want to add to the existing file.  If you want to add to the existing file, you will have to create a file with headers first, like in your first vi.  This is usual practice.  Your first vi works fine.  If you don't record any data, just delete the file.

 

But to do what you want, you would have to set some kind of flag that tells if the file has been created.  The flag (a boolean indicator) should be set to false before the loop.  Create a local variable to use inside the loop.  Upon pressing the record button, in the True case, use another case to check the flag.  If false, create the file with headers, and set the flag to true.  If True, do nothing.  After the case, record your data.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 4 of 8
(3,435 Views)

Here is what the vi would look like.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 5 of 8
(3,429 Views)

Thanks again, tbob.

 

No, I don't want to create a new file each time I push the button.  Once the file is created, I just want to add lines of data and then close the file after I stop the program.  Then, next time I run the program AND push the button, create a new file (with a different name due to the time string added to the path), add lines of data and close, etc.  The times that I run the program but do NOT press the button, I do not want to create a file.

 

I think I understand your suggestion, but since I am running 8.2, I can't see your vi.  Could you send it again in 8.2?  Thanks!

0 Kudos
Message 6 of 8
(3,420 Views)
Solution
Accepted by topic author pfrank

I don't have 8.2.  You could either save my vi and post it to the Downconvert VI Request thread, or you could just look at the picture:

 

OnDemandSpreadsheet.png

- tbob

Inventor of the WORM Global
Message 7 of 8
(3,381 Views)

tbob, thank you so much, your vi does exactly what I wanted! 

 

-pfrank

0 Kudos
Message 8 of 8
(3,337 Views)