lib/integral_st.txt
author Mario de Sousa <msousa@fe.up.pt>
Wed, 18 Dec 2013 18:41:05 +0000
changeset 851 2c59c2b8fca4
parent 276 1679f514f38a
permissions -rwxr-xr-x
Fix bug/issue #33 (correctly access struct/array variables declared inside a FB -> r:=FB1.FB2.struct1.array1[3] )
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