DSPRelated.com
Forums

Re: [Fwd: Re: code working on simulator but not on device?]

Started by Jeff Brower May 22, 2006
Megha-

> I had one question regadring the normalization and I just thought
> if you can help. When I normalize the sos matrix (by diving it by
> a factor), what should I do with value of "g". I guess that is also
> suppose to be normalized.

I assume that "g" is the gain factor for the overall filter. In that case, you don't
have to do anything to it. When you have DAC value ready to output, then you take
your most recent y[n] output (should be in Q15 format):

DAC output = y[n] * k * g

where k is the scaling factor to allow Q15 to work, and g is the filter gain. It
might be a good idea to pre-calculate k*g so you can use it in Q15 format.

-Jeff
Dear Jeff
I had a question regarding normalization.
IIR filter function is as follows:

We convert these into biquads (as we need to trasfer biquads to DSP). We convert with command
[sos,g] = tf2sos(b,a)
A biquad is as shown:

b0 + b1 * z-1 + b2 * z-2
H(z) = ——————————————
1 + a1 * z-1 + a2 * z-2

and sos is:

Now i need to pass these values bo,b,b2,a1 and a2 to DSP and a0 should be 1. What I want is these coeff should be betwen 1 and -1 for DSP. But from MATLAB I am getting them outside the limit. Hence i need to normalize. So Thats the problem. If I normalize then a0 also gets normalize.
Should I normalize only b0,b1,b2,a1 and a2. If I do that will it effect the filter?
I hope my doubt is clear.
Kindly reply
thanking You
Megha Daga

Jeff Brower wrote: Megha-

> I had one question regadring the normalization and I just thought
> if you can help. When I normalize the sos matrix (by diving it by
> a factor), what should I do with value of "g". I guess that is also
> suppose to be normalized.

I assume that "g" is the gain factor for the overall filter. In that case, you don't
have to do anything to it. When you have DAC value ready to output, then you take
your most recent y[n] output (should be in Q15 format):

DAC output = y[n] * k * g

where k is the scaling factor to allow Q15 to work, and g is the filter gain. It
might be a good idea to pre-calculate k*g so you can use it in Q15 format.

-Jeff

---------------------------------
Sneak preview the all-new Yahoo.com. It's not radically different. Just radically better.