author | Manuele Conti <conti.ma@alice.it> |
Mon, 11 Jun 2012 22:38:36 +0200 | |
changeset 581 | 1e158dc9f9c1 |
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:
0
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:
0
diff
changeset
|
2 |
|
1679f514f38a
Updating origin and license info of library fuctions.
Mario de Sousa <msousa@fe.up.pt>
parents:
0
diff
changeset
|
3 |
(* |
1679f514f38a
Updating origin and license info of library fuctions.
Mario de Sousa <msousa@fe.up.pt>
parents:
0
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:
0
diff
changeset
|
5 |
* |
1679f514f38a
Updating origin and license info of library fuctions.
Mario de Sousa <msousa@fe.up.pt>
parents:
0
diff
changeset
|
6 |
* Based on the |
1679f514f38a
Updating origin and license info of library fuctions.
Mario de Sousa <msousa@fe.up.pt>
parents:
0
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:
0
diff
changeset
|
8 |
* |
1679f514f38a
Updating origin and license info of library fuctions.
Mario de Sousa <msousa@fe.up.pt>
parents:
0
diff
changeset
|
9 |
*) |
1679f514f38a
Updating origin and license info of library fuctions.
Mario de Sousa <msousa@fe.up.pt>
parents:
0
diff
changeset
|
10 |
|
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
11 |
FUNCTION_BLOCK RAMP |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
12 |
VAR_INPUT |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
13 |
RUN : BOOL ; (* 0 - track X0, 1 - ramp to/track X1 *) |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
14 |
X0,X1 : REAL ; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
15 |
TR : TIME ; (* Ramp duration *) |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
16 |
CYCLE : TIME ; (* Sampling period *) |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
17 |
END_VAR |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
18 |
VAR_OUTPUT |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
19 |
BUSY : BOOL ; (* BUSY = 1 during ramping period *) |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
20 |
XOUT : REAL := 0.0 ; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
21 |
END_VAR |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
22 |
VAR XI : REAL ; (* Initial value *) |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
23 |
T : TIME := T#0s; (* Elapsed time of ramp *) |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
24 |
END_VAR |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
25 |
BUSY := RUN ; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
26 |
IF RUN THEN |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
27 |
IF T >= TR THEN BUSY := 0 ; XOUT := X1 ; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
28 |
ELSE XOUT := XI + (X1-XI) * TIME_TO_REAL(T) |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
29 |
/ TIME_TO_REAL(TR) ; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
30 |
T := T + CYCLE ; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
31 |
END_IF ; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
32 |
ELSE XOUT := X0 ; XI := X0 ; T := t#0s ; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
33 |
END_IF ; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
34 |
END_FUNCTION_BLOCK |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
35 |