View Single Post
  #2   Spotlight this post!  
Unread 27-01-2006, 09:24
BradAMiller BradAMiller is offline
Registered User
AKA: Brad
#0190 ( Gompei and the Herd)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Worcester, MA
Posts: 592
BradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant future
Re: Velocity Calculation

Quote:
Originally Posted by CyberWolf_22
Does anyone know of a way to get velocity from a simple wheel encoder using WPILib. I know how to do it using timer interrupts but since they are disabled I have not found a simple solution to getting the velocity of a wheel.

Any help would be greatly appreciated.
The velocity is basically the number of ticks / time. If you are taking readings over time, you can use deltaTicks / deltaTime. deltaTicks is the number of ticks between readings, and deltaTime is the amount of time between readings.

To get the time there are a few functions, GetMsClock() to return the running time in millisecods. Alternatively you can use StartTimer(), StopTimer(), GetTimer(), and PresetTimer() to return time in milliseconds.

To improve the accuracy, try to make the time between samples as long as you can, since very short sample times will compound the errors in reading the timers and reading the encoders. Longer sample time will have the same errors, but only once over a much longer time. If you only do the velocity calculation every 200ms it should be pretty accurate.

With the timer functions, you can Preset a timer to 0 each time you do the calculation, and wait until it gets to 200 then calculate again.

Does this solve the problem?
__________________
Brad Miller
Robotics Resource Center
Worcester Polytechnic Institute