NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
Jack_W
Posts: 48
0 Kudos

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

 

 

Active Participant
P@Anand
Posts: 1,617
0 Kudos

Re: Elapsed Time Problem - Logging average values

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

-----

I don't believe in Hard work. I love my work :smileyhappy:
Member
Jack_W
Posts: 48
0 Kudos

Re: Elapsed Time Problem - Logging average values

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

Active Participant
P@Anand
Posts: 1,617
0 Kudos

Re: Elapsed Time Problem - Logging average values

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.

-----

I don't believe in Hard work. I love my work :smileyhappy:
Member
Jack_W
Posts: 48
0 Kudos

Re: Elapsed Time Problem - Logging average values

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!

Member
Jack_W
Posts: 48
0 Kudos

Re: Elapsed Time Problem - Logging average values

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.

By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page