12-29-2014 11:57 PM
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?????
12-30-2014 12:36 AM
12-30-2014 01:27 AM
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.
12-31-2014 05:52 AM
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.
12-31-2014 08:24 AM
Some general comments:
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
01-04-2015 12:42 AM
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.
01-04-2015 01:36 PM
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:
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:
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:
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