Greg Gauper
Member
There have been several discussions in the past regarding ladder code to generate low pass filters.
I'm looking for some advice on building a high pass filter, for an experiment in a project under developement.
I'm currently using the following psuedo code written in ladder from one of my 'cookbooks' of generic formulas and equations.
Filter Terms:
A = Filter Term (ranges from 0.0 to 1.0)
B = Coefficient, = (1.0 + A)/2
C = Coefficient, = -B
Filter Equation:
Filter_Output = (Input * B) + (Previous_Input * C) + (Last_Output * A)
Previous_Input = Input
Last_Output = Filter_Output
The above equation is performed every 5msec in a high speed interupt routine. I adjust the 'A' term to shift the frequency.
The formula works ok but I'm looking for something with a sharper rolloff at lower frequencies. I'm trying to pass signals 2Hz and higher, I want a -3db rolloff at .666Hz and as sharp of a rolloff as possible at frequencies below .666Hz. The routine does reject DC rather nicely. Any suggestions? Any alternate formulas, that are as easy to implement in ladder logic using conventional math? I can use floating point numbers.
I'm looking for some advice on building a high pass filter, for an experiment in a project under developement.
I'm currently using the following psuedo code written in ladder from one of my 'cookbooks' of generic formulas and equations.
Filter Terms:
A = Filter Term (ranges from 0.0 to 1.0)
B = Coefficient, = (1.0 + A)/2
C = Coefficient, = -B
Filter Equation:
Filter_Output = (Input * B) + (Previous_Input * C) + (Last_Output * A)
Previous_Input = Input
Last_Output = Filter_Output
The above equation is performed every 5msec in a high speed interupt routine. I adjust the 'A' term to shift the frequency.
The formula works ok but I'm looking for something with a sharper rolloff at lower frequencies. I'm trying to pass signals 2Hz and higher, I want a -3db rolloff at .666Hz and as sharp of a rolloff as possible at frequencies below .666Hz. The routine does reject DC rather nicely. Any suggestions? Any alternate formulas, that are as easy to implement in ladder logic using conventional math? I can use floating point numbers.