Thread: Speed Sensors
View Single Post
  #8   Spotlight this post!  
Unread 31-01-2007, 13:54
mluckham's Avatar
mluckham mluckham is offline
Registered User
FRC #0758 (Sky Robotics)
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2006
Location: Ontario, Canada
Posts: 116
mluckham will become famous soon enoughmluckham will become famous soon enough
Re: Speed Sensors

Accelerometer doesn't tell you current speed, it just measures acceleration. And if you are turning at the time, you will get the forward component of acceleration plus the lateral component (2-axis accelerometer).

Using encoders, you can figure distance travelled, speed, and acceleration.
Put an IF statement in your code that executes its inner code at a known rate (eg: 10 times per second).

Code:
if (time_elapsed_100msec)
{
   Speed = CurrentEncoderCount - prev_EncoderCount;
   Acceleration = Speed - prev_Speed;

   prev_EncoderCount = CurrentEncoderCount;
   prev_Speed = Speed;
}