S7-SoftPLC:Instruction set

From IBHsoftec Wiki English
Revision as of 12:05, 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 Schieben links wortweise
SLD Schieben links doppelwortweise
SRW Schieben rechts wortweise
SRD Schieben rechts doppelwortweise
SSI Schieben mit Vorzeichen wortweise
SSD Schieben mit Vorzeichen doppelwortweise
RLD Rotieren links doppelwortweise
RLDA Rotieren links durch Al
RRDA Rotieren rechts durch Al
RRD Rotieren rechts doppelwort­weise
konst um feste Anzahl von Bits
Schiebezahl im Akku 2

Timer instructions

Operation Operand Description
SI T Starten als Impuls
SV T Starten als verlängerter Impuls
SE T Starten als Einschaltverzögerung
SS T Starten als speichernde Einschaltverzögerung
SA T Starten als Ausschaltverzögerung
R T Zeitfunktion rücksetzen
FR T Zeitfunktion freigeben

Counter instructions

Operation Operand Description
ZV Z Zählfunktion vorwärtszählen
ZR Z Zählfunktion rückwärtszählen
S Z Zählfunktion setzen
R Z Zählfunktion rücksetzen
FR Z Zählfunktion freigeben

Word instructions

Operation Operand Description
UW UND wortweise
UD UND doppelwortweise
OW ODER wortweise
OD ODER doppelwortweise
XOW Exklusiv-ODER wortweise
XOD Exklusiv-ODER doppelwortweise
konst Mit einer Wort- bzw. Doppelwortkonstanten
mit dem Inhalt von Akku 2

Arithmetic instructions

Operation Operand Description
==I Integervergleich GLEICH
<>I Integervergleich UNGLEICH
>I Integervergleich GRÖSSER
>=I Integervergleich GRÖSSER GLEICH
<I Integervergleich KLEINER
<=I Integervergleich KLEINER GLEICH
==D Doppel-Integervergleich GLEICH
<>D Doppel-Integervergleich UNGLEICH
>D Doppel-Integervergleich GRÖSSER
>=D Doppel-Integervergleich GRÖSSER GLEICH
<D Doppel-Integervergleich KLEINER
<=D Doppel-Integervergleich KLEINER GLEICH
==R REAL-Zahl Vergleich GLEICH
<>R REAL-Zahl Vergleich UNGLEICH
>R REAL-Zahl Vergleich GRÖSSER
>=R REAL-Zahl Vergleich GRÖSSER GLEICH
<R REAL-Zahl Vergleich KLEINER
<=R REAL-Zahl Vergleich KLEINER GLEICH
SIN Sinus
COS Cosinus
TAN Tangens
ASIN Arcussinus
ACOS Arcuscosinus
ATAN Arcustangens
SQR Quadrieren
SQRT Wurzel (Radizieren)
EXP Exponent zur Basis e
LN Natürlicher Logarithmus
+I Integer Addition
-I Integer Subtraktion
*I Integer Multiplikation
/I Integer Division
+D Doppel-Integer Addition
-D Doppel-Integer Subtraktion
*D Doppel-Integer Multiplikation
/D Doppel-Integer Division
+R Realzahl Addition
-R Realzahl Subtraktion
*R Realzahl Multiplikation
/R Realzahl Division
MOD Doppel-Integer Division (Rest)
+ konst Addieren einer Konstante
+P# konst Addieren eines Zeigers
DEC Dekrementieren
INC Inkrementieren

Data type conversion instructions

Operation Operand Description
ITD Wandlung INT nach DINT
ITB Wandlung INT nach BCD
DTB Wandlung DINT nach BCD
DTR Wandlung DINT nach REAL
BTI Wandlung BCD nach INT
BTD Wandlung BCD nach DINT
RND Rundung zur nächsten ganzen Zahl
RND+ Rundung zur nächstgrößeren Zahl
RND- Rundung zur nächstkleineren Zahl
TRUNC ohne Rundung
INVI INT-Einerkomplement
INVD DINT-Einerkomplement
NEGI INT-Negation
NEGD DINT-Negation
NEGR REAL-Negation
ABS REAL-Betragsbildung

Jump instructions

Operation Operand Description
SPA Ziel Sprung absolut (unbedingt)
SPB Ziel Sprung wenn VKE = 1
SPBB Ziel Sprung wenn VKE = 1 (VKE speichern)
SPBN Ziel Sprung wenn VKE = 0
SPBNB Ziel Sprung wenn VKE = 0 (VKE speichern)
SPBI Ziel Sprung wenn BIE = 1
SPBIN Ziel Sprung wenn BIE = 0
SPZ Ziel Sprung bei Vergleichsergebnis = 0
SPN Ziel Sprung bei Vergleichsergebnis ≠ 0
SPP Ziel Sprung bei Vergleichsergebnis > 0
SPPZ Ziel Sprung bei Vergleichsergebnis >= 0
SPM Ziel Sprung bei Vergleichsergebnis < 0
SPMZ Ziel Sprung bei Vergleichsergebnis <= 0
SPU Ziel Sprung bei Vergleichsergebnis ungültig
SPO Ziel Sprung bei Overflow
SPS Ziel Sprung bei speicherndem Overflow
SPL Ziel Sprungverteiler
LOOP Ziel Schleife

Block call instructions

Operation Operand Description
CALL FB Sprung zum Funktionsbaustein
CALL FC Sprung zur Funktion
CALL SFB Sprung zum System-Funktionsbaustein
CALL SFC Sprung zur System-Funktion
UC FB Funktionsbaustein absolut aufrufen
CC FB Funktionsbaustein bedingt aufrufen
UC FC Funktion absolut aufrufen
CC FC Funktion bedingt aufrufen
BEA Bausteinende absolut
BEB Bausteinende bedingt
BE Bausteinende
AUF DB Datenbaustein öffnen
DI Instanz-Datenbaustein öffnen
TDB Datenbausteinregister tauschen

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.