Time Average in Ladder Logic (ControlLogix AOI)

I’ve needed a time-average function several times, so I figure other people have also.  Here is a handy AOI which makes it easy to use in a ControlLogix ladder program.  (AB has the Moving Average MAVE instruction in function block and structured text environments but not ladder)  I use this instruction when I’m trying to control something from a signal that jumps around too much.  The instruction takes samples from the input at the interval you set it to, and outputs the average of all the samples.  I’ve included the import file and screenshots of the ladder code.

AOI:  TimeAve.L5X.zip

Screenshot from 2014-08-29 14:21:54


Screenshot from 2014-08-29 15:59:42

Screenshot from 2014-08-29 14:22:47

Screenshot from 2014-08-29 14:23:20

Screenshot from 2014-08-29 14:23:33


Here is a sample of how the TimeAve instruction is used.  As shown it will give the average of 8 samples taken at 100ms intervals:

Screenshot from 2014-08-29 14:18:01

The standard deviation output is a good indicator how ‘jumpy’ your input is.  I’ve used it to wait for a valid number from a scale.


This entry was posted in Industrial Automation and tagged , , , , , , , . Bookmark the permalink.

One Response to Time Average in Ladder Logic (ControlLogix AOI)

  1. I was looking for a MAVE equivalent and landed on this blog. Thanks for sharing that AOI. It saved me a lot of time.
    One change I had to make though. The Input variable is a DINT type while the SampleArray[] is a REAL type. I needed the precision of a REAL type for my Average so I ended up having to change the Input variable to a REAL type.

Comments are closed.