View Single Post
  #13   Spotlight this post!  
Unread 10-09-2008, 14:11
BornaE's Avatar
BornaE BornaE is offline
Registered User
FRC #0842 (Formerly 39)
Team Role: Engineer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Gilbert, Arizona
Posts: 359
BornaE has a brilliant futureBornaE has a brilliant futureBornaE has a brilliant futureBornaE has a brilliant futureBornaE has a brilliant futureBornaE has a brilliant futureBornaE has a brilliant futureBornaE has a brilliant futureBornaE has a brilliant futureBornaE has a brilliant futureBornaE has a brilliant future
Re: Servo 'smoothing'

You can average the past N analog samples and feed it to the pwm, this will add a little amount of lag but smooths the movement

your current configuration:
(i might be a bit off with the aliases names but you get the idea.)
Code:
pwmXX = Get_Analog_Value(ana_in_yy)/4;
now try this:
averaging 5 samples
Code:
static int temp[5]=0;

temp[4] = temp[3];
temp[3] = temp[2];
temp[2] = temp[1];
temp[1] = temp[0];
temp[0] = Get_Analog_Value(ana_in_yy);

pwmXX = (temp[0] + temp[1] + temp[2] + temp[3] + temp[4])/(5*4);
the more samples you average, the smoother the moviement but the longer the lag.
__________________
-Borna Emami
Team 0x27