Filtering Signals in Ladder Code - HELP!

foamman

Member
Join Date
Jan 2005
Posts
19
Application:
Read in pulses from a volumetric flowmeter via a high-speed counter card to display flowrate i.e. cc/sec.

Present Configuration:
Allen Bradley SLC-5/03 with HSCE2 high-speed counter card.
1. The flowmeter pickup is wired to the input of the high-speed counter card.
2. A selectable timed interrupt routine is programmed; the time interval can be easily changed.
3. When the time interval expires, the interrupt routine is executed as follows; the counter value is read, the counter is reset and then continues to count.
4. The counter value from step 3 is divided by the interrupt time from step 3 (this gives pulses per second) then multiplied by the flowmeter's pulse resolution so the result is flowrate (in my case cc/sec).
5. Repeat the calculation upon the execution of the timed interrupt routine.

Problem:
The above routine works fine but the signal always has bounce or noise. Bounce in the flowrate display is unacceptable of course!
The counter card counter result always has a random bounce of 1 count. This one count results in a flowrate bounce equal to 1 times the flowmeter resolution divided by the sample time. So to minimize the flowrate display bounce the flowmeter resolution can be decreased (less CC's per pulse) or the sample time can be increased. Well in my application a more accurate flowmeter is not an option - they cost too much. Obviously increasing the sample time solves the problem but then the display reacts very slowly to real changes in the flowrate.

Things I've tried:
I have tried several traditional filtering techniques that work but all result in a flowrate display that is slow to react to real changes in the flowrate. For example, a real change would be from 180 cc/sec to 200 cc/sec. I have programmed averaging routines and a first order Butterworth low pass filter. Each of these results is a steady signal but extremely slow transient response to real flowrate changes.

Help!
I'm thinking some sort of intelligent routine that inspects the numbers and decides on some sort of windowed limiting might work but frankly I'm stuck. I'm sure this has been done before and would welcome any suggestions.
Thanks.
 
I may be wrong, but I don't think you can have it both ways. A digital filetering routine essentially averages out readings, so minimizing spikes is always going to have the effect of slowing the response. Have you considered trying to increase the time span on your counter?
 
DON'T RESET THE COUNTER!!!!

One loses on average half a count each time you reset the counter and your readings will be low.

banghead banghead banghead

Tom is right about the delay. Attenuation is achieved at the cost of phase delay. The solution is to sample at a higher frequency. Have you ever heard of the term over sampling?

If you sampled four times faster and threw out the high and low and average the two readings that are left you would get better results. Are you should the bad readings are noise?

Then try a second order Butterworth filter.

ftp://ftp.deltacompsys.com/public/PDF/Mathcad - Butterworth.pdf

I just updated my old butterworth.html to a .pdf. PDF995 and Mathcad are great.

We do a 8 times oversampling on our analog inputs so we can filter without causing a phase delay.
 
Last edited:
I'm not sure if it will help or hurt but the HSCE2 card can give you a rate value without you having to calculate it. It uses different time bases for the frequency calculation based on what frequency it is seeing. This may help but it would let you get away from doing that calcuation yourself and the errors peter mentioned above.
 
I have tried increasing and decreasing the time span of the counter. Decreasing it causes more bounce and faster response and increasing it causes less bounce but slower responce. I can't find an acceptable setting.

I may have misrepresented the bounce as noise. It is not noise but rather bounce due to the method of aquiring the data.

I have not tried using the HSCE2's rate function. The operating manual warns against doing this with signals below 60 HZ. Under some conditions my signal could be much lower than this.

I'm not sure I understand the over sample idea, decreasing the sample time increases the bounce. The bouce is equal to 1 (1 count of bounce) times the flowmeter resolution divided by the sample time.

I think the real answer is this is as good as it gets with my present flowmeter. To get a better signal requires a more accurate flowmter.

I would appreciate more input, Thanks.
 
didn't see the warning about rates under 60Hz, just that it will not give a rate less than 1Hz.

Also, it states that the rate accurace is typically .005% and a maximum of 0.015%.

Are you looking at the specs for the HSCE or the HSCE2?
 
At those slow rates, foamman should be counting the time BETWEEN counts to get a more accurate speed if the HSCE do that?

Excuse me. Oversampling doesn't do any good in this application because a counter instead of a analog tach.

Foamman, you need a higher pulse count rate or an analog output.
 
Is the flowmeter a "SMART" unit? Most can be configured to give very small units per pulse. I have many that give 0.001 units per pulse.

It takes 1000 pulses to give one "unit" of flow. The only limitation is the maximum Hz of the meter and input card.
 
I got to hand it to you guys because you all are thinking the same things as me. Anyway here is some more information and answers to your posts.

I'm using a HSCE2 card and in the latest manual they added the following:

IMPORTANT: Because of the way the 1746-HSCE2 performs rate value calculations, invalid rate measurements may occur if the input frequency is below 60 Hz. Therefore, we recommend that the 1746-HSCE2 module not be used for rate monitoring or rate range control for frequencies below 60 Hz. The invalid measurements apply only to rate values and do not affect the count value reported to the controller, which are always correct.

My frequencies could range from 5 to 500 hz. I haven't tried the built in rate function though. Programming this card is such a pain I guess I got lazy and this warning made me decide to do my own rate calculation. By the way I have a similar problem with a high speed counter on a MicroLogix 1500 which does not do rate calculations. I'm using the built is HSC not an actual card on the MicroLogix.

My flowmeter is not "smart" it is a simple OEM unit with a hall-effect pickup.

I don't believe there is a way to count the time between the pulses because my top frequency has a period of 2ms.

And now...the hitting the nail on the head prize goes to Peter Nachtwey.

Twelve years ago when we first began connecting flowmeters to our equipment we connected the pulse output from the flowmeter to a frequency to voltage converter...then the voltage output was connected to an analog input. It worked beautiful! Anyway nobody (customers, service techs, etc.) could ever understand how everything got scaled to engineering units. Our machines (depending on model) could have different flowmeters requiring different F to V ranges and different scale factors. I even wrote a white paper on how to do all the scaling and presented it at a company conferance! Well nobody read it and the techs always had trouble getting everything to work when a new machine got tested (we did have some F to V failures). So a "hate" developed for the F to V converter. So as the years go by the president of the company gets tired of hearing about it and orders it to be changed to a counter card input. One problem solved and a new one develops. The technical details we have discussed here would not mean anything when stating my case to keep the F to V.

Anyway, I'll probabley fiddle with it a bit more then tell them that's the way it is.

I welcome more feedback and Thanks!
 

Similar Topics

Hi All, I'm currently designing a faceplate for an analog input object, and I'm trying to create an alarm tab with an Alarm and Event Summary...
Replies
1
Views
444
Hello, I am looking to use the same header on every page (global object) that has an alarm summary button on it that will go to a display with an...
Replies
4
Views
1,811
Hi, I have just started with WinCC unified (v17) and there are alot of things I used on Comfort but now are not available. Currently I am finding...
Replies
3
Views
2,831
i have FactoryTalkView Studio ME ver 12; i have a project with more than 40 displays. 1) How to print the entire project into a pdf. 2) I need to...
Replies
3
Views
770
I've become interested in code for digital filtering. I have read this excellent (and old) thread ...
Replies
3
Views
10,494
Back
Top Bottom