Spin Semiconductor Forum Index Spin Semiconductor
Support forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

High Pass and Low Pass Filters
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Spin Semiconductor Forum Index -> Algorithm development
View previous topic :: View next topic  
Author Message
Aaron



Joined: 04 Mar 2015
Posts: 42

PostPosted: Fri Mar 06, 2015 7:02 am    Post subject: High Pass and Low Pass Filters Reply with quote

I have been spending the last few days trying to understand how to do simple low pass and high pass filters. So far, I believe I understand how the low pass filtering is accomplished but I am baffled as to how to create a HPF.

Based on this post http://www.spinsemi.com/forum/viewtopic.php?t=481&highlight=low+pass+filter by Digital Larry I have come to understand that for LPF, the coefficient for RDFX is related to the frequency in the following way:

RDFXcoeff = Freq/(32768/2pi)

So for a cutoff frequency of 72Hz would look something like:

ldax adcl
rdfx LPF, 0.0138
wrax LPF,1
wrax dacl,0

This seems to make sense and works, as far as I can tell.

For high pass, I believe that the WRHX command is needed but I am not sure how to implement it.

If anyone could shine a little light on the subject it would be much appreciated. Thanks!
Back to top
View user's profile Send private message
frank



Joined: 19 Oct 2005
Posts: 972

PostPosted: Fri Mar 06, 2015 8:15 am    Post subject: Reply with quote

Read all the sections in this area: http://spinsemi.com/knowledge_base.html
_________________
Frank Thomson
Experimental Noize
Back to top
View user's profile Send private message Visit poster's website
Aaron



Joined: 04 Mar 2015
Posts: 42

PostPosted: Fri Mar 06, 2015 10:01 am    Post subject: Reply with quote

So from what I gather then, for a hpf all I would need is:

ldax adcl
rdfx hpf,0.00125
wrhx hpf,-1
wrax dacl,0


But whenever I try this code it sure doesn't sound like a HPF.
Back to top
View user's profile Send private message
gfisys



Joined: 14 Dec 2011
Posts: 23
Location: Indonesia

PostPosted: Fri Mar 06, 2015 5:36 pm    Post subject: Re: High Pass and Low Pass Filters Reply with quote

Aaron wrote:
I have been spending the last few days trying to understand how to do simple low pass and high pass filters. So far, I believe I understand how the low pass filtering is accomplished but I am baffled as to how to create a HPF.

Based on this post http://www.spinsemi.com/forum/viewtopic.php?t=481&highlight=low+pass+filter by Digital Larry I have come to understand that for LPF, the coefficient for RDFX is related to the frequency in the following way:

RDFXcoeff = Freq/(32768/2pi)

So for a cutoff frequency of 72Hz would look something like:

ldax adcl
rdfx LPF, 0.0138
wrax LPF,1
wrax dacl,0

This seems to make sense and works, as far as I can tell.

For high pass, I believe that the WRHX command is needed but I am not sure how to implement it.

If anyone could shine a little light on the subject it would be much appreciated. Thanks!



You got the equation wrong, the correct one is
RDFXcoeff = 1 - exp(-2*pi * Freq / 32768)
Back to top
View user's profile Send private message Visit poster's website
Digital Larry



Joined: 12 Nov 2012
Posts: 274

PostPosted: Sat Mar 07, 2015 8:19 am    Post subject: Re: High Pass and Low Pass Filters Reply with quote

gfisys wrote:

You got the equation wrong, the correct one is
RDFXcoeff = 1 - exp(-2*pi * Freq / 32768)


Is that for HPF only or both HPF and LPF?

Thx,

DL
Back to top
View user's profile Send private message Visit poster's website
gfisys



Joined: 14 Dec 2011
Posts: 23
Location: Indonesia

PostPosted: Sat Mar 07, 2015 4:44 pm    Post subject: Re: High Pass and Low Pass Filters Reply with quote

Digital Larry wrote:
gfisys wrote:

You got the equation wrong, the correct one is
RDFXcoeff = 1 - exp(-2*pi * Freq / 32768)


Is that for HPF only or both HPF and LPF?

Thx,

DL


Both HP & LP
Back to top
View user's profile Send private message Visit poster's website
Aaron



Joined: 04 Mar 2015
Posts: 42

PostPosted: Tue Mar 10, 2015 5:28 am    Post subject: Reply with quote

Quote:
RDFXcoeff = 1 - exp(-2*pi * Freq / 32768)



This equation is working much better! Thanks gfisys! Very Happy
Back to top
View user's profile Send private message
MacroMachines



Joined: 12 Dec 2014
Posts: 70
Location: Detroit,MI

PostPosted: Wed Jul 06, 2016 10:08 am    Post subject: Reply with quote

how do you code RDFXcoeff = 1 - exp(-2*pi * Freq / 32768) in spinASM? Im a bit lost as to how to do complex math and how to use the exp instruction, I don't seem to get anything from it when I ran it on a pot for testing
_________________
http://MacroMachines.net
Digital Control for your Analog Soul.
Back to top
View user's profile Send private message Visit poster's website AIM Address
Digital Larry



Joined: 12 Nov 2012
Posts: 274

PostPosted: Thu Jul 07, 2016 11:20 am    Post subject: Reply with quote

You can't make an adjustable filter with RDFX. It is for fixed filters. So you calculate the coefficient ahead of time.
Back to top
View user's profile Send private message Visit poster's website
MacroMachines



Joined: 12 Dec 2014
Posts: 70
Location: Detroit,MI

PostPosted: Thu Jul 07, 2016 10:29 pm    Post subject: Reply with quote

Digital Larry wrote:
You can't make an adjustable filter with RDFX. It is for fixed filters. So you calculate the coefficient ahead of time.


are you sure about that? it doesn't state this in the manual anywhere. Im going to try this now and see. not hard to swap it out for a register based IIR filter if it doesn't work.
_________________
http://MacroMachines.net
Digital Control for your Analog Soul.
Back to top
View user's profile Send private message Visit poster's website AIM Address
frank



Joined: 19 Oct 2005
Posts: 972

PostPosted: Fri Jul 08, 2016 3:50 pm    Post subject: Reply with quote

For RDFX the coefficient is part of the instruction so you cannot use a POT input with it. You would need to code it differently if you want to use a pot to control filter cutoff.
_________________
Frank Thomson
Experimental Noize
Back to top
View user's profile Send private message Visit poster's website
MacroMachines



Joined: 12 Dec 2014
Posts: 70
Location: Detroit,MI

PostPosted: Mon Jul 11, 2016 1:32 am    Post subject: Reply with quote

Thank you Smile
I realized after posting that there was no way to use a register to modify the coefficient. It looks like it doesn't take many more instructions to do a filter with pot controlled cutoff though, so that's good Very Happy
_________________
http://MacroMachines.net
Digital Control for your Analog Soul.
Back to top
View user's profile Send private message Visit poster's website AIM Address
Sweetalk



Joined: 15 Oct 2009
Posts: 95

PostPosted: Thu Aug 18, 2016 10:43 am    Post subject: Re: High Pass and Low Pass Filters Reply with quote

gfisys wrote:
Aaron wrote:
I have been spending the last few days trying to understand how to do simple low pass and high pass filters. So far, I believe I understand how the low pass filtering is accomplished but I am baffled as to how to create a HPF.

Based on this post http://www.spinsemi.com/forum/viewtopic.php?t=481&highlight=low+pass+filter by Digital Larry I have come to understand that for LPF, the coefficient for RDFX is related to the frequency in the following way:

RDFXcoeff = Freq/(32768/2pi)

So for a cutoff frequency of 72Hz would look something like:

ldax adcl
rdfx LPF, 0.0138
wrax LPF,1
wrax dacl,0

This seems to make sense and works, as far as I can tell.

For high pass, I believe that the WRHX command is needed but I am not sure how to implement it.

If anyone could shine a little light on the subject it would be much appreciated. Thanks!



You got the equation wrong, the correct one is
RDFXcoeff = 1 - exp(-2*pi * Freq / 32768)


Seems to work fine but there's a lot of error in low and high frequencies.

For example, for 600Hz, according to the ecuation the RDFXCoefficient is 0.108677. Measuring the -3dB point with an oscilloscope the cutoff frequency is 700Hz. Had to manually adjust it to 0.1050.

And for 5.8KHz the coef is 0.677 but in the oscilloscope is really 3.5KHz.

There's any explanation to this?, some correction is needed?
Back to top
View user's profile Send private message
frank



Joined: 19 Oct 2005
Posts: 972

PostPosted: Fri Aug 19, 2016 7:53 am    Post subject: Reply with quote

What sample rate are you running at? If different than 32768 you need to use it instead of 32768 in the equations.
_________________
Frank Thomson
Experimental Noize
Back to top
View user's profile Send private message Visit poster's website
Sweetalk



Joined: 15 Oct 2009
Posts: 95

PostPosted: Fri Aug 19, 2016 1:09 pm    Post subject: Reply with quote

frank wrote:
What sample rate are you running at? If different than 32768 you need to use it instead of 32768 in the equations.


32768Hz, I'm aware of the sample rate and it's impact on the equations
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Spin Semiconductor Forum Index -> Algorithm development All times are GMT - 8 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group