LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting Elapsed Time in Specific Sequence Frame

Solved!
Go to solution

Hello,

 

I'm running a flat sequence in one of my programs, and wish to read time elapsed in one frame into a formula vi. I don't want to have time elapsed for the entire program, just time elapsed every time that specific frame runs, starting from zero everytime that frame in the sequence starts. The formula is just a linear equation that is dependent on time, so its critical that it resets every time in order to provide a line that progresses from t=0 everytime. I have tried to use time elapsed within the frame but I'm not sure how to set it up properly to give the elapsed time I'm looking for.

 

Time elapsed in frame.JPG

 

I know how long the frame runs for, I just need a way to input what time its at (in ms or s) at any given point during its execution, starting from t=0 every execution.

0 Kudos
Message 1 of 8
(2,710 Views)
Solution
Accepted by topic author MattWarnock

First, your formula.vi will have to be outside this sequence frame.  You can only determine the time of execution AFTER the frame is finished.  Place a tick count vi before and after the frame and subtract them. (delta t is in milliseconds)

0 Kudos
Message 2 of 8
(2,699 Views)

That kind of works, the only problem is I need it to consistently read numbers into the formula in order to produce a linear pattern, but its reading it in in spurts, once its collected data from the tick counter on either side of the frame. It needs to be a steady flow of time data being inputted.

 

Premature solution button click my bad

0 Kudos
Message 3 of 8
(2,683 Views)

You need to be more specific on what you need then.  The time it takes for a single frame to run is not continuous data so I'm not sure what you want.

 

Please provide more details on what you want, what the formula.vi is accomplishing and why you need it.  There may be another solution.

0 Kudos
Message 4 of 8
(2,680 Views)

the formula is dictating servo movement by controlling the degrees being read into the servo vi as specified by the formula vi. the formula is X1*X2 where X2 represents a specified rate that can be controlled on the front panel, and X1 represents what I would like to be a continuous flow of time data in the form of seconds, creating a linearly increasing function of degrees vs time. I need a method of inputting time continously that will start at zero at the beginning of the frame, and increase throughout the frame to the specified stop point that the wait ms vi gives me, creating a motion in the servo that is a linear increase of degrees as the frame executes.

0 Kudos
Message 5 of 8
(2,666 Views)

This process is pretty representative of what I want, but I cant make the elapsed time vi function the way i want in a sequence frame.Example.JPG

The servo is configured, and once the degree input is ready the degrees are read in through a formula vi, defined as X1*X2 where X1 is provided by elapsed time within the loop. The result is a servo motion that is controlled by the manipulation of X2 as a rate. I'm looking to have this in a sequence frame, but it must start at zero at the beginning of the frame or else the formula will pump out large values, eventually reaching beyond 180 degrees (the servo max motion).

0 Kudos
Message 6 of 8
(2,659 Views)

What you want simply can not be done with the current set up as it only runs once.  X1*x2 is a single number... there is no way in your single frame to create multiple X1 values with a multiply function.

 

What you need is a while loop which terminates once a certain time has been reached.  Use a tick count outside the loop to denote it's start time.  Inside the loop, have another tick count and subtract them (this is your tick count for the current interation of the loop).  The loop will keep running until your termination conditions are met, in this case when the tick count meets, or exceeds your designated stop time.

 

Also, if you are just multiplying the two numbers, why not use Multiply from the math pallete?

0 Kudos
Message 7 of 8
(2,655 Views)

The elapsed time express vi you showed basically does what I described.  The first time it runs, it marks the current time.  Then, every following iteration substracts the start time from the current time to get time elapsed.

 

A sequence frame isn't the answer, a while loop is.

0 Kudos
Message 8 of 8
(2,654 Views)