LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

data logging into excel

i am workinng on Labview2014 and currently i am doing event based data logging in excel file. the logging part is working properly.

but my requirement is to rename and save that excel file and generate again new excel file for data logging ofcoures on event basis

i am trying hard on this but results in lots of error. kindly  help in for this isssue or any suggestions?????

0 Kudos
Message 1 of 7
(4,519 Views)
You've neither explained the 'lots of error' or attached your modified code. Pretty hard to help with all of the essential details missing from your post.
0 Kudos
Message 2 of 7
(4,507 Views)

i have attached latest working vi file in which i have to modify for auto save logged data and rename current file with new one and also clear the file for new logging.

0 Kudos
Message 3 of 7
(4,494 Views)

i have filtered the VI so that you can easily get my point what exactly i want to design. I hope this VI will be usefull.

0 Kudos
Message 4 of 7
(4,438 Views)

Some general comments:

  • When developing code, don't worry about the final design of the Front Panel.  In particular,
    • Don't Maximize the Front Panel -- keep it as small as practical (so you can see both the Front Panel and Block Diagram together).
    • Don't scale controls with the Front Panel (so you can scale the Front Panel to be as small as practical).
    • Keep your controls grouped together (to keep the Front Panel as small as practical).
  • Always have an Error Out (so you can "see" the error).  The Error Number might give you a clue.
  • Do you know how to "watch" a program execute (by turning on Highlight Execution, the Light Bulb icon on the Block Diagram)?  If you did, you would have seen an Error -41003, File Open Error, occur when you tried to execute Save Report to File (and might have seen that Dispose Report "got stuck").  If you don't want your code to run "slowly", you can also place a Probe on a wire.
  • Once you get an idea what might be wrong (such as "Why does Save Report to File generate a File Open error?"), you can look at the Help for a function and see if that gives you a clue.

Look at the Save Report to File function.  Read its Help file (right-click on the icon, choose Help).  Make sure all the inputs that need to be there are present.  Look for any that say "If the path is empty or invalid, the VI returns an error".

 

I only looked at your last "focused" example code.  According to the Front Panel description, you want this to run daily at 8 am, yet you have a manual trigger and a manual stop.  I'm assuming that you'll have an external way of starting the program at 8 am, a way of internally triggering it, and an internal way of stopping it.  You can consider generating a unique file name by concatenating a descriptive name ("Log File") with a TimeStamp String ("31 Dec 2014 0800").

 

Bob Schor

0 Kudos
Message 5 of 7
(4,425 Views)

Thanks a lot for your valuable suggetion sir. If you have a look on my pervious VI, i am reading data from PLC on modbus all the time for monitoring but i log the specific data only after comparison. this conmparison indicates a START and STOP of specific cycle. And at that moment only i am logging data into EXCEL. all this task working properly. But i want to create a new file daily at 8am automatically with date as a file name log the data for whole day and on next day save that file and create new on and repeat the same.

0 Kudos
Message 6 of 7
(4,359 Views)

Your original post had the phrase "Event-based data logging".  Using the Event structure is a great idea, as LabVIEW basically stays idle while waiting for an Event, allowing your computer to work on other tasks.  But your code does not seem to include this structure.

 

To solve the problem you have outlined, it is sometimes (always?) better to start by "Writing the Documentation First", which tends to force you to think about the higher levels of What do you want to do, and less about How you will do it.

 

Some questions to consider:

  • How long is the period of a single log file?  [Is it 24 hours?]
  • How long will the entire program run?  [Several days?  Several weeks?]
  • How will data be collected?  Every hour/minute/second/millisecond, or "when something interesting happens"?
  • Can you tolerate a few seconds of "blank time" between the end of one Log file and the beginning of the next?
  • What is the relationship between starting and stopping your program and starting and stopping the Logs?

The last question relates to your requirement that the logs start at 8 am.  I presume that the main program can be started at any time, and can end at any time -- how are you thinking about the timing of the top-level "control" routine and the (possibly multiple) Log routines, which may start/stop at different times than the main?

 

When I think about this task "in the abstract", what occurs to me is a combination of a Producer/Consumer pattern and a State Machine.  It seems to me that you have several "States" that you might have to accomplish this task:

  • Wait until the Start Time (8 am)
  • Open Time-stamped Excel File
  • Collect Event-driven Data points
  • Close Time-stamped Excel File
  • Exit

Again, don't worry too much about the details yet.  I'd also strongly encourage you to "hide" the details inside sub-VIs -- among other things, it will make the Block Diagram of your Top Level program much more compact (and allowing it to fit on a single Computer Screen), which, in turn, will make it much easier to see and understand the overall logic of the code.

 

Here's an example of how you might code the Wait until Start Time state.  The first thing to do is to compute how many seconds there are until Tomorrow at 8.  To do this, you first need the TimeStamp value for Tomorrow at 8.  This Snippet will give this to you:

Tomorrow at 8.png

It starts by converting the current time to a Time Record.  The In-Place Element Unbundle/Bundle function lets me set the time to 8 am, which I then convert back to a TimeStamp (in seconds).  Since I don't want fractional seconds, I round down to the nearest integer.  Finally, to get tomorrow, I add a days-worth of seconds (3600 seconds/hour times 24 hours).

 

The rest is easy.  Subtract the current TimeStamp from Tomorrow at 8 to get Seconds to Wait, multiply by 1000 (to convert to milliseconds), and wire to a Wait (ms) VI.  Your LabVIEW program will conveniently "go to sleep" until 8 am tomorrow.  You better be ready for it ...

 

[Of course you are -- you already wired the Next State to be "Open Time-Stamped Excel File" ...]

 

Bob Schor

0 Kudos
Message 7 of 7
(4,331 Views)