[psas-avionics] Digital filters
I
kirkpad at pdx.edu
Mon Nov 2 23:46:09 PST 2009
Thanks for the replies. I thought I would touch on all of them in one
email to keep the reading shorter.
It was suggested off the list that I consider a decimation filter to
downsample the sample rate. This sounds reasonable, but I implemented
the iir filter at a 100 Hz sample rate and still saw a significant
offset (500 lsb), with many of the same fixed point scaling problems
(resolution less than 16 bits). I would guess that I could get close
by cutting the sample rate to 10 Hz. I think that leads me to
pre-warping the coefficients since 2*PI is not << 10Hz, but that's
just math.
I 'think' the decimation filter needs to remove content above 5 Hz
(nyquist), then cut the samples to 10 Hz. Wouldn't that be about a 1Hz
filter anyway?
I think the FIR structure has the most promise, but I have no
experience with those, especially on a fixed point machine.
Quoting rq17zt at q7.com:
> I don't know much about this sort of thing.
But likely more than I know ;)
> I'm guessing that a different implementation could have better numeric
> stability properties.
>
> Your key-phrase seems to be, "Series of first order difference
> equations." Is that different than MAC-ing a polynomial equation?
That is exactly MAC-ing a polynomial equation:
y = b1 * x + z1;
z1 = b2 * x + z2 - a2 * y;
z2 = b3 * x + 0 - a3 * y;
> I've done similar type things with the latter without trouble, but never
> as low as 1 Hz.
So have I, but the goal was usually a much higher cutoff frequency,
and some DC offset and minor loss of resolution was not a problem.
Here, the offset is a major issue.
Quoting Barton C Massey <bart at cs.pdx.edu>:
> Caveat: I have no idea what I'm talking about. Act
> accordingly.
I have no idea how to interpret this response :) This could be
sarcasm, and you *do* know what you are talking about, but I simply
don't understand. This could be truth, and I should go another route.
> You can't do a 1Hz cutoff against a 1000Hz sampling rate
> with any sane single-stage design, AFAIK.
I'm not sure what you mean by a single stage... I think of a stage as
a memory element when using an IIR filter, in which case I think I'm
using 3 stages.
> The usual plan
> would be to downsample the signal in a series of stages;
> maybe 5 downsample-by-four stages, which would get you to
> about 1Hz very nicely.
Again I'm not up to speed on your terminology, and my googling is not
clearing things up. I see some stuff on downsampling, but I've thought
of this in the context of throwing out data, not combining it. Perhaps
more akin to down-conversion.
> (It also tells you that as a rule of thumb you'd
> need about a 10-pole Butterworth to do this directly; ...
Did you mean 10 *tap* Butterworth? I was originally only trying to get
2 poles, so 10 poles would be overkill?!?!
> I
> still wouldn't recommend it, though, as the numerical
> instability problems will be very real with such high-order
> polynomials.)
This is the problem I have now.
I'll have to show off (Tuesday) an integrating device I'm running now.
It has zero offset, and filter-like response.
> (2009.11.02) kirkpad at pdx.edu:
>> Hey All,
>> I'm looking for advice from someone who's DSP foo is stronger than
>> mine to help with a filter applied to the roll control system..
>>
>> Problem:
>> Implement a 2nd-order low-pass filter (butterworth would be fine)
>> with a 1Hz cutoff frequency and a sampling rate of 1000Hz. Input is
>> uint16, 0-65535 from an ADC.
>>
>> My usual solution:
>> Create the appropriate transfer function, then use Matlab c2d
>> command to obtain the coefficients. Finally, build the filter as a
>> series of first order difference equations. This is working in
>> several products in production, but isn't quite right for our rocket
>> roll-controller.
>>
>> The reason this isn't working:
>> 1) Matlab c2d gives only 4 significant figures, regardless of the
>> format setting.
>> 2) Using only 4 significant figures propagates errors in the filter
>> which make it unstable.
>> 3) When the coefficients are obtained by calculation
>> (float-doubles), the DC offset is too big to make the filter useful
>> when converted to fixed point math.
>> 4) The fixed point data sizes get kind-of big for such a simple
>> filter (long long) if I want to keep my resolution.
>> 5) Filter coefficients for a 1000Hz sample rate and a 1Hz cutoff are
>> so far apart in size (1 vs. 0.00000009808) that 64 bit math or
>> slower sampling are likely the only solutions.
>>
>> A couple of questions:
>> 1) Is there another way to realize a discrete fixed-point filter
>> that has little (1-2 LS bits) offset and full resolution on a 16 bit
>> input?
>>
>> 2) Can another filter be designed more easily ( I had to derive the
>> filter using a bilinear transform. Frequency warping wasn't used
>> because the sampling frequency is much faster than the corner
>> frequency. )?
>>
>> Anyone have any thoughts?
>
>
> _______________________________________________
> psas-avionics mailing list
> psas-avionics at lists.psas.pdx.edu
> http://lists.psas.pdx.edu/mailman/listinfo/psas-avionics
>
>
More information about the psas-avionics
mailing list