author | Mario de Sousa <msousa@fe.up.pt> |
Wed, 01 Aug 2012 09:05:25 +0100 | |
changeset 618 | 5e09f665c2f1 |
parent 276 | 1679f514f38a |
permissions | -rwxr-xr-x |
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 |