lib/integral_st.txt
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Sun, 14 Oct 2018 20:14:13 +0300
changeset 1073 24ef30a9bcee
parent 276 1679f514f38a
permissions -rwxr-xr-x
revert commits improved performance of some extensible Standard Functions (ADD, MUL, AND, OR, XOR)

Following commits are reverted:
mjsousa 0b275a2 improve performance of some extensible Standard Functions (ADD, MUL, AND, OR, XOR) -- increase hardcoded limit to 499
mjsousa 2228799 improve performance of some extensible Standard Functions (ADD, MUL, AND, OR, XOR) -- Add comments!!
mjsousa ce81fa6 improve performance of some extensible Standard Functions (ADD, MUL, AND, OR, XOR)"

The reason is that they cause regression in some cases (if function is
used as argument for function block, for example) and this is not
fixed for a long time.
276
1679f514f38a Updating origin and license info of library fuctions.
Mario de Sousa <msousa@fe.up.pt>
parents: 192
diff changeset
     1
(* Following taken directly from the IEC 61131.3 draft standard *)
1679f514f38a Updating origin and license info of library fuctions.
Mario de Sousa <msousa@fe.up.pt>
parents: 192
diff changeset
     2
1679f514f38a Updating origin and license info of library fuctions.
Mario de Sousa <msousa@fe.up.pt>
parents: 192
diff changeset
     3
(*
1679f514f38a Updating origin and license info of library fuctions.
Mario de Sousa <msousa@fe.up.pt>
parents: 192
diff changeset
     4
 * An IEC 61131-3 IL and ST compiler.
1679f514f38a Updating origin and license info of library fuctions.
Mario de Sousa <msousa@fe.up.pt>
parents: 192
diff changeset
     5
 *
1679f514f38a Updating origin and license info of library fuctions.
Mario de Sousa <msousa@fe.up.pt>
parents: 192
diff changeset
     6
 * Based on the
1679f514f38a Updating origin and license info of library fuctions.
Mario de Sousa <msousa@fe.up.pt>
parents: 192
diff changeset
     7
 * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
1679f514f38a Updating origin and license info of library fuctions.
Mario de Sousa <msousa@fe.up.pt>
parents: 192
diff changeset
     8
 *
1679f514f38a Updating origin and license info of library fuctions.
Mario de Sousa <msousa@fe.up.pt>
parents: 192
diff changeset
     9
 *)
1679f514f38a Updating origin and license info of library fuctions.
Mario de Sousa <msousa@fe.up.pt>
parents: 192
diff changeset
    10
192
c6c2a3d487ac Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff changeset
    11
 FUNCTION_BLOCK INTEGRAL
c6c2a3d487ac Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff changeset
    12
   VAR_INPUT
c6c2a3d487ac Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff changeset
    13
     RUN : BOOL ;       (* 1 = integrate, 0 = hold *)
c6c2a3d487ac Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff changeset
    14
     R1 : BOOL ;        (* Overriding reset        *)
c6c2a3d487ac Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff changeset
    15
     XIN : REAL ;       (* Input variable          *)
c6c2a3d487ac Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff changeset
    16
     X0  : REAL ;       (* Initial value           *)
c6c2a3d487ac Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff changeset
    17
     CYCLE : TIME ;     (* Sampling period         *)
c6c2a3d487ac Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff changeset
    18
   END_VAR
c6c2a3d487ac Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff changeset
    19
   VAR_OUTPUT
c6c2a3d487ac Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff changeset
    20
     Q : BOOL ;         (* NOT R1                  *)
c6c2a3d487ac Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff changeset
    21
     XOUT : REAL ;      (* Integrated output       *)
c6c2a3d487ac Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff changeset
    22
   END_VAR
c6c2a3d487ac Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff changeset
    23
   Q := NOT R1 ;
c6c2a3d487ac Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff changeset
    24
   IF R1 THEN XOUT := X0 ;
c6c2a3d487ac Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff changeset
    25
   ELSIF RUN THEN XOUT := XOUT + XIN * TIME_TO_REAL(CYCLE);
c6c2a3d487ac Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff changeset
    26
   END_IF ;
c6c2a3d487ac Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff changeset
    27
 END_FUNCTION_BLOCK
c6c2a3d487ac Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff changeset
    28