02-04-2010 04:00 PM
What structure is the easiest to use to achieve saving of data at specific increments of time? I've been trying timed loops but I don't quite understand their mechanics. I have the vi attached. If I condition the loops correctly will I be able to have data put into an array every say 10 minutes, and then saved to a file every hour?
Thanks
02-04-2010 04:05 PM
02-04-2010 04:12 PM
02-05-2010 03:34 PM
First off, timed loops on a Windows machine are not what you are looking for. Timed loops are geared towards real-time systems where we can have deterministic behavior. This just isnt possible with a Windows machine. Plus, the way you have it architected now, you are going to write the same data point every time the loop iterates(besides the fact there is no stop condition)
Next, there are many other issues with this code other than timing a loop. You run your configuration VIs(vertical, timing, edge) ever iteration. You also open a file reference log every iteration as well.
What sort of resolution are you looking for here? Log every x milliseconds, seconds, minutes? I guarantee you will not get any sort of millisecond accuracy with your current setup.
Your best bet is to run your acquisition at a semi-fixed rate and then use your iteration counter to determine when to write. I notice you have a 'wait until next ms multiple' but you have 20 milliseconds. I highly doubt that you are getting 20ms out of this since it there is a lot going on with file I/O, dialogues,
Or, you could write your data to a local variable whenever you read it, and have a seperate loop running in parallel at a fixed rate logging that variable(keep in mind you may duplicate writes if the variable hasnt been updated in that time frame!)
Or you include a timestamp every time you pull in a data point (fetch measurement) and use this to determine when to write a data point. You have to keep in mind the time to actually pull the data point in as well, and also that your acquisition has a different dt every time it runs.