DSPRelated.com
Forums

Butterworth

Started by Vladimir Vassilevsky October 4, 2013
On Monday, October 7, 2013 11:56:46 PM UTC+13, Richard Dobson wrote:
> On 07/10/2013 05:09, robert bristow-johnson wrote: > > .. > > > so if a assignment was that these students do something requiring > > > arithmetic on real numbers that involved intrinsically fractional > > > quantities, would these kids have an idea how to do it without the use > > > of float or double? > > > > > > > I will have to ask around a bit (not being a school teacher myself) but > > I suspect almost certainly not; nor most of the teachers either, unless > > they happen to have that sort of background already. For GCSE CS the > > curriculum requires them just to know the basic principles of exponent > > and mantissa, typically modelled simply, in perhaps 16 bits, with a few > > hand-written exercises. Beyond that, they just need to know that there > > are integer and f/p types in most languages. Fixed-point fractional is > > way beyond the curriculum. Subjects are somewhat siloed - very little > > maths in the CS course and very little computing in the maths course. > > And none of either in the music course! > > > > A situation I am with colleagues trying to change: > > > > http://people.bath.ac.uk/masrwd/smcs/smcshome.html > > > > > > So I am open to all suggestions for "simple" multi-disciplinary > > projects, which might for example demonstrate some of the issues you > > describe. An ideal project is one which can be written once, but used in > > (for example) any of a maths, music or CS class (maybe also physics), > > each with their particular focus. A good topic is one which offers > > "progression"; there is something for the weaker students to get marks > > for, but also something which can be used to stretch the brighter students. > > > > > > Richard Dobson
Unless they are going to be elec engineers they won't need fixed-point arithmetic anyway. 99.9% of people are not doing embedded applications or dsp. I am willing to bet most professional programmers don't know any of this stuff either as it is of no everyday use to them.
> >Butterworth-like 3rd order LPF. >Super slim. > >// (c) VLV >//Fc ~ Fs/1400 >//Dynamic range ~ 140 dB > >s32 LPF(s32 *z, s32 x) >{ >x = z[0] += (x - z[0]) >> 8; >x -= z[2] << 1; >z[1] += (x - z[1]) >> 8; >return z[2] += (z[1] - z[2]) >> 8; >} > > >Vladimir Vassilevsky >DSP and Mixed Signal Designs >www.abvolt.com >
As far as I understand the approximation or the trick lies in approximating the residual or the remainder after getting the complex conjugate poles into quadratic form. That is when getting them into the form (1+(1-k)/(1+k)z^-1)^2 + R, where k=1/tan(w0/2) and R is the remainder. The remainder if I calculate correctly is k/(1+k)^2*(z^-2 - 1) but how you got the idea of writing that as 2*z^-1 I don't know. Anyway, your filter does not implement the zeros and still needs an output multiplier to have unit DC gain. What about this one then (just thought of it) s32 LPF(s32 *z, s32 x) { z[0] += (x - z[0]) >> 8; z[1]+= z[2] >> 8; x = z[0] - z[1] - z[2] - z[2] >> 1; z[2]+= x>>8; return z[0]; } It is totally untested but should be similar. It has unit DC gain and implements 2 of the zeros. _____________________________ Posted through www.DSPRelated.com
>> Fixed-point fractional is way beyond the curriculum.
and, if you want my opinion, for good reason. a) There are way too many "secondary" skills to teach them all in advance. ("Everybody should be able to draw the Rankine cycle of a steam engine.") b) It's much easier to study with a real-world task at hand than with artificial classroom examples Thinking back on my own basic digital courses, they were more or less useless. Endless hours spent training speed-solving Karnaugh maps. And then the punch line "it only works for up to two inputs". Hah! General logic (=>DeMorgan's laws), set theory, graph theory would have been much more useful. _____________________________ Posted through www.DSPRelated.com
On 10/7/2013 6:27 AM, niarn wrote:
>> >> Butterworth-like 3rd order LPF. >> Super slim. >> >> // (c) VLV >> //Fc ~ Fs/1400 >> //Dynamic range ~ 140 dB >> >> s32 LPF(s32 *z, s32 x) >> { >> x = z[0] += (x - z[0]) >> 8; >> x -= z[2] << 1; >> z[1] += (x - z[1]) >> 8; >> return z[2] += (z[1] - z[2]) >> 8; >> } >> > > As far as I understand the approximation or the trick lies in approximating > the residual or the remainder after getting the complex conjugate poles > into quadratic form.
Never thought that deep :)
> Anyway, your filter does not implement the zeros and still needs an output > multiplier to have unit DC gain.
Good points. With poles at ~1e-3 of Fs, zeroes at Nyquist won't do much difference. As for the gain (=1/3), it is intentional to alleviate overflow problem near max. 32 bit input. What about this one then (just thought of
> it) > > s32 LPF(s32 *z, s32 x) > { > z[0] += (x - z[0]) >> 8; > z[1]+= z[2] >> 8; > x = z[0] - z[1] - z[2] - z[2] >> 1; > z[2]+= x>>8; > return z[0]; > } > > > It is totally untested but should be similar. It has unit DC gain and > implements 2 of the zeros.
The DC gain = 1 however the response is entirely different from original filter. Looks like 2nd order filter with real poles. Is that what it is supposed to be? Vladimir Vassilevsky DSP and Mixed Signal Designs www.abvolt.com
>> up to two inputs
two input pairs. see wikipedia... _____________________________ Posted through www.DSPRelated.com
On 10/8/2013 11:18 AM, mnentwig wrote:


> Thinking back on my own basic digital courses, they were more or less > useless. Endless hours spent training speed-solving Karnaugh maps. And then > the punch line "it only works for up to two inputs". Hah!
The main purpose of education is teaching you the habit of learning quickly and efficiently. Knowledge of particilars is secondary. VLV
On 10/5/2013 7:45 PM, gyansorova@gmail.com wrote:
> On Saturday, October 5, 2013 12:24:47 PM UTC+13, Vladimir Vassilevsky wrote: >> Butterworth-like 3rd order LPF. >> >> Super slim.
> When Being Clever Is Not Being Smart > A certain kind of programmer likes to demonstrate how clever they are at every opportunity.
http://en.wikipedia.org/wiki/Pearls_before_swine VLV
On Wednesday, October 9, 2013 6:53:10 AM UTC+13, Vladimir Vassilevsky wrote:
> On 10/5/2013 7:45 PM, gyansorova@gmail.com wrote: > > > On Saturday, October 5, 2013 12:24:47 PM UTC+13, Vladimir Vassilevsky wrote: > > >> Butterworth-like 3rd order LPF. > > >> > > >> Super slim. > > > > > When Being Clever Is Not Being Smart > > > A certain kind of programmer likes to demonstrate how clever they are at every opportunity. > > > > http://en.wikipedia.org/wiki/Pearls_before_swine > > > > VLV
Now you're being cheeky!
140 dB seems a little generous.

> >Butterworth-like 3rd order LPF. >Super slim. > >// (c) VLV >//Fc ~ Fs/1400 >//Dynamic range ~ 140 dB > >s32 LPF(s32 *z, s32 x) >{ >x = z[0] += (x - z[0]) >> 8; >x -= z[2] << 1; >z[1] += (x - z[1]) >> 8; >return z[2] += (z[1] - z[2]) >> 8; >} > > >Vladimir Vassilevsky >DSP and Mixed Signal Designs >www.abvolt.com >
_____________________________ Posted through www.DSPRelated.com
>The DC gain = 1 however the response is entirely different from original >filter. Looks like 2nd order filter with real poles. Is that what it is >supposed to be? >
It was intended to be 3rd order. I just checked and it looks 3rd order to me. So not sure what is wrong. But the response is not optimal. I made the code too complex, this one is better :) s32 LPF(s32 *z, s32 x) { z[0] += (x - z[0]) >> 8; z[1]+= z[2] >> 8; x = z[0] - z[1] - z[2]; z[2]+= x>>8; return z[0]; } Here are the responses http://tinypic.com/r/1zganmd/5 where the butterworth reference is fs/1400. (fs=48000 in plot). _____________________________ Posted through www.DSPRelated.com