04-26-2012 03:31 AM
Dear Members,
In my program than controls a stepper motor and reads voltages, I came up with a data logger.
My goal is the following:
The user should be able to enter a time (seconds) of which an average value should be written in a text file. So if I enter 5 s, I want to log an average value every 5 seconds of my incomin g voltage signal. So far so good.
My idea: I store all the data in an array, when a certain time has elapsed (Elapsed Time VI) than a case structure turns true, averages the current values in my array and writes that value to a txt file.
At the moment my problem is the Elapsed Time VI. Can't be that hard, I thought the "Time Target" connector specifies the time until the "Time has elapsed"-Boolean turns true.So when I run the subVI, I expect the "Time has elapsed"-Boolean to turn true every (2) seconds. But it doesn't...
Any help is appreciated.
Regards,
Jack
04-26-2012 04:10 AM
Here I have created a quick example on how can you handle the situation. From this I believe you will get some idea.
Good luck
04-26-2012 04:27 AM
Thank you very much, that's already a great help! But could yu maybe shortly explain the most inner case structure? When the target time is elapsed the first time, the current values in the array are not averaged and stored in the seperate array - I understood that, but don't understand the reason.
Cheers
Jack
04-26-2012 04:33 AM
When you do that for the 1st time you dont have any value and the array size will be 0 so the average value will be NaN/ infinity thats why I just bypass for the 1st time.
04-26-2012 10:09 AM
Thank you very much indeed! I now fully understand the issue. However, one problem is remaining:
I would like to use the previously discussed "data-logging-VI" as a subVI in my main program. However, the data flow gets "stuck" in the while loop within the subVI.
Do you maybe see a solution how to implement the logging within as subVI?
Thank you very much for you help!
04-26-2012 10:30 AM
By the way: My main program consists of one big while loop, so I could solve the issue by using that loop for the logging. However, using the whole logging-VI as subVI would be far more convenient.
Thank you for any help.