Page 1 of 1

Highpass filter with variable cutoff frequency

Posted: Tue Jun 03, 2014 12:31 pm
by jakesteffes
Hey folks,

I'm trying to implement a high pass filter, where the cutoff frequency is controlled via a scaled pot input. This is what I'm trying, but it's giving me a low pass filter instead. ( ? )

Code: Select all

equ hp0 reg5    ;register for high-pass filter
equ khp reg14  ;register for cutoff frequency

;load and scale pot2, write to register
ldax	pot2
sof	-0.07884094,	0.082668548	;450Hz to 20Hz @ 32kHz
wrax	khp,	0.0

rdax	hp0,	-1.0         ; these three lines recreate
mulx	khp                 ; RDFX, but with a register coefficient
rdax	hp0,	1.0          ; instead of a fixed coefficient
wrhx	hp0,	-0.5    


Any help would be greatly appreciated. As I said earlier, when the pot as at 0, I get a *low pass* cutoff around 450 Hz, and when the pot is maxed, I get a *low pass* cutoff around 20 Hz (or something much lower than 450).

Thank you!
-Jake[/code]

Posted: Sat Jun 07, 2014 8:08 am
by slacker
I think the answer is in the notes for the WRHX instruction http://www.spinsemi.com/knowledge_base/ ... .html#WRHX.

"The input signal will be in ACC, and during the execution of the first statement, that input signal will be transferred to PACC. During the second instruction, the written value is multiplied by a coefficient (which would be negative for a shelf), and added to PACC (the original input signal)."

Your version of RDFX will leave the result of the mulx instruction in PACC not the original input signal. I think you'll need to write your own version of WRHX as well.

Posted: Mon Jun 09, 2014 10:50 am
by jakesteffes
Thanks slacker,

I think you're write - I ended up coding a single pole HP filter from the ground up, and it seems to be doing the trick. Thanks for the help!

Posted: Mon Jun 09, 2014 1:15 pm
by Digital Larry
There is a 2-pole variable frequency high pass in each of the algorithms I just posted under "interesting guitar patch". In one case it's controlled by a knob and in the other one a knob and envelope signal are mixed together to control the filter frequency.

The code should be commented in such a way that you can find it.