author | Mario de Sousa <msousa@fe.up.pt> |
Sun, 10 Jun 2012 15:38:24 +0100 | |
changeset 574 | d291a942899b |
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 |
|
1679f514f38a
Updating origin and license info of library fuctions.
Mario de Sousa <msousa@fe.up.pt>
parents:
192
diff
changeset
|
2 |
(* 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
|
3 |
|
1679f514f38a
Updating origin and license info of library fuctions.
Mario de Sousa <msousa@fe.up.pt>
parents:
192
diff
changeset
|
4 |
(* |
1679f514f38a
Updating origin and license info of library fuctions.
Mario de Sousa <msousa@fe.up.pt>
parents:
192
diff
changeset
|
5 |
* 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
|
6 |
* |
1679f514f38a
Updating origin and license info of library fuctions.
Mario de Sousa <msousa@fe.up.pt>
parents:
192
diff
changeset
|
7 |
* Based on the |
1679f514f38a
Updating origin and license info of library fuctions.
Mario de Sousa <msousa@fe.up.pt>
parents:
192
diff
changeset
|
8 |
* 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
|
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 |
|
1679f514f38a
Updating origin and license info of library fuctions.
Mario de Sousa <msousa@fe.up.pt>
parents:
192
diff
changeset
|
12 |
|
192
c6c2a3d487ac
Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff
changeset
|
13 |
FUNCTION_BLOCK DERIVATIVE |
c6c2a3d487ac
Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff
changeset
|
14 |
VAR_INPUT |
c6c2a3d487ac
Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff
changeset
|
15 |
RUN : BOOL ; (* 0 = reset *) |
c6c2a3d487ac
Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff
changeset
|
16 |
XIN : REAL ; (* Input to be differentiated *) |
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 |
XOUT : REAL ; (* Differentiated output *) |
c6c2a3d487ac
Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff
changeset
|
21 |
END_VAR |
c6c2a3d487ac
Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff
changeset
|
22 |
VAR X1, X2, X3 : REAL ; END_VAR |
c6c2a3d487ac
Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff
changeset
|
23 |
IF RUN THEN |
c6c2a3d487ac
Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff
changeset
|
24 |
XOUT := (3.0 * (XIN - X3) + X1 - X2) |
c6c2a3d487ac
Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff
changeset
|
25 |
/ (10.0 * TIME_TO_REAL(CYCLE)) ; |
c6c2a3d487ac
Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff
changeset
|
26 |
X3 := X2 ; X2 := X1 ; X1 := XIN ; |
c6c2a3d487ac
Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff
changeset
|
27 |
ELSE XOUT := 0.0; X1 := XIN ; X2 := XIN ; X3 := XIN ; |
c6c2a3d487ac
Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff
changeset
|
28 |
END_IF ; |
c6c2a3d487ac
Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff
changeset
|
29 |
END_FUNCTION_BLOCK |
c6c2a3d487ac
Adding inclusion of function blocks defined in AnnexF into library blocks
lbessard
parents:
diff
changeset
|
30 |