Author Topic: Average function bug  (Read 1720 times)

Offline spittet

  • PLUS+1 Guru
  • *****
  • Posts: 113
  • Karma: +5/-1
Average function bug
« on: July 02, 2019, 06:40:47 PM »
Hi,

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!

Sam

Offline Nilla

  • PLUS+1 Guru
  • *****
  • Posts: 253
  • Karma: +13/-0
Re: Average function bug
« Reply #1 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
Nilla
PLUS+1 Helpdesk

Offline spittet

  • PLUS+1 Guru
  • *****
  • Posts: 113
  • Karma: +5/-1
Re: Average function bug
« Reply #2 on: July 08, 2019, 05:56:35 PM »
Hi,

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!