High Pass Filter

Greg Gauper

Member
Join Date
May 2002
Location
Hubertus, Wisconsin
Posts
89
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.
 
In order to get a sharper rolloff, you're going to need to increase the order of your filter. You only have a first order filter, which will give you a maximum of 20 dB per decade rolloff from your cutoff frequency. This should be no problem; just design a higher order digital filter, take the inverse Z-transform, and implement the resulting difference equation in the PLC.

By the way, don't forget that high pass filters amplify (or at least don't attenuate) high frequency noise. I'm not sure that I'd want one in most of the systems I've seen.

You can probably find Java Applets on the web that will help you with the filter design.
 
Thanks!

Yes I am aware that high frequency noise will not be attenuated. I'm actually relying on the built-in filtering of the analog input module to filter out any noise above 60Hz, and the range of signal that I am concerned about is l to 5Hz, which should be well within the range of my PLC's sampling capability.

20db/decade rolloff below my cutoff frequency is acceptable in this application.

This is a rather unorthodox application.
 
More

It is easy to get a 40db per decade with a two pole Butterworth filter. This goes for high pass or low pass filters. This can be a significant improvement in many cases.

Many here know of the simple low pass filter:

y(n)=(k-1)*y(n-1)+k*x(n)

This equation only provides 20db per decade attenuation.

Did you know that you can cascade these filters to get extra filtering?

y(n)=(k-1)*y(n-1)+k*x(n)
out(n)=(k-1)*out(n-1)+k*y(n)

The two equations provide 40db per decade attenuation.
These two equations can be optimized into one equation as shwon below.

Greg's high pass filter can also be cascaded to provide a 40db roll off. Greg's high pass filter is just a simple real filter so the corner frequency will not be that sharp. Butterworh filters are much better when using filters with 2 or more poles.
 
They why of it all?

I am truly amazed at the creativity of people and the power of PLCs. Especially in light of the use discussed in this thread. My main question is, why? If filtering is what you need, there are much simpler and less costly ways of providing it, even active filters if you like. To use a PLC for the purpose is quite ingenious and again proves how powerful they are but my question still remains, why? Because it can be done? Like climbing the mountain because it is there? I would like to know a little about the motivation here Greg, and others who seem very willing to use a PLC for this purpose. I hope you will share your thoughts on, why?
 
Re: The why of it all?

randylud said:
I am truly amazed at the creativity of people and the power of PLCs. Especially in light of the use discussed in this thread. My main question is, why? If filtering is what you need, there are much simpler and less costly ways of providing it, even active filters if you like.

Greg's HP filter looks simple to me. Three multiplies and two adds can be done in one compute block. It would take a COP instruction to shift the data. That still fits on one rung. That IS simple and cheap. The alternative is extra hardware, wiring, space and mountung. That isn't cheap.
 
Point Taken!

Thanks, Peter! You Da Man! However, in an industrial environment, what signal is in need of filtering. I realize that some analog voltage signals might be a little noisy, but enough to require a filter? Maybe? Just a good example of how one would use such a SIMPLE coded filter would be helpful to ones understanding.
 
Last edited:
One example of using a "filter" in a PLC that comes to mind is so-called "lag" function.

In an aluminum rolling mill (unwind motor + pressure rolls motor + rewind motor), the master speed is set by means of a speed pot. An operator may turn the pot as fast and sharply as he pleases. However, you do not want the line to change the speed just as fast - or you may start having problems with the web tension.

The filter logic (and I beleive this would be the low-pass filter in this case) would filter out all the rapid changes in the speed pot value and would change the master speed gradually. This is a real-life example.

As far as high pass... One thing that comes to mind is to be able to detect rapid pressure changes in a pneumatic system which might indicate a burst. The pressure may change slowly within the specs, but any sharp change would be filterd out and acted upon.

Peter and the others will correct me if I am wrong.
 
In my case I have a process in which I am already monitoring an analog signal, and I don't want to add anymore hardware, but with a few, fairly simple equations I want my control system to ignore any DC level/low frequency change and only react to high frequency signal changes. I am trying to reject signals 2Hz and lower, but react to signals 2Hz and higher. As I stated before, the module's built-in filtering behaves as a low pass filter up to 60Hz to ignore any noise. I only want to act on signals in the range of 2Hz to 60Hz, and realistically, I only care about 2Hz to 10Hz.

Peter, thanks for the advice. I dug up my simple filter equation from an old cookbook. It can be used as a low pass or high pass filter just by changing the coefficients. I didn't bother to list the full blown equation.

As far as why I want to do this.....the answer is I am trying to duplicate a prototype control scheme that currently utilizes a hardwired high pass filter, with a design goal of eliminating the extra components and perform the operation entirely in the program, while at the same time providing convienient adjustability to the filter tuning parameters. The equations are rather efficient and the frequencies that I am trying to analyze are well within the performance window of my PLC for my application. It is much easier to use a digital filter instead of adding components to build a hardwired one, and I already have the analog input signal available for free.

As I stated before....this is a very unorthodox and somewhat proprietary application.
 

Similar Topics

Hello does any one know or have a source file for a high-pass filter for S7 to help with high speed position control over-shot Thanks in...
Replies
6
Views
4,502
Hi, I need to use 3 filters in my s7300 PLC. These are Low Pass, High Pass, Notch, but there are in the library of STEP 7. I saw these filters in...
Replies
2
Views
6,404
Can anyone recommend a flexible 600-volt shielded ethernet patch cable? I have used them from Allen Bradley / Panduit before and they are too...
Replies
0
Views
60
Hello Folks, Has anyone configured a Momentum high speed counter on Unity 13.1. We need the wiring diagram for Momentum High speed counter and...
Replies
0
Views
65
Hello, I have converted RSView 32 to FTView SE 14 (I have tested FTView 12 before as well and there were some difficulties so I moved on to...
Replies
4
Views
185
Back
Top Bottom