LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Elapsed Time Problem - Logging average values

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

 

 

0 Kudos
Message 1 of 6
(2,581 Views)

Here I have created a quick example on how can you handle the situation. From this I believe you will get some idea.

 

 

Snippet 1.png

 

Snippet 2.png

 

Good luck

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 6
(2,571 Views)

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

0 Kudos
Message 3 of 6
(2,569 Views)

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.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 4 of 6
(2,567 Views)

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!

0 Kudos
Message 5 of 6
(2,563 Views)

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.

0 Kudos
Message 6 of 6
(2,556 Views)