Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Structured text example #1552

Merged
merged 1 commit into from Sep 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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