ΣSigmaStudio Ask AI Русский Log in

different from the helping document

SigmaDSP & SigmaStudio leiming Feb 25, 2011 00:00 10 replies Original on forum ↗
Subscribe
leiming Question
Feb 25, 2011 00:00

Hi! I find a serious proble that the value of coefficient which generate from the SigmaStudio is different from the equation of helping document!

For example,a 1st order filter,We set for 1000HZ frequency,gain of 0dB and as the lowpass filter,I got the coefficient are respectively 0.121918916702271 ,0, 0.878081083297729

In helping a document

The General 1st-Order block has two algorithms options.

Common variables:

ω0 = 2*pi*f0/Fs

gainLinear = 10^(gain/20)

Lowpass

Transfer Function

Coefficients

a1 = 2.7^-ω0
b0 = gainLinear * (1.0 - a1)
b1 = 0

f0=1000Hz;Fs=48000Hz;gain=0;

So w0=2*pi*1000/48000=0.130899693899574718269276;gainlinear=10^(0/20)=1;

a1=2.7^-w0=2.7^-0.130899693899574718269276=1.1388470067969598079945487283746;

a1=1/a1=0.87808107149750427306800276251186;

b0= gainLinear * (1.0 - 1/a1)=0.1219189285024957269319972374; b1=0;

In the actual implementation on the DSP, when the coefficients are stored in parameter RAM, a1 needs to be inverted. This is done in software, automatically, before the parameters are written to memory.

For example,a general 2nd order filter,we set for 1000Hz frequency, gain of 0dB,Q of 1.41, and as the lowpass filter,i got the coefficient are respectively EQ1940Single10B1=0.00408828258514404;

EQ1940Single11B1=0.00817668437957764;

EQ1940Single12B1=0.00408828258514404;

EQ1940Single11A1=1.8951700925827;

EQ1940Single12A1=-0.911523461341858;

But in helping a docment:

Lowpass

ω0 = 2*pi*f0/Fs

gainLinear = 10^(gain/20)

Transfer Function

Coefficients

alpha = sin(ω0)/(2*Q)
a0 = 1 + alpha
a1 = -2*cos(ω0)
a2 = 1 - alpha
b0 = (1 - cos(ω0)) * gainLinear / 2
b1 = 1 - cos(ω0) * gainLinear
b2 = (1 - cos(ω0)) * gainLinear / 2

For all of the above filters, the coefficients are divided by a0, normalizing them and making a0 = 1 so that only 5 coefficients must be stored. In the actual implementation on the DSP, when the coefficients are stored in parameter RAM, a1 and a2 need to be inverted. This is done automatically, in software, before the parameters are written to memory.

Among them
gain=0dB;fs=1000Hz;Fs=48000Hz; Q=1.41;

So w0=2*pi*1000/48000=0.130899693899574718269276; gainlinear=1;

alpha=sin(0.130899693899574718269276)/(2*1.41)=0.0008101520074285072310965239913;

a0=1+0.0008101520074285072310965239913=1.0008101520074285072310965239913;

a1=-2*cos(0.130899693899574718269276)=-1.9999947804650706869450798840089; 1/a1=-0.50000130488713778026095773346491;

a2=1-0.0008101520074285072310965239913=0.999189847992571492768903476009;1/a2=1.0008108088858750397659847761385;

b0=(1-cos(0.130899693899574718269276))/2=--0.0000013048837323282637300289978;

b1=2*b0=-0.000002609767464656527460057994;b2=b0;

Easily we could find the difference between the coefficient values generated by SigmaStudio, and those you calculate accoeding to the equation of helping document.

Egerly look forward to your reply.thanks very much!

coefficient

help

filter

document

sigmastudio

ADIApproved Reply
Mar 8, 2011 00:00

Hi Leiming,

I have requested a complete list of the filter parameter calculations from the software team, but it may take a few days before I receive the information. Once I have it, I will post it here.

leiming Reply
Mar 9, 2011 00:00

Thanks for your reply very much,

I'm waiting for your useful information!

Svilen Reply
Mar 9, 2011 00:00

Hi Leiming,

In helping document b1 is not correct, missing a brackets. Right one is: b1 = (1 - cos(ω0)) * gainLinear.

I think, in your calculations have setup your calculator to use degrees, should be used radians.

leiming Reply
Mar 10, 2011 00:00

Hi! At first thanks for your reply ! b1 is not is the key problem ,because the gainLinear=1,so the bracket don't effect the result,In my opinion there is other problem !

Additionally ,the high order filter block Crossover is used in our design,there arise more coefficient,can you tell me the equation of high order filter coefficient,before some one tell me that general 1st and general 2nd filter is in serise simply become the high order filter, but after many times experiment i find the value of coefficient is not correct.

Do you have any useful information ?

I'm looking forward to your reply!

ADIApproved Reply
Mar 17, 2011 00:00

Hi Leiming,

I posted the coefficient calculation equations here: https://ez.analog.com/message/21166#21166

MagicRuB Reply
May 4, 2011 00:00

This has been brought up several times and now I'm seeing problems with generating the 1st order filter coef for HPF. The 2nd order filters are generated just fine using the new documents in SigmaStudio 3.4 build 0 rev 724 (4/8/2011) using a ADAU144x DSP.

1st order HPF, gain=0db (unity), Fc = 1000 Hz, Fs = 48kHz

w0 = 2*pi*f0/Fs = 2*pi*100/48000 = 0.130899

gainLinear = 10^(0/20) = 1.0

My math:

a1 = pow(2.7,-w0) = 2.7^(-w0) = 0.87808

b0 = gainLinear * a1 = 0.87808

b1 = -a1 * gainLinear = -0.87808

a1 = -a1 = -0.87808

// "a1 needs to be inverted in software". (please please please change the confusing language used here in the documentation)

My results in sequential address order:

b1 = -0.87808

b0 = 0.87808

a1 = -0.87808

SigmaStudio's results:

b1 = -0.93904

b0 = 0.93904

a1 = 0.87808

Firstly, it looks like both the 1st order LPF and HPF do not need their a1 inverted as indicated by the documents.

Secondly, the docs seem to be missing something somewhere in LPF.b0 which generates an inverted copy LPF.b1 (or vice versa?)

ADIApproved Reply
May 5, 2011 00:00

Hi MagicRub,

I was able to get access to the filter math calculations and I found out that the code had been modified recently. It does not match the help documentation in a few places now. I'm trying to get to the bottom of this, but for now, I will give you the new calculations.

/--------------------------------/

First order filters
frequency = Cutoff frequency
gain = Linear Gain
fs = Sample Rate

PI = π

For lowpass filters,

A1 = Pow(2.7,(-2 * PI * frequency/fs))
B0 = gain * (1.0 - A1)
B1 = 0

For highpass filters,

A1 = Pow(2.7,(-2 * PI * frequency/fs))
B1 = (1.0 + A1) * 0.5 * gain
B0 = -B1

For allpass filters,

A1 = Pow(2.7,(-2 * PI * frequency/fs))
B0 = -gain * A1
B1 = gain

/--------------------------------/

Note that the calculation for the highpass filters differs from what you have been using.

I just checked and the calcuation works out.

Sorry for the confusion. I will be pushing to get this documentation updated.

MagicRuB Reply
May 6, 2011 00:00

Thanks Brett!

Just to make sure everything is A-OK across the board (so to speak), could you do me/us a favor and double check the filter math calcs with the current (SigmaStudio 3.4) help docs and make sure everything jives 100%?

ADIApproved Reply
May 6, 2011 00:00

Hi MagicRub,

I'm juggling some other priorities right now, but I will make a sincere effort to update all filter coefficient calculation equations in SigmaStudio's help file in time for the next major release (which I guess would be 3.5).

EZAdministrator Reply
Aug 2, 2018 00:00

This question has been assumed as answered either offline via email or with a multi-part answer. This question has now been closed out. If you have an inquiry related to this topic please post a new question in the applicable product forum.

Thank you,
EZ Admin