-
Notifications
You must be signed in to change notification settings - Fork 36
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
Add new integral function block for determining approximate integral over time. #648
base: develop
Are you sure you want to change the base?
Add new integral function block for determining approximate integral over time. #648
Conversation
Test Results 110 files ±0 110 suites ±0 48s ⏱️ ±0s Results for commit 054e1c9. ± Comparison against base commit b2b0d82. This pull request removes 2 tests.
|
</EventOutputs> | ||
<InputVars> | ||
<VarDeclaration Name="IN" Type="REAL" Comment="Input value" InitialValue="0.0"/> | ||
<VarDeclaration Name="TM" Type="DINT" Comment="Time since last call in msec" InitialValue="0"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer TM to have type TIME
to better indicate the meaning of this value. But I fully understand the implications this has on the integration as soon as people start to use values in nanoseconds...
IF (1.0E38 - IN * DINT_TO_REAL(TM) < OUT OR -1.0E38 - IN * DINT_TO_REAL(TM) > OUT) THEN | ||
OVERFLOW := TRUE; | ||
ELSIF (TM > 0) THEN // Time Difference since last call must be positive. | ||
OUT := OUT + IN * DINT_TO_REAL(TM) / 1000.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When testing this in the Interpreter I got the following case:
- send RESET
- set IN to 9.0E9, TM to 1 send REQ; OUT goes to 8999999.0
- set the input to 1.0, send REQ; OUT does not change
- set the input to -1.0, send REQ; OUT also does not change
this is caused by the variable resolution of the REAL
datatype - a warning for the case where the integration does not work (i.e. OUT does not change with IN <> 0) could be nice-to-have
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are totally right:
our colleges at CODESYS have same issue with same Function.
this comes from the internal representation of REAL.
maybe we should also make a LREAL Version, as well a Fixed-comma Version in DINT.
i will think about it, and in the MEantime make the warning as written above.
Seeing the comments and the implications for the correct operation of this Function Block, I don't think this should be written as a SFB in ST at all, but as a SiFB, which can do all the relevant checking and error signalling on the system level. |
@MartinMelikMerkumians i totally agree to you. and then step a big Moment back, go deep, take time, and make the improved Version with ANY_NUM, agree ? |
No description provided.