Hi, I'm trying to build a filter for a resolver. I'm getting issues with noise spikes where I will get a sample that is way out of proportion with other samples. I have a pretty good design for filter minor glitches in the shaft angle, say up to 5 degrees off. But where I really need to do more filtering is right after the ADC samples. I have 2 ADCs sampling 10kHz sine and cosine signals at 20kHz. So, I get a positive peak with the first sample then a negative peak with the second sample, and I can flip the sign of the sample so that all peaks are positive. The problem comes in when I get a bad sample and it throws off the angle by around 180 degrees. What kind of filter(s) can I use to reject these bad samples but still maintain accuracy?

It looks like this:

Theta (in per-unit, so multiply by 360 to get degrees):
0.5795626
0.5775594
0.5762954
0.07511029 <-
0.6119945 <- off, but the other filter can smooth this out
0.06884149 <-
0.5638001
0.5955495
0.07234372 <-
0.5802317
0.5606241
0.5626645

12-bit ADC values. VrefHi = 3.3V, VrefLo = 0.0. Centered around 1.473V
sin samples: cos samples:
2509 3075
1166 579
2486 3094
1489 <- 1164 <-
292 <- 18 <-
1260 <- 598 <-
1385 783
3289 3962
2061 <- 2305 <-
3009 3969
1549 1204
2437 3349