LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Alternative to Elapsed time for periodic logging

Dear All,

           I want the Periodic logging of the data into excel file at one minute, and as usual i am using the Elapsed time to log periodically, but Elapsed time.vi is not executing at exactly 1 minute ( i think because of heavy code) and it adds 1 second of delay after every 1 or 2 logging, which adds so much of delay in logging after long time (almost 50 seconds in 1.5 hours), so i think it is not possible for me to use this method for the logging, thats why i am looking for the alternative to "Elapsed time", is there any other way that i cna do the same (Logging at every 60 seconds) accurately without any delay?

              Can anybody tell me what could be the reason for the delay? i think it is heavy coding, but have u had this problem in the past? can anybody help me in either of the case?

Thanks in Advance,
Nishant
0 Kudos
Message 1 of 8
(2,984 Views)

Consider multithreading your application, pass the data using a queue to a seperate thread (loop) which will wait for 1 minute and then empty the queue and append the new values to a file (tab delimited).  This will take the overhead from the main loop and should help.  Remember that if you are logging large sums of data (MBs ) at a time you will eventually see a slowdown when the application overwhelms your ram and your virtual memory kicks in so try to avoid this with multitreading and load balancing.

 

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 2 of 8
(2,979 Views)
Use the time of day clock. When the current time is equal to or greater than the last save time plus interval (1 minute in your case), save again and update the last saved time in a shift register. You can put this code in line or encapsulate most of it into a subVI. This approach can also allow pause/resume functions as well.

Lynn
0 Kudos
Message 3 of 8
(2,966 Views)

Dear Johnsold,

                Thanks for the input buddy, ya that is wat i think could be the best option for me, because i am also doing some value addition in the variable at the same time, so it also be done on the same period, and this is what i think is the best option, but for i think i have to convert the curret time into the relative time, isnt it? but what could be the method to do so? should i convert it into the miliseconds or seconds? and relative to what?

Thanks,

Nishant

0 Kudos
Message 4 of 8
(2,949 Views)

Dear Paul,

             As you told me, i am not sending datas into the MBs, and my vi is round about 1 MB, but the problem is vi is taking more time in gethering the signal and then converting that array to the string and giving that data to the Excel file and because of that codr slows down in each loop, so i m not able to place the another code, either i can modify this code, and there is no other option.

Thanks,

Nishant

0 Kudos
Message 5 of 8
(2,947 Views)

When you have an inaccurate timing, that keeps adding up, then you should make the reference time different.

In stead of timings against the last save time (which includes all previous timing errors!), you should time against the start time of the experiment.   You only need a counter that keeps track of the number of times you saved allready.   (Often simply the 'i' in one of your loops)

Thus save when: 
        current time >=  start time + (counter * interval).

(Can be done with the elapsed time vi, by putting (counter*interval) at the time target input.)

This method assures that even after many hours, you still have at most the 1 second inaccuracy from the vi that's checking the current time. The error in the timing can never add up.

0 Kudos
Message 6 of 8
(2,942 Views)

Dear Anthony,

                  Thanks for the reply and even i like the idea, now what i have done is to use the Tick Count/60, which gives current second, store the initial into the shift register and then each time after 60 seconds, we will make the option true to log the data and that second will be logged into the shift register and loop continues for n time, and it also works fine for me. anyways thanks for the input, its real nice one.

Thanks,

Nishant

0 Kudos
Message 7 of 8
(2,936 Views)
Nishant,

Here is a demo which is similar to some code I use in some projects. The outer while loop could be the state machine loop in your program.

Lynn
0 Kudos
Message 8 of 8
(2,922 Views)