# Choosing a position sensor (encoder) and obtaining velocity from it

Not an Arduino specific question but I was hoping someone here might be able to help:

How do I know how many counts per revolution I need for an encoder for my application?

I need to be able to accurately capture a 1000 Hz signal on an input side running from 1-133 rev/sec (60-8000 RPM) and a 1000 Hz signal on an output side with gear ratio 1:100, so speeds are .01-1.33 rev/sec (.6 - 80 RPM).

Here is the math I have but am not sure if it is correct:

For a 1000 Hz signal, it takes .001 sec for one period. But if I want to accurately capture this and accurately obtain velocity from this position data, I need 100 counts (is this a good assumption? what would be a better value?). Hence, I need 100/.001 = 100,000 cts/sec. Now, if I divide this by my rev/sec, I'll get cts/rev which is what encoders are rated at.
Assuming input is running at 10 rev/sec, I need 100,000/10 = 10,000 cts/rev.
Assuming output is running at .1 rev/sec, I need 1,000,000 cts/rev.

I strongly suspect my math is incorrect however because the best encoders that meet the speed requirement of my application are 1024 cts/rev for input and 72,000 cts/rev for output. Would these cts/rev actually be good enough for my application then?

For context, I need to obtain the Bode plot of a gear drive and hence plan to give sinusoidal inputs to my motor. I do not expect this the bandwidth of my gear drive to be more than 1000 Hz, but since I am not sure what it's exact number is, I would like my design to be capable of accurately measuring a 1000 Hz signal. This sinusoid will be in terms of velocity which is why I want to obtain velocity data.
Also, I know it may seem odd that I am using position first and then getting velocity rather than getting velocity directly, but I want this system to be capable of positional control so I would like to only use position sensors if possible.

TLDR: How many position counts are needed to get an accurate velocity reading?
How many position counts per revolution do you need to capture velocity changing at a frequency of 1000 Hz?

You should start by describing your setup, a drawing might help. Then explain how you mangle a (fixed) frequency (1kHz) with a (variable) rotation speed. I don't know why you think you need 100 pulses to get a velocity, usually two pulses plus the time difference between the two is enough to get a reading.

If you know the gear ratio, measuring the rotational velocity on one side of a gearbox is all you need to know the other.

@pylon: Well, I am kind of hoping it is indeed possible to get a 1kHz variable rotational speed on a motor by giving it an analog signal or if that doesn't work, using the motor driver's software (Kollmorgen Workbench). As for why I need 100 pulses, I figured noise might be an issue since I am converting position to velocity and I know I need a good number of pulses to accurately draw say one period of a sine wave where the sine wave is velocity. If I just sample every period which is every .001 s, I will never get the shape of the sine wave, all I would get would be a horizontal line. As for a drawing, I hope the above explanation helps, but if it still does not, I'll try to get a drawing.

@jremington: That is true, but I want input and output to create a Bode plot as by definition, I would need to compare the input and output to do so.

You don't need 100 pulses to resolve a sine wave. Start by studying the Nyquist Theorem

The time between any two transitions gives you the velocity, since the distance between transitions is (mostly) fixed. So to resolve 1000Hz, you need transitions at 2000Hz at your target speed.

You give a very wide speed range. At 0rpm, you don't get any transitions on the encoder, so how could there be any signal to detect?

Maybe instead of using a position encoder, you should look for a velocity sensor with a response in the 1000Hz to 2000Hz range. Something like a TLE5012B can give velocity outputs at that kind of frequency. It is also a position encoder, with frighteningly good resolution.

Well, I am kind of hoping it is indeed possible to get a 1kHz variable rotational speed on a motor by giving it an analog signal or if that doesn't work, using the motor driver's software (Kollmorgen Workbench).

No, that's not possible as it either is a 1kHz (I guess that should be 60'000RPM) rotational speed or you get a variable speed, but having both, a fixed speed and a variable speed is impossible to get.

As for why I need 100 pulses, I figured noise might be an issue since I am converting position to velocity and I know I need a good number of pulses to accurately draw say one period of a sine wave where the sine wave is velocity.

So you have a velocity that is showing a sine wave? What kind of device are we talking about?

f I just sample every period which is every .001 s, I will never get the shape of the sine wave, all I would get would be a horizontal line. As for a drawing, I hope the above explanation helps, but if it still does not, I'll try to get a drawing.

The would give you the velocity, the line is simple the average velocity. As I wrote, a velocity in the form of a sine wave is definitely uncommon, so a drawing of that setup would help.

For context, I need to obtain the Bode plot of a gear drive

I don't know what use this is but it sounds like an undergraduate project.

I'm guessing it is looking at torsional vibrations. Drive the gearbox with a motor with specific torsion vibration and measure how much of that comes out the output.

@jremington: That is true, but I want input and output to create a Bode plot as by definition, I would need to compare the input and output to do so.

For a gear drive, the magnitude and phase shift of the output are fixed and independent of frequency.

So your plot is predictable and will be completely uninteresting.