Filter analog input Logix5000

the_msp

Lifetime Supporting Member
Join Date
May 2008
Location
Northern Ireland
Posts
1,271
I have a 4-20 ultrasonic sensor on an oil tank. I am getting spikes that I would like to get rid of.

You could try a filter:

FV=FV+C(NV-FV)
Where:
FV= Filtered value
C= constant (range 0-1) The smaller the number the more dampening.
NV= New Value

Have tried this but I get 1.#QNAN.

V18, no logic preceeding what you see.

Searching the forum there was a suggestion to add the filter in the module properties. To do this the data format must be changed when adding the input module to the IO tree. Tried this but my only option in the drop down is "integer". Series C rev 3-1 1734-Ie2C.

Can someone tell me where I am going wrong.

Edit: spotted a typo in that CPT, have changed to "FV+C*(NV-FV)" - same result

spikes.png logic.jpg
 
Last edited:
Hmmm. I use that filter logic all the time in Micrologix1400 controllers. Could it be a problem to have two references to the destination of the CPT instruction embedded within the expression?

With CPT instructions, when I run into problems, sometimes I will break it down into individual math instructions with separate scratch registers to carry from one to the next so I can see where things are failing apart.
 
I just had to do this for several ultrasonic level sensors....I used the Low Pass Filter Function block in RSLogix5000 and it worked like a champ. I think I ended up with a 2nd order filter with pretty low gain and it steadied the signal out nicely.

In regards to your equation, is FV declared as a REAL or DINT? If DINT and truncated, I can see the equation quickly exceeding the max a 32 bit DINT can hold because you'll always be adding a small amount.
 
Last edited:
All tags are REAL.

I didn't attempt the FBD as I'm using Lite version of L5k and thought it could only do LAD, however I just had a go and it seems to be working. Currently just using 1st order. What parameter in the LPF is the constant?

Now just to wait on a spike...

Still keen to know why the LAD attempt doesn't work
 
All tags are REAL.

I didn't attempt the FBD as I'm using Lite version of L5k and thought it could only do LAD, however I just had a go and it seems to be working. Currently just using 1st order. What parameter in the LPF is the constant?

Now just to wait on a spike...

Still keen to know why the LAD attempt doesn't work

Wlag
 
All tags are REAL.

I didn't attempt the FBD as I'm using Lite version of L5k and thought it could only do LAD, however I just had a go and it seems to be working. Currently just using 1st order. What parameter in the LPF is the constant?

Now just to wait on a spike...

Still keen to know why the LAD attempt doesn't work

Have you tried zeroing it after you corrected everything? Since it's an accumulated value, once it reached an invalid value (either divide by 0 or exceeded the tag type numerical limit), it would stay invalid since it adds to itself.
 
FBD Wlag at 100, C in LAD at 0.1

I think the reason it isn't filtering is the spike lasts for several seconds?

I once encountered a situation in which keying the mic on a walkie talkie in a certain location caused a spike like that in a thermocouple temperature reading, which would lead to an equipment shutdown.

Until I could replace the thermocouple transmitter, I instituted a software patch that detected a sudden rise in temperature and would ignore the input and hold the last valid value until the spike subsided. It had a watchdog timeout in case the temperature actually increased.

Of course, that was a software patch for a hardware problem, and I generally don't recommend employing such patches.
 
I once did an audiovisual alarm system on a cabinet wash in a meat processing facility. If the water temperature fell out of a certain range, it would either give a warning indicator, and if it had to stop the line it would also have an audio indicator.

What we found was that when a certain valve shifted, there would be a temperature spike, and when it closed there would be a sudden drop. This was for about 1.5 seconds, but it was enough to cause problems.

Rather than filter I put in a debounce timer for 5 seconds to detect the condition.
 
I once encountered a situation in which keying the mic on a walkie talkie in a certain location caused a spike like that in a thermocouple temperature reading, which would lead to an equipment shutdown.

Back in the 70's a coworker had a pace-maker, you could not use a walkie talkie around him. It would cause personal shutdown.
 
in taking a look at the figure that you gave us in your Post #9 (reproduced below) – it seems like the disturbance that you're seeing is more like a "bump" which lasts quite some substantial amount of time – rather than just a very quick "spike" ... (I couldn't find the "time units" on your graph being specified) ...

so (as you've already discovered) a normal "Filter" approach isn't likely to do you any good ... the "debounce" timer arrangement mentioned by sparkie in Post #13 might be more beneficial – as long as your system can tolerate any "signal delays" that might result ...

here is another idea/approach that MIGHT help you move forward ...

the Point I/O hardware that you're using is obviously being set up as "Remote I/O" (specifically, not as "Local I/O") ...

take a look at the GREEN trace in Figure 22 at this link:

http://www.plctalk.net/qanda/showthread.php?p=392460&postcount=16

that one looks a lot like the "stair step" appearance of your "problem" trace ...

now look at the MUCH SMOOTHER green trace shown in Figure 24 at this link:

http://www.plctalk.net/qanda/showthread.php?p=392463&postcount=18

so ...

everything else being equal (not very likely) you MIGHT get some better results by tinkering with the RPI (Requested Packet Interval) and the RTS (Real Time Sampling) settings ...

I'm just GUESSING – but maybe smoothing out the input signal MIGHT make your disturbance much quicker in duration – and make any attempt to "filter" the input signal more effective ...

it hasn't been fully specified whether you're using CONTROL-Logix or COMPACT-Logix (in some cases it can make a difference) ...

I'm literally swamped with work right now – so I won't be able to contribute anything further - but hopefully these ideas will be helpful (or at least mildly entertaining) ... good luck with your project ...
.

spike%20filter.png
 

Similar Topics

Hi! I like to ask is there a way i can filter my analog input?
Replies
1
Views
1,083
Hey fellas, I've got some Point I/O analog inputs (1734-IE8C) that I would like to filter. FYI, this is for some flow meters. The raw...
Replies
9
Views
7,338
This sounds like a stupid question, but I can't find an answer anywhere. I realize that a lower filter freq on an analog input channel results in...
Replies
10
Views
3,483
I have an analog signal that has a small amount of noise. It is on an RX3I PLC and the analog in module (IC693ALG442) does not have filter...
Replies
35
Views
9,307
How does one configure a 'delay' block or 'lead/lag' block in a Modicon quantum PLC? Wish to delay an analog signal by a few seconds to I can sum...
Replies
1
Views
1,749
Back
Top Bottom