How to MULTIPLY by fraction ?? (making variable iir)

J

Jam

Guest
Hi all,

I am making a variable IIR filter:

in the form of (1/z-"coeff") . For 51 kHz (fs=10e6) the coeff would be
0.96875
Which can be made as 1-1/2^5. Which is 1*Sa - shr(Sa,5)
Because of the shift I get an attenuation of 2^5. Therefor I compensate Sa
first by multiplying (SHL) by 2^5

To make smaller steps I can use 1-(1/2^5+1/2^6)
But now the multiplying part.... I cannot use the same trick
here....multiplying by 2^5+2^6 is not ok. I have to multiply by 1/2^5 +
1/2^6 =21,3

Anyone knows how to solve this problem ?
 
"Jam" <no@email.please> wrote in message
news:ci93a6$bh1$1@voyager.news.surf.net...
Hi all,

I am making a variable IIR filter:

in the form of (1/z-"coeff") . For 51 kHz (fs=10e6) the coeff would be
0.96875
Which can be made as 1-1/2^5. Which is 1*Sa - shr(Sa,5)
Because of the shift I get an attenuation of 2^5. Therefor I compensate Sa
first by multiplying (SHL) by 2^5

To make smaller steps I can use 1-(1/2^5+1/2^6)
But now the multiplying part.... I cannot use the same trick
here....multiplying by 2^5+2^6 is not ok. I have to multiply by 1/2^5 +
1/2^6 =21,3

Anyone knows how to solve this problem ?
The way to do a general fractional multiply Sa * x is to pick a scaling
factor n and do it as (Sa * (x * 2^n)) / (2^n). In your first case, where x
was 1/(2^5), it's easy - pick n = 5. In general, however, you can't do
that. I'm not quite sure from your post if you now have x = (1/(2^5) +
1/(2^6)), or x = 1/((2^5) + (2^6)). In the first case, the answer is again
easy - pick n = 6, giving (Sa * 3) / (2^6), i.e., shr(Sa*3, 6). In the
second case, it's going to be inexact - you might pick n = 9 and use
shr(Sa*5, 9), or use bigger shifts for higher accuracy (and more work in the
multiplier).
 
I should attenuate by 1/2^5 because the gain would be 32 if I didn't
Unfortunately it is 1- ((1/2^5) + (1/2^6))
Maybe there is another way

0-----|1/2^7|--
| |
v+ |
--------------------------------
0-----|1/2^6|--
| |
v+ |
-------------------------------

0-----|1/2^5|--
out<--| |
v - ----- | ------
--SAin-- 0-----| T |----------|1/2^5|--SAlfp
^ + ----- | -------
|__________ _|

SaLPF <= (SAin + Salpf-(Salpf*1/2^5)) *1/2^5

With multiple 1/2^n maybe by taking another point as output I don't need the
final attenuation.

So Out<= Salpf*(1/2^5+1/2^6+....)
Salpf<=SAin+Salpf-Out

I still have to compile the idea....
Who knows a better way ?


"David Brown" <david@no.westcontrol.spam.com> wrote in message
news:ci95hf$6ql$1@news.netpower.no...
"Jam" <no@email.please> wrote in message
news:ci93a6$bh1$1@voyager.news.surf.net...
Hi all,

I am making a variable IIR filter:

in the form of (1/z-"coeff") . For 51 kHz (fs=10e6) the coeff would be
0.96875
Which can be made as 1-1/2^5. Which is 1*Sa - shr(Sa,5)
Because of the shift I get an attenuation of 2^5. Therefor I compensate
Sa
first by multiplying (SHL) by 2^5

To make smaller steps I can use 1-(1/2^5+1/2^6)
But now the multiplying part.... I cannot use the same trick
here....multiplying by 2^5+2^6 is not ok. I have to multiply by 1/2^5 +
1/2^6 =21,3

Anyone knows how to solve this problem ?


The way to do a general fractional multiply Sa * x is to pick a scaling
factor n and do it as (Sa * (x * 2^n)) / (2^n). In your first case, where
x
was 1/(2^5), it's easy - pick n = 5. In general, however, you can't do
that. I'm not quite sure from your post if you now have x = (1/(2^5) +
1/(2^6)), or x = 1/((2^5) + (2^6)). In the first case, the answer is
again
easy - pick n = 6, giving (Sa * 3) / (2^6), i.e., shr(Sa*3, 6). In the
second case, it's going to be inexact - you might pick n = 9 and use
shr(Sa*5, 9), or use bigger shifts for higher accuracy (and more work in
the
multiplier).
 

Welcome to EDABoard.com

Sponsor

Back
Top