Quote:
Originally Posted by pfreivald
We tried using this optical sensor yesterday with a half-black, half-white wheel, and found that it didn't seem to refresh fast enough at frisbee-shooting speeds. (This is what was reported to me -- I wasn't there).
Does this seem like a legitimate problem for this sensor? And how would I go about determining whether or not any given sensor is suitable for these kinds of rates?
|
This should work fine if you decode the signal the right way.
There are two different methods commonly used in FRC for decoding sensor pulses into RPM. Each has advantages and disadvantages.
Method1
Divide the pulse count by the elapsed time and convert to RPM
Method2
Measure the elapsed time between pulse counts and convert to RPM.
If you are using a low pulse-per-rev sensor (like you described above), you should used Method2. If you use Method1 you'll get a very noisy signal (lots of jitter).
For example, let's say your wheel speed is 5000 RPM and you are using Method1, and you are reading speed samples at 20ms (TeleOp speed).
At 20ms (50Hz), you'll sometimes get 2 pulse counts and sometimes only 1. So sometimes you'll read 6000 RPM and sometimes you'll read 3000 RPM, when your true speed is actually 5000 RPM. That's a lot of noise.
But if you use Method2 you can get a good signal. Use the GetPeriod() method of the Counter class. This will return the elapsed time between the most recent 2 pulses. This will give you a jitter of roughly 3 RPM. Much better.