lib/hysteresis_st.txt
author mjsousa
Sun, 09 Feb 2014 07:23:30 +0000
changeset 861 443e8243f289
parent 276 1679f514f38a
permissions -rwxr-xr-x
Code cleanup (part 3): generate_c_typedecl_c is no longer needed for code generation in POUS.c It is now only needed for datatype declaration in POUS.h
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
1679f514f38a Updating origin and license info of library fuctions.
Mario de Sousa <msousa@fe.up.pt>
parents: 192
diff changeset
    11
192
c6c2a3d487ac Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff changeset
    12
FUNCTION_BLOCK HYSTERESIS
c6c2a3d487ac Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff changeset
    13
    (* Boolean hysteresis on difference *)
c6c2a3d487ac Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff changeset
    14
    (* of REAL inputs, XIN1 - XIN2      *)
c6c2a3d487ac Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff changeset
    15
  VAR_INPUT XIN1, XIN2, EPS : REAL; END_VAR
c6c2a3d487ac Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff changeset
    16
  VAR_OUTPUT Q : BOOL := 0; END_VAR
c6c2a3d487ac Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff changeset
    17
  IF Q THEN IF XIN1 < (XIN2 - EPS) THEN Q := 0; END_IF ;
c6c2a3d487ac Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff changeset
    18
  ELSIF XIN1 > (XIN2 + EPS) THEN Q := 1 ;
c6c2a3d487ac Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff changeset
    19
  END_IF ;
c6c2a3d487ac Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff changeset
    20
END_FUNCTION_BLOCK
c6c2a3d487ac Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff changeset
    21