View Single Post
  #72   Spotlight this post!  
Unread 30-04-2010, 02:59
vamfun vamfun is offline
Mentor :Contol System Engineer
AKA: Chris
FRC #0599 (Robodox)
Team Role: Engineer
 
Join Date: Jan 2009
Rookie Year: 2003
Location: Van Nuys, California
Posts: 182
vamfun is a glorious beacon of lightvamfun is a glorious beacon of lightvamfun is a glorious beacon of lightvamfun is a glorious beacon of lightvamfun is a glorious beacon of lightvamfun is a glorious beacon of light
Send a message via AIM to vamfun
Re: Unexpected results from Encoder::GetRate()

Quote:
Originally Posted by Alan Anderson View Post
I have no idea what you're trying to say here.
Here is pseudo simulation code that I would write to illustrate the error amplification
Code:
Param: 
T = edge oscillation period
A  = edge oscillation amplitude
dt = T/20,  sample rate small enough to measure oscillation
variables: 
t = time,
x = encoder input
y = encoder output
x_dot = encoder input rate 
y_dot= encoder output rate

Run Simulation:
while(t < runtime){

Encoder input movement:

x = A*sin(2*pi*t/T); Small oscillation movement , A < 1 to be on same edge.

x_dot = A*2*pi/T*cos(2*pi*t/T)

Encoder output change when x is centered on a threshold:

If(x > 0 ) {y = .5 }   //sample
else {y = -.5 }

y_dot = (y-y_last)/dt   //Derive simple rate 
y_last = y;
t= t + dt;
}
Expected Results:
The output amplitude will oscillate between -.5 and .5

The amplitude ratio y/x = .5/A.

peak |y_dot| = 1/dt,

average |y_dot| = 2/dt/(20)= 2/T Average over oscillation period



Then (avg |y_dot|)/(x_dot amplitude) = 1/(A*pi)
(this is slightly less than my .5/A approximation.)
Reply With Quote