# Velocity Question

## Recommended Posts

I am a Mechanical Engineering student and we are working on a project to dynamically measure velocity of Human Powered Vehicle. We are using a LabJack U3 LV DAQ system. I have hooked it up and I used the sample counter provided with DAQFactory. We have just a simple magnet-sensor set up on the wheel and it is counting just fine.

In order to get velocity you multiply your number of turns times pi and diameter and divide all of that by your time interval. I need to figure out a couple of things in order to do this...

1. The counter I worked with just keeps going as long as its open. I think I'll need to get one to reset after a few seconds and start over in order to properly calculate velocity. It needs to be taken as a derivative of time and I think that would be the best way to do it.

2. I would also like to graph this data of velocity versus time. I know that it automatically graphs the counter vs. time. I just don't know how to set it up to show a graph of velocity vs. time whenever I figure out to how to calculate velocity.

3. I would like to store the data once I start getting the numbers in for calculations.

Any help would be greatly appreciated. Thanks in advance!

##### Share on other sites

The DAQFactory / LabJack application guide and other posts I believe talk a little about this: in general you do not want to reset the counters. Instead you should let them free run and use the channel event to calc the velocity based on a difference between two consecutive counts. To do this:

1) Create a new channel, Device Type Test, I/O Type D to A, Channel #0. Call it velocity.

2) In your rawcounts channel's event (click on the channel name in the workspace and then the event tab) put:

```private dc = rawcounts[1] - rawcounts[0]
private dt = rawcounts.time[1] - rawcounts.time[0]
private vel = dc * pi() * diameter / dt
vel.time = systime()

diameter is presumably a global variable with the diameter. Replace with a number if you want. You can then plot or log velocity the same way you would any normal channel.

##### Share on other sites

Ok, I've been working on it. I'm still trying to work through the basics but I believe I have gotten enough info and read enough to get done what we need done. Here is my event code for my RawCounts Event.

```// calc counts in interval

// calc counts per second in interval
Hertz.AddValue((RawCounts[0] - RawCounts[1]) / (RawCounts.Time[0] - RawCounts.Time[1]))

private dc = RawCounts[1] - RawCounts[0]
private dt = RawCounts.Time[1] - RawCounts.Time[0]
private vel = (dc * 4.81949)/(2*dt)

vel.time = systime()

On my page view I have rawcounts, counts in interval, frequency and my velocity all displaying. My raw counts seem to be counting by two and I accounted for that in my equation by just dividing by two. My counts in interval goes from 1, 0, -1. Because of this, my frequency and velocity are fluctuating between a negative number, 0, and a positive number.

I tried changing the interval of the raw counts from 1 sec to 0.1, 0.001, and 3 just to see if it changed anything and it did not seem to help.

Any ideas of where I need to go from here? I'll keep playing around and see what else I can come up with.

Thanks.

I tried

##### Share on other sites

Looking more into my situation, my raw counts seem to be working just fine. But, my counts in interval is just outputting a sin wave even when our wheel is not spinning. I realize that it is still supposed to be plotting against time, but there should be no value to plot against.

So, I decided to take out the code that is giving value to my counts in interval and the frequency calculation. They are still outputting information onto our front page just as they did before. To me, it seems like they are outputting some other value and are not taking the value they are supposed to recieve and it seems that my velocity is doing the same thing.