LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to calculate distance from velocity

Hello reader,

the problem is to exactly calculate a covered distance from a velocity.

In my case I get a velocity signal, consequently a car would do a certain stretch. I tried to calculate the stretch by adding the velocity (m/s) every round of a while loop.

Is there a better way to do it under LabVIEW 7.0, particularly when I use a wait function (50ms)?
0 Kudos
Message 1 of 8
(3,237 Views)
If the curve is an acceleration curve for example, you could fit it to a polynomial and then integrate the polynomial between two time points.

Of course if you're adding the individual m/s points together, don't forget to compensate for the timebase (50ms, not 1000ms). In other words, don't forget to divide your result by 20.

Hope this helps

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 2 of 8
(3,229 Views)
Herakles,

When you start the test, is the car at a constant velocity?
In other words, is there an acceleration factor in the equation?

If the car is at constant velocity from the beginning to the end of the test, then the distance is simply:

D = V * t

If I understand your question, you are concerned about the delay in the vi.
You could take a timestamp at the beginning of the test and an other at the end of the test. The difference between both time stamps would give you the value for "t" (time). In that case, you would not worry about 50ms delays in a loop or other delays in the VI.

If you need continuous readings displayed or captured during the test, you could wire the timestamp before an acquisition loop (start time) and another within the loop (actual / end time). This way, if there are changes in velocity, you could take a distance sample every X-number of seconds (or ms?) and calculate the total distance. The data could also be plotted for velocity or distance over time.

-JLV-

😄
Message 3 of 8
(3,221 Views)
This is how I would do it...

Since the accuracy and precision of the time between measurements is important, I would acquire a continuous velocity measurement at hardware timed intervals. That way, the distance travelled by the object from measurement to measurement is easy to calculate provided the acceleration/deceleration is uniform within the measurement period. If the mass is large and you measure frequently the acceleration/deceleration will be uniform from measurement to measurement. Summing up all the distances gives you the total distance travelled.
0 Kudos
Message 4 of 8
(3,212 Views)
Thank you for the answers,
the proposal to devide the result by 20 is right, but my computer is not very fast. So that I have to devide the result by 19,2. If I change my computer, I will have to find the new dividend.

The problem is also, that I need the distance every 50 ms for other calculations.

Who can help?
0 Kudos
Message 5 of 8
(3,200 Views)
Why not start a continuous acquisition at 20Hz (50ms period)? In your while loop, read the data into an array and process the distance travelled between data points. I believe using the wait function the elapsed time will not be as accurate as a hardware timed aquisition.
0 Kudos
Message 6 of 8
(3,192 Views)
You mention that you use the "wait" function to wait 50 ms.

Try the "wait untim ms multiple", this helps give mush more reproducible values, as the time your code takes to execute isn't added to the wait as it is with the normal "wait" function.

The first execution may be off a bit, but the second and later should all be pretty close to 50ms.

Hope this helps

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 7 of 8
(3,191 Views)
Shane,
I was inexact, because I'm using the "wait until ms multiple" function.

Perhaps the idea using a hardware timer is a good one. Actually I acquire the velocity signal at 20 Hz or faster. I will try it.

Thanks
0 Kudos
Message 8 of 8
(3,173 Views)