Quote:
Originally Posted by Ether
Another option is to use an IIR filter instead of FIR. It's simpler and it's tunable:
Code:
public void getSpeed(){
filtered_count = a*filtered_count + (1-a)*Shooter_En.getRaw();
Shooter_En.reset();
Rate = filtered_count /0.48;
}
... set a=0 and you've got no filtering. As you increase a from zero to 1, the filtering becomes stronger.
|
I agree with you here, but if the FIR version is desired, they should implement it in the recursive form. It then approaches the timing of the IIR filter. The ring is still required but rather than summing over the whole ring each time the output is updated with the difference between the fresh sample and the oldest sample.
avg(n) = avg(n) + (sample(n) -sample(n-L))/L where L is the length of the average.
Essentially before you overwrite the oldest sample, you calculate the difference and then overwrite and compute the new average.