Programming in ST
1. Example in ST
Let’s considering the logical equation:
%M0 = %I0.%I1+%I2. /%I3
PROGRAM LogicalFunction %M0 := %I0 AND %I1 OR %I2 AND NOT %I3; END_PROGRAM
2. Example of Grafcet in ST
Let’s considering the elementary Grafcet
a. Programming Transition/Transition
PROGRAM TrTr (* INIT *) IF %S2 THEN %M0 := TRUE; %M1 := FALSE; END_IF (* TRANSITIONS *) IF %M0 AND %I0 THEN %M1 := TRUE; %M0 := FALSE; END_IF IF %M1 AND %I1 THEN %M0 := TRUE; %M1 := FALSE; END_IF (* ACTIONS *) %Q0 := %M1; END_PROGRAM
b. Programming Transition/Transition with Crossing bits
PROGRAM TrTrB (* INIT *) IF %S2 THEN %M0 := TRUE; %M1 := FALSE; END_IF (* TRANSITIONS *) %M10 := %M0 AND %I0; %M11 := %M1 AND %I1; (* CROSSING *) IF %M10 THEN %M1 := TRUE; %M0 := FALSE; END_IF IF %M11 THEN %M0 := TRUE; %M1 := FALSE; END_IF (* ACTIONS *) %Q0 := %M1; END_PROGRAM
c. Programming Step/Step
PROGRAM StepStep (* STEP *) IF %M1 AND %I1 OR %M0 AND NOT %I0 OR %S2 THEN %M0 := TRUE; %M1 := FALSE; END_IF IF (%M0 AND %I0 OR %M1 AND NOT %I1) AND NOT %S2 THEN %M1 := TRUE; %M0 := FALSE; END_IF (* ACTIONS *) %Q0 := %M1; END_PROGRAM
d. Programming Step/Step with Crossing Bits
PROGRAM StepStepB (* STEP *) %M10 := %M1 AND %I1 OR %M0 AND NOT %I0 OR %S2; %M11 := (%M0 AND %I0 OR %M1 AND NOT %I1) AND NOT %S2; (* CROSSING *) IF %M10 THEN %M0 := TRUE; %M1 := FALSE; END_IF IF %M11 THEN %M1 := TRUE; %M0 := FALSE; END_IF (* ACTIONS *) %Q0 := %M1; END_PROGRAM