@Basavaraj093 wrote:
Its working fine but it also makes it run slow,
for example, if you want to stop loop at exact 30min using elapsed time, it stops loop when time is elapsed, but it also skips some seconds during logging data into the excel.
"Make it run slow" and "exactly" are very poorly defined terms. You probably know the loop rate and the program can stop according to the number of iterations instead of elapsed time.
Typically, the acquisition time is important. The time for saving is not part of the experiment and is irrelevant. In order to efficiently save, you need to use an efficient file format (e.g.open the file once, keep it open while appending data, and only close it at the end). Most high level file IO will open/close the file around each write, which is significantly more expensive. In addition, the saving can be done in a parallel loop where more jitter is acceptable.