Page 1 of 1

Simple low pass filter?

Posted: Fri May 28, 2010 8:04 am
by sad1024
equ temp reg0 ;setup registry

ldax adcl ; read input
rdfx temp, 0.01 ;?
wrlx temp, 1 ;?
wrax dacl ; write output

Posted: Tue Jun 01, 2010 5:11 am
by sad1024
Can anybody tell me what the variables do and the proper way to write the code for a low pass filter?

Posted: Tue Jun 01, 2010 9:47 am
by frank
What you have there is a single pole low pass, see http://www.spinsemi.com/knowledge_base/ ... le_filters for a description of the structure and equations to calculate the coefficient.

Posted: Tue Jun 01, 2010 10:24 am
by sad1024
I am unable to get it to work using various coefficents. I have read the link but still no luck. This code is all new to me and I would appreciate any help I can get.

Posted: Tue Jun 01, 2010 10:52 am
by livingston
It depends what you're trying to do with it. For example, if using a lowpass to detect an input envelope, you would want the coefficients set one way so that the cutoff was below audio frequencies. Here's what I have used as a one-pole lowpass, using a pot to vary frequency:

rdax adcr, 1
rdax lp_filt,-1.0
mulx pot2
rdax lp_filt,1.0
wrax lp_filt,1.0

Posted: Tue Jun 01, 2010 11:05 am
by sad1024
What about the rdfx and wrlx commands?

Posted: Tue Jun 01, 2010 2:25 pm
by livingston
Well, as I said the coefficients will be different depending on what you're doing and what cutoff you want. Here's what I use for envelope detecting:

rdfx envfil,0.0004
wrlx envfil,-1

A bigger number for RDFX will be a higher cutoff freq.

Posted: Tue Jun 01, 2010 6:09 pm
by frank
If you don't understand how to calculate the coefficient after reading the article I linked to then you probably need to get a basic DSP book. Programming a DSP is not like programming a micro, you need to understand Z domain basics, basic FIR and IIR structures, etc.

Posted: Tue Jun 01, 2010 6:55 pm
by sad1024
I have read a DSP book. I am slowly getting the hang of it. I am very rusty at programming though, I had BASIC, but that was 30 years ago. I can calculate the coefficients, just didn't know where they go. Do the input and output have anti-aliasing filters? I am able to write the code for low pass filters now, thanks for the help.

Posted: Thu Jun 03, 2010 1:37 pm
by frank
Inputs do have filtering, always helps to add a little externally. No anti-aliasing filters on outputs, not necessary.

Posted: Mon Sep 13, 2010 6:54 pm
by mdroberts1243
Back to the OP's question, I just had to implement a 'simple' low-pass filter for the Dattorro Plate Reverb.

I didn't realize you couldn't do that with the 2-statement Low-pass... or can you?

To get a more pleasing result in the Dattorro Plate I had to implement the low pass discretely (just one extra instruction)...

Code: Select all

; k1 for freqs: 
equ	k1_1kHz	0.82552
equ	k1_2kHz	0.68148
equ	k1_4kHz	0.46441
equ	bandwidth	1-k1_2kHz	; coefficient for input low-pass

; input low-pass 
rda	predelay#,bandwidth
rdax	lp_inp,1-bandwidth
wrax	lp_inp,1