LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

report generation write to file at interval

Hi,

 

I am using the report generation toolkit to write data to an excel sheet. I am recieving a lot of data but only want to save the data to the excel sheet every minute. I have found threads about doing this with the Write to Measurement Express VI but I am not using that and am unsure how to translate that code to something I could use. Any ideas? I have tried using a case selector around all of the report generation VIs but that doesn't seem to work...

 

Any help is appreciated!

0 Kudos
Message 1 of 27
(4,852 Views)
Why doesn't it work? What did you wire to the case selector? The Elapsed Time function is one obvious way to set a save interval.
0 Kudos
Message 2 of 27
(4,844 Views)

The answer is "Of course this is possible".  However, it is not at all clear what you are trying to do.

 

We have an application where we run an Experiment with Trial parameters that define the particulars of the Trial.  Each row of the Spreadsheet has about 60 columns.  Each Trial, we read the entire row, and at the end of the Trial, we write the row back (filling in a few columns with Trial-specific results).  Trials take from 5 to 50 seconds (depending), and an Experiment can have 150 Trials.  We do it all with the Report Generation Toolkit -- so can you.

 

Bob Schor

0 Kudos
Message 3 of 27
(4,832 Views)

Yes I figured I had to use the Elapsed Time function and that is what I have hooked up to the report generation portion of the program. However, it is still reporting all of the data. I only want it to report every minute and to report the average of all the data taken in that minute. I am using the mean.vi in my subvis to take the average of that data (if that is the correct way to go about it). What am I missing?

 

0 Kudos
Message 4 of 27
(4,775 Views)

You are writing all of your data to the report when you exit your main loop.

 

If you only want to write a one minute intervals then you need to have your write to report inside your program loop.

 

You also will have to rewrite your report section almost completely if you don'w that all the headers repeated with every write

 

Frankly I have found the report tool useless.

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 5 of 27
(4,764 Views)

I tried putting the report generation inside the while loop but it stopped with an error which I think was caused because the report generation creates a new report and if it is in the loop, then it will create a new report every time it is just supposed to be recording the data. Maybe that is wrong but as of now, my program isn't working if everything is inside the while loop. Unless, what I have said is incorrect and I just connected it wrong?

0 Kudos
Message 6 of 27
(4,750 Views)

Yeah that is one of the reason's why I found it useless.

 

Do you really NEED to out put an Excel file (.XLS)?

 

It is a lot easier to just write text to a .csv file and open it in Excel. 

 

If you really need to have an Excel file out put then I suggest you look into one of the third patry add-ons like XLR8. https://www.ni.com/en-us/shop/product/xlr8.html

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 7 of 27
(4,744 Views)

 

Frankly I have found the report tool useless.

 


I, on the other hand, find it Wonderful, Powerful, a Joy to use.  It took me about ten minutes to knock off a demo that writes rows of data at the rate of once per second (you can obviously do it slower ...).  Each row is 5 random numbers + the row index (so the first row is (0,1), the second is (1, 2), etc.  I didn't put in "fancies", like headers (which would be done outside the While loop).

Excel Report Demo.png

The computation inside the In Place Element structure makes each Append Table to Report start on a new row.  The other "trick" is that this function needs a 2D array, so I pass my 1D array of 5 numbers through a Build Array function to "fatten it up".  And no ActiveX is required!

 

Bob Schor

0 Kudos
Message 8 of 27
(4,722 Views)

@Bob_Schor wrote:

 

Frankly I have found the report tool useless.

 


I, on the other hand, find it Wonderful, Powerful, a Joy to use.  It took me about ten minutes to knock off a demo that writes rows of data at the rate of once per second (you can obviously do it slower ...).  Each row is 5 random numbers + the row index (so the first row is (0,1), the second is (1, 2), etc.  I didn't put in "fancies", like headers (which would be done outside the While loop).

 

The computation inside the In Place Element structure makes each Append Table to Report start on a new row.  The other "trick" is that this function needs a 2D array, so I pass my 1D array of 5 numbers through a Build Array function to "fatten it up".  And no ActiveX is required!

 

Bob Schor


Nice, can you help  @kmarcella work that into his code?

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 9 of 27
(4,710 Views)

Nice, can you help  kmarcella work that into his code?


Well, the example that I post shows the Big Picture for doing what KMarcella wants to do, namely collect data periodically (like once a minute) and write all of the data, presumably one Excel row at a time, to an Excel Workbook.

 

The Original Poster has the best understanding of the details of the task, but here are some suggestions that should help him (or her!).

 

  • Divide the task into phases.
  • Initialization Phase -- set up DAQmx channels, define timing parameters, open Excel Workbook.
  • Loop (repetitive) Phase -- take a single reading, write a single row (or rows) into Excel, and wait for the next point.
  • Finalization Phase -- close DAQmx, save the Excel Workbook and Dispose Report.

Note that these phases are illustrated in the example -- there's stuff before the loop, the loop, and stuff after the loop.

  • Strive for compactness and simplicity.  Try to fit it on a single screen (1280 by 1024) -- use sub-VIs where necessary to "encapsulate" (or "hide") the Messy Details.
  • Try to not use Express VIs.  For example, a simple Wait to Next ms Multiple is much simpler, more compact, and intuitive than Elapsed Time.  You are to be commended for using DAQmx calls directly.
  • I am completely befuddled by your use of the Dynamic Data Type.  It looks very complicated, lots of extra wires, bloating the Block Diagram.  It might be necessary (only you know the requirements of the task), but I suspect there is a simpler solution that works with the arrays of data directly.
  • However, that raises another question as to the nature of the data being collecting and the data being saved.  I notice that you are sampling M channels, N samples (I don't know what M and N are),  Am I correct that you are sampling way more points than you are writing to Excel?  If you are only doing one write a minute, are you sampling faster than 1/minute?  What are you doing with the other points?
  • The reason for the previous question is that my model of your task might be wrong!  I'm assuming (and my code does this) that you sample periodically (one sample at a time) and write each sample to Excel.  On the other hand, if you are sampling frequently and writing infrequently (say, sampling at 100Hz, maybe displaying the data, and writing a "representative point" every minute), then my model, with the writing in the same loop as the sampling, should probably be replaced with a Producer/Consumer pattern, where you "export" a point once a minute to a parallel "Write-to-Excel" loop.
  • Another possibly-helpful example is one I posted here about a year ago.  If you go to the Search box and type the word Revised, the first entry that pops up should be my earlier post.  I think it's a snippet -- try it out and adapt it to your problem (as far as formatting and structuring the page).

Bob Schor

Message 10 of 27
(4,686 Views)