Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

[HELP] How to code an equalizer on DSP ?

Status
Not open for further replies.

0zMax

Newbie level 4
Joined
Jan 31, 2013
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,330
Hello.

I actualy try to code a digital my firts equalizer with the 56k DSP (56374). I would like to know if my way to make it is good because the final response isn't look like I want.

1) take sample x(n) from ADC
2) calculate x(n) for each filter and store it.
3) Pop out results from 2) and add it to form y(n)
4) send y(n) to DAC

Before building a complete equalizer, I only use 3 IIR filters for testing the method.

1st filter : Lowpass Fcutoff = 1kHz
2nd filter : Band pass Fcentral 2kHz, Bandwidth 2kHz
3rd filter : Band pass Fcentral 4kHz, Bandwidth 4kHz

So the ideal bode graph should be a straigth line from 0 to 4,2kHz and then go down. But in practice it isn't look like this. :-|

Does my method is good ? Do i miss something ?
 

zorro

Advanced Member level 4
Joined
Sep 6, 2001
Messages
1,131
Helped
356
Reputation
710
Reaction score
298
Trophy points
1,363
Location
Argentina
Activity points
8,902
Hi 0zMax ,

The final amplitude characteristic can be different from a staight line, especially near the cutoff frequencies, depending of type and order of the filters.
But it is fundamental to assure that the designed gains in the bassbands are the same for the 3 filters. Are they?
What result do you get in practice?
Regards

Z
 

0zMax

Newbie level 4
Joined
Jan 31, 2013
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,330
Yes, the gains in the bassbands are the same for the 3 filters (Gain of 0dB for each one). The result in practice was similar like a bandpass filter with a 10 kHz central frequency. :S

So I decided to remove the third filter (Bandpass filter 4kHz) to make it easier and the result was a fail again...

I don't what to do and I stress a lot because this equalizer is a project school and no teacher can help because they never worked on DSP. :/
Anyone have a good tip ?
 

zorro

Advanced Member level 4
Joined
Sep 6, 2001
Messages
1,131
Helped
356
Reputation
710
Reaction score
298
Trophy points
1,363
Location
Argentina
Activity points
8,902
Hi 0zMax ,

Have you tested the filters one at a time?
You could have different kinds of probles, like wrong coefficients or corruption of variables.
I'd try to test the filters separately.
Regards

Z
 

0zMax

Newbie level 4
Joined
Jan 31, 2013
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,330
I zorro, thank for reply me.
I tested each filters one by one they work very well. The problem come from when I want assemble differents filters to "one".
Here is the code I wrote. I hope you will find why it's not work.

The first part is a do loop. I would like to implement 2 bandpass filters. Their good Coeff are already loading in the Y memory by a table. I do the loop 2 time becauce there is 2 filters the calculate.


....
;Configuration of memories
move #000192,r0
move #000192,r4
move #000200,r2
move #4,m0
move #4,m4
move #1,m2
clr a
...
;sample in X memory and coeff in Y memory

do #2,_enddo
move x:(r0)+,x0 y:(r4)+,y0
mpy x0,y0,a x:(r0)+,x1 y:(r4)+,y0 ;a = x(n)*b0
mac x1,y0,a x:(r0)+,x0 y:(r4)+,y0 ;a = a + x(n-1)*b1
mac x0,y0,a x:(r0)+,x0 y:(r4)+,y0 ;a = a + x(n-2)*b2
mac -x0,y0,a x:(r0)+,x0 y:(r4)+,y0 ;a = a - y(n-1)*a1
macr -x0,y0,a ;a = a - y(n-2)*a2
nop
lsl a ; Left shift a because every coeff devided by 2
nop
move a,x:(r2)+ ;Each result are store in x memory (C8h adress) indexed by r2 pointer.
;_enddo
...


When the second filters have been calculate, I add results together .

...
move x:(r2)+,b
add a,b ; last result was store in 'a' so I don't need to pop out it from r2 .
move (r2)+
move a,x:TxBuffBase ; -> DAC left output
...


After I don't forget to switch sample X(n) and y(n) in their respective memories to form x(n-1),y(n-1), etc ...


...
move x:(r0)+,x0
move x0,x:(r0)+ ; x(n) -> x(n-1)
move x1,x:(r0)+ ; x(n-1) -> x(n-2)
move x:(r0),x0 ; save y(n-2)
move a,x:(r0)+ ; y(n) -> y(n-1)
move x0,x:(r0)+ ; y(n-1) -> y(n-2)

jmp AudioLoop
...
 

zorro

Advanced Member level 4
Joined
Sep 6, 2001
Messages
1,131
Helped
356
Reputation
710
Reaction score
298
Trophy points
1,363
Location
Argentina
Activity points
8,902
Unfortunately I haven't worked with 56K DSP assembly language, so I can't check the correctness of the assembly code. But I look to the comments.
Please consider this observation:
Although the filters share the same input samples (x variables), their respective outputs (y variables) must be kept separate in memory. I don't see in the las part (... ... ; y(n) -> y(n-1) ... etc) that the y variables of the different filters are updated. Are they really different?
Regards

Z
 
  • Like
Reactions: 0zMax

    0zMax

    points: 2
    Helpful Answer Positive Rating

0zMax

Newbie level 4
Joined
Jan 31, 2013
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,330
Ho yes ! You're right, y variables must be updated vis-a-vis the actual calculated filter. I never think about it before. Thank you :). Now I understand how it's hard to do an IIR filter but it still possible. But I guess that if I do it with FIR filter, it will be easier.

I looked out for FIR filter documentation and I find the output equation : y(n) = b0.x(n) + b1.x(n-1) + b2.x(n-2) + ...

However, how I can find all the coefficients values and how many tap I need to form a bandpass filter ?
 

zorro

Advanced Member level 4
Joined
Sep 6, 2001
Messages
1,131
Helped
356
Reputation
710
Reaction score
298
Trophy points
1,363
Location
Argentina
Activity points
8,902
However, how I can find all the coefficients values and how many tap I need to form a bandpass filter ?
There are synthesis methods and computer aided design tools for these tasks.
For example, Matlab has an interactive tool (fdatool) for designing any type of filter, FIR or IIR.

Z
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top