SIEMENS TIA PORTAL

STL Programming Language




Statement List (STL)

STL is a text-based transition language. STL is a language widely used in onboard control.

Anyone who has experience with the start of microprocessors or have start-up experience with the language Assembler will see similarities with the transition in STL. This language consists of several lines of code, with each line representing exactly one operation.

If the programmer uses only instructions defined by the IEC, a program written in that language can be easily applied in various hardware platforms.

The STL language is a low level language and, as such, it will run much faster in the PLC than graphic languages, such as Ladder. This language is also very compact and will consume less space in the PLC memory.

PLCs are reactive systems that interact in a cyclic method with its environment. In each cycle, the inputs (values of the sensors) are read, the computation is executed and the outputs are written (for actuators). It is possible that a number of STL programs are called sequentially within a cycle.

Each STL program begins with a part of the statement, defining program variables and their respective types. STL basically supports booleans, integers and floating point numbers.

Outside of the variable variable part, the STL programs are sequences of statements. A statement consists of an instruction (operator) and an operand, which can be a variable, a constant or a jump label. In addition, programs can recite comments. STL variables support the use of a recorder or accumulator. Each computer is stored in an accumulator. That is, the value of a variable is stored inside the accumulator, some operations are executed and then the current value of the accumulator is saved back in the same variable.

The program in STL is divided into networks. Each network can contain one or more lines. The numbering of the lines starts at 1 in each network and follow an increasing order to each new line. The individual instructions in STL are programmed in the lines of a network, where only one STL instruction can be specified per line. Each declaration (statement) represents an instruction for the CPU. A CPU executes instructions from the top to bottom.

STL basic instructions:
Logic instructions

A

The AND instruction performs an AND logic between the contents of the accumulator and the operand.

Example:



If Tag_Input_1 and Tag_Input_2 have value 1, Tag_Output receives the value 1.

O

The OR instruction performs an OR logic between the contents of the accumulator and the operand.

Example:



Tag_Output = (Tag_Input_1 AND Tag_Input_2) OR (Tag_Input_3 AND Tag_Input_4) OR Tag_Input_5.

X

The X instruction performs an exclusive XOR or OR logic between the contents of the accumulator and the operand.

Example:



Tag_Output receives the value 1 when the Tag_Input_1 value is different from the Tag_Input_2 value.

NOT

RLO invert

Example:



Tag_Output = NOT (Tag_Input_1 AND Tag_Input_2 AND Tag_Input_3)

FN

RLO scan for negative signal transition.

Example:

When Tag_Input goes from 1 to 0 (negative signal transition), Tag_Output goes to 1 for a scan (pulse) and then returns to 0.



FP

RLO scan for positive signal transition

Example:

When Tag_Input goes from 0 to 1 (positive signal transition), Tag_Output goes to 1 for a scan (pulse) and then returns to 0.



Modifiers

Modifiers are letters added to conventional instructions that alter their function.

N

The N modifier is used to invert the operand value.

Example:



Tag_Output = Tag_Input_1 AND (NOT Tag_Input_2)

C

Modifier C is used to carry out an instruction associated if the value of the accumulator is 1 (TRUE).

Example JC: Conditional Jump with RLO = 1 (details in Structural Instructions).

CN

If modifiers C and N are combined, the instruction is only executed if the accumulator value is 0 (FALSE).

Example JCN: Conditional Jump with RLO = 0 (details in Structural Instructions).

(

The modifier (used to bring the operator's value up the operator) appears. The number of parentheses on the left must be the same as the parentheses on the right.

Example:



The instructions inside the parentheses (direct OR) are executed before the AND instruction.

Instructions for loading and saving

L

The value of an operand is loaded in Accumulator 1 using the Instrument Load L. The operand to be loaded can be directed as a byte, word or double word in the following memory areas: I, Q, M, L, DB, DI, Pointer, PI (I / O), T (Timer) and C (Counter). The memory area of the accumulator is divided into bytes and has 32 bits.



In some instructions, the content of Accumulator 1 is transferred to Accumulator 2 before being loaded with a new value. In the sequence, the values of the two accumulators are used in the execution of the instruction.

Example:



In this example, the first instruction Tag_Value_1 is loaded in the Accumulator 1. In the second instruction Tag_Value_1 is transferred to Accumulator 2 and Tag_Value_2 is loaded in Accumulator 1. The third instruction executes the multiplication of the Real type of the values in the two accumulators and stores the product in Accumulator 1. The fourth instruction transfers the value in Accumulator 1 for Accumulator 2 and carries Tag_Value_3 in Accumulator 1. The fifth instruction executes the addition of the Real type of the values in the two accumulators and stores the sum in Accumulator 1. The sixth instruction transfers the contents of Accumulator 1 to Tag_Result variable.

T

The current value of Accumulator 1 is stored in the operand using T. The contents of Accumulator 1 to be charged can be addressed as a byte, word or double word in the following memory areas: I, Q, M, L, DB, DI and PQ (I/O).

Set and Reset instructions

S

S sends the operand for "1" when the result of the logical operation is equal to 1. If the result of the logical logic is equal to 0, the value of Tag_Output is not changed. Usually, this operator is used together with the reset operator R as a pair.

Example:



R

S sends the operand to "0" when the result of the logical logic is equal to 0. If the result of the logical logic is equal to 1, the Tag_Output value is not changed.

Example:



Arithmetic instructions
** Power
+ Addition
- Subtraction
* Multiplication
/ Division
INC Increase
DEC Decrement
MOD Module

Examples:

Addition of operators of the Inteiro type



Division of operators of the Real type



Increment of 5



Comparison instructions
== Equal
<> Different
> Larger than
< Smaller than
>= Larger or equal to
<= Less than or equal to

Examples:

Comparator Larger than for operators of type Int. The operator > compare the contents of Accumulator 2 (Tag_Input_1) is larger than the contents of Accumulator 1 (Tag_Input_2). If for the greater, Tag_Output receives the Boolean value 1. If for less or equal, Tag_Output receives a Boolean 0.



Comparator Larger than for Real-type operators.



Call instructions

CALL

A Function Block or a Function is called with CALL. values of variables the constants can be assigned/received for/of parameters of the block (attribution). In Function blocks calls, the DB Database Block must be informed.

Examples:



Structural instructions
JU Jump unconditional
JC Jump if RLO = 1
JCN Jump if RLO = 0

With a jump ocorre a jump from the point of the program for a label (label), conditionally or unconditionally.

Example:

If Tag_Input_1 is larger than Tag_Input_2, it takes a hop of execution to the MyLABEL label. In this case, the instructions L "Tag_Input_3" and T "Tag_Output" before the MyLABEL label does not run.



Cotton Ginning Project

• Create Function block MOTOR_STL for engine with STL logic. Click on Add new block en Project tree > Devices > PLC_1 > Program blocks.

• Select Function block (FB). The programming language It will be STL. The function block number is determined automatically. Click on OK

• Open the MOTOR_STL function block to editing.

• Create function block input, output, input/output and internal parameters.

• In Interface, enter with the input parameters:

K1 Bool Motor Status
Q1 Bool Motor Thermal
BE Bool Emergency Button
INTMT Bool Motor Interlock
TMR Time Start/Stop Time
RST Bool Alarm Reset

• In Interface, enter with the InOut parameters:

S1 Bool Motor Start Button
S2 Bool Motor Stop Button
ALM Bool Motor Alarm
YC Bool Motor Command

• In Interface, enter with the Static parameters:

AUX1 Bool
TON1 TON_TIME
AUX2 Bool
AUX3 Bool
TON2 TON_TIME
AUX4 Bool


Network 1

Motor activation by the operator (button S1). Motor não it must be intertrave (INTMT = 1), it must not be in alarm (ALM = 0) and the emergency button must not be attached.



Network 2

Stop the motor by operator (button S2) or by system (emergency, alarm or interlock).



Network 3

Motor alarm generated by input Q1 - Thermal, start failure or stop failure.



Network 4

System reset of buttons S1 and S2 operated by operator.



Network 5

Alarm reset via recognition by the operator (Reset button).





• Create a new block FC (function) DESC2. Click on Add new block en Project tree > Devices > PLC_1 > Program blocks.

• Select Function (FC) and name block as DESC2. The programming language will be STL. The function number is determined automatically. Click on OK

• Call function DESC2 to execute in Main [OB1].

• Program DESC2.

• Insert Temp parameters:

AUX2 Bool
M3AUX Bool
M3AUX2 Bool
M3AUX3 Bool
M3INVDI DInt


Networks 1 and 2

Open / closed front sensor of the ginner (at 1 = closed). In simulation, the signal from D2R2 (command to act on the solenoid valve that closes the front of the gin) is sent to D2LS1 (closed ginner front sensor).

Create variables:

D2LS1 Bool %M0.1 Front Ginner Sensor 2 Closed
D2R2 Bool %M2.5 Auxiliary close front Ginner 2
D2S3 Bool %M2.3 Button close front of Ginner 2




Network 3

Movement of the analog current input of M1 Motor Ginner 200 Saws. In simulation (SIMULA = 1), the movement is blocked to allow the insertion of values for the test (jump JC for SIMULA1).

Create variables:

D2M1TDM1 Int %MW12 M1 Ginner 2 200 Saws – Current


Network 4

Converts the value of the variable D2M1TDM1 of the intero type to value of variable D2M1TDM1INDI of type DInt (ITD instruction). Next, convert the value D2M1TDM1INDI of type DInt to value D2M1TDM1IN of type Real (DTR instruction).

Divide value of D2M1TDM1IN by 138.24 (instruction / R - real) for the conversion of the analog input signal from 0 to 27648 to 0 to 200 A.

Create variables:

D2M1TDM1INDI DInt %MD40 M1 Ginner 2 200 Saws – Current Input
D2M1TDM1IN Real %MD24 M1 Ginner 2 200 Saws – Current Input


Network 5

Instance of function block MOTOR_STL for M1 - Ginner 2 200 Saws. Parameter INTMT receives value 1 (motor always released for start).

Crear variable:

D2S1 Bool %M2.2 Reset alarms Ginner 2


Network 6

Movement of input parameter K1 of D2M1. When SIMULA = 1, input K1 is supplied by the motor control output YC itself.



Network 7

High current indication of M1 Ginner 200 Saws. When reaching a current above 120 A, the cotton feed must be interrupted. However, that interlock should only be released after 15 seconds of the engine start.

Create variable:

D2HIDESC Bool %M3.2 High Current Ginner 2 200 Saws


Network 8

The D2S1 button gives a reset on the D2HIDESC alarm.



Network 9

MOTOR_STL function block instance of M2 - Agitator of Ginner 2.



Network 6

Movement of input parameter K1 of D2M2. When SIMULA = 1, input K1 is supplied by the motor control output YC itself.



Network 11

Interlock of the M2 Agitator Ginner 2. For turn the M2 motor, the agitator door must be closed (D2LS2 = 1) and the M1 motor must be running.



Network 12

MOTOR_STL function block instance of M3 – Feeder Ginner 2.



Network 13

Movement of input parameter K1 of D2M3. When SIMULA = 1, input K1 is supplied by the motor control output YC itself.



Network 14

M3 motor interlock Gin Feeder 2. To turn the M3 motor, the agitator door must be closed (D2LS2 = 1) and the M1 and M2 motors must be turning. If the current of the M1 ginner exceeds 120A, the inverter must stop.



Network 15

Command to open or close in front of the ginner. the the operator must press the D2S3 button to close the front of the gin and start the cotton feed. The control to act on the pneumatic valve VS1 (close front and keep closed) is activated when:

1 - there is vacuum (D2VC1 = 1),

2 - there is no M1 high current (< 120A);

3 – closed agitator door;

4 – the 3 motors do not contain alarms.

Create variable:

D2S4 Bool %M2.4 Button close front of Ginner 2


Network 16

Control for pneumatic valve to open/close front of the ginner. Inserted TOF lock to ensure the front closed for more 4 seconds after a command to open in front. This waiting time is important to wait for the total stop of cotton feed in the ginner before open the front.



Network 17

Command to split M3 - Feeder. The engine automatically starts 3 seconds after the front of the closed ginner. Obs: the operator does not control the M3 engine directly. The drive depends on the front condition of the ginner (open / closed).



Network 18

Stop command of M3 - Feeder. The motor for automatically when the operator operates the button to open the front of the ginner (D2S4) or when a loss of closed front signal occurs (D2LS1 = 0).



Network 19

Reset of the button Open front of ginner.



Network 20

Control of cotton feed in the ginner.



Network 21

PID reset when ErrorBits parameter is different from 0.



Network 22

When the button D2PID_AM is in manual (value 0), the Mode parameter must receive the value 4. But the PID only goes effectively to manual when the ModeActivate parameter receives the value 1. The State parameter indicates what the current mode of the PID is. If D2PID_AM is set to automatic (value 1), the logic jumps to AUTO and the Mode parameter not receive the 4.Reset value of the PID when the ErrorBits parameter is different from 0.



Network 23

When the D2PID_AM button is set to automatic (value 1), the the Mode parameter must receive the value 3. If D2PID_AM is in manual (value 1), the logic jumps to MANUAL and the Mode parameter does not receive the value 3.



Network 24

El parámetro ModeActivate (que activa la transferencia del valor del parámetro Mode para el PID) va a 1 en dos condiciones: cuando el botón D2PID_AM está en automático y el parámetro State es igual a 4 (indicando estado Manual) o cuando el botón D2PID_AM está en manual y el parámetro State es igual a 3 (indicando estado automático). Después de 1 segundo de activación, el parámetro ModeActivate recibe un reset (va a 0).



Network 25

Convierte la salida del PID de 0 a 100% a 0 a 27648 de la salida analógica de velocidad de M3 Alimentador Desmotador 2.

The ModeActivate parameter (which activates the value transfer) of the Mode parameter for the PID) goes to 1 in two conditions: when the D2PID_AM button is in automatic and the State parameter is equal to 4 (indicating Manual status) when the D2PID_AM button is in manual and the State parameter is equal to 3 (indicating automatic status). After 1 second of activation, the parameter ModeActivate receives a reset (goes to 0). The button D2PID_AM is set to automatic (value 1), the Mode parameter must receive the value 3. If D2PID_AM is in manual (value 1), the logic jumps to MANUAL and the Mode parameter does not receives the value 3.


Network 26

The TRUNC variable variable instruction of the Real type for DInt. Then, the Transfer T instruction converts a variable of type DInt to Int.



Network 27

Reset of the alarm recognition button (D2S1) .





• Configure PID. Click on the right mouse button on PID_Compact and select Functional View menu item.



• Select the Input type for the Input parameter and the type Output for the Output parameter. These two types enable values of the Real type in Input and Output. The options Input_PER and Output_PER enable values of type Int with range from 0 to 27648 in the parameters Input and output (same band of channels of analog input and output modules).



• Assign value 0.5 to proportional (Proportional gain) and value 50.0 to the integral (Integral action time).



• Click on the Save window settings button to save the changes.

Operator Screen

• Create Desc2 screen.





• Simulate Ginner 2.