Structured text

The structured text (English Structured Text, abbreviation: . ST, in Siemens S7 also engl Structured Control Language, abbreviation SCL) is used for the programming of programmable logic controllers ( PLC). The EN 61131-3 standard specifies, among other also the language range of ST. The syntax of the language elements is similar to those of high- Pascal language and it will be like all the languages ​​of EN 61131-3 is no distinction between upper and lower case made ​​( Case Insensitive ).

ST offers more possibilities than structuring STL and therefore achieves this more and more from. However, many developers still cling to the programming with STL because bringing ST programs after compilation usually an increased memory use. This may well lead to smaller PLC by rapid reaching the memory limits to problems.

Example 1 ( IF statement )

IF ( MASCHINE_EINGESCHALTET = TRUE ) THEN      DESIRED POSITION: = DESIRED POSITION 100;      OUT1: = IN1 AND IN2; ELSE      OUT1: = FALSE; END_IF; Alternatively, the following program when:

IF THEN MASCHINE_EINGESCHALTET     DESIRED POSITION: = DESIRED POSITION 100; END_IF; OUT1: = IN1 AND IN2 AND MASCHINE_EINGESCHALTET; The result of both variants is identical (but not the internal implementation in the instruction list). Note: The target position is not changed when the MASCHINE_EINGESCHALTET variable is FALSE.

Example 2 (CASE statement)

If Cmd = 2 ( * or Cmd = 9 * ) then    case of slot ( * Record *)      1: T_Dicke [ 3 * i]: = DINT_TO_INT ( ( RB_Ist [ RB_Ist ] 499 ) / 1000);      2: T_Dicke [ 3 * i]: = DINT_TO_INT ( ( Z1_Ist [ Z1_Ist ] 499 ) / 1000);      3: T_Dicke [ 3 * i]: = DINT_TO_INT ( ( FB_Ist 499 ) / 1000);    END_CASE; else T_Dicke [ 3 * i]: = DINT_TO_INT ( ( T_ist [i ] 499 ) / 1000); end_if; Example 3 (FOR statement)

ENO: = true; for i: = 0 to 499 by 1 do    D: = D1 [ i];    D1 [ i]: = D2 [i];    D2 [i ] = D; end_for; Example 4 (REPEAT statement)

If RB_Ist = 0 ( * and RB_Soll = 0 *)    then Data [ X [ i] ]: = Data [ X [ i] ] 1;    else      repeat        Data [ X [ i] ]: = Data [ X [ i] ] 1;        k: = UINT_TO_INT (data [X [i ] ]); (* Index of the channel *)      until data [X [i ] k] = 69 or Data [ X [i ] k] = 99      END_REPEAT;   end_if; Example 5 (WHILE statement)

If RST_Tisch then    M: = false;    k: = 1;    while Data [ X k] < > 60 and data [X k ] < > 99 and k < 49 do      k: = k 1;    END_WHILE;    Data [X ]: = INT_TO_UINT (k); ( * New set for second operation *)    Wait: = false; end_if; example 6

Realization of a flashlight with flip-flops, timers and variable on / off times for a Siemens S7 -300

752065
de