Skip to content

Commit

Permalink
Structured text example (#1552)
Browse files Browse the repository at this point in the history
Structured text example
  • Loading branch information
alexdima committed Sep 19, 2019
2 parents e647012 + 847025b commit 9ac4ec8
Showing 1 changed file with 34 additions and 14 deletions.
48 changes: 34 additions & 14 deletions website/index/samples/sample.st.txt
@@ -1,14 +1,34 @@
FUNCTION_BLOCK SubFB
VAR_INPUT
TimeIN : BOOL; (* Boolean input variable *)
TimeQ : BOOL; (* Boolean input variable *)
END_VAR
VAR_IN_OUT
Timer : TON; (* pointer to instance Time1 of TON – input/output variable *)
END_VAR
VAR_OUTPUT
Time3 : TON; (* 3rd instance of TON *)
END_VAR
VAR
Start : BOOL := TRUE; (* local Boolean variable *)
END_VAR
CONFIGURATION DefaultCfg
VAR_GLOBAL
Start_Stop AT %IX0.0: BOOL; (* This is a comment *)
END_VAR
TASK NewTask (INTERVAL := T#20ms);
PROGRAM Main WITH NewTask : PLC_PRG;
END_CONFIGURATION

PROGRAM demo
VAR_EXTERNAL
Start_Stop: BOOL;
END_VAR
VAR
a : REAL; // Another comment
todTest: TIME_OF_DAY := TOD#12:55;
END_VAR
a := csq(12.5);
TON1(IN := TRUE, PT := T#2s);
16#FAC0 2#1001_0110
IF TON1.Q AND a > REAL#100 THEN
Start_Stop := TRUE;
END_IF
END_PROGRAM;

/* Get a square of the circle */
FUNCTION csq : REAL
VAR_INPUT
r: REAL;
END_VAR
VAR CONSTANT
c_pi: REAL := 3.14;
END_VAR
csq := ABS(c_pi * (r * 2));
END_FUNCTION

0 comments on commit 9ac4ec8

Please sign in to comment.