S7-SoftPLC:Instruction set

From IBHsoftec Wiki English
Revision as of 13:32, 23 January 2013 by Jonas (Talk | contribs)

Jump to: navigation, search

The programming language of the IBHsoftec S7-SoftPLC 315and S7-SoftPLC 416 controls is STEP®7 and can be made with the programming tools S7 for Windows® or STEP®7 from Siemens. The complete instruction set of the STEP®7 language is supported.

The S7-SoftPLC 315 has the complete instruction set of the SIMATIC® S7-315 CPU.

The S7-SoftPLC 416 has the complete instruction set of the SIMATIC® S7-416 CPU.

Bit logic instructions

Instruction Operand Description
A AND with a scan to "1"“
AN AND with a scan to "0"
O OR with scan to "1"
ON OR with scan to "0"
X Exclusive-OR with a scan to "1"
XN Exclusive-OR with a scan to "0"
I of an input
Q of an output
M of a memory
L of a local data bit
T of a timer
C of a counter
DBX of a data bit
DIX of an instant data bit
==0 result equal zero
<>0 result unequal zero
>0 result greater than zero
>=0 result greater or equal zero
<0 result less than zero
<=0 result less or equal zero
UO invalid result
OV overflow
OS overflow (saving)
BR binary result

Other boolean logic instructions

Operation Operand Description
A( AND left parenthesis
AN( AND NOT left parenthesis
O( OR left parenthesis
ON( OR NOT left parenthesis
X( Exclusive OR left parenthesis
XN( Exclusive OR NOT left parenthesis
) Right parenthesis
O OR-ing AND operations
NOT Negate RLO
SET Set RLO to "1"
CLR Set RLO to "0"
SAVE Save RLO to the BR bit
Operation Operand Description
= Assign value of RLO
S Set
R Reset
FP Positive edge detection
FN Negative edge detection
I of an input bit
Q of an output bit
M of a memory bit
L of a local data bit
DBX of a data bit
DIX of a instance data bit

Master Control Relay

Operation Operand Description
MCRA Activate MCR
MCRD Deactivate MCR
MCR( Open MCR zone
)MCR Close MCR zone

Load / Transfer instructions

Operation Operand Description
L Load operand
T Transfer operand
IB Input byte
IW Input word
ID Input double word
QB Output byte
QW Output word
QD Ouput double word
MB Memory byte
MW Memory word
MD Memory double word
LB Local data byte
LW Local data word
LD Local data double word
DBB Data block byte
DBW Data block word
DBD Data block double word
DIB Instance data block byte
DIW Instance data block word
DID Instance data block double word
STW Status word
L const Load constant value
L #Pointer Load pointer
L T Timer
LC T Timer (BCD coded)
L Z Counter
LC Z Counter (BCD coded)
L DBNO Data block number
L DBLG Data block length
L DINO Instance data block number
L DILG Instance data block length

Peripheral access instructions

Operation Operand Description
L PIB Load peripheral input byte
L PIW Load peripheral input word
L PID Load peripheral input double word
T PQB Transfer peripheral output byte
T PQW Transfer peripheral output word
T PQD Transfer peripheral output double word

Accumulator instructions

Operation Operand Description
PUSH Push accumulators upwards
POP Push accumulators downwards
ENT Push accumulators (without A1) A2->A3, A3->A4
LEAVE Push accumulators (without A1) A4->A3, A3->A2
TAK Change ACCU1 with ACCU2
CAW Change ACCU1 bytes 0 and 1
CAD Change ACCU1 bytes 0 and 3, 1 and 2

Shift and rotating instructions

Operation Operand Description
SLW Shift ACCU1-L left (word shift)
SLD Shift ACCU1 left (double word shift)
SRW Shift ACCU1-L right (word shift)
SRD Shift ACCU1 right (double word shift)
SSI Shift ACCU1-L right (word shift with sign)
SSD Shift ACCU1 right (double word shift with sign)
RLD Rotate ACCU1 left (double word)
RLDA Rotate ACCU1 left through CC1
RRDA Rotate ACCU1 right through CC1
RRD Rotate ACCU1 right (double word)
const Number of places to shift/rotate
- Number of places to shift/rotate located in ACCU2

Timer instructions

Operation Operand Description
SP T Start as impulse
SE T Start as extendet impulse
SD T Start as ON-delay
SS T Start as saving ON-delay
SF T Start as OFF-delay
R T Reset timer
FR T Enable timer

Counter instructions

Operation Operand Description
CU C Count up (increment)
CD C Count down (decrement)
S C Set counter
R C Reset counter
FR C Enable counter

Word instructions

Operation Operand Description
AW AND ACCU1-L (AND word)
AD AND ACCU1 (AND double word)
OW OR ACCU1-L (OR word)
OD OR ACCU1 (OR double word)
XOW Exclusive-OR ACCU (XOR word)
XOD Exclusive-OR ACCU (XOR double word)
const with a word or double word constant
- with ACCU2

Arithmetic instructions

Operation Operand Description
==I Integer values equal
<>I Integer values unequal
>I Integer values greater
>=I Integer values greather or equal
<I Integer values less
<=I Integer values less or equal
==D Double integer values equal
<>D Double integer values unequal
>D Double integer values greater
>=D Double integer values greater or equal
<D Double integer values less
<=D Double integer values less or equal
==R Real values equal
<>R Real values unequal
>R Real values greater
>=R Real values greater or equal
<R Real values less
<=R Real values less or equal
SIN Sine of a real value
COS Cosine of a real value
TAN Tangent of a real value
ASIN Arcsine of a real value
ACOS Arccosine of a real value
ATAN Arctangent of a real value
SQR Square a real value
SQRT Square root a real value
EXP e to the power of a real value
LN Natural logarithm of a real value
+I Integer addition
-I Integer subtraction
*I Integer multiplication
/I Integer division
+D Double-integer addition
-D Double-integer subtraction
*D Double-integer multiplication
/D Double-integer division
+R Real addition
-R Real subtraction
*R Real multiplication
/R Real division
MOD Double integer division (modulo)
+ const Add a constant
+P# const Add a pointer
DEC dekrement ACCU1-LL (one byte)
INC inkrement ACCU1-LL (one byte)

Data type conversion instructions

Operation Operand Description
ITD Convert integer to double integer
ITB Convert integer to BCD
DTB Convert double integer to BCD
DTR Convert double integer to real
BTI Convert BCD to integer
BTD Convert BCD to double integer
RND Convert real to double integer (round)
RND+ Convert real to double integer (round up)
RND- Convert real to double integer (round down)
TRUNC Convert reeal to double integer (truncate)
INVI Invert ACCU1-L (integer)
INVD Invert ACCU1 (double integer)
NEGI Negate ACCU1-L (integer)
NEGD Negate ACCU1 (double integer)
NEGR Negate ACCU1 (real)
ABS Absolute value (real)

Jump instructions

Operation Operand Description
JU goal Jump unconditional
JC goal Jump if RLO = 1
JCB goal Jump if RLO = 1 (save RLO)
JCN goal Jump if RLO = 0
JNB goal Jump if RLO = 0 (save RLO)
JBI goal Jump if BR = 1
JNBI goal Jump if BR = 0
JZ goal Jump if compare result = 0
JN goal Jump if compare result != 0
JP goal Jump if compare result > 0
JPZ goal Jump if compare result >= 0
JM goal Jump if compare result < 0
JMZ goal Jump if compare result <= 0
JUO goal Jump if compare result "Unordered Math Instruction"
JO goal Jump on overflow
JOS goal Jump on saving overflow
JL goal Jump distributor
LOOP goal Loop programming (decrement ACCU1-L and jump if != 0

Block call instructions

Operation Operand Description
CALL FB Unconditional call of an FB with parameter transfer
CALL FC Unconditional call of an FC with parameter transfer
CALL SFB Unconditional call of an SFB with parameter transfer
CALL SFC Unconditional call of an SFC with parameter transfer
UC FB Unconditional call of an FB without parameter transfer
CC FB Conditional call of an FB without parameter transfer
UC FC Unconditional call of an FC without parameter transfer
CC FC Conditional call of an FC without parameter transfer
BEU End block unconditionally
BEC End block conditionally (RLO = 1)
BE End block
OPN
DB Open data block
DI Open instance data block
TDB Exchange data block registers

Indirect adressing instructions

Operation Operand Description
LAR1 AR1 laden
LAR2 AR2 laden
MD mit Merkerdoppelwort
LD mit Lokaldatendoppelwort
DBD mit Datenbausteindoppelwort
DID mit Instanz-Datenbausteindoppelwort
LAR1 AR1 laden mit Inhalt aus Akku1
LAR2 AR2 laden mit Inhalt aus Akku1
LAR1 AR2 AR1 laden mit Inhalt aus A2
LAR1 P# AR1 laden mit Zeiger
LAR2 P# AR2 laden mit Zeiger
TAR1 Schreibe AR1
TAR2 Schreibe AR2
MD in Merkerdoppelwort
LD in Lokaldatendoppelwort
DBD in Datenbausteindoppelwort
DID in Instanz-Datenbausteindoppelwort
TAR1 Schreibe AR1 in Akku1
TAR2 Schreibe AR2 in Akku1
TAR1 AR2 AR1 nach AR2 transferieren
TAR AR1 mit AR2 tauschen
+AR1 Addiere Akku1 zu AR1
+AR2 Addiere Akku1 zu AR2
+AR1 P# Addiere Pointer zu AR1
+AR2 P# Addiere Pointer zu AR2

Program display and null operation instructions

Operation Operand Description
NOP 0 Nulloperation
NOP 1 Nulloperation
BLD konst Bildaufbau

Layout of S7-SoftPLC memory

The memory of S7-SoftPLC 315 and S7-SoftPLC 416 is compatible to the memory of SIMATIC®-control S7-315 or S7-416.
Please note, that the low-order byte has to be interchanged with the high-order byte when accessing this memory with Windows programs.

Layout of SoftPLC system data

The layout of the system data in the system data is compatible to the system data of SIMATIC®-control S7-315 or S7-416.

Integrated organisation blocks

The organisation blocks, listed in the chart below, are executed, if they are programmed:
OB-Nr Kurzbeschreibung
OB 1 Hauptprogramm
OB 10 – OB 17 Uhrzeitalarm
OB 20 – OB 23 Verzögerungsalarm
OB 30 – OB 38 Zeitbausteine (zyklischer Aufruf)
OB 80 – OB 87 Fehlerbausteine
OB 90 Hintergrundbearbeitung
OB 100/OB 101 Neustart bzw. Wiederanlauf
OB 121/OB 122 Programmierfehler

Integrated system functions

All system functions (SFC) relevant for a Software PLC are integrated in S7-SoftPLC.
The chart below shows the available SFCs(in numeric listing)
SFC-Nr SFC-Name Kurzbeschreibung
SFC 0 SET_CLK Setzen der Systemzeit
SFC 1 READ_CLK Lesen der Systemzeit
SFC 5 (3) GADR_LGC Logische Basisadresse einer Baugruppe ermitteln
SFC 6 RD_SINFO Startinformation des aktuellen OBs auslesen
SFC 13 (1) DPNRM_DG Slave-Diagnose eines DP-Slaves
SFC 14 (2) DPRD_DAT Konsistente Daten eines DP-Normslaves lesen
SFC 15 (2) DPWR_DAT Daten konsistent auf DP-Normslave schreiben
SFC 20 BLKMOV SPS-Variable in Zielbereich kopieren
SFC 21 FILL SPS-Variable in Zielbereich vorbesetzen
SFC 22 CREAT_DB Anlegen von Datenbausteinen
SFC 23 DEL_DB Datenbaustein löschen
SFC 24 TEST_DB Attribute eines Datenbausteins testen
SFC 25 COMPRESS Ladespeicher komprimieren
SFC 28 SET_TINT Stellen eines Uhrzeitalarms
SFC 29 CAN_TINT Uhrzeitalarm anhalten (nicht ausführen)
SFC 30 ACT_TINT Uhrzeitalarm freigeben
SFC 31 QRY_TINT Status des Uhrzeitalarms
SFC 32 SRT_DINT Starte Verzögerungsalarm
SFC 33 CAN_DINT Unterbreche Verzögerungsalarm
SFC 34 QRY_DINT Statusabfrage des Verzögerungsalarms
SFC 36 MSK_FLT Maskieren eines synchronen Fehlerereignisses
SFC 37 DMSK_FLT Demaskieren eines synchronen Fehlerereignisses
SFC 38 READ_ERR Auslesen des Ereignisstatusregister
SFC 39 DIS_IRT Sperren der Asynchron- und Alarmfehlerbearbeitung
SFC 40 EN_IRT Freigeben der Asynchron- und Alarmfehlerbearbeitung
SFC 41 DIS_AIRT Verzögerung höherpriorer Asynchron- und Alarmfehlerbearbeitung
SFC 42 EN_AIRT Freigabe höherpriorer Asynchron- und Alarmfehlerbearbeitung
SFC 43 RE_TRIGR Nachtriggern des Watchdogs
SFC 46 STP CPU Betriebszustand STOP
SFC 49 (3) LGC_GADR Ermitteln des Steckplatzes einer logischen Adresse
SFC 50 (3) RD_LAGADR Ermitteln aller logischer Adressen einer Baugruppe
SFC 51 RDSYST Systemzustandsliste (SZL) auslesen
SFC 64 TIME_TCK Timer Tick
SFC 81 UBLKMOV Block Move der nicht unterbrochen werden kann


1)The SFC 13 is available only, when the driver Cifcfg.dll is loaded. Furthermore it can only return valid results, if the PROFIBUS® configuration has been created via the S7 for Windows® hardware configuration or the STEP®7 hardware configuration. This is only possible when using the driver CIFCFG.DLL.

2)The SFC 14 and SFC 15 are available only, if they are loaded via the driver CIF30D0.DLL or the driver CIFCFG.DLL.
3)The SFCs can only return valid results, if the PROFIBUS®7 configuration has been created via the S7 for Windows®7 hardware configuration or the STEP®7 hardware configuration. This is only possible when using the driver CIFCFG.DLL.

Integrated system blocks

The system blocks (SFB) relevant for a software PLC are integrated in S7-SoftPLC. 
The following system function blocks are supported:
SFB-Nr SFB-Name Kurzbeschreibung
SFB 0 CTU Vorwärtszähler (Counter Up)
SFB 1 CTD Rückwärtszähler (Counter Down)
SFB 2 CTUD Vorwärts- und Rückwärtszähler
SFB 3 TP Zeitimpuls
SFB 4 TON Einschaltverzögerung
SFB 5 TOF Ausschaltverzögerung
SFB 32 DRUM Schaltwerk zur Steuerung von Schrittketten
SFB 52 (4) RDREC_DP Datensatz lesen
SFB 53 (4) WRREC_DP Datensatz schreiben


4)The SFB 52 and SFB 53 are only available if the driver CIFCFG.DLL is loaded and the entry DPV1=1 is set.