PLUS+1 Software > Function Library

Average function bug



I noticed a bug where the output of the AverageFilter function block goes to 0 if the value of "Smpl Tm" input is not a constant. I used the version 3.0 of this block and I just noticed that there are new versions for this function block. But, I looked at the Revision History of this Function Block and I don't see any mention of bug correction, so I'm thinking this bug might still be there.

Easy to reproduce, simply connect the "Smpl Tm" to the value from the ouptut of a varying U16 number.

Have a good day!


Hi spittet!

If you read the information on Smpl_Tm within the function block (v4.00) it says;

Time between two consecutive samples.
If equal to zero, the function is bypassed.
If less than Loop Tm, then Loop Tm is used for the sample time.
Range: 0-65535
Unit: 1ms

I think this answers what you thought was a bug but it isn't. If you have e.g. a NV memory connected to Smpl_Tm I prosume this is set to 0 at start up.

Best regards
PLUS+1 Helpdesk


I took the time to build a sample project that shows the problem. Please see the joined files.

Avg1 has a varying SmplTm value.
Avg2 has a fixed SmplTm value.

When you run this program on a controller and when you check with the Diagnostic file, you will see that Avg1Output will spike to 0 in a cyclic fashion. Avg2Output has a nice filtered output like it should.

So, I think that the SmplTm parameter should be able to take variable values, not only fixed values. If this is not possible, please modify the Help File associated with this function block to tell the users that SmptTm parameter must be a constant.

Have a good day!


[0] Message Index

Go to full version