From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Creat new files at the beginning of every hour

Solved!
Go to solution

I am trying to write a VI to store data in text file. To avoid a too large file, I want to store the data in different files. I want these files to be created at the beginning of every hour. How could I achieve this?

 

Thanks in advance!

 

 

0 Kudos
Message 1 of 14
(4,063 Views)

Hey,

 

Maybe you could integrate this in your code. It will increment the number in the filename every half second.

 

Rgds - Rkll

0 Kudos
Message 2 of 14
(4,045 Views)

Hey,

 

Maybe you could integrate this in your code. It will increment the number in the filename every half second.

 

Rgds - Rkll

Download All
0 Kudos
Message 3 of 14
(4,045 Views)
Solution
Accepted by topic author masterwho

Many people like to have a timestamp in their file name.  Makes it unique and gives information on the time the file was created.  Here is some code that will create a new filename with timestamp every hour on the hour.  It checks every second to see if the minutes part of the time string is "00".  If so, then it creates a filename.  The date string keeps it unique from day to day.

 

20513i32A3BF8B9A8B7A63

 

Ooops. Just noticed a flaw.  The code will create a new filename every second as long as the minutes are 00.  Changing the delay value to one minute (60000) should fix the problem.

- tbob

Inventor of the WORM Global
Message 4 of 14
(4,002 Views)

Thank you for your help. It's very helpful!

0 Kudos
Message 5 of 14
(3,965 Views)

Thank you very much for your reply. I tried to use time stamp to control the creation of the files. However, it seems that the wait function isn't stable enough, it didn't sample as expected. For example, I set the wait function to wait for 10ms, but it delays for about 12ms. It's really weird! Do you know how to fix it?

 

Thanks a lot!

0 Kudos
Message 6 of 14
(3,961 Views)

Can I have one more question?

 

I tried to use the way you told me to control the creation of the files. However, it seems that the wait function isn't stable enough, it didn't sample as expected. For example, I set the wait function to wait for 10ms and jump out of the ture or false loop to check whether the minute is 00, but it delays for about 12ms. So if I use a for loop with 360,000 iterations, and set a wait for 10ms in each loop, it always misses the minute of 00. It's really weird!

 

Do you know how to fix it?

 

Thank you very much!

0 Kudos
Message 7 of 14
(3,956 Views)

I saw a video a while ago. It's about timing and that sort. I'm at work now and don't have to possibility to view the video, but I think it should be relevant.

Regards,
Even
_________________________________
Certified LabVIEW Associate Developer

Automated Test Developer
Topro AS
Norway
Message 8 of 14
(3,949 Views)

I like the video very much. It's really a nice one and very helpful.

 

Thank you very much!

0 Kudos
Message 9 of 14
(3,935 Views)

Glad to help:) That guy have many nice videos that also might be useful some day.

Regards,
Even
_________________________________
Certified LabVIEW Associate Developer

Automated Test Developer
Topro AS
Norway
0 Kudos
Message 10 of 14
(3,927 Views)