PLUS+1 User Forum

PLUS+1 Software => Function Library => Topic started by: spittet on July 02, 2019, 06:40:47 PM

Title: Average function bug
Post by: spittet on July 02, 2019, 06:40:47 PM

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!

Title: Re: Average function bug
Post by: Nilla on July 05, 2019, 10:25:40 AM
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
Title: Re: Average function bug
Post by: spittet on July 08, 2019, 05:56:35 PM

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!