Simple low pass filter?

Algorithm development and general DSP issues

Moderator: frank

Post Reply
sad1024
Posts: 34
Joined: Mon May 24, 2010 3:34 pm

Simple low pass filter?

Post by sad1024 »

equ temp reg0 ;setup registry

ldax adcl ; read input
rdfx temp, 0.01 ;?
wrlx temp, 1 ;?
wrax dacl ; write output
sad1024
Posts: 34
Joined: Mon May 24, 2010 3:34 pm

Post by sad1024 »

Can anybody tell me what the variables do and the proper way to write the code for a low pass filter?
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post 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.
Frank Thomson
Experimental Noize
sad1024
Posts: 34
Joined: Mon May 24, 2010 3:34 pm

Post 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.
livingston
Posts: 131
Joined: Sun Nov 15, 2009 3:37 pm
Location: New Orleans, LA US

Post 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
sad1024
Posts: 34
Joined: Mon May 24, 2010 3:34 pm

Post by sad1024 »

What about the rdfx and wrlx commands?
livingston
Posts: 131
Joined: Sun Nov 15, 2009 3:37 pm
Location: New Orleans, LA US

Post 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.
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post 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.
Frank Thomson
Experimental Noize
sad1024
Posts: 34
Joined: Mon May 24, 2010 3:34 pm

Post 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.
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post by frank »

Inputs do have filtering, always helps to add a little externally. No anti-aliasing filters on outputs, not necessary.
Frank Thomson
Experimental Noize
mdroberts1243
Posts: 18
Joined: Tue Jul 22, 2008 3:54 pm
Location: Ottawa, Canada
Contact:

Post 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
-mark
My blog: http://tubenexus.com
Post Reply