Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FILTER_MAV_DW wrong calculation #71

Open
pldroit opened this issue May 18, 2021 · 5 comments
Open

FILTER_MAV_DW wrong calculation #71

pldroit opened this issue May 18, 2021 · 5 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@pldroit
Copy link

pldroit commented May 18, 2021

What is the issue/what feature do you want to develop?

FILTER_MAV_DW calculates wrong moving average values when input value decreases

here a small example run with codesys 3.5 SP17

PROGRAM POU
VAR
	mav : OSCAT_BASIC.FILTER_MAV_DW;
END_VAR
mav(X := 10, N := 2, RST := FALSE);
mav(X := 8);
IF mav.Y <> 9 THEN
	mav.X := mav.X; // we should never get here
END_IF

What are the requirements?

  • codesys 3.5
  • N > 1
  • RST = FALSE
  • X value decreases

How do we want to solve it?

@Maghnie Maghnie self-assigned this May 26, 2021
@Maghnie
Copy link
Contributor

Maghnie commented May 26, 2021

Thank you @pldroit for the notification. We looked into it, and your initial guess about the problem cause seems right.
To better solve the issue, could you please tell use what is your use-case for using the function with DWORD instead of REAL?

@Maghnie Maghnie added question Further information is requested bug Something isn't working labels May 26, 2021
@pldroit
Copy link
Author

pldroit commented May 27, 2021

Hi, many fieldbus systems don't support REAL types. It's common to sent values as integer types like DINT with a defined scale and unit (eg. 3 decimal places and volt).
If you want to filter this input data to reduce noise, you would use this function.

@Maghnie
Copy link
Contributor

Maghnie commented Apr 11, 2022

@LZimmermannLZI This is also interesting for the unit tests initial runs

@StGoebel
Copy link
Collaborator

StGoebel commented Jan 2, 2024

Hi @Maghnie, did you solve the problem and can we close this issue?

@Maghnie
Copy link
Contributor

Maghnie commented Jan 2, 2024

Thanks @StGoebel for the reminder!

Unfortunately, we didn't get to solve this bug when we looked into it the first time. And the person who was working on this issue already left the team.

I did a little memory-refreshing now, and it appears that there was a similar bug in the WORD variant of this moving average function. However, it had been solved:

https://github.com/RWTH-EBC/AixOCAT/blob/b34ffd698296056d62b585420758c5a2c3b77f74/OSCAT/OSCAT/OSCAT/oscat_basic/POUs/Engineering/signal%20processing/FILTER_MAV_W.TcPOU#L35C1-L49C17

For the next step, I'd suggest testing if the fix from FILTER_MAV_W works in this function as well. I could do that, but I'd have to set up my Twincat environment again, so that might get scheduled until after a couple of weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants