Upload
enercon
View
156
Download
7
Tags:
Embed Size (px)
DESCRIPTION
S7 300 Training Manual
Citation preview
s
SIMATIC
Working with STEP 7 V5.3 Getting Started
This manual is part of the documentation package with the order number: 6ES7810-4CA07-8BW0
Edition 01/2004 A5E00261403-01
Copyright © Siemens AG 2004 All rights reserved
The reproduction, transmission or use of this document or its contents is not permitted without express written authority. Offenders will be liable for damages. All rights, including rights created by patent grant or registration of a utility model or design, are reserved. Siemens AG Bereich Automation and Drives Geschaeftsgebiet Industrial Automation Systems Postfach 4848, D- 90327 Nuernberg
Disclaimer of Liability
We have checked the contents of this manual for agreement with the hardware and software described. Since deviations cannot be precluded entirely, we cannot guarantee full agreement. However, the data in this manual are reviewed regularly and any necessary corrections included in subsequent editions. Suggestions for improvement are welcomed. ©Siemens AG 2004 Technical data subject to change.
Siemens Aktiengesellschaft A5E00261403-01
Safety Guidelines
This manual contains notices intended to ensure personal safety, as well as to protect the products and
connected equipment against damage. These notices are highlighted by the symbols shown below and
graded according to severity by the following texts:
! Danger indicates that death, severe personal injury or substantial property damage will result if proper precautions are not taken.
! Warning indicates that death, severe personal injury or substantial property damage can result if proper precautions are not taken.
! Caution indicates that minor personal injury can result if proper precautions are not taken.
Caution indicates that property damage can result if proper precautions are not taken.
Notice
draws your attention to particularly important information on the product, handling the product, or to a particular part of the documentation.
Qualified Personnel
Only qualified personnel should be allowed to install and work on this equipment. Qualified persons are
defined as persons who are authorized to commission, to ground and to tag circuits, equipment, and
systems in accordance with established safety practices and standards.
Correct Usage
Note the following:
! Warning This device and its components may only be used for the applications described in the catalog or the
technical description, and only in connection with devices or components from other manufacturers
which have been approved or recommended by Siemens.
This product can only function correctly and safely if it is transported, stored, set up, and installed correctly, and operated and maintained as recommended.
Trademarks
SIMATIC®, SIMATIC HMI® and SIMATIC NET® are registered trademarks of SIEMENS AG.
Third parties using for their own purposes any other names in this document which refer to trademarks might
infringe upon the rights of the trademark owners.
STEP 7 Getting Started A5E00261403-01 iii
Welcome to STEP 7...
...the SIMATIC standard software for creating programmable logic control programs in Ladder Logic, Function Block Diagram, or Statement List for SIMATIC S7-300/400 stations.
About This Getting Started Manual
In this manual, you will get to know the basics of SIMATIC STEP 7. We will show you the most important screen dialog boxes and the procedures to follow using practical exercises, which are structured so that you can start with almost any chapter.
Each section is split into two parts: a descriptive part, marked in gray, and a process-oriented part, marked in green. The instructions start with an arrow in the green margin and may be spread out over several pages, finishing in a full stop and a box containing related topics.
Previous experience of working with the mouse, window handling, pull-down menus, etc. would be useful, and you should preferably be familiar with the basic principles of programmable logic control.
The STEP 7 training courses provide you with in-depth knowledge above and beyond the contents of this Getting Started manual, teaching you how entire automation solutions can be created with STEP 7.
Requirements for Working with the Getting Started Manual
In order to carry out the practical exercises for STEP 7 in this Getting Started manual, you require the following:
• A Siemens programming device or a PC
• The STEP 7 software package and the respective license key
• A SIMATIC S7-300 or S7-400 programmable controller (for Chapter 7 "Downloading and Debugging the Program").
Additional Documentation on STEP 7
• STEP 7 Basic Information
• STEP 7 Reference Information
After you have installed STEP 7, you will find the electronic manuals in the Start menu under Simatic > Documentation or alternatively, you can order them from any Siemens sales center. All of the information in the manuals can be called up in STEP 7 from the online help.
Have fun and good luck!
SIEMENS AG
S7-300 Programmable Controller CPU Specifications, CPUs 312C to 314C-2DP/PtPA5E00105475-01 3-1
3Structure and communication functionsof a CPU 31xC 33.1 Control and Display Elements
Elements
The figure below shows the control and display elements of a CPU 31xC.Arrangement and number of elements differ in some CPUs.
2 Interface(PtP interface or DP)
Displays Status andError
Mode selector
power supply port
MultipointMPI interface
Ejector for MMC
Card slot for MMC
Outputs andinputsconnectorterminal
6ES7 953-8Lx00-0AA0
Micro
Mem
ory
Card
SIM
AT
IC
64
kB
yte
MMC (see nextchapter)
SF
BF
DC5V
RUN
STOP
SIEMENS
RUN
STOP
MRES
FRCE
Figure 3-1 Elements and assembly of a CPU 31xC, for example, a CPU 314C-2 PtP
Structure and communication functions of a CPU 31xC
S7-300 Programmable Controller CPU Specifications, CPUs 312C to 314C-2DP/PtP3-2 A5E00105475-01
The figure below shows the digital/analog I/O integrated in the CPU.
SF
BF
DC5V
FRCE
RUN
STOP
SIEMENS
RUN
STOP
MRES per 8 digitaloutputs
per 8digitalinputs
Analogoutputsandinputs
Front connector(Front doors are not open)
X1 X2
Figure 3-2 Integrated I/O of the CPU 31xC, for example, a CPU 314C-2 PtP
Structure and communication functions of a CPU 31xC
S7-300 Programmable Controller CPU Specifications, CPUs 312C to 314C-2DP/PtPA5E00105475-01 3-3
Differences Between CPUs
Table 3-1 Differences Between CPUs
Element CPU312C
CPU313C
CPU313C-2 DP
CPU313C-2 PtP
CPU314C-2 DP
CPU314C-2 PtP
SIMATIC Micro MemoryCard (always requiredfor operation)
x x x x x x
9-pin MPI interface x x x x x x
9-pin DP interface – – x – x –
15-pin PtP interface – – – x – x
Digital inputs 10 24 16 16 24 24
Digital outputs 6 16 16 16 16 16
Analog inputs – 4 + 1 – – 4 + 1 4 + 1
Analog outputs – 2 – – 2 2
Technological functions 2 counters 3 counters 3 counters 3 counters 4 counters
1 Channelforpositioning
4 counters
1 Channelforpositioning
Status and Error Displays
The CPU is equipped with the following LED displays:
CPU LEDs:
SF (red)
BF (red)
DC5V (green)
FRCE (yellow)
RUN (green)
STOP (yellow)
Hardware or software error
Bus error (only CPU 313C-2 DP and 314C-2 DP)
The 5 V power supply for the CPU and S7 300 bus is ok
Force job is active
CPU is in RUN; LED blinks during restart at 2 Hz; in HOLD at 0.5 Hz
CPU is in STOP or HOLD or restart; LED blinks during memory reset
request at 0.5 Hz, during memory reset at 2 Hz.
Figure 3-3 Status and Error Displays
Diagnostics
How you can use the LED displays is explained in the Installation Guide, ChapterTesting functions, Diagnostics and Fault Elimination.
Structure and communication functions of a CPU 31xC
S7-300 Programmable Controller CPU Specifications, CPUs 312C to 314C-2DP/PtP3-4 A5E00105475-01
Slot for the SIMATIC Micro Memory Card (MMC)
SIMATIC Micro Memory Cards (MMCs) are used as memory submodule forCPUs 31xC. The MMC can be used as load memory or portable storage medium.The MMC must be inserted to operate the CPU, since CPUs 31xC are notequipped with an integrated load memory.
Mode Selector Switch
You can use the mode selector switch to set the current CPU operating mode.Theswitch has 3 positions.
Positions of the mode selector switch
The positions of the mode selector are explained in the order in which they appearon the CPU.
Table 3-2 Mode Selector Positions
Position Mode Description
RUN RUN mode The CPU scans the user program.
STOP STOP mode The CPU does not scan user programs.
MRES Memory Reset Mode selector switch position with pushbutton function forresetting CPU memory. Memory reset requires a specificsequence of operation (refer to the Installation Guide,Chapter Commissioning).
Power Supply Connection
The CPU 31xC series are equipped with a 2-pole power supply socket. The plugwith screw terminals is included in the delivery and already inserted into the CPU.
Further Information
Further information on CPU operating modes is found in the STEP 7 Online Help.
For information on resetting memory per mode selector operation please refer tothe Installation Guide, Chapter Commissioning.
Details on error / diagnostics evaluation per LEDs are found in your InstallationGuide, Chapter Testing functions, Diagnostics and Fault Elimination. Informationon MMC usage and memory conception are found in the same chapters.
Digital Modules
3-4S7-300 and M7-300 Programmable Controllers Module Specifications
EWA 4NEB 710 6067-02 02
3.1 Module Overview
Introduction
The following tables summarize the most important characteristics of the digitalmodules. This overview is intended to make it easy to choose the suitable modulefor your task.
Table 3-1 Digital Input Modules: Characteristics at a Glance
Module
Characteristics
SM 321; DI 3224 VDC
(-1BLx0-)
SM 321; DI 16 24 VDC
(-1BH02-)
SM 321; DI 16 24 VDC
(-7BHx0-)
SM 321; DI 1624 VDC;sourceinput
(-1BH50-)
SM 321; DI 1648-125VDC
(-1CH80-)
SM 321; DI 16
120 VAC
(-1EH01-)
SM 321; DI 8120/230 VAC
(-1FFx1-)
SM 321; DI 32
120 VAC
(-1EL00-)
Number of inputs 32 DI;isolated ingroupsof 16
16 DI;isolated ingroupsof 16
16 DI;isolated ingroupsof 16
16 DI;source in-put, iso-lated ingroupsof 16
16 DI; iso-lated ingroupsof 8
16 DI;isolated ingroupsof 4
8 DI, iso-lated ingroupsof 2
32 DI;isolated ingroupsof 8
Rated input volt-age
24 VDC 24 VDC 24 VDC 24 VDC 48 to125 VDC
120 VAC 120/230 VAC
120 VAC
Suitable for... Switches;
two, three, and four-wire proximity switches (BEROs)
Switches;
two and three-wire AC proximityswitches
Programmablediagnostics
No No Yes No No No No No
Diagnostic inter-rupt
No No Yes No No No No No
Hardware inter-rupt upon edgechange
No No Yes No No No No No
Adjustable inputdelays
No No Yes No No No No No
Special features – – 2 short-circuit-proof sen-sor sup-plies for8 chan-nels each
Externalredundantpowersupplypossibleto supplysensors
– – – – –
Digital Modules
3-5S7-300 and M7-300 Programmable Controllers Module SpecificationsEWA 4NEB 710 6067-02 02
Table 3-2 Digital Output Modules: Characteristics at a Glance
Module
Characteristics
SM 322;DO3224 VDC/
0.5 A
(-1BL00-)
SM 322;DO1624 VDC/
0.5 A
(-1BHx1-)
SM 322;DO 824VDC/2 A
(-1BF01-)
SM 322;DO 824
VDC/ 0.5 A
(-8BFx1-)
SM 322;DO 848-125VDC/ 1.5 A
(-1CF80-)
SM 322;DO16
120 VAC/1 A
(-1EH01-)
SM 322;DO
8120/230 VAC/
2A(-1FFx1-)
SM 322;DO
32120VAC/ 1.0 A
(-1EL00-)
Number of out-puts
32 DO;isolated ingroupsof 8
16 DO;isolated ingroupsof 8
8 DO; iso-lated ingroupsof 4
8 DO; iso-lated ingroupsof 8
8 DO; iso-lated andreversepolarityprotection,in groupsof 4
16 DO;isolated ingroupsof 8
8 DO, isolated ingroupsof 4
32 DO,isolated ingroupsof 8
Output current 0.5 A 0.5 A 2 A 0.5 A 1.5 A 1 A 2 A 1.0 A
Rated load volt-age
24 VDC 24 VDC 24 VDC 24 VDC 48 to 125 VDC
120 VAC 120/230 VAC
120 VAC
Suitable for... Solenoid valves, DC contactors and indicator lights AC solenoid valves, contactors,motor starters, fractional h.p. mo-tors and indicator lights.
Programmablediagnostics
No No No Yes No No No No
Diagnostic inter-rupt
No No No Yes No No No No
Substitute valueoutput
No No No Yes No No No No
Special features Redun-dant driv-ing of aload pos-sible
– Fuse blown indicator.Replaceable fuse foreach group
Blownfuse indi-cator foreachgroup
Digital Modules
3-6S7-300 and M7-300 Programmable Controllers Module Specifications
EWA 4NEB 710 6067-02 02
Table 3-3 Relay Output Modules: Characteristics at a Glance
Module
Characteristics
SM 322; DO16 REL. 120 VAC
(-1HH00-)
SM 322; DO 8 REL.230 VAC
(-1HF01-)
SM 322; DO 8 230VAC/5A REL.
(-1HF10/-1HF80-)
SM 322; DO 8 230VAC/5A REL.
(-1HF20-)
Number ofoutputs
16 outputs, isolated ingroups of 8
8 outputs, isolated ingroups of 2
8 outputs, isolated ingroups of 1
8 outputs, isolated ingroups of 1
Rated loadvoltage
24 to 120 VDC,
48 to 120 VAC
24 to 120 VDC,
48 to 230 VAC
24 to 120 VDC,
48 to 230 VAC
24 to 120 VDC,
24 to 230 VAC
Suitable for... AC/DC solenoid valves, contactors, motor starters, fractional horsepower motors and indicatorlights
Special features –
Table 3-4 Digital Input/Output Modules: Characteristics at a Glance
ModuleCharacter-istics
SM 323; DI 16/DO 16 24 VDC/0.5 A
(-1BL00-)
SM 323; DI 8/DO 8 24 VDC/0.5 A
(-1BHx1-)
Number of inputs 16 inputs, isolated in groups of 16 8 inputs, isolated in groups of 8
Number of outputs 16 outputs, isolated in groups of 8 8 outputs, isolated in groups of 8
Rated input voltage 24 VDC 24 VDC
Output current 0,5 A 0,5 A
Rated load voltage 24 VDC 24 VDC
Inputs suitable for... Switches and two, three and four-wire proximity switches (BEROs).
Outputs suitable for... Solenoid valves, DC contactors and indicator lights
Programmablediagnostics
No No
Diagnostic interrupt No No
Hardware interrupt uponedge change
No No
Adjustable input delays No No
Substitute value output No No
Special features –
Digital Modules
3-13S7-300 and M7-300 Programmable Controllers Module SpecificationsEWA 4NEB 710 6067-02 02
3.6 Digital Input Module SM 321; DI 16 24 VDC; (6ES7 321-1BHx2-0AA0)
Order number: “Standard module”
6ES7 321-1BH02-0AA0
Order number: “SIMATIC Outdoor module”
6ES7 321-1BH82-0AA0
Characteristics
The digital input module SM 321; DI 16 24 VDC has the following salientfeatures:
16 inputs, isolated in groups of 16
24 VDC rated input voltage
Suitable for switches and two/three/four-wire BEROs (proximity switches).
Digital Modules
3-14S7-300 and M7-300 Programmable Controllers Module Specifications
EWA 4NEB 710 6067-02 02
Terminal assignment and block diagram of the SM 321; DI 16 24 VDC
Status LEDs – green
Channel number
Backplane bus interface module
M24 V
Figure 3-3 Module View and Block Diagram of Digital Input Module SM 321; DI 16 24 VDC
Digital Modules
3-15S7-300 and M7-300 Programmable Controllers Module SpecificationsEWA 4NEB 710 6067-02 02
Technical specifications of the SM 321; DI 16 24 VDC
Dimensions and Weight
Dimensions W H D(in millimeters)
40 125 120
Weight Approx. 200 g
Data for Specific Module
Number of inputs 16
Length of cable
Unshielded
Shielded
max. 600 m
max. 1000 m
Voltage, Currents, Potentials
Number of inputs that can betriggered simultaneously
Horizontal configuration
Up to 40 C
Vertical configuration
Up to 60 C
16
16
Isolation
Between channels andbackplane bus
Yes
Permitted potential difference
Between the differentcircuits
75 VDC / 60 VAC
Insulation tested with 500 VDC
Current consumption
From the backplane bus max. 10 mA
Power dissipation of the module typ. 3.5 W
Status, Interrupts, Diagnostics
Status display Green LEDs perchannel
Interrupts None
Diagnostic functions None
Data for Selecting a Sensor
Input voltage
Rated value
For signal “1”
For signal “0”
24 VDC
13 to 30 V
–30 to + 5 V
Input current
At signal “1” typ. 7 mA
Input delay
At “0” to “1”
At “1” to “0”
1.2 to 4.8 ms
1.2 to 4.8 ms
Input characteristic curve According to IEC 1131,Type 1
Connection of Two-WireBEROs
Permitted bias current
Possible
max. 1.5 mA
Digital Modules
3-37S7-300 and M7-300 Programmable Controllers Module SpecificationsEWA 4NEB 710 6067-02 02
3.13 Digital Output Module SM 322; DO 32 24 VDC/ 0.5 A; (6ES7 322-1BL00-0AA0)
Order number
6ES7 322-1BL00-0AA0
Characteristics
The digital output module SM 322; DO 32 24 VDC/0.5 A has the followingsalient features:
32 outputs, isolated in groups of 8
0.5 A output current
24 VDC rated load voltage
Suitable for solenoid valves, DC contactors and indicator lights
Using the module with high-speed counters
Please take note of the following information on the use of the module inconnection with high-speed counters:
Note
When connecting the 24 V power supply via a mechanical contact, the outputs ofthe SM 322; DO 32 24 VDC/0.5 A carry a ”1” signal for approximately 50 s forreasons associated with the circuitry.
Digital Modules
3-38S7-300 and M7-300 Programmable Controllers Module Specifications
EWA 4NEB 710 6067-02 02
Module view and block diagram of the SM 322; DO 32 24 VDC/ 0.5 A
Channelnumber
Status LEDs -green
Backplane businterface
L+
L+
L+
L+
1
2
3
4
M M
M M
1M
2M
3M
4M
24 V
24 V
24 V
24 V
Figure 3-11 Module View and Block Diagram of Digital Output Module SM 322; DO 32 24 VDC/0.5 A
Terminal assignment
The following figure shows the assignment of the channels to the addresses.
Output byte x
Output byte (x + 1)
Output byte (x + 2)
Output byte (x + 3)
Figure 3-12 Terminal Assignment of the SM 322; DO 32 24 VDC
Digital Modules
3-39S7-300 and M7-300 Programmable Controllers Module SpecificationsEWA 4NEB 710 6067-02 02
Technical specifications of the SM 322; DO 32 24 VDC/ 0.5 A
Dimensions and Weight
Dimensions W H D(in millimeters)
40 125 120
Weight Approx. 260 g
Data for Specific Module
Number of outputs 32
Length of cable
Unshielded
Shielded
max. 600 m
max. 1000 m
Voltage, Currents, Potentials
Rated load voltage L+ 24 VDC
Total current of the outputs (pergroup)
Horizontal configuration
Up to 40 C
Up to 60 C
max. 4 A
max. 3 A
Vertical configuration
Up to 40 C max. 2 A
Isolation
Between channels andbackplane bus
Yes
Between the channels
In groups of
Yes
8
Permitted potential difference
Between the differentcircuits
75 VDC60 VAC
Insulation tested with 500 VDC
Current consumption
From the backplane bus
From load voltage L +(without load)
max. 110 mA
max. 160 mA
Power dissipation of the module typ. 6.6 W
Status, Interrupts, Diagnostics
Status display Green LEDs perchannel
Interrupts None
Diagnostic functions None
Data for Selecting an Actuator
Output voltage
At signal “1” min. L + (– 0.8 V)
Output current
At signal “1”
Rated value
Permitted range
0.5 A
5 mA to 0.6 A
At signal “0” (leakagecurrent)
max. 0.5 mA
Output delay (for resistive load)
From “ 0” to “1” max. 100 s
At “1” to “0” max. 500 s
Load resistor range 48 to 4 k
Lamp load max. 5 W
Connecting two outputs inparallel
For redundant triggering of a load
Possible (only outputsof the same group)
To increase performance Not possible
Triggering a digital input Possible
Switch rate
For resistive load max. 100 Hz
For inductive loadaccording to IEC 947-5-1, 13 DC
max. 0.5 Hz
For lamp load max. 10 Hz
Limit (internal) of the inductivecircuit interruption voltage up
typ. L + (– 53 V)
Short-circuit protection of theoutput
Threshold on
Yes, electronic
typ. 1 A
Analog Modules
4-4S7-300 and M7-300 Programmable Controllers Module Specifications
EWA 4NEB 710 6067-02 02
4.1 Module Overview
Introduction
The following tables summarize the most important characteristics of the analogmodules. This overview is intended to make it easy to choose the suitable modulefor your task.
Table 4-1 Analog Input Modules: Characteristics at a Glance
Module
Character-istics
SM 331; AI 8 12
Bit(-7KF02-)
SM 331; AI 8 16 Bit
(-7NF00-)
SM 331; AI 212 Bit
(-7KBx2-)
SM 331;AI 8RTD
(-7PF00-)
SM 331;AI 8TC
(-7PF10-)
Number of inputs 8 inputs in4 channelgroups
8 inputs in4 channelgroups
2 inputs in1 channelgroup
8 inputs in4 channelgroups
8 inputs in4 channelgroups
Resolution adjustable foreach channelgroup:
9 bits +sign
12 bits +sign
14 bits +sign
adjustable foreach channelgroup:
15 bits +sign
adjustable foreach channelgroup:
9 bits +sign
12 bits +sign
14 bits +sign
adjustable foreach channelgroup:
15 bits +sign
adjustable foreach channelgroup:
15 bits +sign
Measuring Method adjustable foreach channelgroup:
Voltage
Current
Resistors
Tempera-ture
adjustable foreach channelgroup:
Voltage
Current
adjustable foreach channelgroup:
Voltage
Current
Resistors
Tempera-ture
adjustable foreach channelgroup:
Resistors
Tempera-ture
adjustable foreach channelgroup:
Tempera-ture
Selection of measuringrange
Arbitrary, perchannelgroup
Arbitrary, perchannelgroup
Arbitrary, perchannelgroup
Arbitrary, perchannelgroup
Arbitrary, perchannelgroup
Programmablediagnostics
Yes Yes Yes Yes Yes
Diagnostic Interrupt Adjustable Adjustable Adjustable Adjustable Adjustable
Limit value monitoring Adjustablefor2 channels
Adjustablefor2 channels
Adjustablefor 1 channel
Adjustablefor8 channels
Adjustablefor8 channels
Hardware interrupt uponlimit violation
Adjustable Adjustable Adjustable Adjustable Adjustable
Hardware interrupt atend of cycle
No No No Adjustable Adjustable
Analog Modules
4-5S7-300 and M7-300 Programmable Controllers Module SpecificationsEWA 4NEB 710 6067-02 02
Table 4-1 Analog Input Modules: Characteristics at a Glance, continued
Module SM 331;AI 8TC
(-7PF10-)
SM 331;AI 8RTD
(-7PF00-)
SM 331; AI 212 Bit
(-7KBx2-)
SM 331; AI 8 16 Bit
(-7NF00-)
SM 331; AI 8 12
Bit(-7KF02-)
Character-istics
Potential relationships Galvanicisolation to:
CPU
Loadvoltage(not for2-DMU)
Galvanicisolation to:
CPU
Galvanicisolation to:
CPU
Loadvoltage(not for2-DMU)
Galvanicisolation to:
CPU
Galvanicisolation to:
CPU
Permitted potentialdifference between theinputs (E CM)
2.5 VDC 50 VDC 2.5 VDC 120 VAC 120 VAC
Special Features – – – –
VZ sign
2-DMU Two-wire transmitter
Table 4-2 Analog Output Modules: Characteristics at a Glance
Module
Character-istics
SM 332; AO 4 12 Bit
(-5HD01-)
SM 332; AO 2 12 Bit
(-5HB01-)
SM 332; AO 416 Bit
(-7ND00-)
Number of outputs 4 outputs in 4 channelgroups
2 output in 2 channelsgroups
4 outputs in 4 channelgroups
Resolution 12 bits 12 bits 16 bits
Output type Channel by channel:
Voltage
Current
Channel by channel:
Voltage
Current
Channel by channel:
Voltage
Current
Programmablediagnostics
Yes Yes Yes
Diagnostic Interrupt Adjustable Adjustable Adjustable
Substitute value output Adjustable Adjustable Adjustable
Potential relationships Galvanic isolation to:
CPU
of the load voltage
Galvanic isolation to:
CPU
of the load voltage
Galvanic isolationbetween:
CPU and channel
the channels
output and L+, M
CPU and L+, M
Special features – – –
Analog Modules
4-6S7-300 and M7-300 Programmable Controllers Module Specifications
EWA 4NEB 710 6067-02 02
Table 4-3 Analog Input/Output Modules: Characteristics at a Glance
ModuleCharacter-istics
SM 334; AI 4/AO 2 8/8 Bit(-0CE01-)
SM 334; AI 4/AO 2 12 Bit(-0KE00-)
Number of inputs 4 inputs in 1 channel group 4 inputs in 2 channel groups
Number of outputs 2 outputs in 1 channel group 2 outputs in 1 channel group
Resolution 8 bits 12 bits + sign
Measuring method Adjustable per channel group:
Voltage
Current
Adjustable per channel group:
Voltage
Resistors
Temperature
Output type Per channel:
Voltage
Current
Per channel:
Voltage
Programmable diagnostics No No
Diagnostic interrupt No No
Limit value monitoring No No
Hardware interrupt upon limitviolation
No No
Hardware interrupt at end ofcycle
No No
Substitute value output No No
Potential relationships Non-isolated to CPU
Galvanic isolation to loadvoltage
Galvanic isolation to:
CPU
of the load voltage
Special features Not parameterizable, setting ofmeasurement and output type bymeans of wiring
–
Analog Modules
4-74S7-300 and M7-300 Programmable Controllers Module Specifications
EWA 4NEB 710 6067-02 02
4.18 Analog Input Module SM 331; AI 8 12 Bit;(6ES7 331-7KF02-0AB0)
Order number
6ES7 331-7KF02-0AB0
Characteristics
The analog input module SM 331; AI 8 12 Bit has the following characteristicfeatures:
8 inputs in 4 channel groups
Measured-value resolution; settable per group (depending on the integrationtime set)
– 9 bits + sign
– 12 Bit + sign
– 14 Bit + sign
Measuring method selectable per channel group:
– Voltage
– Current
– Resistors
– Temperature
Arbitrary measuring range selection per channel group
Programmable diagnostics
Programmable diagnostic interrupt
Two channels with limit monitoring
Programmable limit interrupt
Galvanic isolation to the backplane bus interface
Galvanic isolation to load voltage (not for two-wire transmitter)
Resolution
The resolution of the measured value is a direct function of the integration timeselected. In other words the longer the integration time for an analog input channel,the more accurate the resolution of the measured value will be (see TechnicalSpecifications of the module and Table 4-5 on page 4-9).
Analog Modules
4-75S7-300 and M7-300 Programmable Controllers Module SpecificationsEWA 4NEB 710 6067-02 02
Terminal connection diagram and block diagram of the SM 331; AI 8 12 Bit
M3
Comp – / Mana
Fault indicator - red
Thermocouples,Voltage measurementCurrent measurement
Resistancetest
M0 +
M0
M1 +
Comp +
SF Internal supply
MM
L+Current source
Multi-plexer
Meas. rangemodule
Ext. compensation
None
ADC
GalvanicIsolation
Backplane businterface
SF
+
Int.Comp.
CH0 M0 + CH0M0IC0 +CH1
M1 IC0
M2 + CH2 M1 + CH2M2 M1
M3 + CH3 IC1 +
IC1
M4 +
M4
M5 +
CH4 M2 + CH4M2IC2 +CH5
M5 IC2
M6 + CH6 M3 + CH6M6 M3
M7 + CH7 IC3 +
M7 IC3
Comp
24V
T
Figure 4-29 Module View and Block Diagram of the Analog Input Module SM 331; AI 8 12 Bit
The input resistances depend on the measuring range selected (see TechnicalSpecifications).
Analog Modules
4-76S7-300 and M7-300 Programmable Controllers Module Specifications
EWA 4NEB 710 6067-02 02
Technical specifications of the SM 331; AI 8 12 Bit
Dimensions and Weight
Dimensions W H D
(in millimeters)
40 125 120
Weight Approx. 250 g
Module-Specific Data
Number of inputs
For resistance-typesensor
8
4
Lenght of cable
Shielded
max. 200 m
max. 50 m at 80 mV andthermocouples
Voltage, Currents, Potentials
Power rated voltage of theelectronics L +
24 VDC
Reverse polarityprotection
Yes
Power supply of thetransmitters
Supply current max. 60 mA (per channel)
Short-circuit-proof Yes
Constant measured currentfor resistance-type sensor
typ. 1.67 mA
Isolation
Between channels andbackplane bus
Yes
Between channels andpower supply of theelectronics
Yes
Permitted potentialdifference
Between inputs andMANA (ECM)
– At signal = 0 V
– Not for two-wiretransmitter
2.5 VDC
Between the inputs(ECM)
2.5 VDC
Between MANA andMinternal (EISO)
75 VDC / 60 VAC
Insulation tested with 500 VDC
Current consumption
From the backplane bus max. 50 mA
From the load voltageL +
max. 30 mA (without two-wiretransmitter)
Power dissipation of themodule
typ. 1 W
Analog Value Generation
Measuring principle Integrating
Integration time/conversiontime/resolution (per channel)
Parameters can beassigned
Yes
Integration time in ms 2.5 162/3 20 100
Basic conversion timeincluding Integrationtime in ms
3 17 22 102
Additional conversiontime for measuringresistance, in msor
1 1 1 1
Additional conversiontime for open-circuitmonitoring, in msor
10 10 10 10
Additional conversiontime for measuringresistance andopen-circuit monitoring,in ms
16 16 16 16
Resolution in bitsincluding sign
9bits
12 bits
12 bits
14 bits
Suppression ofinterference voltage forinterferencefrequency f1 in Hertz
400 60 50 10
Basic response time ofmodule, in ms (allchannels enabled)
24 136 176 816
Smoothing of the measuredvalues
None
Analog Modules
4-77S7-300 and M7-300 Programmable Controllers Module SpecificationsEWA 4NEB 710 6067-02 02
Suppression of interference, Limits of Error
Suppression of interference for f = nx (f1 1 %),(f1 = interference frequency)
Common-modeinterference(ECM < 2.5 V)
> 70 dB
Series-modeinterference (peak valueof the interference <rated value of the inputrange)
> 40 dB
Crosstalk between theinputs
> 50 dB
Operational limit (in the entire temperature range, withreference to the input range)
Voltage input 80 mV 1 %
250 to1000 mV
0.6 %
2.5 to 10 V 0.8 %
Current input 3.2 to 20 mA 0.7 %
Resistor 150Ω; 300Ω;600 Ω
0.7 %
Thermocouple Type E, N, J,K, L
1, 1 %
Resistance thermometer
Pt 100/Ni 100
0.7 %
Pt 100climate
0.8 %
Basic error (operational limit at 25 C with reference to the input range)
Voltage input 80 mV 0.7 %
250 to1000 mV
0.4 %
2.5 to 10 V 0.6 %
Current input 3.2 to 20 mA 0.5 %
Resistor 150Ω; 300Ω;600 Ω
0.5 %
Thermocouple Type E, N, J,K, L
0.7 %
Resistance thermometer
Pt 100/Ni 100
0.5 %
Pt 100climate
0.6 %
Temperature error (withreference to the input range)
0.005 %/K
Linearity error (withreference to the input range)
0.05 %
Repeatability (in steadystate at 25 C with referenceto the input range)
0.05 %
Temperature error of theinternal compensation
1 %
Status, Interrupts, Diagnostics
Interrupts
Hardware interruptwhen limit has beenexceeded
Parameters can beassignedChannels 0 and 2
Diagnostic Interrupt Parameters can beassigned
Diagnostic functions
Group error display
Diagnostic informationcan be displayed
Parameters can beassigned
Red LED (SF)
Possible
Data for Selecting a Sensor
Input range (rated values)/Input resistance
Voltage 80 mV
250 mV
500 mV
1000 mV
2.5 V;
5 V;
1 to 5 V;
10 V;
/10 MΩ/10 MΩ/10 MΩ/10 MΩ/100kΩ/100kΩ/100kΩ/100kΩ
Current 3.2 mA
10 mA
20 mA
0 to 20 mA;
4 to 20 mA:
/25 Ω/25 Ω/25 Ω/25 Ω/25 Ω
Resistor 150 Ω300 Ω600 Ω
/10 ΜΩ/10 ΜΩ/10 ΜΩ
Thermocouple Type E, N, J,K, L
/10 ΜΩ
Resistance thermometer
Pt 100,Ni 100
/10 ΜΩ
Maximum input voltage forvoltage input (destructionlimit)
20 V continuous; 75 V for max. 1 s(pulse duty factor 1:20)
Maximum input current forcurrent input (destructionlimit)
40 mA
Analog Modules
4-78S7-300 and M7-300 Programmable Controllers Module Specifications
EWA 4NEB 710 6067-02 02
Connection of the sensor
For measuring voltage Possible
For measuring current
As two-wire transmitter
As four-wire transmitter
Possible
Possible
For measuringresistance
With two-conductorterminal
With three-conductorterminal
With four-conductorterminal
Possible
Possible
Possible
Load of the two-wiretransmitter
max. 820 Ω
Characteristic linearization
For thermocouples
Parameters can beassigned
Type E, N, J, K, L
For RTD ResistanceTemperarture Detector
Pt 100 (standard, climate range)Ni 100 (standard, climate range)
Temperature compensation Parameters can beassigned
Internal temperaturecompensation
Possible
External temperaturecompensation withcompensating box
Possible
Compensation for 0 Creference junctiontemperature
Possible
Technical unit formeasuring temperature
Degrees Celsius
Analog Modules
4-128S7-300 and M7-300 Programmable Controllers Module Specifications
EWA 4NEB 710 6067-02 02
4.23 Analog Output Module SM 332; AO 4 12 Bit;(6ES7 332-5HD01-0AB0)
Order number
6ES7 332-5HD01-0AB0
Characteristics
The analog output module SM 332; AO 4 12 Bit has the following characteristicfeatures:
4 outputs in 4 channel groups
The individual output channels can be programmed as
– voltage outputs
– current outputs
Resolution 12 bits
Programmable diagnostics
Programmable diagnostic interrupt
Programmable substitute value output
Isolated to backplane bus interface and load voltage
Analog Modules
4-129S7-300 and M7-300 Programmable Controllers Module SpecificationsEWA 4NEB 710 6067-02 02
Terminal connection and block diagram of analog output module SM 332; AO 4 12 Bit
Currentoutput
QI0
MANA
QI1
MANA
QI2
MANAQI3
MANA
CH0
CH1
CH2
CH3
Voltageoutputs
QV0
S0
S0 +
MANA
QV1
S1 +
S1
MANA
QV2S2 +
S2
MANAQV3
S3 +
S3
MANA
CH0
CH1
CH2
CH3
SF
Fault indicator - red
Internal supply
GalvanicIsolation
Backplanebus interface
SF
L +24VDAC
MM
Figure 4-34 Module View and Block Diagram of the Analog Output Module SM 332; AO 4 12 Bit
Analog Modules
4-130S7-300 and M7-300 Programmable Controllers Module Specifications
EWA 4NEB 710 6067-02 02
Technical specifications of the SM 332; AO 4 12 Bit
Dimensions and Weight
Dimensions W H D(in millimeters)
40 125 120
Weight Approx. 220 g
Module-Specific Data
Number of outputs 4
Lenght of cable
Shielded max. 200 m
Voltage, Currents, Potentials
Rated load voltage L +
Reverse polarity protection
24 VDC
Yes
Isolation
Between channels andbackplane bus
Yes
Between channels andpower supply of theelectronics
Yes
Between the channels No
Between channels and loadvoltage L+
Yes
Permitted potential difference
Between outputs and MANA(ECM)
3 VDC
Between S– and MANA(ECM)
3 VDC
Between MANA andMinternal (EISO)
75 VDC / 60 VAC
Insulation tested with 600 VDC
Current consumption
From the backplane bus max. 60 mA
From the load voltage L+(without load)
max. 240 mA
Power dissipation of the module typ. 3 W
Analog Value Generation
Resolution including sign
10 V; 20 mA;4 to 20 mA; 1 to 5 V
11 bits + sign
0 to 10 V; 0 to 20 mA 12 bits
Conversion time (per channel) max. 0.8 ms
Settling time
For resistive load
For capacitive load
For inductive load
0.1 ms
3.3 ms
0.5 ms
Suppression of interference, Limits of Error
Crosstalk between the outputs > 40 dB
Operational limit (in the entire temperature range, withreference to the output range)
Voltage outputs
Current outputs
0.5 %
0.6 %
Basic error (operational limit at 25 °C, with reference tothe output range)
Voltage outputs
Current outputs
0.2 %
0.3 %
Temperature error (withreference to the output range)
0.02 %/K
Linearity error (with reference tothe output range)
0.05 %
Repeatability (in steady state at25 C, with reference to theoutput range)
0.05 %
Output ripple; band width 0 to50 kHz (with reference to theoutput range)
0.05 %
Status, Interrupts, Diagnostics
Interrupts
Diagnostic Interrupt Parameters can beassigned
Diagnostic functions Parameters can beassigned
Group error display Red LED (SF)
Diagnostic information can be displayed
Possible
Substitute value can be applied Parameters can beassigned
1-1ET 200S Distributed I/O SystemEWA-4NEB 780602402-12
Product Overview
Chapter overview
The product overview tells you:
• The place of the ET 200S distributed I/O system in the ET 200 distributed I/Osystem.
• The place of ET 200S as an I/O device in PROFINET IO.
• The components that make up the ET 200S distributed I/O system
• Which of the manuals in the ET 200S manual package contains the informationyou require.
Chapter overview
Chapter Description Page
1.1 What are distributed I/O systems? 1-1
1.2 What is PROFINET IO? 1-4
1.3 What is the ET 200S distributed I/O system? 1-5
1.4 Guide to the ET 200S manuals 1-12
1.1 What are distributed I/O systems?
Distributed I/O systems -- area of application
When a system is set up, the inputs and outputs from and to the process are oftenlocated centrally in the programmable logic controller.
If there are inputs and outputs at considerable distances from the programmablelogic controller, there may be long runs of cabling which are not immediatelycomprehensible, and electromagnetic interference may impair reliability.
Distributed I/O systems are the ideal solution in such cases:
• The controller CPU is located centrally.
• The I/O systems (inputs and outputs) operate locally on a distributed basis.
• The high-performance PROFIBUS DP bus system with its high datatransmission rates ensures that the PLC’s CPU and the I/O systemscommunicate smoothly.
1
Product Overview
1-2ET 200S Distributed I/O System
EWA-4NEB 780602402-12
What is PROFIBUS DP?
PROFIBUS DP is an open bus system based on theIEC 61784-1:2002 Ed1 CP 3/1 standard with the ”DP” transmission protocol(DP stands for distributed I/O).
PROFIBUS DP is physically either an electrical network based on a shieldedtwo-wire line or an optical network based on a fiber-optic cable.
The ”DP” transmission protocol allows a rapid, cyclic exchange of data betweenthe controller CPU and the distributed I/O systems.
What are DP masters and DP slaves?
The DP master links the controller CPU with the distributed I/O systems. The DPmaster exchanges data with the distributed I/O systems and monitors thePROFIBUS DP bus system via PROFIBUS DP.
The distributed I/O systems (= DP slaves) prepare the data of the sensors andactuators locally so that they can be transmitted to the PLC CPU byPROFIBUS DP.
Which devices can be connected to the PROFIBUS DP?
An extremely wide range of devices can be connected to the PROFIBUS as DPmasters or DP slaves, provided their behavior complies withIEC 61784-1:2002 Ed1 CP 3/1. The devices that can be used include the following:
• SIMATIC S5
• SIMATIC S7/M7/C7
• SIMATIC programming device/PC
• SIMATIC human-machine interface, or HMI (operator panel, OP; operatorstation, OS; and text display, TD)
• Devices from other manufacturers
Product Overview
1-3ET 200S Distributed I/O SystemEWA-4NEB 780602402-12
Structure of a PROFIBUS DP network
The figure below illustrates a typical PROFIBUS DP network structure. The DPmasters are integrated into the relevant device -- for example, the S7 400 has aPROFIBUS DP interface and the IM 308-C is inserted in an S5-115U. The DPslaves are the distributed I/O systems connected to the DP masters byPROFIBUS DP.
DP-master
DP-slaves
PROFIBUS DP
S7-400 Programming device/PC
ET 200L ET 200M ET 200B S5-95U-DP
Other field devices
with IM 308-CS5-115U
ET 200X OP/OS
S7-200Drive DP/AS-I LINKET 200S
Figure 1-1 Typical PROFIBUS DP network structure
Interface Modules
8-11ET 200S Distributed I/O SystemEWA-4NEB 780602402-12
8.3 IM151-1 STANDARD interface module(6ES7 151-1AA04-0AB0)
Order number
6ES7 151-1AA04-0AB0
Properties
The IM151-1 STANDARD interface module has the following features:
• It connects the ET 200S with PROFIBUS DP via the RS485 interface.
• It prepares the data for the electronic modules and motor starters that are fitted.
• It supplies the backplane bus.
• The PROFIBUS DP address of the ET 200S can be set by means of switches.
• If the 24 VDC power supply is disconnected, the IM151-1 STANDARD interfacemodule is also disconnected.
• The maximum address space is 244 bytes for inputs, and 244 bytes for outputs.
• The reference potential M of the rated supply voltage of theIM151-1 STANDARD to the rail (protective conductor) is connected by meansof an RC combination, thus permitting an ungrounded configuration.
• Operation as a DPV0 slave.
• A maximum of 63 modules can be operated with the IM151-1 STANDARD.
• The maximum bus length is 2 m (can be set).
• Supports option handling (see Chapter 3.8) and the status byte for powermodules.
Supplementary properties compared to the IM151-1 STANDARD interface module(up to 6ES7 151-1AA03-0AB0):
• Operation as a DPV1 slave.
-- Acyclic data exchange (read/write data record):class 2 services and class 1 services
-- Diagnostics Interrupts
-- Process Alarms
-- Removal/Insertion Interrupt
• Firmware update via PROFIBUS DP
• Identification data (see Sec. 3.9)
Interface Modules
8-12ET 200S Distributed I/O System
EWA-4NEB 780602402-12
Terminal assignment
The following table shows the terminal assignment of the IM151 1 STANDARDinterface module for the 24 VDC voltage supply and PROFIBUS DP:
Table 8-7 Terminal assignment of the IM151 1 STANDARD interface module
View Signal name Name
1 -- --
2 -- --
53 RxD/TxD--P Data line B
543
98
4 RTS Request To Send32
876
5 M5V2 Data reference potential (station)216 6 P5V2 Supply plus (station)
7 -- --
8 RxD/TxD--N Data line A
9
2L+ 1M 2M1L+ 1L+ 24 VDC
2L+ VDC (for loop through)
1M Chassis ground
2M Ground (for loop through)
Block diagram
6 (P1)2 (P1)
7 (P2)3 (P2)
Bac
kpla
nebu
s
ET
200S
back
plan
ebu
sin
terf
ace
conn
ectio
n
Electroniccomponents
Internal powersupply
A1A2B1B2
PROFIBUS DPconnection
ElectricalisolationBF ONSF
PROFIBUSaddress
Figure 8-2 Block diagram for the IM151-1 STANDARD interface module
Interface Modules
8-13ET 200S Distributed I/O SystemEWA-4NEB 780602402-12
Technical specifications
Dimensions and weight
DimensionsW×H×D (mm) 45 x 119.5 x 75
Weight Approx. 150 g
Module-specific data
Data transfer rate 9,6; 19,2; 45,45; 93s,75;187,5; 500 kbps,1,5 ; 3; 6; 12 Mbps
Bus protocol PROFIBUS DP
Interface RS 485
SYNC capability Yes
FREEZE capability Yes
Manufacturer’s ID 806AH
Direct Data Exchange Yes
Clock synchronization No
Max. output current ofthe PROFIBUS DPinterface (5, 6)
80 mA
Voltages, currents, electrical potentials
Rated supply voltage ofthe electroniccomponents (1L+)
24 VDC
• Polarity reversalprotection
Yes
• Power failurebypass
Min. 20 ms
Electrical isolation
• between backplanebus and electroniccircuits
No
• Between thePROFIBUS DP andelectroniccomponents
Yes
• Between the supplyvoltage andelectroniccomponents
No
Permitted potentialdifference (to the rail)
75 VDC, 60 VAC
Insulation tested with 500 VDC
Current consumptionfrom rated supplyvoltage (1L+)
Approx. 200 mA
Power dissipation of themodule
Typical 3.3 W
Status, interrupts, diagnostics
Interrupts Yes
Diagnostics function Yes
• Group error
• PROFIBUS DP busmonitoring
red LED ”SF”
red LED ”BF”
• Monitoring of thepower supply of theelectronic system
green LED ”ON”
Configuring Hardware and Communication Connections STEP 7 V5.1A5E00069881-03 1-1
1 Basics of Configuring Hardware with STEP 7
1.1 Introduction to Configuring Hardware
Configuring
The term "configuring" refers to the arranging of racks, modules, distributed I/O(DP) racks, and interface submodules in a station window. Racks are representedby a configuration table that permits a specific number of modules to be inserted,just like a real rack.
In the configuration table, STEP 7 automatically assigns an address to eachmodule. You can change the addresses of the modules in a station if the CPU inthe station can be addressed freely (meaning an address can be assigned freely toevery channel of the module, independent of its slot).
You can copy your configuration as often as you like to other STEP 7 projects,modify it as necessary, and download it to one or more existing plants. When theprogrammable controller starts up, the CPU compares the preset configurationcreated in STEP 7 with the actual configuration of the plant. Any errors aretherefore recognized immediately and reported.
Assigning Parameters
The term ”assigning parameters" refers to the following:
• Setting properties for programmable modules in a local configuration and in anetwork. For example: a CPU is a module to which you can assign parametersand its watchdog time is a parameter you can set.
• Setting bus parameters, DP master and DP slave parameters for a mastersystem (PROFIBUS-DP)
The parameters are downloaded to the CPU and transferred by the CPU to therespective modules. Modules can easily be replaced because the parameters setwith STEP 7 are automatically downloaded to the new module during startup.
Basics of Configuring Hardware with STEP 7
Configuring Hardware and Communication Connections STEP 7 V5.11-2 A5E00069881-03
When Should You Configure Your Hardware?
The properties of the S7 programmable controllers and modules are preset withdefault values such that in many cases you do not need to configure them.
Configuration is necessary in the following cases:
• If you want to change the default parameters of a module (for example, enablea hardware interrupt for a module)
• If you want to configure communication connections
• For stations with a distributed I/O (PROFIBUS-DP)
• For S7-400 stations with a number of CPUs (multicomputing) or expansionracks
• For fault-tolerant (H) programmable control systems (optional package)
Basics of Configuring Hardware with STEP 7
Configuring Hardware and Communication Connections STEP 7 V5.1A5E00069881-03 1-3
1.2 Basic Procedure for Configuring Hardware
Window for Configuring
Configuring a programmable controller involves the use of two windows:
• The station window in which you place the racks for the station structure
• The "Hardware Catalog" window from which you select the required hardwarecomponents, for example, racks, modules, and interface submodules
Displaying the Hardware Catalog
If the ”Hardware Catalog" window is not displayed, select the menu commandView > Catalog. This command toggles the display of the Hardware Catalog onand off.
1.2.1 Basic Steps for Configuring a Station
Independent of which structure a station has – you always configure using thefollowing steps:
1. Select a hardware component in the ”Hardware Catalog" window.
2. Copy the selected component to the station window using drag & drop.
The following figure shows the basic operation:
Basics of Configuring Hardware with STEP 7
Configuring Hardware and Communication Connections STEP 7 V5.11-4 A5E00069881-03
1.2.2 Layout of the Station Window
The lower part of the station window shows a detailed view of the inserted/selectedrack. The order numbers and addresses of the modules are shown here in tableform.
The table has the structure shown below for a central rack equipped with modules(detailed view):
Slot
1
2
3
4
5
6
7
8
9
Module
CPU314
DI8xAC120/230V
AI8x12Bit
AI8x16Bit
AI8xTC/4xRDT, Ex
AO2x12Bit
AO2x12Bit
Order Number
6ES7 314-1AE0
6ES7 321-1FF8
6ES7 331-7KF0
6ES7 331-7NF0
6ES7 331-7SF0
6ES7 332-5HB0
6ES7 332-5HB8
M... I...
0
272...
288...
304...
Q...
320...
336...
Comment
Basics of Configuring Hardware with STEP 7
Configuring Hardware and Communication Connections STEP 7 V5.1A5E00069881-03 1-5
1.2.3 Configuration Table as a Representation of a Rack
For a local configuration you arrange the modules beside the CPU in a rack andcontinue into additional expansion racks. The number of racks which can beconfigured depends on the CPU you used.
Just as you do in a real plant, you arrange your modules in racks with STEP 7. Thedifference is that in STEP 7 racks are represented by ”configuration tables" thathave as many rows as the rack has slots for modules.
The following figure shows an example of how a real structure is converted into aconfiguration table. The configuration table corresponds to the rack used; STEP 7automatically places the number of the rack in brackets in front of the name.
Example: (0) UR corresponds to the central rack (Universal Rack) number 0.
Configuration table(racks)
1.2.4 Setting the Properties of Components
Once you have arranged your components in the station window, you always arrivein the following manner in a dialog box for changing the default properties(parameters or addresses):
• Double-click the component or select the menu command Edit > ObjectProperties.
• Right mouse button: Move the cursor on the component, press the right mousebutton and select the command Object Properties from the pop-up menu.
Basics of Configuring Hardware with STEP 7
Configuring Hardware and Communication Connections STEP 7 V5.11-6 A5E00069881-03
Properties of CPUs
The properties of the CPUs have a special significance for the behavior of thesystem. In the dialog boxes for a CPU, you can set the following, for example:startup characteristics, local data areas and priorities for interrupts, memory areas,retentive behavior, clock memory, protection level, and password – to name only afew. STEP 7 "knows" what can be set and within what range limits.
In the "General" tab of the CPU or via the properties of the CPU interface you canassign parameters to the interfaces (for example, MPI or integrated PROFIBUS-DPinterfaces). Via these dialog boxes you can also access the properties dialog boxfor the corresponding subnet to which the CPU is to be connected.
Other Ways of Assigning Parameters
For S7-300 and S7-400 programmable controllers you can set the parameters forsome modules in the user program (for example, for analog modules). You need tocall the system functions (SFCs) WR_PARM, WR_DPARM, and PARM_MOD inthe user program to do this. These settings are lost following a warm restart.
You will find more detailed information about system functions in the SystemSoftware for S7-300 and S7-400, System and Standard Functions ReferenceManual
For M7-300 and M7-400 programmable control systems you can set theparameters for signal modules in the C program. You need to call the M7 APIfunction ”M7StoreRecord" in the C program to do this. This function transfers theparameters to a signal module.
You will find more information about the M7 API functions in the manuals on thesystem software for M7-300 and M7-400.
1.2.5 What You Should Know About Slot Rules and Other Rules
STEP 7 offers you support with configuring a station so that a message is generallydisplayed immediately if, for example, a module cannot be inserted in the slot youwant to insert it in.
Furthermore, because address ranges are checked automatically, double addressassignments cannot occur.
In this connection, please pay attention to the status bar at the lower edge of thewindow and to any displayed messages that provide details on the causes andeffects of an operation. You can also use the online help to obtain additionalinformation for the messages.
Other additional, temporary rules (for a specific release), such as restrictions to theslots you can use owing to a functional restriction to individual modules, are nottaken into account. Consequently, always consult the documentation or the currentProduct Information for the modules.
Basics of Configuring Hardware with STEP 7
Configuring Hardware and Communication Connections STEP 7 V5.1A5E00069881-03 1-7
1.3 Overview: Procedure for Configuring and AssigningParameters to a Local Configuration
Requirement
You must have opened a project or created a new project in the SIMATICManager.
Basic Procedure
To configure and assign parameters to a structure, proceed as shown below:
Create a station
Call up the application "Configuring Hardware"
Determine module properties
Arrange racks
Save configuration
Download configuration to the programmable logic controller
Arrange modules
Summary
As usual in Windows applications, you can put together the whole configuration inSTEP 7 using drag and drop. You will find detailed information on handling andsetting up your real plant configuration, for example, how you configure theconnection to expansion racks or how you configure special components in theSTEP 7 online help.
STEP 7 Getting Started 1-1A5E00069681-03
1 Introduction to STEP 7
1.1 What You Will Learn
Using practical exercises, we will show you how easy it is to program in LadderLogic, Statement List, or Function Block Diagram with STEP 7.
Detailed instructions in the individual chapters will show you step-by-step themany ways in which you can use STEP 7.
Creating a Program with Binary Logic
In Chapters 2 to 7, you will create a program with binary logic. Using theprogrammed logic operations, you will address the inputs and outputs of your CPU(if present).
The programming examples in the Getting Started manual are based, among otherthings, on three fundamental binary logic operations.
The first binary logic operation, which you will program later on, is the ANDfunction. The AND function can be best illustrated in a circuit diagram using twokeys.
The second binary logic operation is the OR function. The OR function can also berepresented in a circuit diagram.
Key 1 Key 2
Key 3
If both Key 1 and Key 2are pressed, the bulblights up.
Key 4If either key 3 or key 4is pressed, the bulblights up.
Introduction to STEP 7
1-2 STEP 7 Getting StartedA5E00069681-03
The third binary logic operation is the memory element. The SR function reactswithin a circuit diagram to certain voltage states and passes these on accordingly.
Memory Element
S
R
Key S
Key R
If key S is pressed, the bulb lights upand remains lit until key R is pressed.
Introduction to STEP 7
1-3STEP 7 Getting StartedA5E00069681-03
1.2 Combining Hardware and Software
Using the STEP 7 software, you can create your S7 program within a project. TheS7 programmable controller consists of a power supply unit, a CPU, and input andoutput modules (I/O modules).
The programmable logic controller (PLC) monitors and controls your machine withthe S7 program. The I/O modules are addressed in the S7 program via theaddresses.
Transferring a program
STEP 7 software
Machine to becontrolled
Input module
CPU
Power supply module
Output module
Programmingdevice cable
Programming device
Introduction to STEP 7
1-4 STEP 7 Getting StartedA5E00069681-03
1.3 Basic Procedure Using STEP 7
Before you create a project, you should know that STEP 7 projects can be createdin different orders.
Option 2Option 1
If you are creating comprehensive programs with many inputs and outputs, werecommend you configure the hardware first. The advantage of this is that STEP 7displays the possible addresses in the Hardware Configuration Editor.
If you choose the second option, you have to determine each address yourself, dependingon your selected components and you cannot call these addresses via STEP 7.
In the hardware configuration, not only can you define addresses, but you can also changethe parameters and properties of modules. If you want to operate several CPUs, forexample, you have to match up the MPI addresses of the CPUs.
Since we are only using a small number of inputs andoutputs in the Getting Started manual, we will skip thehardware configuration for now and start with theprogramming.
Configuring the hardware(Chapter 6)
Creating a program(Chapters 3 to 5)
Creating a program(Chapters 3 to 5)
Configuring the hardware(Chapter 6)
Transferring the program to the CPU and debugging(Chapter 7)
Designing the solution to the automation task
Creating a project (Chapter 2)
STEP 7 Getting Started 2-1A5E00069681-03
2 The SIMATIC Manager
2.1 Starting the SIMATIC Manager and Creating a Project
The SIMATIC Manager is the central window which becomes active when STEP 7is started. The default setting starts the STEP 7 Wizard, which supports you whencreating a STEP 7 project. The project structure is used to store and arrange allthe data and programs in order.
Double-click the SIMATIC Managericon. The STEP 7 Wizard is activated.
In the preview, you can toggle theview of the project structure beingcreated on and off.
To move to the next dialog box, clickNext.
Within the project, data are stored in theform of objects in a hierarchical structure
The SIMATIC station and the CPUcontain the configuration andparameter data of the hardware
The S7 program comprises all theblocks with the programs necessary forcontrolling the machine
The SIMATIC Manager
2-2STEP 7 Getting StartedA5E00069681-03
For the "Getting Started" sampleproject, select CPU 314. The examplehas been created in such a way thatyou can actually select the CPU youhave been supplied with at any time.
The default setting for the MPI addressis 2.
Click Next to confirm the settings andmove to the next dialog box.
Select the organization block OB1 (ifthis is not already selected).
Select one of the programminglanguages: Ladder Logic (LAD),Statement List (STL), or FunctionBlock Diagram (FBD).
Confirm your settings with Next.
Every CPU has certainproperties; for example,regarding its memoryconfiguration or addressareas. This is why you haveto select the CPU before youstart programming.
The MPI address (multipointinterface) is required in orderfor your CPU to communicatewith your programming deviceor PC.
OB1 represents the highestprogramming level and organizes theother blocks in the S7 program.
You can change the programminglanguage again at a later date.
The SIMATIC Manager
2-3STEP 7 Getting StartedA5E00069681-03
Double-click to select the suggestedname in the "Project name" field andoverwrite it with "Getting Started."
Click Make to generate your newproject according to the preview.
When you click the Make button, the SIMATIC Manager will open with the window for the"Getting Started" project you have created. On the following pages, we will show you whatthe created files and folders are for and how you can work effectively with them.
The STEP 7 Wizard is activated each time the program is started. You can deactivate thisdefault setting in the first dialog box for the Wizard. However, if you create projects withoutthe STEP 7 Wizard, you must create each directory within the project yourself.
You can find more information underHelp > Contents in the topic "SettingUp and Editing the Project."
The SIMATIC Manager
2-4STEP 7 Getting StartedA5E00069681-03
2.2 The Project Structure in the SIMATIC Manager and Howto Call the Online Help
As soon as the STEP 7 Wizard is closed, the SIMATIC Manager appears with theopen project window "Getting Started." From here, you can start all the STEP 7functions and windows.
Downloading the programand monitoring thehardware
Opening, organizing, and printingprojects
Calling the STEP 7 online help
Setting the window display andarrangement, selecting thelanguage, and making settings forprocess data
Editing blocks and inserting programcomponents
The contents of the right-hand paneshow the objects and other foldersfor the folder selected on the left
The contents of the left-hand paneshow the project structure
The SIMATIC Manager
2-5STEP 7 Getting StartedA5E00069681-03
Calling the Help on STEP 7
F1 Option 1:
Place the cursor on any menucommand and press the F1 key. Thecontext-sensitive help for the selectedmenu command will appear.
Option 2:Use the menu to open the STEP 7online help.The contents page with various helptopics appears in the left-hand paneand the selected topic is displayed inthe right-hand pane.Navigate to the topic you want byclicking the + sign in the Contents list.At the same time, the contents of theselected topic are displayed in theright-hand pane.Using Index and Find, you can entersearch strings and look for the specifictopics you require.Option 3:Click the question mark button in thetoolbar to turn your mouse into a helpcursor. The next time you click on aspecific object, the online help isactivated.
Navigating in the Project Structure
The project you have just created isdisplayed with the selected S7 stationand CPU.
Click the + or – sign to open or close afolder.
You can start other functions later onby clicking the symbols displayed inthe right-hand pane.
The SIMATIC Manager
2-6STEP 7 Getting StartedA5E00069681-03
Click the S7 Program (1) folder. Thiscontains all the necessary programcomponents.
You will use the Symbols componentin Chapter 3 to give the addressessymbolic names.
The Source Files component is used tostore source file programs. These arenot dealt with in the Getting Startedmanual.
Click the Blocks folder. This containsthe OB1 you have already createdand, later on, all the other blocks.
From here, you will start programmingin Ladder Logic, Statement List, orFunction Block Diagram in Chapters 4and 5.
Click the SIMATIC 300 Station folder.All the hardware-related project dataare stored here.
You will use the Hardware componentin Chapter 6 to specify the parametersof your programmable controller.
If you require further SIMATIC software for your automation task; for example, the optionalpackages PLCSIM (hardware simulation program) or S7 Graph (graphic programminglanguage), these are also integrated in STEP 7. Using the SIMATIC Manager, for example,you can directly open the relevant objects such as an S7 Graph function block.
You can find more information under Help > Contents in thetopics "Working Out the Automation Concept" and "Basics ofDesigning the Program Structure."
You can find more information on optional packages in theSIMATIC catalog ST 70, "Components for CompletelyIntegrated Automation."
STEP 7 Getting StartedA5E00069681-03 3-1
3 Programming with Symbols
3.1 Absolute Addresses
Every input and output has an absolute address predefined by the hardwareconfiguration. This address is specified directly; that is, absolutely.
The absolute address can be replaced by any symbolic name you choose.
SF
BATF
DC 5V
FRCE
RUN
RUN PRUN
STOPM RES
STOP
ON
OFF
0
1
2
3
4
5
6
7
0
1
2
3
4
5
6
7
0
1
2
3
4
5
6
7
0
1
2
3
4
5
6
7
0
1
2
3
4
5
6
7
0
1
2
3
4
5
6
7
L+
L+
M M
M
N
L+ L+
M
Digital inputmoduleByte 1
Bits 0 to 7
Digital inputmoduleByte 0
Bits 0 to 7
Digital outputmoduleByte 4
Bits 0 to 7
Digital outputmoduleByte 5
Bits 0 to 7
Bit 5
Absolute address: I 1.5
Byte 1
You should only use absolute programming if you do nothave to address many inputs and outputs in your S7program.
Input
Programming with Symbols
3-2 STEP 7 Getting StartedA5E00069681-03
3.2 Symbolic Programming
In the symbol table, you assign a symbolic name and the data type to all theabsolute addresses which you will address later on in your program; for example,for input I 0.1 the symbolic name Key 1. These names apply to all parts of theprogram and are known as global variables.
Using symbolic programming, you can considerably improve the legibility of theS7 program you have created.
Working with the Symbol Editor
Navigate in the project window"Getting Started" until you reachS7 Program (1) and double-click toopen the Symbols component.
Your symbol table currently onlyconsists of the predefined organizationblock OB1.
Click Cycle Execution and overwrite itwith "Main Program" for our example.
Enter "Green Light" and "Q 4.0" inrow 2. The data type is addedautomatically.
Click in the comment column of row 1or 2 to enter a comment on thesymbol. You complete your entries in arow by pressing Enter, which thenadds a new row.
Enter "Red Light" and "Q 4.1" in row 3and press Enter to complete the entry.
In this way, you can assign symbolic names to allthe absolute addresses of the inputs and outputswhich your program requires.
Programming with Symbols
3-3STEP 7 Getting StartedA5E00069681-03
Save the entries or changes you havemade in the symbol table and close thewindow.
Because there are lots of names for the entire "Getting Started" project, you cancopy the symbol table to your "Getting Started" project in Section 4.1.
The data type which was previously added automatically to the symbol table determinesthe type of the signal to be processed for the CPU. STEP 7 uses, among others, thefollowing data types:
BOOLBYTEWORDDWORD
Data of this type are bit combinations. 1 bit (type BOOL) to 32 bits (DWORD).
CHAR Data of this type occupy exactly one character of the ASCII character set.INTDINTREAL
They are available for the processing of numerical values (for example, to calculatearithmetic expressions).
S5TIMETIMEDATETIME_OF_DAY
Data of this type represent the different time and date values within STEP 7 (forexample, to set the date or to enter the time value for a timer).
Here you can see the symboltable for the S7 program in the"Getting Started" example forStatement List.
Generally speaking, only onesymbol table is created perS7 program, regardless ofwhich programming languageyou have selected.
All printable characters (forexample, special characters,spaces) are permitted in thesymbol table.
You can find more information under Help >Contents in the topics “Programming Blocks“and "Defining Symbols".
STEP 7 Getting StartedA5E00069681-03 4-1
4 Creating a Program in OB1
4.1 Opening the LAD/STL/FBD Program Window
Choosing Ladder Logic, Statement List, or Function Block Diagram
With STEP 7, you create S7 programs in the standard languages Ladder Logic(LAD), Statement List (STL), or Function Block Diagram (FBD). In practice, and forthis chapter too, you must decide which language to use.
Ladder Logic (LAD)Suitable for users from the electrical engineering industry, for example.
Statement List (STL)Suitable for users from the world of computer technology, for example.
Function Block Diagram (FBD)Suitable for users from the world of circuit engineering, for example.
The block OB1 will now be opened according to the language you chosewhen you created it in the project Wizard. However, you can change thedefault programming language again at any time.
Creating a Program in OB1
4-2 STEP 7 Getting StartedA5E00069681-03
Copying the Symbol Table and Opening OB1
If necessary, open your "GettingStarted" project. To do this, click theOpen button in the toolbar, select the"Getting Started" project you created,and confirm with OK.
Depending on which programminglanguage you have decided to use,open one of the following projects aswell:
• ZEn01_05_STEP7__LAD_1-9
• ZEn01_01_STEP7__STL_1-9
or
• ZEn01_03_STEP7__FDB_1-9
Here you can see all three sampleprojects displayed.
Navigate in the „ZEn01_XXX“ until youreach the Symbols component andcopy this by dragging and dropping itto the S7 Program folder in yourproject window "Getting Started."
Then close the window „ZEn01_XXX“.
Double-click OB1 in the "GettingStarted" project. The LAD/STL/FBDprogram window is opened.
In STEP 7, OB1 is processed cyclically by the CPU. The CPU reads line by line andexecutes the program commands. When the CPU returns to the first program line, it hascompleted exactly one cycle. The time required for this is known as the scan cycle time.
Depending on which programming language you have selected, continue reading in eitherSection 4.2 for programming in Ladder Logic, Section 4.3 for Statement List, or Section 4.4for Function Block Diagram.
You can find more information under Help > Contentsin the topics “Programming Blocks“ and "CreatingBlocks and Libraries.“
Drag and drop means that you click any objectwith the mouse and move it whilst keeping themouse button depressed. When you release themouse button, the object is pasted at the selectedposition.
Creating a Program in OB1
4-3STEP 7 Getting StartedA5E00069681-03
The LAD/STL/FBD Program Window
All blocks are programmed in the LAD/STL/FBD program window. Here, you cansee the view for Ladder Logic.
Program Elements catalog,here for Ladder Logic
Help on the selectedprogram element
Program input line (also networkand current path)
Title and comment field forthe block or network
Toggling the ProgramElements catalog on and off
Inserting a newnetwork
Changing theprogramming languageview
The most important programelements for Ladder Logic andFunction Block Diagram
Moving the table split(toggling the view of thetable on and off)
The variable declaration table containsthe parameters and local variables forthe block
Information on the selectedprogram element
Creating a Program in OB1
4-4 STEP 7 Getting StartedA5E00069681-03
4.2 Programming OB1 in Ladder Logic
In the following section, you will program a series circuit, a parallel circuit, and theset / reset memory function in Ladder Logic (LAD).
Programming a Series Circuit in Ladder Logic
If necessary, set LAD as theprogramming language in the Viewmenu.
Click in the title area of OB1 and enter"Cyclically processed main program,"for example.
Select the current path for your firstelement.
Click the button in the toolbar andinsert a normally open contact.
In the same way, insert a secondnormally open contact.
Insert a coil at the right-hand end ofthe current path.
The addresses of the normally opencontacts and the coil are still missing inthe series circuit.
Check whether symbolicrepresentation is activated.
Creating a Program in OB1
4-5STEP 7 Getting StartedA5E00069681-03
Click the ??.? sign and enter thesymbolic name "Key_1" (in quotationmarks).Confirm with Enter.
Enter the symbolic name "Key_2" forthe second normally open contact.
Enter the name "Green_Light" for thecoil.
You have now programmed acomplete series circuit.
Save the block if there are no moresymbols shown in red.
Symbols are indicated in red if, for example, they do not exist in the symbol table, or ifthere is a syntax error.
You can also insert the symbolic name directly from the symbol table. Click the ??.?sign and then the menu command Insert > Symbol. Scroll through the pull-down listuntil you reach the corresponding name and select it. The symbolic name is addedautomatically.
Creating a Program in OB1
4-6 STEP 7 Getting StartedA5E00069681-03
Programming a Parallel Circuit in Ladder Logic
Select Network 1.
Insert a new network.
Select the current path again.
Insert a normally open contact and acoil.
Select the vertical line of the currentpath.
Insert a parallel branch.
Add another normally open contact inthe parallel branch.
Close the branch (if necessary, selectthe lower arrow).
The addresses are still missing in theparallel circuit.
To assign symbolic addresses,proceed in the same way as for theseries circuit.
Overwrite the upper normally opencontact with "Key_3," the lower contactwith "Key_4," and the coil with"Red_Light."
Save the block.
Creating a Program in OB1
4-7STEP 7 Getting StartedA5E00069681-03
Programming a Memory Function in Ladder Logic
Select Network 2 and insert anothernetwork.
Select the current path again.
Navigate in the Program Elementscatalog under Bit Logic until youreach the SR element. Double-click toinsert the element.
Insert a normally open contact in frontof each of the inputs S and R.
Enter the following symbolic names forthe SR element:Upper contact "Automatic_On"Lower contact "Manual_On"SR element "Automatic_Mode"
Save the block and close the window.
If you want to see the difference between absolute and symbolic addressing, deactivate themenu command View > Display > Symbolic Representation.
You can change the line break for symbolic addressing in the LAD/STL/FBD programwindow by using the menu command Options > Customize and then selecting "Width ofaddress field" in the "LAD/FBD" tab. Here you can set the line break between 10 and 24characters.
Example:Symbolic addressing in LAD
Example:Absolute addressing in LAD
You can find more information under Help >Contents in the topics "Programming Blocks,""Creating Logic Blocks," and "Editing LadderInstructions."
Creating a Program in OB1
4-8 STEP 7 Getting StartedA5E00069681-03
4.3 Programming OB1 in Statement List
In the following section, you will program an AND instruction, an OR instruction,and the memory instruction set/reset in Statement List (STL).
Programming an AND Instruction in Statement List
If necessary, set STL as theprogramming language in the Viewmenu.
Check whether symbolicrepresentation is activated.
Click in the title area of OB1 and enter"Cyclically processed main program,"for example.
Select the area for your first statement.
Type an A (AND) in the first programline, a space, and then the symbolicname "Key_1" (in quotation marks).
Complete the line with Enter. Thecursor jumps to the next line.
Creating a Program in OB1
4-9STEP 7 Getting StartedA5E00069681-03
In the same way, complete the ANDinstruction as shown.
You have now programmed acomplete AND instruction. Save theblock if there are no more symbolsshown in red.
Programming an OR Instruction in Statement List
Select Network 1.
Insert a new network and select theinput area again.
Enter an O (OR) and the symbolicname "Key_3" (in the same way as forthe AND instruction).
Complete the OR instruction and saveit.
Symbols are indicated in red if, for example, they do not exist in the symbol table, orif there is a syntax error.
You can also insert the symbolic name directly from the symbol table. Click the ??.?sign and then the menu command Insert > Symbol. Scroll through the pull-down listuntil you reach the corresponding name and select it. The symbolic name is addedautomatically.
Creating a Program in OB1
4-10 STEP 7 Getting StartedA5E00069681-03
Programming a Memory Instruction in Statement List
Select Network 2 and insert anothernetwork.
In the first line, type the instruction Awith the symbolic name"Automatic_On."
Complete the memory instruction andsave it. Close the block.
If you want to see the difference between absolute and symbolic addressing, deactivate themenu command View > Display > Symbolic Representation.
Example:Symbolic addressing in STL
Example:Absolute addressing in STL
You can find more information under Help >Contents in the topics "Programming Blocks,""Creating Logic Blocks," and "Editing STLStatements."
Creating a Program in OB1
4-11STEP 7 Getting StartedA5E00069681-03
4.4 Programming OB1 in Function Block Diagram
In the following section, you will program an AND function, an OR function, and amemory function in Function Block Diagram (FBD).
Programming an AND Function in Function Block Diagram
If necessary, set FBD as theprogramming language in the Viewmenu.
Click in the title area of OB1 and enter"Cyclically processed main program,"for example.
Select the input area for the ANDfunction (below the comment field).
Insert an AND box (&) and anassignment (=).
The addresses of the elements are stillmissing in the AND function.
Check whether symbolicrepresentation is activated.
Creating a Program in OB1
4-12 STEP 7 Getting StartedA5E00069681-03
Click on the ??.? sign and enter thesymbolic name "Key_1" (in quotationmarks). Confirm with Enter.
Enter the symbolic name "Key_2" forthe second input.
Enter the name "Green_Light" for theassignment.
You have now programmed acomplete AND function.
If there are no more symbols shown inred, you can save the block.
Symbols are indicated in red if, for example, they do not exist in the symbol table, orif there is a syntax error.
You can also insert the symbolic name directly from the symbol table. Click the ??.?sign and then the menu command Insert > Symbol. Scroll through the pull-down listuntil you reach the corresponding name and select it. The symbolic name is addedautomatically.
Creating a Program in OB1
4-13STEP 7 Getting StartedA5E00069681-03
Programming an OR Function in Function Block Diagram
Insert a new network.
Select the input area again for the ORfunction.
Insert an OR box (≥1) and anassignment (=).
The addresses are still missing in theOR function. Proceed in the same wayas for the AND function.
Enter "Key_3" for the upper input,"Key_4" for the lower input, and"Red_Light" for the assignment.
Save the block.
Creating a Program in OB1
4-14 STEP 7 Getting StartedA5E00069681-03
Programming a Memory Function in Function Block Diagram
Select Network 2 and insert anothernetwork. Select the input area again(below the comment field).
Navigate in the Program Elementscatalog under Bit Logic until youreach the SR element. Double-click toinsert the element.
"Automatic Mode"
"Automatic on"
"Manual on"
Enter the following symbolic names forthe SR element:Set "Automatic_On"Reset "Manual_On"Memory bit "Automatic_Mode"
Save the block and close the window.
If you want to see the difference between absolute and symbolic addressing, deactivate themenu command View > Display > Symbolic Representation.
You can change the line break for symbolic addressing in the LAD/STL/FBD programwindow by using the menu command Options > Customize and then selecting "AddressField Width" in the "LAD/FBD" tab. Here you can set the line break between 10 and 24h
Example:Symbolic addressing in FBD
Example:Absolute addressing in FBD
"Green_Light"
"Key_2"
"Key_1"
You can find more information under Help >Contents in the topics "Programming Blocks,""Creating Logic Blocks," and "Editing FBDStatements."
5-1STEP 7 Getting StartedA5E00069681-03
5 Creating a Program with Function Blocksand Data Blocks
5.1 Creating and Opening Function Blocks (FB)
The function block (FB) is below the organization block in the program hierarchy. Itcontains a part of the program which can be called many times in OB1. All theformal parameters and static data of the function block are saved in a separatedata block (DB), which is assigned to the function block.
You will program the function block (FB1, symbolic name "Engine"; see symboltable, page 3-3) in the LAD/STL/FBD program window, which you are now familiarwith. To do this, you should use the same programming language as in Chapter 4(programming OB1).
You should have already copied thesymbol table into your project "GettingStarted." If not, read how to do this onpage 4-2, copying the symbol table,and then return to this section.
If necessary, open the "GettingStarted" project.
Navigate to the Blocks folder andopen it.
Click in the right-hand half of thewindow with the right mouse button.
The pop-up menu for the right mousebutton contains the most importantcommands from the menu bar. Insert afunction block as a new object.
Creating a Program with Function Blocks and Data Blocks
5-2 STEP 7 Getting StartedA5E00069681-03
Double-click FB1 to open theLAD/STL/FBD program window.
In the "Properties – Function Block"dialog box, select the language inwhich you want to create the block,activate the check box "Multipleinstance FB," and confirm theremaining settings with OK.
The function block FB1 has beeninserted in the Blocks folder.
Depending on which programming language you have selected, continue reading in eitherSection 5.2 for Ladder Logic, Section 5.3 for Statement List, or Section 5.4 for FunctionBlock Diagram.
You can find more information under Help >Contents in the topics "Programming Blocks" and"Creating Blocks and Libraries."
Creating a Program with Function Blocks and Data Blocks
5-3STEP 7 Getting StartedA5E00069681-03
5.2 Programming FB1 in Ladder Logic
We will now show you how to program a function block which can, for example,control and monitor a petrol or diesel engine using two different data blocks.
All "engine-specific" signals are passed on as block parameters from theorganization block to the function block and must therefore be listed in the variabledeclaration table as input and output parameters (declaration "in" and "out").
You should already know how to enter a series circuit, a parallel circuit, and amemory function with STEP 7.
1. Filling out the Variable Declaration Table
Your LAD/STL/FBD program window isopen and the option View > LAD(programming language) is activated.
Note that FB1 is now in the header,because you double-clicked FB1 toopen the program window.
Enter the following declarations in the variable declaration table.
To do this, click a cell and use the corresponding name and the comment from theillustration below.
You can select the type with the pop-up menu command Elementary Types usingthe right mouse button. When you press Enter, the cursor jumps to the nextcolumn, or a new row is inserted.
Only letters, numbers, and the underscore are permittedcharacters for the names of the block parameters in thevariable declaration table.
Creating a Program with Function Blocks and Data Blocks
5-4 STEP 7 Getting StartedA5E00069681-03
2. Programming an Engine to Switch On and Off
Insert a normally open contact, anormally closed contact, and an SRelement in series in Network 1 usingthe corresponding buttons in thetoolbar or the Program Elementscatalog.
Then select the current pathimmediately before the input R.
Insert another normally open contact.Select the current path immediatelybefore this contact.
Insert a normally closed contactparallel to the normally open contact.
Check whether symbolicrepresentation is activated.
Select the question marks and enter the corresponding names from the variabledeclaration table (the # sign is assigned automatically).
Enter the symbolic name "Automatic_Mode" for the normally closed contact in theseries circuit.
Then save your program.
Local block variables are indicated with a # sign and are only valid in theblock.
Global variables appear in quotation marks. These are defined in thesymbol table and are valid for the entire program.
The signal state "Automatic_Mode" is defined in OB1 (Network 3; see page4-7) by another SR element and now queried in FB1.
Creating a Program with Function Blocks and Data Blocks
5-5STEP 7 Getting StartedA5E00069681-03
3. Programming Speed Monitoring
Insert a new network and select thecurrent path.
Then navigate in the ProgramElements catalog until you reach theCompare function and insert aCMP>=I.
Also insert a coil in the current path.
Select the question marks again and label the coil and the comparator with thenames from the variable declaration table.
Then save your program.
When is the engine switched on and off?When the variable #Switch_On has signal state "1" and the variable "Automatic_Mode" hassignal state "0," the engine is switched on. This function is not enabled until"Automatic_Mode" is negated (normally closed contact).
When the variable #Switch_Off has signal state "1" or the variable #Fault has signal state"0," the engine is switched off. This function is achieved again by negating #Fault (#Fault isa "zero-active" signal and has the signal "1" in the normal state and "0" if a fault occurs).
How does the comparator monitor the engine speed?The comparator compares the variables #Actual_Speed and #Setpoint_Speed and assignsthe result of the variables to #Setpoint_Speed_Reached (signal state "1").
You can find more information under Help >Contents in the topics "Programming Blocks,""Creating Logic Blocks," and "Editing the VariableDeclaration Table" or in "Editing LAD Instructions."
Creating a Program with Function Blocks and Data Blocks
5-6 STEP 7 Getting StartedA5E00069681-03
5.3 Programming FB1 in Statement List
We will now show you how to program a function block which can, for example,control and monitor a petrol or diesel engine using two different data blocks.
All "engine-specific" signals are passed on as block parameters from theorganization block to the function block and must therefore be listed in the variabledeclaration table as input and output parameters (declaration "in" and "out").
You should already know how to enter an AND instruction, an OR instruction, andthe set/reset memory instructions with STEP 7.
1. Filling out the Variable Declaration Table
Your LAD/STL/FBD program window isopen and the option View > STL(programming language) is activated.
Note that FB1 is now in the header,because you double-clicked FB1 toopen the program window.
Enter the following declarations in the variable declaration table.
To do this, click a cell and use the corresponding name and the comment from theillustration below.
You can select the type with the pop-up menu command Elementary Types usingthe right mouse button. When you press Enter, the cursor jumps to the nextcolumn, or a new row is inserted.
Only letters, numbers, and the underscore are permittedcharacters for the names of the block parameters in thevariable declaration table.
Creating a Program with Function Blocks and Data Blocks
5-7STEP 7 Getting StartedA5E00069681-03
2. Programming an Engine to Switch On and Off
Check whether symbolicrepresentation is activated.
Enter the corresponding instructions inNetwork 1.
3. Programming Speed Monitoring
Insert a new network and enter thecorresponding instructions. Then saveyour program.
Local block variables are indicated with a # sign andare only valid in the block.
Global variables appear in quotation marks. Theseare defined in the symbol table and are valid for theentire program.
The signal state "Automatic_Mode" is defined inOB1 (Network 3; see page 4-10) by another SRelement and now queried in FB1.
When is the engine switched on and off?When the variable #Switch_On has signal state "1" and the variable "Automatic_Mode" hassignal state "0," the engine is switched on. This function is not enabled until"Automatic_Mode" is negated (normally closed contact).
When the variable #Switch_Off has signal state "1" or the variable #Fault has signal state"0," the engine is switched off. This function is achieved again by negating #Fault (#Fault isa "zero-active" signal and has the signal "1" in the normal state and "0" if a fault occurs).
How does the comparator monitor the engine speed?The comparator compares the variables #Actual_Speed and #Setpoint_Speed and assignsthe result of the variables to #Setpoint_Speed_Reached (signal state "1").
You can find more information under Help >Contents in the topics "Programming Blocks,""Creating Logic Blocks," and "Editing the VariableDeclaration Table" or in "Editing STL Statements."
Creating a Program with Function Blocks and Data Blocks
5-8 STEP 7 Getting StartedA5E00069681-03
5.4 Programming FB1 in Function Block Diagram
We will now show you how to program a function block which can, for example,control and monitor a petrol or diesel engine using two different data blocks.
All "engine-specific" signals are passed on as block parameters from theorganization block to the function block and must therefore be listed in the variabledeclaration table as input and output parameters (declaration "in" and "out").
You should already know how to enter an AND function, an OR function, and amemory function with STEP 7.
1. Filling out the Variable Declaration Table
Your LAD/STL/FBD program window isopen and the option View > FBD(programming language) is activated.
Note that FB1 is now in the header,because you double-clicked FB1 toopen the program window.
Enter the following declarations in the variable declaration table.
To do this, click a cell and use the corresponding name and the comment from theillustration below.
You can select the type with the pop-up menu command Elementary Types usingthe right mouse button. When you press Enter, the cursor jumps to the nextcolumn, or a new row is inserted.
Only letters, numbers, and the underscore arepermitted characters for the names of the blockparameters in the variable declaration table.
Creating a Program with Function Blocks and Data Blocks
5-9STEP 7 Getting StartedA5E00069681-03
2. Programming an Engine to Switch On and Off
Insert an SR function in Network 1using the Program Elements catalog(Bit Logic folder).
Add an AND box at input S (Set), andan OR box at input R (Reset).
Check whether symbolicrepresentation is activated.
Click the ??.? sign and enter the corresponding names from the declaration table(the # sign is assigned automatically).
Make sure that one input of the AND function is addressed with the symbolicname "Automatic_Mode."
Negate the inputs "Automatic_Mode" and #Fault with the corresponding buttonfrom the toolbar.
Then save your program.
Local block variables are indicated with a # sign and are onlyvalid in the block.
Global variables appear in quotation marks. These aredefined in the symbol table and are valid for the entireprogram.
The signal state "Automatic_Mode" is defined in OB1(Network 3; see page 4-14) by another SR element and nowqueried in FB1.
Creating a Program with Function Blocks and Data Blocks
5-10 STEP 7 Getting StartedA5E00069681-03
3. Programming Speed Monitoring
Insert a new network and select theinput area.
Then navigate in the ProgramElements catalog under you reach theCompare function, and insert aCMP>=I.
Append an output assignment to the comparator and address the inputs with thenames from the variable declaration table.
Then save your program.
When is the engine switched on and off?When the variable #Switch_On has signal state "1" and the variable "Automatic_Mode" hassignal state "0," the engine is switched on. This function is not enabled until"Automatic_Mode" is negated (normally closed contact).
When the variable #Switch_Off has signal state "1" or the variable #Fault has signal state"0," the engine is switched off. This function is achieved again by negating #Fault (#Fault isa "zero-active" signal and has the signal "1" in the normal state and "0" if a fault occurs).
How does the comparator monitor the engine speed?The comparator compares the variables #Actual_Speed and #Setpoint_Speed and assignsthe result of the variables to #Setpoint_Speed_Reached (signal state "1").
You can find more information under Help >Contents in the topics "Programming Blocks,""Creating Logic Blocks," and "Editing the VariableDeclaration Table" or in "Editing FBD Instructions."
Creating a Program with Function Blocks and Data Blocks
5-11STEP 7 Getting StartedA5E00069681-03
5.5 Generating Instance Data Blocks and Changing ActualValues
You have just programmed the function block FB1 ("Engine") and defined, amongother things, the engine-specific parameters in the variable declaration table.
In order for you to be able to program the call for the function block in OB1 lateron, you must generate the corresponding data block. An instance data block (DB)is always assigned to a function block.
The function block is to control and monitor a petrol or diesel engine. The differentsetpoint speeds of the engines are stored in two separate data blocks, in whichthe actual value (#Setpoint_Speed) is changed.
By centrally programming the function block only once, you can cut down on theamount of programming involved.
The "Getting Started" project is open inthe SIMATIC Manager.
Navigate to the Blocks folder and clickin the right half of the window with theright mouse button.
Insert a data block using the pop-upmenu with the right mouse button.
Accept all the settings displayed in the"Properties" dialog box with OK.
The data block DB1 is added to the"Getting Started" project.
Double-click to open DB1.
Creating a Program with Function Blocks and Data Blocks
5-12 STEP 7 Getting StartedA5E00069681-03
Activate the option Data blockreferencing a function block in the"New Data Block" dialog box.
Confirm the assignment "FB1, Engine“with OK.
The LAD/STL/FBD program windowopens with the data from the variabledeclaration table for FB1.
DB1 is now to contain the data specificto a petrol engine. You still have toenter these data. First set the DataView.
Next enter the value "1500" for thepetrol engine in the Actual Valuecolumn (in the row "Setpoint_Speed).You have now defined the maximumspeed for this engine.
Save DB1 and close the programwindow.
In the same way as for DB1, generateanother data block, DB2, for FB1.
Now enter the actual value "1200" forthe diesel engine.
By changing the actual values, you have finished your preparations for controlling twoengines with just one function block. To control more engines, all you have to do is generateadditional data blocks.
The next thing you have to do is program the call for the function block in OB1. To do this,continue reading in Section 5.6 for Ladder Logic, Section 5.7 for Statement List, orSection 5.8 for Function Block Diagram, depending on the programming language you areusing.
You can find more information under Help > Contentsin the topics "Programming Blocks" and "CreatingData Blocks."
Creating a Program with Function Blocks and Data Blocks
5-13STEP 7 Getting StartedA5E00069681-03
5.6 Programming a Block Call in Ladder Logic
All the work you have done programming a function block is of no use unless youcall this block in OB1. A data block is used for each function block call, and in thisway, you can control both engines.
The SIMATIC Manager is open withyour "Getting Started" project.
Navigate to the Blocks folder andopen OB1.
Insert Network 4 in the LAD/STL/FBDprogram window. Then navigate in theProgram Elements catalog until youreach FB1 and insert this block.
Insert a normally open contact in frontof each of the following: Switch_On,Switch_Off, and Fault.
Click the ??? sign above "Engine" andthen, keeping the cursor in the sameposition, click in the input frame withthe right mouse button.
Select Insert Symbol in the pop-upmenu using the right mouse button. Apull-down list will appear. The first timeyou do this, the procedure may takesome time.
OB1
Call
DB1Petrol Engine
Data
DB2Diesel Engine
Data
FB1"Engine"
Creating a Program with Function Blocks and Data Blocks
5-14 STEP 7 Getting StartedA5E00069681-03
Click the data block Petrol. This blockis then entered automatically in theinput frame in quotation marks.
Click the question marks and address all the other parameters of the functionblock using the corresponding symbolic names in the pull-down list.
The engine-specific inputand output variables(declaration "in" and "out")are displayed in the FB"Engine."
A signal "PE_xxx" isassigned to each of thevariables for the petrolengine.
Creating a Program with Function Blocks and Data Blocks
5-15STEP 7 Getting StartedA5E00069681-03
Program the call for the function block "Engine" (FB1) with the data block "Diesel"(DB2) in a new network and use the corresponding addresses from the pull-downlist.
Save your program and close theblock.
A signal "DE_xxx" isassigned to each of thevariables for the dieselengine.
When you create program structures with organization blocks, function blocks, and datablocks, you must program the call for subordinate blocks (such as FB1) in the block abovethem in the hierarchy (for example, OB1). The procedure is always the same.
You can also give the various blocks symbolic names in the symbol table (for example,FB1 has the name "Engine" and DB1 the name "Petrol").
You can archive or print out the programmed blocks at any time. The correspondingfunctions can be found in the SIMATIC Manager under the menu commands File >Archive or File > Print.
You can find more information under Help > Contentsin the topics "Calling Reference Helps," "LanguageDescription: LAD," and "Program Control Instructions."
Creating a Program with Function Blocks and Data Blocks
5-16 STEP 7 Getting StartedA5E00069681-03
5.7 Programming a Block Call in Statement List
All the work you have done programming a function block is of no use unless youcall this block in OB1. A data block is used for each function block call, and in thisway, you can control both engines.
The SIMATIC Manager is open withyour "Getting Started" project.
Navigate to the Blocks folder andopen OB1.
Insert Network 4 in the LAD/STL/FBDprogram window.
Type CALL "Engine", "Petrol" in thecode section and then press Enter.
All the parameters of the function block"Petrol" are displayed.
Position the cursor after the equalssign of Switch_On and press the rightmouse button.
Select Insert Symbol in the pop-upmenu using the right mouse button. Apull-down list will appear. The first timeyou do this, the procedure may takesome time.
OB1
Call
DB1Petrol Engine
Data
DB2Diesel Engine
Data
FB1"Engine"
Creating a Program with Function Blocks and Data Blocks
5-17STEP 7 Getting StartedA5E00069681-03
Click the name Switch_On_PE. Thisis taken from the pull-down list andadded automatically in quotationmarks.
Assign all the required addresses tothe variables of the function blockusing the pull-down list.
Program the call for the function block"Engine" (FB1) with the data block"Diesel" (DB2) in a new network.Proceed in the same way as for theother call.
Save your program and close theblock.
A signal "PE_xxx" is assignedto each of the variables forthe petrol engine.
When you create program structures with organization blocks, function blocks, and datablocks, you must program the call for subordinate blocks (such as FB1) in the block abovethem in the hierarchy (for example, OB1). The procedure is always the same.
You can also give the various blocks symbolic names in the symbol table (for example, FB1has the name "Engine" and DB1 the name "Petrol").
You can archive or print out the programmed blocks at any time. The correspondingfunctions can be found in the SIMATIC Manager under the menu commands File >Archive or File > Print.
You can find more information under Help > Contentsin the topics "Calling Reference Helps," "LanguageDescription: STL," and "Program Control Instructions."
Creating a Program with Function Blocks and Data Blocks
5-18 STEP 7 Getting StartedA5E00069681-03
5.8 Programming a Block Call in Function Block Diagram
All the work you have done programming a function block is of no use unless youcall this block in OB1. A data block is used for each function block call, and in thisway, you can control both engines.
The SIMATIC Manager is open withyour "Getting Started" project.
Navigate to the Blocks folder andopen OB1.
Insert Network 4 in the LAD/STL/FBDprogram window. The navigate in theProgram Elements catalog until youreach FB1 and insert this block.
All the engine-specific input and outputvariables are displayed.
Click the ??? sign above "Engine" andthen, keeping the cursor in the sameposition, click in the input frame withthe right mouse button.
Select Insert Symbol in the pop-upmenu using the right mouse button. Apull-down list will appear. The first timeyou do this, the procedure may takesome time.
OB1
Call
DB1Petrol Engine
Data
DB2Diesel Engine
Data
FB1"Engine"
Creating a Program with Function Blocks and Data Blocks
5-19STEP 7 Getting StartedA5E00069681-03
Click the data block Petrol. It is takenfrom the pull-down list and enteredautomatically in the input frame inquotation marks.
Address all the other parameters of the function block using the correspondingsymbolic names in the pull-down list.
A signal "PE_xxx" is assignedto each of the variables for thepetrol engine.
Creating a Program with Function Blocks and Data Blocks
5-20 STEP 7 Getting StartedA5E00069681-03
Program the call for the function block "Engine" (FB1) with the data block "Diesel"(DB2) in a new network and use the corresponding addresses from the pull-downlist.
Save your program and close theblock.
When you create program structures with organization blocks, function blocks, and datablocks, you must program the call for subordinate blocks (such as FB1) in the block abovethem in the hierarchy (for example, OB1). The procedure is always the same.
You can also give the various blocks symbolic names in the symbol table (for example, FB1has the name "Engine" and DB1 the name "Petrol").
You can archive or print out the programmed blocks at any time. The correspondingfunctions can be found in the SIMATIC Manager under the menu commands File > Archiveor File > Print.
A signal "DE_xxx" is assigned toeach of the variables for thediesel engine.
You can find more information under Help > Contentsin the topics "Calling Reference Helps," "LanguageDescription: FBD," and "Program Control Instructions."
STEP 7 Getting StartedA5E00069681-03 6-1
6 Configuring the Central Rack
6.1 Configuring Hardware
You can configure the hardware once you have created a project with a SIMATICstation. The project structure which was created with the STEP 7 Wizard inSection 2.1 meets all the requirements for this.
The hardware is configured with STEP 7. These configuration data are transferredto the programmable controller later on "downloading" (see Chapter 7).
The starting point is the open SIMATICManager together with the "GettingStarted" project.
Open the SIMATIC 300 Station folderand double-click the Hardwaresymbol.
The "HW Config“ window opens. The CPU you selected on creating the project isdisplayed. For the "Getting Started" project, this is CPU 314.
Rack with individual slots
Configuration table withthe MPI and I/Oaddresses
HardwareCatalog
Help on the selected element
Short information on theselected element
Configuring the Central Rack
6-2 STEP 7 Getting StartedA5E00069681-03
First you require a power supplymodule. Navigate in the catalog untilyou reach the PS307 2A and drag anddrop this onto slot 1.
Navigate until you find the inputmodule (DI, Digital Input) SM321DI32xDC24V and insert this in slot 4.Slot 3 remains empty.
In the same way, insert the outputmodule SM322 DO32xDC24V/0.5A inslot 5.
In order to change the parameters (for example, address) of a module within aproject, double-click the module. However, you should only change theparameters if you are sure you know what effects the changes will have on yourprogrammable controller.
No changes are necessary for the "Getting Started" project.
The data are prepared for transfer tothe CPU using the menu commandSave and Compile.
Once you close the "HW Config"application, the System Data symbolwill appear in the Blocks folder.
You can also check your configuration for errors using the menu command Station >Consistency Check. STEP 7 will provide you with possible solutions to any errors whichmay have occurred.
You can find more information under Help > Contents inthe topics "Configuring theHardware" and "ConfiguringCentral Racks."
STEP 7 Getting StartedA5E00069681-03 7-1
7 Downloading and Debugging the Program
7.1 Establishing an Online Connection
Using the supplied project "GS-LAD_Example" or the "Getting Started" project youhave created and a simple test configuration, we will show you how to downloadthe program to the programmable logic controller (PLC) and then debug it.
You should have:
• Configured the hardware for the "Getting Started" project (see Chapter 6)
• Set up the hardware according to the installation manual
Example of a series circuit (AND function):Output Q 4.0 is not to light up (diode Q 4.0 lights up on the digital output module)unless both Key I 0.1 and Key I 0.2 are pressed. Set up the test configurationbelow using wires and your CPU.
Programmingdevice withSTEP 7software
Operating modekeyswitch
RackPower supply(on / off)
Programming devicecable
I 0.1
I 0.2
Q 4.0
Connection bridge
Downloading and Debugging the Program
7-2 STEP 7 Getting StartedA5E00069681-03
Configuring the Hardware
To assemble a module on the rail, proceed in the order given below:
• Attach the module onto the bus connector
• Hang the module on the rail and swing it downwards
• Screw the module in place
• Assemble the remaining modules
• Insert the key in the CPU once you have finished assembling all the modules.
You can still carry out the test even if you are using different hardware to that shown in thediagram. You simply have to keep to the addressing of the inputs and outputs.STEP 7 offers you various ways of debugging your program; for example, using theprogram status or by means of the variable table.
You can find more information on configuring thecentral rack in the manuals "S7-300, Hardware andInstallation / Module Specifications" and "S7-400 /M7-400 – Hardware."
Downloading and Debugging the Program
7-3STEP 7 Getting StartedA5E00069681-03
7.2 Downloading the Program to the Programmable Controller
You must have already established an online connextion in order tp download theprogram...................................................................................................................
Switch on the power supply using theON/OFF switch. The diode "DC 5V"will light up on the CPU.
Turn the operating mode switch to theSTOP position (if not already inSTOP). The red "STOP" LED will lightup.
Resetting the CPU and Switching it to RUN
Turn the operating mode switch to theMRES position and hold it there for atleast 3 seconds until the red "STOP"LED starts flashing slowly.
Release the switch and, after amaximum of 3 seconds, turn it to theMRES position again. When the"STOP" LED flashes quickly, the CPUhas been reset.
If the "STOP" LED does not startflashing quickly, repeat the procedure.
Downloading the Program to the CPU
Now turn the operating mode switch to"STOP" again to download theprogram.
A memory reset deletesall the data on the CPU.The CPU is then in theinitial state.
Downloading and Debugging the Program
7-4 STEP 7 Getting StartedA5E00069681-03
Start the SIMATIC Manager and openthe "Getting Started" project in the"Open" dialog box (if it is not alreadyopen).
In addition to the "Getting StartedOffline" window, open the "GettingStarted ONLINE" window. The onlineor offline status is indicated by thedifferent colored headers.
Navigate in both windows to theBlocks folder.
The offline window shows the situationon the programming device; the onlinewindow shows the situation on theCPU.
Select the Blocks folder in the offlinewindow and then download theprogram to the CPU using the menucommand PLC > Download.Confirm the prompt with OK.
The program blocks are displayed inthe online window when you downloadthem.
The system functions (SFCs) remain inthe CPU even though you have carriedout a memory reset. The CPU providesthese functions of the operating system.They do not have to be downloaded, butthey cannot be deleted.
You can also call the menu commandPLC > Download using thecorresponding button in the toolbar orfrom the pop-up menu using the rightmouse button.
Downloading and Debugging the Program
7-5STEP 7 Getting StartedA5E00069681-03
Switching on the CPU and Checking the Operating Mode
Turn the operating mode switch toRUN-P. The green "RUN" LED lightsup and the red "STOP" LED goes out.The CPU is ready for operation.
When the green LED lights up, youcan start testing the program.
If the red LED remains lit, an error hasoccurred. You would then have toevaluate the diagnostic buffer in orderto diagnose the error.
Downloading individual blocks
In order to react to errors quickly in practice, blocks can be transferred individually to theCPU using the drag and drop function.When you download blocks, the operating mode switch on the CPU must be in either"RUN-P" or "STOP" mode. Blocks downloaded in "RUN-P" mode are activated immediately.You should therefore remember the following:• If error-free blocks are overwritten with faulty blocks, this will lead to a plant failure. You
can avoid this by testing your blocks before you download them.• If you do not observe the order in which blocks are to be downloaded – first the
subordinate blocks and then the higher-level blocks – the CPU will go into "STOP"mode. You can avoid this by downloading the entire program to the CPU.
Programming online
In practice, you may need to change the blocks already downloaded to the CPU for testpurposes. To do this, double-click the required block in the online window to open theLAD/STL/FBD program window. Then program the block as usual. Note that theprogrammed block immediately becomes active in your CPU.
You can find more information under Help >Contents in the topics "Establishing an OnlineConnection and Making CPU Settings" and"Downloading from the PG / PC to theProgrammable Controller."
Downloading and Debugging the Program
7-6 STEP 7 Getting StartedA5E00069681-03
7.3 Testing the Program with Program Status
Using the program status function, you can test the program in a block. Therequirement for this is that you have established an online connection to the CPU,the CPU is in RUN or RUN-P mode, and the program has been downloaded.
Open OB1 in the project window"Getting Started ONLINE."
The LAD/STL/FBD program window isopened.
Activate the function Debug >Monitor.
Debugging with Ladder Logic
The series circuit in Network 1 isdisplayed in Ladder Logic. The currentpath is represented as a full line up toKey 1 (I 0.1); this means that power isalready being applied to the circuit.
Debugging with Function Block Diagram
The signal state is indicated by "0" and"1." The dotted line means that there isno result of logic operation.
Debugging with Statement List
For Statement List the following isdisplayed in tabular form:– Result of logic operation (RLO)– Status bit (STA)– Standard status (STANDARD)
Using Options > Customizeyou can change the way inwhich the programminglanguage is represented duringtesting.
Downloading and Debugging the Program
7-7STEP 7 Getting StartedA5E00069681-03
Now press both keys in your testconfiguration.
The diodes for input I 0.1 and I 0.2 lightup on the input module.
The diode for output Q 4.0 lights up onthe output module.
In the graphic programming languagesLadder Logic and Function BlockDiagram, you can trace the test resultby following the change in color in theprogrammed network. This colorchange shows that the result of logicoperation is fulfilled up to this point.
With the Statement List programminglanguage, the display in the STA andRLO columns changes when the resultof logic operation is fulfilled.
Deactivate the function Debug >Monitor and close the window.
Then close the online window in theSIMATIC Manager.
We recommend you do not completely download extensive programs onto the CPU to runthem, because diagnosing errors is more difficult due to the number of possible sources ofan error. Instead, you should download blocks individually and then test them in order toobtain a better overview.
You can find more information under Help > Contentsin the topics "Debugging" and "Testing with ProgramStatus."
I 0.1
I 0.2
Downloading and Debugging the Program
7-8 STEP 7 Getting StartedA5E00069681-03
7.4 Testing the Program with the Variable Table
You can test individual program variables by monitoring and modifying them. Therequirement for this is that you have established an online connection to the CPU,the CPU is in RUN-P mode, and the program has been downloaded.
As with testing with program status, you can monitor the inputs and outputs inNetwork 1 (series circuit or AND function) in the variable table. You can also testthe comparator for the engine speed in FB1 by presetting the actual speed.
Creating the Variable Table
The starting point is the SIMATICManager again with the open projectwindow "Getting Started Offline."
Navigate to the Blocks folder and clickin the right half of the window with theright mouse button.
Use the right mouse button to insert aVariable Table from the pop-up menu.
Accept the default settings by closingthe "Properties" dialog box with OK.
A VAT1 (variable table) is created inthe Blocks folder.
Double-click to open VAT1; the"Monitoring and Modifying Variables"window will open.
Downloading and Debugging the Program
7-9STEP 7 Getting StartedA5E00069681-03
At first, the variable table is empty. Enter the symbolic names or the addresses forthe "Getting Started" example according to the illustration below. The remainingdetails will be added when you complete your entry with Enter.
Change the status format of all the speed values to DEC (decimal) format. To dothis, click the corresponding cell in the header (the cursor will change to an arrowover the Status Format column) and select DEC format using the right mousebutton.
Save your variable table.
Switching the Variable Table Online
Click the ON button in the toolbar ofthe "Monitoring and ModifyingVariables" window to establish aconnection to the configured CPU. Theword "ONLINE" will appear in thestatus bar.
Set the keyswitch of the CPU toRUN-P (if you have not already doneso).
Downloading and Debugging the Program
7-10 STEP 7 Getting StartedA5E00069681-03
Monitoring Variables
Click the Monitor Variables button inthe toolbar. The operating mode of theCPU is displayed in the status bar.
Press Key 1 and Key 2 in your testconfiguration and monitor the result inthe variable table.
The status values in the variable tablewill change from false to true.
Modifying Variables
Enter the value "1500" for the address MW2 in the Modify Value column and"1300" for the address MW4.
Transfer the modify values to yourCPU.
Downloading and Debugging the Program
7-11STEP 7 Getting StartedA5E00069681-03
Following transfer, these values will be processed in your CPU. The result of thecomparison becomes visible.
Stop monitoring the variables (click the button in the toolbar again) and close thewindow. Acknowledge any queries with Yes or OK.
Very large variable tables often cannot be displayed fully due to the limited screen space.If you have large variable tables, we recommend you create several tables for oneS7 program using STEP 7. You can adapt the variable tables to precisely match your owntest requirements.You can assign individual names to variable tables in the same way as for blocks (forexample, the name OB1_Network1 instead of VAT1). Use the symbol table to assign newnames.
You can find more information under Help > Contentsin the topics "Debugging" and "Testing with theVariable Table."
Downloading and Debugging the Program
7-12 STEP 7 Getting StartedA5E00069681-03
7.5 Evaluating the Diagnostic Buffer
If, in an extreme case, the CPU goes into STOP while processing an S7 program,or if you cannot switch the CPU to RUN after you have downloaded the program,you can determine the cause of the error from the events listed in the diagnosticbuffer.
The requirement for this is that you have established an online connection to theCPU and the CPU is in STOP mode.
First turn the operating mode switch onthe CPU to STOP.
The starting point is the SIMATICManager again with the open projectwindow "Getting Started Offline."
Select the Blocks folder.
If there are several CPUs in yourproject, first determine which CPU hasgone into STOP.
All the accessible CPUs are listed inthe "Diagnosing Hardware" dialog box.The CPU with the STOP operatingmode is highlighted.
The "Getting Started" project only hasone CPU which is displayed.
Click Module Information to evaluatethe diagnostic buffer of this CPU.
If only one CPU is connected, you canquery the module information for thisCPU directly using the menu commandPLC > Module Information.
Downloading and Debugging the Program
7-13STEP 7 Getting StartedA5E00069681-03
The "Module Information" window provides you with information on the propertiesand parameters of your CPU. Now select the "Diagnostic Buffer" tab to determinethe cause of the STOP state.
The latest event (number 1) is at the top of the list. The cause of the STOP state isdisplayed. Close all windows except for the SIMATIC Manager.
If a programming error caused the CPU to go into STOP mode, select the event and clickthe "Open Block" button.
The block is then opened in the familiar LAD/STL/FBD program window and the faultynetwork is highlighted.
With this chapter you have successfully completed the "Getting Started" sample project,from creating a project through to debugging the finished program. In the next chapters,you can extend your knowledge further by working through selected exercises.
You can find more information under Help > Contentsin the topics "Calling the Module Information."
The "Open Block"button is disabled,because there was noerror in the block in the"Getting Started"project.
Programming with STEP 7 V5.3 A5E00261405-01 23-1
23 Diagnostics
23.1 Diagnosing Hardware and Troubleshooting
You can see whether diagnostic information is available for a module by the presence of diagnostics symbols. Diagnostics symbols show the status of the corresponding module and, for CPUs, the operating mode as well.
Diagnostics symbols are displayed in the project window in the online view as well as in the quick view (default setting) or the diagnostic view when you call the function "Diagnose Hardware." Detailed diagnostic information is displayed in the "Module Information" application, which you can start by double-clicking a diagnostics symbol in the quick view or the diagnostic view.
SIMATIC Manager ONLINE
Project
Station
Diagnosticssymbol ofCPU
S7 Program
Module Information
Diagnostic View
UR (0)
1
2
PS 307 5A
CPU 314
3 AI-300
Call the function"Diagnose Hardware"
Quick View
CPU
+ Failed Modules
Diagnostics
Programming with STEP 7 V5.3 23-2 A5E00261405-01
How to Locate Faults
1. Open the online window for the project with the menu command View > Online.
2. Open all the stations so that the programmable modules configured in them are visible.
3. Check to see which CPU is displaying a diagnostics symbol indicating an error or fault. You can open the help page with an explanation of the diagnostics symbols using the F1 key.
4. Select the station that you want to examine.
5. Select the menu command PLC > Diagnostics/Settings > Module Information to display the module information for the CPU in this station.
6. Select the menu command PLC > Diagnostics/Settings > Diagnose Hardware to display the "quick view" with the CPU and the failed modules in this station. The display of the quick view is set as default (menu command Option > Customize, "View" tab).
7. Select a faulty module in the quick view.
8. Click the "Module Information" button to obtain the information on this module.
9. Click the "Open Station Online" button in the quick view to display the diagnostic view. The diagnostic view contains all the modules in the station in their slot order.
10. Double-click a module in the diagnostic view in order to display its module information. In this way, you can also obtain information for those modules that are not faulty and therefore not displayed in the quick view.
You do not necessarily have to carry out all of the steps; you can stop as soon as you have obtained the diagnostic information you require.
23.2 Diagnostics Symbols in the Online View
Diagnostics symbols are displayed in the online project window and in the hardware configuration window with the online view of configuration tables.
Diagnostics symbols make it easier for you to detect a fault. You can see by a glance at a module symbol whether diagnostic information is available. If there are no faults present, the symbols for the module types are displayed without additional diagnostics symbols.
If diagnostic information is available for a module, a diagnostics symbol is displayed in addition to the module symbol or the module symbol is displayed with reduced contrast.
Diagnostics
Programming with STEP 7 V5.3 A5E00261405-01 23-3
Diagnostics Symbols for Modules (Example: FM / CPU)
Symbol Meaning
Mismatch between preset and actual configuration: the configured module does not exist or a different module type is inserted
Fault: module has a fault. Possible causes: diagnostic interrupt, I/O access error, or error LED detected
Diagnosis not possible: no online connection, or the CPU does not return diagnostic information to the module (for example, power supply, or submodule).
Diagnostics Symbols for Operating Modes (Example: CPU)
Symbol Mode
STARTUP
STOP
STOP
triggered by STOP mode on another CPU in multicomputing operation
RUN
HOLD
Diagnostics Symbol for Forcing
Symbol Mode
Variables are being forced on this module, meaning variables in the user program for the module are assigned fixed values that cannot be changed by the program.
The symbol for forcing can also appear in combination with other symbols (here with the symbol for RUN mode).
Updating the Display of Diagnostic Symbols
The appropriate window must be activated.
• Press F5 or
• Select the menu command View > Update in the window.
Diagnostics
Programming with STEP 7 V5.3 23-4 A5E00261405-01
23.3 Diagnosing Hardware: Quick View
23.3.1 Calling the Quick View
The quick view offers you a quick way of using "Diagnosing Hardware" with less information than the more detailed displays in the diagnostic view of HW Config. The quick view is displayed as default when the "Diagnose Hardware" function is called.
Displaying the Quick View
You call this function from the SIMATIC Manager using the menu command PLC > Diagnostics/Settings > Diagnose Hardware.
You can use the menu command as follows:
• In the online window of the project if a module or an S7/M7 program is selected.
• If a node ("MPI=...") is selected in the "Accessible Nodes" window and this entry belongs to a CPU.
From the configuration tables displayed, you can select modules whose module information you want to display.
23.3.2 Information Functions in the Quick View
The following information is displayed in the quick view:
• Data for the online connection to the CPU
• Diagnostic symbol for the CPU
• Diagnostic symbols for the modules in which the CPU has detected a fault (for example, diagnostic interrupt, I/O access error)
• Module type and address of the module (rack, slot, DP master system with station number).
Other Diagnostic Options in the Quick View
• Displaying the Module Information You can call this dialog box by clicking the "Module Information" button. The dialog box displays detailed diagnostic information, depending on the diagnostic capabilities of the selected module. In particular, you can display the entries in the diagnostic buffer via the diagnostic information of the CPU.
• Displaying the Diagnostic View Using the "Open Station Online" button, you can open the dialog box which, in contrast to the quick view, contains a graphic overview of the whole station as well as configuration information. It focuses on the module which is highlighted in the list "CPU / Faulty Modules."
Diagnostics
Programming with STEP 7 V5.3 A5E00261405-01 23-5
23.4 Diagnosing Hardware: Diagnostic View
23.4.1 Calling the Diagnostic View
Using this method you can open the "Module Information" dialog box for all modules in the rack. The diagnostic view (configuration table) shows the actual structure of a station at the level of the racks and DP stations with their modules.
Note
• If the configuration table is already open offline, you can also get the online view of the configuration table using the menu command Station > Open Online.
• Depending on the diagnostics capability of the module, a varying number of tabs are displayed in the ”Module Information" dialog box.
• In the "Accessible Nodes" window, only the modules with their own node address (MPI or PROFIBUS address) are ever visible.
Diagnostics
Programming with STEP 7 V5.3 23-6 A5E00261405-01
Calling from the ONLINE view of a project in the SIMATIC Manager
1. Establish an online connection to the programmable controller using the menu command View > Online in the project view in the SIMATIC Manager.
2. Select a station and open it with a double-click.
3. Then open the "Hardware" object in it. The diagnostic view is opened.
Now you can select a module and call up its module information using the menu command PLC > Diagnostics/Settings > Module Information.
Calling from the offline view of a project in the SIMATIC Manager
Execute the following steps:
1. Select a station from the project view of the SIMATIC Manager and open it with a double-click.
2. Then open the "Hardware" object in it. The configuration table is opened.
3. Select the Station > Open Online menu command.
4. The diagnostic view of HW Config is opened with the station configuration as determined from the modules (for example, CPU). The status of the modules is indicated by means of symbols. Refer to the online help for the meaning of the various symbols. Faulty modules and configured modules which are missing are listed in a separate dialog box. From this dialog box you can navigate directly to one of the selected module (”Go To” button).
5. Double-click the symbol for the module whose status you are interested in. A dialog box with tabs (depending on the type of module) gives you a detailed analysis of the module status.
Calling from the "Accessible Nodes" window in the SIMATIC Manager
Execute the following steps:
1. Open the "Accessible Nodes" window in the SIMATIC Manager using the menu command PLC > Display Accessible Nodes.
2. Select a node in the ”Accessible Nodes" window.
3. Select the menu command PLC > Diagnostics/Settings > Diagnose Hardware.
Note
In the "Accessible Nodes" window, only the modules with their own node address (MPI or PROFIBUS address) are ever visible.
Diagnostics
Programming with STEP 7 V5.3 A5E00261405-01 23-7
23.4.2 Information Functions in the Diagnostic View
In contrast to the quick view, the diagnostic view displays the entire station configuration available online. This consists of:
• Rack configurations
• Diagnostics symbols for all configured modules From these, you can read the status of each module and, with CPU modules, the operating mode.
• Module type, order number and address details, comments on the configuration.
Additional Diagnostic Options in the Diagnostic View
By double-clicking a module, you can display the operating mode of this module.
23.5 Module Information
23.5.1 Options for Displaying the Module Information
You can display the "Module Information" dialog box from different starting points. The following procedures are examples of frequently used methods of calling module information:
• In the SIMATIC Manager from a window with the project view "online" or "offline."
• In the SIMATIC Manager from an "Accessible Nodes" window
• In the diagnostic view of HW Config
Diagnostics
Programming with STEP 7 V5.3 23-8 A5E00261405-01
SIMATIC Manager(Online)
Project
Station
CPU
S7 program
Module Information
Diagnostic view of HWConfig
Call from the diagnostic view
Call from the SIMATIC Manager
Accessible Nodes
Accessible Nodes
MPI=2
Call from "Accessible Nodes"
UR (0)
1
2
PS 307 5A
CPU 314
3 AI-300
"Module Information""Diagnosing Hardware"
In order to display the status of a module with its own node address, you require an online connection to the programmable controller. You establish this connection via the online view of a project or via the "Accessible Nodes" window.
23.5.2 Module Information Functions
The module information functions can each be found in the various tabs within the "Module Information" dialog box. When displayed in an active situation, only those tabs relevant to the selected module are displayed.
Function/Tab Information Use
General Identification data on the selected module; for example, order number, release number, status, slot in rack
The online information from the inserted module can be compared with the data for the configured module
Diagnostic Buffer Overview of events in the diagnostic buffer and detailed information on the selected event
To find the cause of a CPU STOP and evaluate the events on the selected module leading to it
Using the diagnostic buffer, errors in the system can still be analyzed at a later time to find the cause of a STOP or to trace back and categorize the occurrence of individual diagnostic events
Diagnostic Interrupt Diagnostic data for the selected module To evaluate the cause of a module fault
DP Slave Diagnostics Diagnostic data for the selected DP slave (to EN 50170)
To evaluate the cause of a fault in a DP slave
Diagnostics
Programming with STEP 7 V5.3 A5E00261405-01 23-9
Function/Tab Information Use
Memory Memory capacity. Current utilization of the work memory, load memory and retentive memory of the selected CPU or M7 function module
Before new or extended blocks are transferred to a CPU, to check whether sufficient load memory is available in the CPU/function module or to compress the memory content.
Scan Cycle Time Duration of the longest, shortest, and last scan cycle of the selected CPU or M7 function module
To keep a check on the configured minimum cycle time, and the maximum and current cycle times
Time System Current time, operating hours, and
information about synchronizing clocks (synchronization intervals)
To display and set the time and date of a module and to check the time synchronization
Performance Data Address areas and the available blocks for the selected module (CPU/FM)
Before and during the creation of a user program to check whether the CPU fulfils the requirements for executing a user program; for example, load memory size or size of the process image
Blocks (can be opened from the ”Performance Data" tab)
Display of all block types available in the scope of supply of the selected module List of OBs, SFBs, and SFCs you can use for this module
To check which standard blocks your user program can contain or call to be able to run on the selected CPU.
Communication Transmission rates, the overview of communication connections, the communication load, and the maximum message frame size on the communication bus of the selected module
To determine how many and which CPU or M7 FM connections are possible and how many are in use
Stacks Stacks tab: Can only be called up in STOP mode or HOLD mode. The B stack for the selected module is displayed. You can then also display the I stack, the L stack, and the nesting stack and jump to the error location in the interrupted block.
To determine the cause of a transition to STOP and to correct a block
Additional Information Displayed
For each tab, the following information is displayed:
• Online path to the selected module
• Operating mode of the corresponding CPU (for example, RUN, STOP)
• Status of the selected module (for example, error, OK)
• Operating mode of the selected module (for example, RUN, STOP) if it has its own operating mode (for example, CP 342-5)
The operating mode of the CPU itself and the status of the selected module cannot be displayed if the module information for a non-CPU module is opened from the "Accessible Nodes" window.
Diagnostics
Programming with STEP 7 V5.3 23-10 A5E00261405-01
Displaying a Number of Modules Simultaneously
You can display the module information for a number of modules simultaneously. To do this, you must change to the respective module context, select another module, and then call the module information for it. Another ”Module Information" dialog box is then displayed. Only one dialog box can be opened for each module.
Updating the Display of Module Information
Each time you switch to a tab in the "Module Information" dialog box, the data are read from the module again. While a page is displayed, however, the contents are not updated. If you click the "Update" button, you can read the data from the module without changing the tab.
23.5.3 Scope of the Module Type-Dependent Information
The scope of information that can be evaluated and displayed is dependent on:
• The module selected, and
• From which view you call the module information A full scope of information is available when called from the online view of the configuration tables or from the project window. A limited scope of information is available when called from the "Accessible Nodes" window.
Depending on the scope of the information, the modules are divided into the categories "with system diagnostic capability," "with diagnostic capability," or "without diagnostic capability." The following figure shows these categories:
Diagnostic buffer and SZL of themodule
Modules with system diagnostics capability
Modules with diagnostic capabilityDiagnostic data of the module
Diagnostic information of theCPU via the module
All modules ≠ CPU
• Modules with system diagnostic capability are, for example, the modules FM 351 and FM 354
• Modules with diagnostic capability are most analog signal modules.
• Modules without diagnostic capability are most digital signal modules.
Diagnostics
Programming with STEP 7 V5.3 A5E00261405-01 23-11
Tabs Displayed
The table shows which property tabs are present in the ”Module Information" dialog box for each module type.
Tab CPU or M7 FM
Module with System Diagnostics Capability
Module with Diagnostics Capability
Module without Diagnostics Capability
DP Slave
General yes yes yes yes yes
Diagnostic Buffer yes yes − − −
Diagnostic Interrupt − yes yes − yes
Memory yes − − − −
Scan Cycle Time yes − − − −
Time System yes − − − −
Performance Data yes − − − −
Stacks yes − − − −
Communication yes − − − −
DP Slave Diagnostics
− − − − yes
H state 1) yes − − − − 1) Only for CPUs in H systems
In addition to the information in the tabbed property sheets, the operating mode is displayed for modules with an operating mode. When you open the dialog box from the configuration tables online, the status of the module from the viewpoint of the CPU is displayed (for example, OK, fault, module not available).
23.5.4 Displaying the Module Status of PA Field Devices and DP Slaves After a Y-Link
As of STEP 7 V5.1 Service Pack 3, you can evaluate the module status of DP slaves and PA field devices "after" a DP/PA link (IM 157).
This affects the following configurations:
• IM 157 with DP/PA connectors for connecting a PROFIBUS-PA
• IM 157 as a redundant modular interface module for connecting a non-redundant PROFIBUS-DP ("Y-link")
In this configuration, the programming device (PG) is connected to the same PROFIBUS subnet as the DP/PA link.
In addition, there is another configuration option in which the PG is connected to an Industrial Ethernet and routes an S7-400 station to the PROFIBUS subnet.
The prerequisites for this setup are shown in the following diagram:
Diagnostics
Programming with STEP 7 V5.3 23-12 A5E00261405-01
IM 157 with DP/PA connectors for connection to PROFIBUS-PA
PROFIBUS DP
PGDP/PA Link
(IM 157+DP/PA connector)
PROFIBUS PA PA fielddevice
IM 157 as Y-link
PROFIBUS DP (redundant)
PGDP/PA Link
(IM 157 "Y-Link")
DP SlavePROFIBUS DP (not redundant)
PG in an Industrial Ethernet
Ind. Ethernet
S7-400CPU
CP443-1
CP443-5
PROFIBUS DP
DP/PA Link(IM 157+DP/PA connector)
PROFIBUS-PA PA- fielddevice
PG
CP 443-5DX02, as of V3.0 "Data-record" gateway option enabled
Diagnostics
Programming with STEP 7 V5.3 A5E00261405-01 23-13
23.6 Diagnosing in STOP Mode
23.6.1 Basic Procedure for Determining the Cause of a STOP
To determine why the CPU has gone into "STOP" mode, proceed as follows:
1. Select the CPU that has gone into STOP.
2. Select the menu command PLC > Diagnostics/Settings > Module Information.
3. Select the "Diagnostic Buffer" tab.
4. You can determine the cause of the STOP from the last entries in the diagnostic buffer.
If a programming error occurs:
1. The entry "STOP because programming error OB not loaded" means, for example, that the CPU has detected a program error and then attempted to start the (non-existent) OB to handle the programming error. The previous entry points to the actual programming error.
2. Select the message relating to the programming error.
3. Click the "Open Block" button.
4. Select the "Stacks" tab.
23.6.2 Stack Contents in STOP Mode
By evaluating the diagnostic buffer and the stack contents you can determine the cause of the fault in the processing of the user program.
If, for example, the CPU has gone into STOP as a result of a programming error or the STOP command, the "Stacks" tab in the module information displays the block stack. You can display the contents of the other stacks using the ”I Stack", ”L Stack", and ”Nesting Stack" buttons. The stack contents give you information on which instruction in which block led to the CPU going into STOP.
B Stack Contents
The B stack, or block stack, lists all the blocks that were called before the change to STOP mode and which were not completely processed.
Diagnostics
Programming with STEP 7 V5.3 23-14 A5E00261405-01
I Stack Contents
When you click the ”I Stack" button, the data at the interrupt location are displayed. The I stack, or interrupt stack, contains the data or the states which were valid at the time of the interrupt, for example:
• Accumulator contents and register contents
• Open data blocks and their size
• Content of the status word
• Priority class (nesting level)
• Interrupted block
• Block in which program processing continues after the interrupt
L Stack Contents
For every block listed in the B stack, you can display the corresponding local data by selecting the block and clicking the ”L Stack" button.
The L stack, or local data stack, contains the local data values of the blocks the user program was working with at the time of the interrupt.
In-depth knowledge of the system is required to interpret and evaluate the local data displayed. The first part of the data displayed corresponds to the temporary variables for the block.
Nesting Stack Contents
When you click the ”Nesting Stack" button, the contents of the nesting stack at the interrupt location are displayed.
The nesting stack is a memory area that the logic operations A(, AN(, O(, ON(, X(, and XN( use.
The button is only active if bracket expressions were still open at the time of interruption.
Diagnostics
Programming with STEP 7 V5.3 A5E00261405-01 23-15
23.7 Checking Scan Cycle Times to Avoid Time Errors
23.7.1 Checking Scan Cycle Times to Avoid Time Errors
The "Scan Cycle Time" tab in the module information gives information about the scan cycle times of the user program.
If the duration of the longest cycle time is close to the configured maximum scan cycle time, there is a danger that fluctuations in the cycle time might cause a time error. This can be avoided if you extend the maximum cycle time (watchdog time) of the user program.
If the cycle length is less than the configured minimum scan time, the cycle is automatically extended by the CPU/FM to the configured minimum cycle time. In the case of a CPU, the background OB (OB90) is processed during this extended time (if it has been downloaded).
Setting the Scan Cycle Time
You can set the maximum and minimum cycle times when you configure the hardware. To do this, double-click in the offline view of the configuration table on the CPU/FM to define its properties. You can enter the appropriate values in the ”Cycle/Clock Memory" tab.
Diagnostics
Programming with STEP 7 V5.3 23-16 A5E00261405-01
23.8 Flow of Diagnostic Information
23.8.1 Flow of Diagnostic Information
The following figure shows the flow of diagnostic information in SIMATIC S7.
CPU Modules
The diagnosticfunction of amodule detectsan error andgenerates adiagnosticinterrupt(OB 82).
DiagnosticinterruptSystem status list
Diagnosticbuffer
STEP 7
The diagnostic function of the CPUdetects a system error.
The diagnostic function of the CPUdetects an error in the userprogram
User program
SFCs
Displaying Diagnostic Information
You can read out the diagnostic entries using SFC51 RDSYSST in the user program or display the diagnostic messages in plain language with STEP 7.
They provide information about the following:
• Where and when the error occurred
• The type of diagnostic event to which the entry belongs (user-defined diagnostic event, synchronous/asynchronous error, operating mode change).
Diagnostics
Programming with STEP 7 V5.3 A5E00261405-01 23-17
Generating Process Control Group Messages
The CPU enters events of the standard diagnostics and extended diagnostics in the diagnostic buffer. It also generates a process control group message for the standard diagnostic events if the following conditions are met:
• You have specified that process control messages will be generated in STEP 7.
• At least one display unit has logged on at the CPU for process control messages.
• A process control group message is only generated when there is not currently a process control group message of the corresponding class (there are seven classes).
• One process control group message can be generated per class.
23.8.2 System Status List SSL
The system status list (SSL) describes the current status of the programmable logic controller. It provides an overview of the configuration, the current parameter assignment, the current statuses and sequences on the CPU, and the modules belonging to it.
You can only read the data in the system status list but not modify them. It is a virtual list that is only created on request.
The information that you can display using the system status list can be divided into four areas.
System status list
System data
Diagnostic statusdata in the CPU
Diagnostic dataon modules
Diagnostic buffer
Diagnostics
Programming with STEP 7 V5.3 23-18 A5E00261405-01
Reading Out the System Status List
There are two ways of reading out the information in system status lists, as follows:
• Implicitly, via STEP 7 menu commands from the programming device (for example, memory configuration, static CPU data, diagnostic buffer, status displays).
• Explicitly, via the system function SFC 51 RDSYSST in the user program, by entering the number of the required partial system status list (see Help on Blocks )
System Data of the System Status List
System data are intrinsic or assigned characteristic data of a CPU. The following table shows the topics about which information can be displayed (partial system status lists):
Topic Information
Module identification Order number, type ID, and version of the module
CPU characteristics Time system, system behavior (for example,. multicomputing) and language description of the CPU
Memory areas Memory configuration of the module (size of the work memory).
System areas System memory of the module (for example, number of memory bits, timers, counters, memory type).
Block types Which blocks (OB, DB, SDB, FC, FB) exist on the module, the maximum number of blocks of one type, and the maximum size of a block type
Assignment of interrupts and errors
Assignment of interrupts/errors to OBs
Interrupt status Current status of interrupt processing/interrupts generated
Status of the priority classes Which OB is being executed, which priority class is disabled due to the parameter setting
Operating mode and mode transition
Which operating modes are possible, the last operating mode change, the current operating mode
Diagnostic Status Data in the CPU
Diagnostic status data describe the current status of the components monitored by the system diagnostics. The following table shows the topics about which information can be displayed (partial system status lists):
Topic Information
Communication status data All the communication functions currently set in the system
Diagnostic modules The modules with diagnostics capability logged on at the CPU
Start information list of the OB Start information about the OBs of the CPU
Start event list Start events and priority classes of the OBs
Module status information Status information about all assigned modules that are plugged in, faulty, or generate hardware interrupts
Diagnostics
Programming with STEP 7 V5.3 A5E00261405-01 23-19
Diagnostic Data on Modules
In addition to the CPU, there are also other modules with diagnostic capabilities (SMs, CPs, FMs) whose data are entered in the system status list. The following table shows the topics about which information can be displayed (partial system status list):
Topic Information
Module diagnostic information Module start address, internal/external faults, channel faults, parameter errors (4 bytes)
Module diagnostic data All the diagnostic data of a particular module
23.8.3 Sending Your Own Diagnostic Messages
You can also extend the standard system diagnostics of SIMATIC S7 by using the system function SFC 52 WRUSMSG to:
• Enter your own diagnostic information in the diagnostic buffer (for example, information about the execution of the user program).
• Send user defined diagnostic messages to logged on stations (monitoring devices such as a PG, OP or TD).
User Defined Diagnostic Events The diagnostic events are divided into event classes 1 to F. The user defined diagnostic events belong to event classes 8 to B. These can be divided into two groups, as follows:
• Event classes 8 and 9 include messages with a fixed number and predefined text that you can call up based on the number.
• Event classes A and B include messages to which you can assign a number (A000 to A0FF, B000 to B0FF) and text of your own choice.
Sending Diagnostic Messages to Stations In addition to making a user defined entry in the diagnostic buffer, you can also send your own user defined diagnostic messages to logged on display devices using SFC52 WRUSMSG. When SFC52 is called with SEND = 1, the diagnostic message is written to the send buffer and automatically sent to the station or stations logged on at the CPU.
If it is not possible to send messages (for example, because no display device is logged on or because the send buffer is full) the user-defined diagnostic event is still entered in the diagnostic buffer.
Generating a Message with Acknowledgement
If you acknowledge a user defined diagnostic event and want to record the acknowledgement, proceed as follows:
• When the event enters the event state, write 1 to a variable of the type BOOL, when the event leaves the event state write 0 to the variable.
• You can then monitor this variable using SFB33 ALARM.
Diagnostics
Programming with STEP 7 V5.3 23-20 A5E00261405-01
23.8.4 Diagnostic Functions
System diagnostics detect, evaluate, and report errors that occur within a programmable controller. For this purpose, every CPU and every module with system diagnostics capability (for example, FM 354) has a diagnostic buffer in which detailed information on all diagnostic events is entered in the order they occurred.
Diagnostic Events
The following entries are displayed as diagnostic events, for example:
• Internal and external faults on a module
• System errors in the CPU
• Operating mode changes (for example, from RUN to STOP)
• Errors in the user program
• Inserting/removing modules
• User messages entered with the system function SFC52
The content of the diagnostic buffer is retained following a memory reset. Using the diagnostic buffer, errors in the system can still be analyzed at a later time to find the cause of a STOP or to trace back and categorize the occurrence of individual diagnostic events
Acquiring Diagnostic Data
You do not need to program the acquisition of diagnostic data by system diagnostics. This is a standard feature that runs automatically. SIMATIC S7 provides various diagnostic functions. Some of these functions are integrated on the CPU, others are provided by the modules (SMs, CPs, and FMs).
Displaying Faults
Internal and external module faults are displayed on the front panels of the module. The LED displays and their evaluation are described in the S7 hardware manuals. With the S7-300, internal and external faults are displayed together as a group error.
The CPU recognizes system errors and errors in the user program and enters diagnostic messages in the system status list and the diagnostic buffer. These diagnostic messages can be read out on the programming device.
Signal and function modules with diagnostic capability detect internal and external module errors and generate a diagnostic interrupt to which you can react using an interrupt OB.
Diagnostics
Programming with STEP 7 V5.3 A5E00261405-01 23-21
23.9 Program Measures for Handling Errors
When it detects errors in program processing (synchronous errors) and errors in the programmable controller (asynchronous errors), the CPU calls the appropriate organization block (OB) for the error:
Error Error OB
I/O redundancy error OB70 CPU redundancy error OB72 Time error OB80 Power supply error OB81 Diagnostic interrupt OB82 Insert/remove module interrupt OB83 CPU hardware fault OB84 Priority class error OB85 Rack failure or failure of a station in the distributed I/O OB86 Communication error OB87 Programming error OB121 I/O access error OB122
If the appropriate OB is not available, the CPU goes into STOP mode. Otherwise, it is possible to store instructions in the OB as to how it should react to this error situation. This means the effects of an error can be reduced or eradicated.
Basic Procedure
Creating and Opening the OB
1. Display the module information for your CPU.
2. Select the "Performance Data" tab.
3. Decide on the basis of the list displayed whether the OB you want to program is permitted for this CPU.
4. Insert the OB in the "Blocks" folder of your program and open the OB.
5. Enter the program for handling the error.
6. Download the OB to the programmable controller.
Programming Measures for Handling Errors
1. Evaluate the local data of the OB to determine the exact cause of the error. The variables OB8xFLTID and OB12xSWFLT in the local data contain the error code. Their meaning is described in the "System and Standard Functions Reference Manual."
2. Branch to the program segment which reacts to this error.
You will find an example of handling diagnostic interrupts in the reference online help on System and Standard Functions under the heading "Example of Module Diagnostics with SFC51 (RDSYSST)."
You can find detailed information on OBs, SFBs, and SFCs in the corresponding Help on Blocks.
Diagnostics
Programming with STEP 7 V5.3 23-22 A5E00261405-01
23.9.1 Evaluating the Output Parameter RET_VAL
Using the RET_VAL output parameter (return value), a system function indicates whether or not the CPU was able to execute the SFC function correctly
Error Information in the Return Value
The return value is of the integer data type (INT). The sign of an integer indicates whether it is a positive or negative integer. The relationship of the return value to the value ”0" indicates whether or not an error occurred while the function was being executed (see table):
• If an error occurs while the function is being executed, the return value is less than "0." The sign bit of the integer is ”1."
• If the function is executed free of errors, the return value is greater than or equal to "0." The sign bit of the integer is ”0."
Processing of the SFC by the CPU Return Value Sign of the Integer
Error occurred Less than ”0" Negative (sign bit is "1")
No error Greater than or equal to ”0"
Positive (sign bit is "0")
Reacting to Error Information
If an error occurs while an SFC is being executed, the SFC provides an error code in the return value (RET_VAL).
A distinction is made between the following:
• A general error code that all SFCs can output and
• A specific error code that the SFC can output depending on its specific function.
Transferring the Function Value
Some SFCs also use the output parameter RET_VAL to transfer the function value, for example, SFC64 TIMETCK transfers the system time it has read using RET_VAL.
You can find more detailed information on the output parameter RET_VAL in the Help on SFBs/SFCs.
Diagnostics
Programming with STEP 7 V5.3 A5E00261405-01 23-23
23.9.2 Error OBs as a Reaction to Detected Errors
Detectable Errors
The system program can detect the following errors:
• CPU functioning incorrectly
• Error in the system program execution
• Errors in the user program
• Error in the I/Os
Depending on the type of error, the CPU is set to STOP mode or an error OB is called.
Programming Reactions
You can design programs to react to the various types of errors and to determine the way in which the CPU reacts. The program for a particular error can then be saved in an error OB. If the error OB is called, the program is executed.
The CPU calls the corresponding error OB.
If an error OB is programmed, the CPU executesthe program in the OB. If no error OB isprogrammed, the CPU goes into "STOP" mode.(Exception: OB 81)
An error occurs...
Error OBs
A distinction is made between synchronous and asynchronous errors as follows:
• Synchronous errors can be assigned to an MC7 instruction (for example, load instruction for a signal module which has been removed).
• Asynchronous errors can be assigned to a priority class or to the entire programmable logic controller (for example, cycle time exceeded).
Diagnostics
Programming with STEP 7 V5.3 23-24 A5E00261405-01
The following table shows what types of errors can occur. Refer to your "S7-300 Programmable Controller, Hardware and Installation Manual" or the "S7-400, M7-400 Programmable Controllers, Hardware and Installation Manual" for information as to whether your CPU provides the specified OBs.
Error Class Error Type OB Priority
Redundancy I/O redundancy error (only in H CPUs)
OB 70 25
CPU redundancy error (only in H CPUs)
OB 72 28
Asynchronous Time error OB 80 26
Power supply error OB 81 (or 28 if the error OB is called
Diagnostic Interrupt OB 82 in the startup program)
Insert/remove module interrupt
OB 83
CPU hardware fault OB 84
Program sequence error OB 85
Rack failure OB 86
Communication error OB 87
Synchronous Programming error OB 121 Priority of the OB that caused the error
I/O access error OB 122
Example of Using Error OB81
Using the local data (start information) of the error OB, you can evaluate the type of error that has occurred.
If, for example, the CPU detects a battery error, the operating system calls OB81 (see figure).
Program execution
OB 81
Operating system
OB81 checks the type of power supply error that was detected and displays whether the error was caused by a battery failure.
Battery exhausted (CPU) 1) No backup voltage (CPU) 24 V power supply failure (CPU) 1) Battery exhausted (Expansion unit) 1) No backup voltage (Expansion unit ) 1) 24V power supply failure (Expansion unit) 1)
21
22
23
31
32
33
1) Not with the S7-300.
The CPU detects a battery error.
Types of power supply error
Diagnostics
Programming with STEP 7 V5.3 A5E00261405-01 23-25
You can write a program that evaluates the event code triggered by the OB81 call. You can also write a program that brings about a reaction, such as activating an output connected to a lamp on the operator station.
Local Data of Error OB81
The following table shows the temporary variables that must be declared, in this case, in the variable declaration table of OB81.
The symbol Battery error (BOOL) must be identified as an output (for example, Q 4.0) so that other parts of the program can access these data.
Decl. Name Type Description
TEMP OB81EVCLASS BYTE Error class/error identifier 39xx
TEMP OB81FLTID BYTE Error code:
b#16#21 =
At least one backup battery of the CPU is exhausted 1)
b#16#22 =
No backup voltage in the CPU
b#16#23 =
Failure of the 24-V power supply in the CPU 1
b#16#31 =
At least one backup battery of an expansion rack is exhausted 1)
b#16#32 =
Backup voltage not present in an expansion rack 1
b#16#33 =
Failure of the 24-V power supply of an expansion rack 1)
TEMP OB81PRIORITY BYTE Priority class = 26/28
TEMP OB81OBNUMBR BYTE 81 = OB81
TEMP OB81RESERVED1 BYTE Reserved
TEMP OB81RESERVED2 BYTE Reserved
TEMP OB81MDLADDR INT Reserved
TEMP OB81RESERVED3 BYTE Only relevant for error codes B#16#31, B#16#32, B#16#33
TEMP OB81RESERVED4 BYTE
TEMP OB81RESERVED5 BYTE
TEMP OB81RESERVED6 BYTE
TEMP OB81DATETIME DATEAND TIME
Date and time at which the OB was started
1) = Not with the S7-300.
Diagnostics
Programming with STEP 7 V5.3 23-26 A5E00261405-01
Sample Program for the Error OB81
The sample STL program shows how you can read the error code in OB81.
The program is structured as follows:
• The error code in OB81 (OB81FLTID) is read and compared with the value of the event ”battery exhausted" (B#16#3921).
• If the error code corresponds to the code for ”battery exhausted," the program jumps to the label Berr and activates the output batteryerror.
• If the error code does not correspond to the code for ”battery exhausted," the program compares the code with the code for ”battery failure".
• If the error code corresponds to the code for ”battery failure," the program jumps to the label Berr and activates the output batteryerror. Otherwise the block is terminated.
AWL Description
L B#16#21 // Compare event code "battery exhausted"
//(B#16#21) with
L #OB81_FLT_ID // the error code for OB81.
==I // If the same (battery is exhausted),
// jump to Berr.
JC Berr
L B#16#22 // Compare event code "battery failure"
//(b#16#22) with
==I // the error code for OB81.
JC BF // If the same, jump to Berr.
BEU // No message about battery failure
Berr: L B#16#39 // Compare the ID for the next event with
L #OB81_EV_CLASS // the error code for OB81.
==I // If a battery failure or an exhausted battery
// is found,
S batteryerror // set the output "battery error."
// (Variable from the symbol table)
L B#16#38 // Compare the ID for the concluding event with
==I // the error code for OB81.
R batteryerror // reset the output "battery error, when
// the error is fixed.
You can find detailed information on OBs, SFBs, and SFCs, as well as an explanation of event IDs, in the corresponding Help on Blocks.
Diagnostics
Programming with STEP 7 V5.3 A5E00261405-01 23-27
23.9.3 Inserting Substitute Values for Error Detection
With certain types of error (for example, a wire break affecting an input signal), you can supply substitute values for values that are not available due to the error. There are two ways in which you can supply substitute values:
• You can assign substitute values for configurable output modules using STEP 7. Output modules that cannot have parameters assigned have the default substitute value 0.
• Using SFC44 RPLVAL, you can program substitute values in error OBs (only for input modules).
For all load instructions that lead to synchronous errors, you can specify a substitute value for the accumulator content in the error OB.
Sample Program for Substituting a Value
In the following sample program, a substitute value is made available in SFC44 RPLVAL. The following figure shows how OB122 is called when the CPU recognizes that an input module is not reacting.
OB1
OB 122
L PIB0T IB0
SFC44
RPL_VAL
In this example, the substitute value in the following figure is entered in the program so that the program can continue to operate with feasible values.
Substitute value: 0 0 0 1 0 0 1 0
Stop_Sw I 0.1
Stand_Eval I 0.3
Full_Sw I 0.4
Start_Sw I 0.0
If an input module fails, the processing of the statement L PIB0 produces a synchronous error and starts OB122. As standard, the load instruction reads in the value 0. With SFC44, however, you can define any substitute value suitable for the process. The SFC replaces the accumulator content with the specified substitute value.
The following sample program could be written in OB122. The following table shows the temporary variables that must be declared, in this case, in the variable declaration table of OB122.
Diagnostics
Programming with STEP 7 V5.3 23-28 A5E00261405-01
Decl. Name Type Description
TEMP OB122EVCLASS BYTE Error class/error ID 29xx
TEMP OB122SWFLT BYTE Error code:
16#42, 16#43, 16#44 1), 16#45 1)
TEMP OB122PRIORITY BYTE Priority class = priority of the OB in which the error occurred
TEMP OB122OBNUMBR BYTE 122 = OB122
TEMP OB122BLKTYPE BYTE Block type in which the error occurred
TEMP OB122MEMAREA BYTE Memory area and type of access
TEMP OB122MEMADDR WORD Address in the memory at which the error occurred
TEMP OB122BLKNUM WORD Number of the block in which the error occurred
TEMP OB122PRGADDR WORD Relative address of the instruction that caused the error
TEMP OB122DATETIME DATEANDTIME Date and time at which the OB was started
TEMP Error INT Saves the error code of SFC44 1) Not with the S7-300.
STL Description
L B#16#2942
L #OB122SWFLT
==I
JC Aerr
L B#16#2943
<> I
JC Stop
Aerr: CALL ”REPL_VAL"
VAL : = DW#16#2912
RETVAL : = #Error
L #Error
L 0
==I
BEC
Stop: CALL ”STP"
Compare the event code of OB122 with the event code (B#16#2942) for the acknowledgement of a time error when reading the I/O. If the same, jump to ”Aerr".
Compare the event code of OB122 with the event code (B#16#2943) for an addressing error (writing to a module that does not exist). If not the same, jump to ”Stop."
Label ”Aerr": transfers DW#16#2912 (binary 10010) to SFC44 (REPL_VAL). SFC44 loads this value in accumulator 1 (and substitutes the value that triggered the OB122 call). The SFC error code is saved in #Error.
Compare #Error with 0 (if the same, no error occurred when executing OB122). End the block if no error occurred.
"Stop" label: calls SFC46 ”STP" and changes the CPU to STOP mode.
Diagnostics
Programming with STEP 7 V5.3 A5E00261405-01 23-29
23.9.4 I/O Redundancy Error (OB70)
Description
The operating system of a H CPU calls OB70 if a loss of redundancy occurs on the PROFIBUS DP (for example, if there is a bus failure on the active DP master or an error in the DP slave interface module) or if the active DP master changes from DP slaves with switched I/Os.
Programming OB70
You must create OB70 as an object in your S7 program using STEP 7. Write the program to be executed in OB70 in the generated block and download it to the CPU as part of your user program.
You can use OB70, for example, for the following purposes:
• To evaluate the start information of OB70 and determine which event triggered the loss of I/O redundancy.
• To determine the status of your system using SFC51 RDSYSST (SZLID=B#16#71).
The CPU does not change to STOP mode if an I/O redundancy error occurs and OB70 is not programmed.
If OB70 is downloaded and the H system is not in redundant mode, OB70 is processed in both CPUs. The H system remains in redundant mode.
You can find detailed information on OBs, SFBs, and SFCs in the corresponding Help on Blocks.
23.9.5 CPU Redundancy Error (OB72)
Description
The operating system of the H CPU calls OB72 if one of the following events occurs:
• Loss of redundancy on the CPUs
• Comparison error (for example, RAM, PIQ)
• Standby-master switchover
• Synchronization error
• Error in a SYNC submodule
• Update process aborted
• OB72 is executed by all CPUs which are in RUN mode or STARTUP mode after an accompanying start event.
Diagnostics
Programming with STEP 7 V5.3 23-30 A5E00261405-01
Programming OB72
You must create OB72 as an object in your S7 program using STEP 7. Write the program to be executed in OB72 in the generated block and download it to the CPU as part of your user program.
You can use OB72, for example, for the following purposes:
• To evaluate the start information of OB72 and determine which event triggered the loss of CPU redundancy.
• To determine the status of your system using SFC51 RDSYSST (SZLID=B#16#71).
• To react to the loss of CPU redundancy specifically for the plant.
The CPU does not change to STOP mode if a CPU redundancy error occurs and OB72 is not programmed.
You can find detailed information on OBs, SFBs, and SFCs in the corresponding Help on Blocks.
23.9.6 Time Error (OB80)
Description
The operating system of the CPU calls OB80 when a time error occurs. Time errors include the following, for example:
• Maximum cycle time exceeded
• Time-of-day interrupts skipped by moving the time forward
• Delay too great when processing a priority class
Programming OB80
You must create OB80 as an object in your S7 program using STEP 7. Write the program to be executed in OB80 in the generated block and download it to the CPU as part of your user program.
You can use OB80, for example, for the following purposes:
• To evaluate the start information of OB80 and to determine which time-of-day interrupts were skipped.
• By including SFC29 CANTINT, you can deactivate the skipped time-of-day interrupt so that it is not executed and only time-of-day interrupts relative to the new time will be executed.
If you do not deactivate skipped time-of-day interrupts in OB80, the first skipped time-of-day interrupt is executed, all others are ignored.
If you do not program OB80, the CPU changes to STOP mode when a time error is detected.
You can find detailed information on OBs, SFBs, and SFCs in the corresponding Help on Blocks.
Diagnostics
Programming with STEP 7 V5.3 A5E00261405-01 23-31
23.9.7 Power Supply Error (OB81)
Description
The operating system of the CPU calls OB81 if one of the following fails in a CPU or an expansion unit
• The 24-V voltage supply
• A battery
• The complete backup
This OB is also called when the problem has been eliminated (the OB is called when an event comes and goes).
Programming OB81
You must create OB81 as an object in your S7 program using STEP 7. Write the program to be executed in OB81 in the generated block and download it to the CPU as part of your user program.
You can, for example, use OB81 for the following purposes:
• To evaluate the start information of OB81 and determine which power supply error has occurred.
• To find out the number of the rack with the defective power supply.
• To activate a lamp on an operator station to indicate that maintenance personnel should replace a battery.
If you do not program OB81, the CPU does not change to STOP mode if a power supply error is detected, in contrast to all other asynchronous error OBs. The error is, however, entered in the diagnostic buffer and the corresponding LED on the front panel indicates the error.
You can find detailed information on OBs, SFBs, and SFCs in the corresponding Help on Blocks.
Diagnostics
Programming with STEP 7 V5.3 23-32 A5E00261405-01
23.9.8 Diagnostic Interrupt (OB82)
Description
The operating system of the CPU calls OB82 when a module with diagnostics capability on which you have enabled the diagnostic interrupt detects an error and when the error is eliminated (the OB is called when the event comes and goes).
Programming OB82
You must create OB82 as an object in your S7 program using STEP 7. Write the program to be executed in OB82 in the generated block and download it to the CPU as part of your user program.
You can, for example, use OB82 for the following purposes:
• To evaluate the start information of OB82.
• To obtain exact diagnostic information about the error that has occurred.
When a diagnostic interrupt is triggered, the module on which the problem has occurred automatically enters 4 bytes of diagnostic data and their start address in the start information of the diagnostic interrupt OB and in the diagnostic buffer. This provides you with information about when an error occurred and on which module.
With a suitable program in OB82, you can evaluate further diagnostic data for the module (which channel the error occurred on, which error has occurred). Using SFC51 RDSYSST, you can read out the module diagnostic data and enter this information in the diagnostic buffer with SFC52 WRUSRMSG. You can also send a user-defined diagnostic message to a monitoring device.
If you do not program OB82, the CPU changes to STOP mode when a diagnostic interrupt is triggered.
You can find detailed information on OBs, SFBs, and SFCs in the corresponding Help on Blocks.
Diagnostics
Programming with STEP 7 V5.3 A5E00261405-01 23-33
23.9.9 Insert/Remove Module Interrupt (OB83)
Description
S7-400 CPUs monitor the presence of modules in the central rack and expansion racks at intervals of approximately 1 second.
After the power supply is turned on, the CPU checks whether all the modules listed in the configuration table created with STEP 7 are actually inserted. If all the modules are present, the actual configuration is saved and is used as a reference value for cyclic monitoring of the modules. In each scan cycle, the newly detected actual configuration is compared with the previous actual configuration. If there are discrepancies between the configurations, an insert/remove module interrupt is signaled and an entry is made in the diagnostic buffer and the system status list. In RUN mode, the insert/remove module interrupt OB is started.
Note Power supply modules, CPUs, and IMs must not be removed in RUN mode.
Between removing and inserting a module, at least two seconds must be allowed to pass so that the CPU can detect that a module has been removed or inserted.
Assigning Parameters to a Newly Inserted Module
If a module is inserted in RUN mode, the CPU checks whether the module type of the new module matches the original module. If they match, the module is assigned parameters. Either the default parameters or the parameters you assigned with STEP 7 are transferred to the module.
Programming OB83
You must create OB83 as an object in your S7 program using STEP 7. Write the program to be executed in OB83 in the generated block and download it to the CPU as part of your user program.
You can use OB83, for example, for the following purposes:
• To evaluate the start information of OB83.
• By including system functions SFC55 to 59, to assign parameters to a newly inserted module.
If you do not program OB83, the CPU changes from RUN to STOP when an insert/remove module interrupt occurs.
You can find detailed information on OBs, SFBs, and SFCs in the corresponding Help on Blocks.
Diagnostics
Programming with STEP 7 V5.3 23-34 A5E00261405-01
23.9.10 CPU Hardware Fault (OB84)
Description
The operating system of the CPU calls OB84 when an error is detected on the interface to the MPI network, to the communication bus, or to the network card for the distributed I/Os; for example, if an incorrect signal level is detected on the line. The OB is also called when the error is eliminated (the OB is called when the event comes and goes).
Programming OB84
You must create OB84 as an object in your S7 program using STEP 7. Write the program to be executed in OB84 in the generated block and download it to the CPU as part of your user program.
You can use OB84, for example, for the following purposes:
• To evaluate the start information of OB84.
• By including system function SFC52 WRUSMSG to send a message to the diagnostic buffer.
If you do not program OB84, the CPU changes to STOP mode when a CPU hardware fault is detected.
You can find detailed information on OBs, SFBs, and SFCs in the corresponding Help on Blocks.
23.9.11 Program Sequence Error (OB85)
Description
The operating system of the CPU calls OB85:
• When a start event for an interrupt OB exists but the OB cannot be executed because it has not been downloaded to the CPU.
• When an error occurs accessing the instance data block of a system function block.
• When an error occurs updating the process image table (module does not exist or defective).
Diagnostics
Programming with STEP 7 V5.3 A5E00261405-01 23-35
Programming OB85
You must create OB85 as an object in your S7 program using STEP 7. Write the program to be executed in OB85 in the generated block and download it to the CPU as part of your user program.
You can use OB85, for example, for the following purposes:
• To evaluate the start information of OB85 and determine which module is defective or not inserted (the module start address is specified).
• By including SFC49 LGCGADR to find out the slot of the module involved.
If you do not program OB85, the CPU changes to STOP mode when a priority class error is detected.
You can find detailed information on OBs, SFBs, and SFCs in the corresponding Help on Blocks.
23.9.12 Rack Failure (OB86)
Description
The operating system of the CPU calls OB86 when a rack failure is detected; for example:
• Rack failure (missing or defective IM or break on the connecting cable)
• Distributed power failure on a rack
• Failure of a DP slave in a master system of the SINEC L2-DP bus system
The OB is also called when the error is eliminated (the OB is called when the event comes and goes).
Programming OB86
You must create OB86 as an object in your S7 program using STEP 7. Write the program to be executed in OB86 in the generated block and download it to the CPU as part of your user program.
You can use OB86, for example, for the following purposes:
• To evaluate the start information of OB86 and determine which rack is defective or missing.
• To enter a message in the diagnostic buffer with system function SFC 52 WRUSMSG and to send the message to a monitoring device.
If you do not program OB86, the CPU changes to STOP mode when a rack failure is detected.
You can find detailed information on OBs, SFBs, and SFCs in the corresponding Help on Blocks.
Diagnostics
Programming with STEP 7 V5.3 23-36 A5E00261405-01
23.9.13 Communication Error (OB87)
Description
The operating system of the CPU calls OB87 when a communication error occurs in data exchange using communication function blocks or in global data communication, for example:
• When receiving global data, an incorrect frame ID was detected
• The data block for the status information of the global data does not exist or is too short.
Programming OB87
You must create OB87 as an object in your S7 program using STEP 7. Write the program to be executed in OB87 in the generated block and download it to the CPU as part of your user program.
You can use OB87, for example, for the following purposes:
• To evaluate the start information of OB87.
• To create a data block if the data block for the status information of global data communication is missing.
If you do not program OB87, the CPU changes to STOP mode when a communication error is detected.
You can find detailed information on OBs, SFBs, and SFCs in the corresponding Help on Blocks.
23.9.14 Programming Error (OB121)
Description
The operating system of the CPU calls OB121 when a programming error occurs, for example:
• Addressed timers do not exist.
• A called block is not loaded.
Programming OB121
You must create OB121 as an object in your S7 program using STEP 7. Write the program to be executed in OB121 in the generated block and download it to the CPU as part of your user program.
You can use OB121, for example, for the following purposes:
• To evaluate the start information of OB121.
• To enter the cause of an error in a message data block.
If you do not program OB121, the CPU changes to STOP mode when a programming error is detected.
Diagnostics
Programming with STEP 7 V5.3 A5E00261405-01 23-37
You can find detailed information on OBs, SFBs, and SFCs in the corresponding Help on Blocks.
23.9.15 I/O Access Error (OB122)
Description
The operating system of the CPU calls OB122 when a STEP 7 instruction accesses an input or output of a signal module to which no module was assigned at the last warm restart, for example:
• Errors with direct I/O access (module defective or missing)
• Access to an I/O address that is not known to the CPU.
Programming OB122
You must create OB122 as an object in your S7 program using STEP 7. Write the program to be executed in OB122 in the generated block and download it to the CPU as part of your user program.
You can use OB122, for example, for the following purposes:
• To evaluate the start information of OB122
• To call the system function SFC 44 and supply a substitute value for an input module so that program execution can continue with a meaningful, process-dependent value.
If you do not program OB122, the CPU changes to STOP mode when an I/O access error is detected.
You can find detailed information on OBs, SFBs, and SFCs in the corresponding Help on Blocks.
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingA5E00068865-02 1-1
1 Bit Logic Instructions
1.1 Overview of Bit Logic Instructions
Description
Bit logic instructions work with two digits, 1 and 0. These two digits form the baseof a number system called the binary system. The two digits 1 and 0 are calledbinary digits or bits. In the world of contacts and coils, a 1 indicates activated orenergized, and a 0 indicates not activated or not energized.
The bit logic instructions interpret signal states of 1 and 0 and combine themaccording to Boolean logic. These combinations produce a result of 1 or 0 that iscalled the “result of logic operation” (RLO).
The logic operations that are triggered by the bit logic instructions perform a varietyof functions. There are bit logic instructions to perform the following functions:
• ---| |--- Normally Open Contact (Address)
• ---| / |--- Normally Closed Contact (Address)
• ---(SAVE) Save RLO into BR Memory
• XOR Bit Exclusive OR
• ---( ) Output Coil
• ---( # )--- Midline Output
• ---|NOT|--- Invert Power Flow
The following instructions react to an RLO of 1:
• ---( S ) Set Coil
• ---( R ) Reset Coil
• SR Set-Reset Flip Flop
• RS Reset-Set Flip Flop
Other instructions react to a positive or negative edge transition to perform thefollowing functions:
• ---(N)--- Negative RLO Edge Detection
• ---(P)--- Positive RLO Edge Detection
• NEG Address Negative Edge Detection
• POS Address Positive Edge Detection
Bit Logic Instructions
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingA5E00068865-02 1-3
1.3 ---| |--- Normally Open Contact (Address)
Symbol
<address>
---| |---
Parameter Data Type Memory Area Description
<address> BOOL I, Q, M, L, D, T, C Checked bit
Description
---| |--- (Normally Open Contact) is closed when the bit value stored at thespecified <address> is equal to "1". When the contact is closed, ladder rail powerflows across the contact and the result of logic operation (RLO) = "1".
Otherwise, if the signal state at the specified <address> is "0", the contact is open.When the contact is open, power does not flow across the contact and the result oflogic operation (RLO) = "0".
When used in series, ---| |--- is linked to the RLO bit by AND logic. When used inparallel, it is linked to the RLO by OR logic.
Status word BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: - - - - - X X X 1
Example
I 0.0 I 0.1
I 0.2
Power flows if one of the following conditions exists:
The signal state is "1" at inputs I0.0 and I0.1
Or the signal state is "1" at input I0.2
Bit Logic Instructions
Ladder Logic (LAD) for S7-300 and S7-400 Programming1-4 A5E00068865-02
1.4 ---| / |--- Normally Closed Contact (Address)
Symbol
<address>
---| / |---
Parameter Data Type Memory Area Description
<address> BOOL I, Q, M, L, D, T, C Checked bit
Description
---| / |--- (Normally Closed Contact) is closed when the bit value stored at thespecified <address> is equal to "0". When the contact is closed, ladder rail powerflows across the contact and the result of logic operation (RLO) = "1".
Otherwise, if the signal state at the specified <address> is "1", the contact isopened. When the contact is opened, power does not flow across the contact andthe result of logic operation (RLO) = "0".
When used in series, ---| / |--- is linked to the RLO bit by AND logic. When used inparallel, it is linked to the RLO by OR logic.
Status word BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: - - - - - X X X 1
Example
I 0.0 I 0.1
I 0.2
Power flows if one of the following conditions exists:
The signal state is "1" at inputs I0.0 and I0.1
Or the signal state is "1" at input I0.2
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingA5E00068865-02 2-1
2 Comparison Instructions
2.1 Overview of Comparison Instructions
Description
IN1 and IN2 are compared according to the type of comparison you choose:
== IN1 is equal to IN2<> IN1 is not equal to IN2> IN1 is greater than IN2< IN1 is less than IN2>= IN1 is greater than or equal to IN2<= IN1 is less than or equal to IN2
If the comparison is true, the RLO of the function is "1". It is linked to the RLO of arung network by AND if the compare element is used in series, or by OR if the boxis used in parallel.
The following comparison instructions are available:
• CMP ? I Compare Integer
• CMP ? D Compare Double Integer
• CMP ? R Compare Real
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingA5E00068865-02 3-1
3 Conversion Instructions
3.1 Overview of Conversion Instructions
Description
The Conversion Instructions read the contents specified in the input parameter INas and convert this value or invert the sign bit. The output parameter OUT providesthe result.
The following conversion instructions are available:
• BCD_I BCD to Integer
• I_BCD Integer to BCD
• BCD_DI BCD to Double Integer
• I_DINT Integer to Double Integer
• DI_BCD Double Integer to BCD
• DI_REAL Double Integer to Floating-Point
• INV_I Ones Complement Integer
• INV_DI Ones Complement Double Integer
• NEG_I Twos Complement Integer
• NEG_DI Twos Complement Double Integer
• NEG_R Negate Floating-Point Number
• ROUND Round to Double Integer
• TRUNC Truncate Double Integer Part
• CEIL Ceiling
• FLOOR Floor
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingA5E00068865-02 4-1
4 Counter Instructions
4.1 Overview of Counter Instructions
Area in Memory
Counters have an area reserved for them in the memory of your CPU. Thismemory area reserves one 16-bit word for each counter address. The ladder logicinstruction set supports 256 counters.
The counter instructions are the only functions that have access to the countermemory area.
Count Value
Bits 0 through 9 of the counter word contain the count value in binary code. Thecount value is moved to the counter word when a counter is set. The range of thecount value is 0 to 999.
You can vary the count value within this range by using the following counterinstructions:
• S_CUD Up-Down Counter
• S_CD Down Counter
• S_CU Up Counter
• ---( SC ) Set Counter Coil
• ---( CU ) Down Counter Coil
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingA5E00068865-02 5-1
5 Data Block Instructions
5.1 ---(OPN) Open Data Block: DB or DI
Symbol
<DB no.> or <DI no.>
---(OPN)
Parameter Data Type Memory Area Description
<DB no.><DI no.>
BLOCK_DB DB, DI Number of DB/DI; range dependson CPU
Description
---(OPN) (Open a Data Block) opens a shared data block (DB) or an instance datablock (DI). The ---(OPN) function is an unconditional call of a data block. Thenumber of the data block is transferred into the DB or DI register. The subsequentDB and DI commands access the corresponding blocks, depending on the registercontents.
Status word BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: - - - - - - - - -
Example
Network 2
Network 1
OPN
DB10
Q 4.0DBX0.0
Data block 10 (DB10) is opened. The contact address (DBX0.0) refers to bit zero ofdata byte zero of the current data record contained in DB10. The signal state of thisbit is assigned to the output Q4.0.
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingA5E00068865-02 6-1
6 Logic Control Instructions
6.1 Overview of Logic Control Instructions
Description
You can use logic control instructions in all logic blocks: organization blocks (OBs),function blocks (FBs), and functions (FCs).
There are Logic Control instructions to perform the following functions:
• ---( JMP )--- Unconditional Jump
• ---( JMP )--- Conditional Jump
• ---( JMPN )--- Jump-If-Not
Label as Address
The address of a Jump instruction is a label. A label consists of a maximum of fourcharacters. The first character must be a letter of the alphabet; the other characterscan be letters or numbers (for example, SEG3). The jump label indicates thedestination to which you want the program to jump.
Label as Destination
The destination label must be at the beginning of a network. You enter thedestination label at the beginning of the network by selecting LABEL from theladder logic browser. An empty box appears. In the box, you type the name of thelabel.
SEG3
JMP
I 0.1 =
Q 4.0
I 0.4
Network 1
Network 2
Network X
SEG3
.
.
R
Q 4.1
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingA5E00068865-02 7-1
7 Integer Math Instructions
7.1 Overview of Integer Math Instructions
Description
Using integer math, you can carry out the following operations with two integernumbers (16 and 32 bits):
• ADD_I Add Integer
• SUB_I Subtract Integer
• MUL_I Multiply Integer
• DIV_I Divide Integer
• ADD_DI Add Double Integer
• SUB_DI Subtract Double Integer
• MUL_DI Multiply Double Integer
• DIV_DI Divide Double Integer
• MOD_DI Return Fraction Double Integer
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingA5E00068865-02 8-1
8 Floating Point Math
8.1 Overview of Floating-Point Math Instructions
Description
The IEEE 32-bit floating-point numbers belong to the data type called REAL.You can use the floating-point math instructions to perform the following mathinstructions using two 32-bit IEEE floating-point numbers:
• ADD_R Add Real
• SUB_R Subtract Real
• MUL_R Multiply Real
• DIV_R Divide Real
Using floating-point math, you can carry out the following operations with one 32-bit IEEE floating-point number:
• Establish the Absolute Value (ABS)
• Establish the Square (SQR) and the Square Root (SQRT)
• Establish the Natural Logarithm (LN)
• Establish the Exponential Value (EXP) to base e (= 2,71828)
• Establish the following trigonometrical functions of an angle represented as a32-bit IEEE floating-point number
- Establish the Sine (SIN) and the Arc Sine (ASIN)
- Establish the Cosine (COS) and the Arc Cosine (ACOS)
- Establish the Tangent (TAN) and the Arc Tangent (ATAN)
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingA5E00068865-02 9-1
9 Move Instructions
9.1 MOVE Assign a Value
Symbol
MOVE
IN
ENOEN
OUT
Parameter Data Type Memory Area Description
EN BOOL I, Q, M, L, D Enable input
ENO BOOL I, Q, M, L, D Enable output
IN All elementary datatypes with a length of8, 16, or 32 bits
I, Q, M, L, D orconstant
Source value
OUT All elementary datatypes with a length of8, 16, or 32 bits
I, Q, M, L, D Destination address
Description
MOVE (Assign a Value) is activated by the Enable EN Input. The value specified atthe IN input is copied to the address specified at the OUT output. ENO has thesame logic state as EN. MOVE can copy only BYTE, WORD, or DWORD dataobjects. User-defined data types like arrays or structures have to be copied withthe system function "BLKMOVE" (SFC 20).
Status word BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: 1 - - - - 0 1 1 1
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingA5E00068865-02 10-1
10 Program Control Instructions
10.1 Overview of Program Control Instructions
Description
The following program control instructions are available:
• ---(CALL) Call FC SFC from Coil (without Parameters)
• CALL_FB Call FB from Box
• CALL_FC Call FC from Box
• CALL_SFB Call System FB from Box
• CALL_SFC Call System FC from Box
• Call Multiple Instance
• Call Block from a Library
• Important Notes on Using MCR Functions
• ---(MCR<) Master Control Relay On
• ---(MCR>) Master Control Relay Off
• ---(MCRA) Master Control Relay Activate
• ---(MCRD) Master Control Relay Deactivate
• RET Return
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingA5E00068865-02 11-1
11 Shift and Rotate Instructions
11.1 Shift Instructions
11.1.1 Overview of Shift Instructions
Description
You can use the Shift instructions to move the contents of input IN bit by bit to theleft or the right. Shifting to the left multiplies the contents of input IN by 2 to thepower n (2 n ); shifting to the right divides the contents of input IN by 2 to the powern (2 n ). For example, if you shift the binary equivalent of the decimal value 3 to theleft by 3 bits, you obtain the binary equivalent of the decimal value 24 in theaccumulator. If you shift the binary equivalent of the decimal value 16 to the rightby 2 bits, you obtain the binary equivalent of the decimal value 4 in theaccumulator.
The number that you supply for input parameter N indicates the number of bits bywhich to shift. The bit places that are vacated by the Shift instruction are eitherfilled with zeros or with the signal state of the sign bit (a 0 stands for positive and a1 stands for negative). The signal state of the bit that is shifted last is loaded intothe CC 1 bit of the status word. The CC 0 and OV bits of the status word are resetto 0. You can use jump instructions to evaluate the CC 1 bit.
The following shift instructions are available:
• SHR_I Shift Right Integer
• SHR_DI Shift Right Double Integer
• SHL_W Shift Left Word
• SHR_W Shift Right Word
• SHL_DW Shift Left Double Word
• SHR_DW Shift Right Double Word
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingA5E00068865-02 12-1
12 Status Bit Instructions
12.1 Overview of Statusbit Instructions
Description
The status bit instructions are bit logic instructions that work with the bits of thestatus word. Each of these instructions reacts to one of the following conditions thatis indicated by one or more bits of the status word:
• The Binary Result bit (BR ---I I---) is set (that is, has a signal state of 1).
• A math function had an Overflow (OV ---I I---) or a Stored Overflow(OS ---I I---).
• The result of a math function is unordered (UO ---I I---).
• The result of a math function is related to 0 in one of the following ways:== 0, <> 0, > 0, < 0, >= 0, <= 0.
When a status bit instruction is connected in series, it combines the result of itssignal state check with the previous result of logic operation according to the Andtruth table. When a status bit instruction is connected in parallel, it combines itsresult with the previous RLO according to the Or truth table.
In this chapter, the Exception Bit BR Memory element, which checks the signalstate of the BR (Binary Result) bit of the status word, is shown in its internationaland SIMATIC form.
Status word
The status word is a register in the memory of your CPU that contains bits that youcan reference in the address of bit and word logic instructions. Structure of thestatus word:
BR CC1 CC0 OV OS OR STA RLO /FC
28 27 26 25 24 23 22 21 20...29215...
You can evaluate the bits in the status word
• with Integer Math Functions,
• with Floating-point Functions.
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingA5E00068865-02 13-1
13 Timer Instructions
13.1 Overview of Timer Instructions
Description
The following timer instructions are available:
• S_PULSE Pulse S5 Timer
• S_PEXT Extended Pulse S5 Timer
• S_ODT On-Delay S5 Timer
• S_ODTS Retentive On-Delay S5 Timer
• S_OFFDT Off-Delay S5 Timer
• ---( SP ) Pulse Timer Coil
• ---( SE ) Extended Pulse Timer Coil
• ---( SD ) On-Delay Timer Coil
• ---( SS ) Retentive On-Delay Timer Coil
• ---( SA ) Off-Delay Timer Coil
Timer Instructions
Ladder Logic (LAD) for S7-300 and S7-400 Programming13-4 A5E00068865-02
Choosing the right Timer
This overview is intended to help you choose the right timer for your timing job.
t
t
t
t
t
I 0.0
Q 4.0 S_PULSE
Q 4.0 S_PEXT
Q 4.0 S_ODT
Q 4.0 S_ODTS
Q 4.0 S_OFFDT
Timer Description
S_PULSEPulse timer
The maximum time that the output signal remains at 1 is the same as theprogrammed time value t. The output signal stays at 1 for a shorter period if theinput signal changes to 0.
S_PEXTExtended pulse timer
The output signal remains at 1 for the programmed length of time, regardlessof how long the input signal stays at 1.
S_ODTOn-delay timer
The output signal changes to 1 only when the programmed time has elapsedand the input signal is still 1.
S_ODTSRetentive on-delay timer
The output signal changes from 0 to 1 only when the programmed time haselapsed, regardless of how long the input signal stays at 1.
S_OFFDTOff-delay timer
The output signal changes to 1 when the input signal changes to 1 or while thetimer is running. The time is started when the input signal changes from 1 to 0.
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingA5E00068865-02 14-1
14 Word Logic Instructions
14.1 Overview of Word Logic Instructions
Description
Word logic instructions compare pairs of words (16 bits) and double words (32 bits)bit by bit, according to Boolean logic.
If the result at output OUT does not equal 0, bit CC 1 of the status word is set to"1". If the result at output OUT does equal 0, bit CC 1 of the status word is set to"0".
The following word logic instructions are available:
• WAND_W (Word) AND Word
• WOR_W (Word) OR Word
• WXOR_W (Word) Exclusive OR Word
• WAND_DW (Word) AND Double Word
• WOR_DW (Word) OR Double Word
• WXOR_DW (Word) Exclusive OR Double Word
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingA5E00068865-02 A-1
A Overview of All LAD Instructions
A.1 LAD Instructions Sorted According to EnglishMnemonics (International)
EnglishMnemonics
GermanMnemonics
Program ElementsCatalog
Description
---|/|--- ---|/|--- Bit logic Instruction Normally Closed Contact (Address)
---| |--- ---| |--- Bit logic Instruction Normally Open Contact (Address)
---( ) ---( ) Bit logic Instruction Output Coil
---(#)--- ---(#)--- Bit logic Instruction Midline Output
==0 ---| |--- ==0 ---| |--- Status bits Result Bit Equal 0
>0 ---| |--- >0 ---| |--- Status bits Result Bit Greater Than 0
>=0 ---| |--- >=0 ---| |--- Status bits Result Bit Greater Equal 0
<=0 ---| |--- <=0 ---| |--- Status bits Result Bit Less Equal 0
<0 ---| |--- <0 ---| |--- Status bits Result Bit Less Than 0
<>0 ---| |--- <>0 ---| |--- Status bits Result Bit Not Equal 0
ABS ABS Floating point Instruction Establish the Absolute Value of a Floating-Point Number
ACOS ACOS Floating point Instruction Establish the Arc Cosine Value
ADD_DI ADD_DI Integer Math Instruction Add Double Integer
ADD_I ADD_I Integer Math Instruction Add Integer
ADD_R ADD_R Floating point Instruction Add Real
ASIN ASIN Floating point Instruction Establish the Arc Sine Value
ATAN ATAN Floating point Instruction Establish the Arc Tangent Value
BCD_DI BCD_DI Convert BCD to Double Integer
BCD_I BCD_I Convert BCD to Integer
BR ---| |--- BIE ---| |--- Status bits Exception Bit Binary Result
----(CALL) ----(CALL) Program control Call FC SFC from Coil (without Parameters)
CALL_FB CALL_FB Program control Call FB from Box
CALL_FC CALL_FC Program control Call FC from Box
CALL_SFB CALL_SFB Program control Call System FB from Box
CALL_SFC CALL_SFC Program control Call System FC from Box
----(CD) ----(ZR) Counters Down Counter Coil
CEIL CEIL Convert Ceiling
CMP ? D CMP ? D Compare Compare Double Integer (==, <>, >, <, >=, <=)
CMP ? I CMP ? I Compare Compare Integer (==, <>, >, <, >=, <=)
Overview of All LAD Instructions
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingA-2 A5E00068865-02
CMP ? R CMP ? R Compare Compare Real (==, <>, >, <, >=, <=)
COS COS Floating point Instruction Establish the Cosine Value
----(CU) ---( ZV ) Counters Up Counter Coil
DI_BCD DI_BCD Convert Double Integer to BCD
DI_R DI_R Convert Double Integer to Floating-Point
DIV_DI DIV_DI Integer Math Instruction Divide Double Integer
DIV_I DIV_I Integer Math Instruction Divide Integer
DIV_R DIV_R Floating point Instruction Divide Real
EXP EXP Floating point Instruction Establish the Exponential Value
FLOOR FLOOR Convert Floor
I_BCD I_BCD Convert Integer to BCD
I_DI I_DI Convert Integer to Double Integer
INV_I INV_I Convert Ones Complement Integer
INV_DI INV_DI Convert Ones Complement Double Integer
---(JMP) ---(JMP) Jumps Unconditional Jump
---(JMP) ---(JMP) Jumps Conditional Jump
---(JMPN) ---(JMPN) Jumps Jump-If-Not
LABEL LABEL Jumps Label
LN LN Floating point Instruction Establish the Natural Logarithm
---(MCR>) ---(MCR>) Program control Master Control Relay Off
---(MCR<) ---(MCR<) Program control Master Control Relay On
---(MCRA) ---(MCRA) Program control Master Control Relay Activate
---(MCRD) ---(MCRD) Program control Master Control Relay Deactivate
MOD_DI MOD_DI Integer Math Instruction Return Fraction Double Integer
MOVE MOVE Move Assign a Value
MUL_DI MUL_DI Integer Math Instruction Multiply Double Integer
MUL_I MUL_I Integer Math Instruction Multiply Integer
MUL_R MUL_R Floating point Instruction Multiply Real
---( N )--- ---( N )--- Bit logic Instruction Negative RLO Edge Detection
NEG NEG Bit logic Instruction Address Negative Edge Detection
NEG_DI NEG_DI Convert Twos Complement Double Integer
NEG_I NEG_I Convert Twos Complement Integer
NEG_R NEG_R Convert Negate Floating-Point Number
---| NOT |--- ---| NOT |--- Bit logic Instruction Invert Power Flow
---( OPN ) ---( OPN ) DB call Open Data Block: DB or DI
OS ---| |--- OS ---| |--- Status bits Exception Bit Overflow Stored
OV ---| |--- OV ---| |--- Status bits Exception Bit Overflow
---( P )--- ---( P )--- Bit logic Instruction Positive RLO Edge Detection
POS POS Bit logic Instruction Address Positive Edge Detection
---( R ) ---( R ) Bit logic Instruction Reset Coil
---(RET) ---(RET) Program control Return
ROL_DW ROL_DW Shift/Rotate Rotate Left Double Word
ROR_DW ROR_DW Shift/Rotate Rotate Right Double Word
Overview of All LAD Instructions
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingA5E00068865-02 A-3
ROUND ROUND Convert Round to Double Integer
RS RS Bit logic Instruction Reset-Set Flip Flop
---( S ) ---( S ) Bit logic Instruction Set Coil
---( SAVE ) ---( SAVE ) Bit logic Instruction Save RLO into BR Memory
---( SC ) ---( SZ ) Counters Set Counter Value
S_CD Z_RUECK Counters Down Counter
S_CU Z_VORW Counters Up Counter
S_CUD ZAEHLER Counters Up-Down Counter
---( SD ) ---( SE ) Timers On-Delay Timer Coil
---( SE ) ---( SV ) Timers Extended Pulse Timer Coil
---( SF ) ---( SA ) Timers Off-Delay Timer Coil
SHL_DW SHL_DW Shift/Rotate Shift Left Double Word
SHL_W SHL_W Shift/Rotate Shift Left Word
SHR_DI SHR_DI Shift/Rotate Shift Right Double Integer
SHR_DW SHR_DW Shift/Rotate Shift Right Double Word
SHR_I SHR_I Shift/Rotate Shift Right Integer
SHR_W SHR_W Shift/Rotate Shift Right Word
SIN SIN Floating point Instruction Establish the Sine Value
S_ODT S_EVERZ Timers On-Delay S5 Timer
S_ODTS S_SEVERZ Timers Retentive On-Delay S5 Timer
S_OFFDT S_AVERZ Timers Off-Delay S5 Timer
---( SP ) ---( SI ) Timers Pulse Timer Coil
S_PEXT S_VIMP Timers Extended Pulse S5 Timer
S_PULSE S_IMPULS Timers Pulse S5 Timer
SQR SQR Floating point Instruction Establish the Square
SQRT SQRT Floating point Instruction Establish the Square Root
SR SR Bit logic Instruction Set-Reset Flip Flop
---( SS ) ---( SS ) Timers Retentive On-Delay Timer Coil
SUB_DI SUB_DI Integer Math Instruction Subtract Double Integer
SUB_I SUB_I Integer Math Instruction Subtract Integer
SUB_R SUB_R Floating point Instruction Subtract Real
TAN TAN Floating point Instruction Establish the Tangent Value
TRUNC TRUNC Convert Truncate Double Integer Part
UO ---| |--- UO ---| |--- Status bits Exception Bit Unordered
WAND_DW WAND_DW Word logic Instruction AND Double Word
WAND_W WAND_W Word logic Instruction AND Word
WOR_DW WOR_DW Word logic Instruction OR Double Word
WOR_W WOR_W Word logic Instruction OR Word
WXOR_DW WXOR_DW Word logic Instruction Exclusive OR Double Word
WXOR_W WXOR_W Word logic Instruction Exclusive OR Word
Overview of All LAD Instructions
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingA-4 A5E00068865-02
A.2 LAD Instructions Sorted According to GermanMnemonics (SIMATIC)
GermanMnemonics
EnglishMnemonics
Program ElementsCatalog
Description
---| |--- ---| |--- Bit logic Instruction Normally Open Contact (Address)
---|/|--- ---|/|--- Bit logic Instruction Normally Closed Contact (Address)
---( ) ---( ) Bit logic Instruction Output Coil
---(#)--- ---(#)--- Bit logic Instruction Midline Output
==0 ---| |--- ==0 ---| |--- Status bits Result Bit Equal 0
>0 ---| |--- >0 ---| |--- Status bits Result Bit Greater Than 0
>=0 ---| |--- >=0 ---| |--- Status bits Result Bit Greater Equal 0
<=0 ---| |--- <=0 ---| |--- Status bits Result Bit Less Equal 0
<0 ---| |--- <0 ---| |--- Status bits Result Bit Less Than 0
<>0 ---| |--- <>0 ---| |--- Status bits Result Bit Not Equal 0
ABS ABS Floating pointInstruction
Establish the Absolute Value of a Floating-Point Number
ACOS ACOS Floating pointInstruction
Establish the Arc Cosine Value
ADD_DI ADD_DI Integer Math Instruction Add Double Integer
ADD_I ADD_I Integer Math Instruction Add Integer
ADD_R ADD_R Floating point Instruction Add Real
ASIN ASIN Floating point Instruction Establish the Arc Sine Value
ATAN ATAN Floating point Instruction Establish the Arc Tangent Value
BCD_DI BCD_DI Convert BCD to Double Integer
BCD_I BCD_I Convert BCD to Integer
BIE ---| |--- BR ---| |--- Status bits Exception Bit Binary Result
----(CALL) ----(CALL) Program control Call FC SFC from Coil (withoutParameters)
CALL_FB CALL_FB Program control Call FB from Box
CALL_FC CALL_FC Program control Call FC from Box
CALL_SFB CALL_SFB Program control Call System FB from Box
CALL_SFC CALL_SFC Program control Call System FC from Box
CEIL CEIL Convert Ceiling
CMP ? D CMP ? D Compare Compare Double Integer (==, <>, >, <, >=,<=)
CMP ? I CMP ? I Compare Compare Integer (==, <>, >, <, >=, <=)
CMP ? R CMP ? R Compare Compare Real (==, <>, >, <, >=, <=)
COS COS Floating point Instruction Establish the Cosine Value
DI_BCD DI_BCD Convert Double Integer to BCD
DI_R DI_R Convert Double Integer to Floating-Point
DIV_DI DIV_DI Integer Math Instruction Divide Double Integer
DIV_I DIV_I Integer Math Instruction Divide Integer
DIV_R DIV_R Floating point Instruction Divide Real
Overview of All LAD Instructions
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingA5E00068865-02 A-5
EXP EXP Floating point Instruction Establish the Exponential Value
FLOOR FLOOR Convert Floor
I_BCD I_BCD Convert Integer to BCD
I_DI I_DI Convert Integer to Double Integer
INV_I INV_I Convert Ones Complement Integer
INV_DI INV_DI Convert Ones Complement Double Integer
---(JMP) ---(JMP) Jumps Conditional Jump
---(JMP) ---(JMP) Jumps Unconditional Jump
---(JMPN) ---(JMPN) Jumps Jump-If-Not
LABEL LABEL Jumps Label
LN LN Floating point Instruction Establish the Natural Logarithm
---(MCR>) ---(MCR>) Program control Master Control Relay Off
---(MCR<) ---(MCR<) Program control Master Control Relay On
---(MCRA) ---(MCRA) Program control Master Control Relay Activate
---(MCRD) ---(MCRD) Program control Master Control Relay Deactivate
MOD_DI MOD_DI Integer Math Instruction Return Fraction Double Integer
MOVE MOVE Move Assign a Value
MUL_DI MUL_DI Integer Math Instruction Multiply Double Integer
MUL_I MUL_I Integer Math Instruction Multiply Integer
MUL_R MUL_R Floating point Instruction Multiply Real
---( N )--- ---( N )--- Bit logic Instruction Negative RLO Edge Detection
NEG NEG Bit logic Instruction Address Negative Edge Detection
NEG_DI NEG_DI Convert Twos Complement Double Integer
NEG_I NEG_I Convert Twos Complement Integer
NEG_R NEG_R Convert Negate Floating-Point Number
---| NOT |--- ---| NOT |--- Bit logic Instruction Invert Power Flow
---( OPN ) ---( OPN ) DB call Open Data Block: DB or DI
OS ---| |--- OS ---| |--- Status bits Exception Bit Overflow Stored
OV ---| |--- OV ---| |--- Status bits Exception Bit Overflow
---( P )--- ---( P )--- Bit logic Instruction Positive RLO Edge Detection
POS POS Bit logic Instruction Address Positive Edge Detection
---( R ) ---( R ) Bit logic Instruction Reset Coil
---(RET) ---(RET) Program control Return
ROL_DW ROL_DW Shift/Rotate Rotate Left Double Word
ROR_DW ROR_DW Shift/Rotate Rotate Right Double Word
ROUND ROUND Convert Round to Double Integer
RS RS Bit logic Instruction Reset-Set Flip Flop
---( S ) ---( S ) Bit logic Instruction Set Coil
---( SA ) ---( SF ) Timers Off-Delay Timer Coil
---( SAVE ) ---( SAVE ) Bit logic Instruction Save RLO into BR Memory
S_AVERZ S_OFFDT Timers Off-Delay S5 Timer
---( SE ) ---( SD ) Timers On-Delay Timer Coil
S_EVERZ S_ODT Timers On-Delay S5 Timer
Overview of All LAD Instructions
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingA-6 A5E00068865-02
SHL_DW SHL_DW Shift/Rotate Shift Left Double Word
SHL_W SHL_W Shift/Rotate Shift Left Word
SHR_DI SHR_DI Shift/Rotate Shift Right Double Integer
SHR_DW SHR_DW Shift/Rotate Shift Right Double Word
SHR_I SHR_I Shift/Rotate Shift Right Integer
SHR_W SHR_W Shift/Rotate Shift Right Word
---( SI ) ---( SP ) Timers Pulse Timer Coil
S_IMPULS S_PULSE Timers Pulse S5 Timer
SIN SIN Floating point Instruction Establish the Sine Value
SQR SQR Floating point Instruction Establish the Square
SQRT SQRT Floating point Instruction Establish the Square Root
SR SR Bit logic Instruction Set-Reset Flip Flop
---( SS ) ---( SS ) Timers Retentive On-Delay Timer Coil
S_SEVERZ S_ODTS Timers Retentive On-Delay S5 Timer
SUB_DI SUB_DI Integer Math Instruction Subtract Double Integer
SUB_I SUB_I Integer Math Instruction Subtract Integer
SUB_R SUB_R Floating point Instruction Subtract Real
---( SV ) ---( SE ) Timers Extended Pulse Timer Coil
S_VIMP S_PEXT Timers Extended Pulse S5 Timer
---( SZ ) ---( SC ) Counters Set Counter Value
TAN TAN Floating point Instruction Establish the Tangent Value
TRUNC TRUNC Convert Truncate Double Integer Part
UO ---| |--- UO ---| |--- Status bits Exception Bit Unordered
WAND_DW WAND_DW Word logic Instruction AND Double Word
WAND_W WAND_W Word logic Instruction AND Word
WOR_DW WOR_DW Word logic Instruction OR Double Word
WOR_W WOR_W Word logic Instruction OR Word
WXOR_DW WXOR_DW Word logic Instruction Exclusive OR Double Word
WXOR_W WXOR_W Word logic Instruction Exclusive OR Word
ZAEHLER S_CUD Counters Up-Down Counter
----(ZR) ----(CD) Counters Down Counter Coil
Z_RUECK S_CD Counters Down Counter
---( ZV ) ----(CU) Counters Up Counter Coil
Z_VORW S_CU Counters Up Counter
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingA5E00068865-02 B-1
B Programming Examples
B.1 Overview of Programming Examples
Practical Applications
Each ladder logic instruction triggers a specific operation. When you combine theseinstructions into a program, you can accomplish a wide variety of automation tasks.This chapter provides the following examples of practical applications:
• Controlling a conveyor belt using bit logic instructions
• Detecting direction of movement on a conveyor belt using bit logic instructions
• Generating a clock pulse using timer instructions
• Keeping track of storage space using counter and comparison instructions
• Solving a problem using integer math instructions
• Setting the length of time for heating an oven
Instructions Used
Mnemonik Program Elements Catalog Description
WAND_W Word logic instruction (Word) And Word
WOR_W Word logic instruction (Word) Or Word
--- ( CD ) Counters Down Counter Coil
--- ( CU ) Counters Up Counter Coil
---( R ) Bit logic instruction Reset Coil
---( S ) Bit logic instruction Set Coil
---( P ) Bit logic instruction Positive RLO Edge Detection
ADD_I Floating-Point instruction Add Integer
DIV_I Floating-Point instruction Divide Integer
MUL_I Floating-Point instruction Multiply Integer
CMP <=I, CMP >=I Compare Compare Integer
––| |–– Bit logic instruction Normally Open Contact
––| / |–– Bit logic instruction Normally Closed Contact
––( ) Bit logic instruction Output Coil
---( JMPN ) Jumps Jump-If-Not
---( RET ) Program control Return
MOVE Move Assign a Value
--- ( SE ) Timers Extended Pulse Timer Coil
Programming Examples
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingB-2 A5E00068865-02
B.2 Example: Bit Logic Instructions
Example 1: Controlling a Conveyor Belt
The following figure shows a conveyor belt that can be activated electrically. Thereare two push button switches at the beginning of the belt: S1 for START and S2 forSTOP. There are also two push button switches at the end of the belt: S3 forSTART and S4 for STOP. It it possible to start or stop the belt from either end.Also, sensor S5 stops the belt when an item on the belt reaches the end.
MOTOR_ON
S1S2
O StartO Stop
S3S4
O StartO Stop
Sensor S5
Absolute and symbolic Programming
You can write a program to control the conveyor belt using absolute values orsymbols that represent the various components of the conveyor system.
You need to make a symbol table to correlate the symbols you choose withabsolute values (see the STEP 7 Online Help).
System Component Absolute Address Symbol Symbol Table
Push Button Start Switch I 1.1 S1 I 1.1 S1
Push Button Stop Switch I 1.2 S2 I 1.2 S2
Push Button Start Switch I 1.3 S3 I 1.3 S3
Push Button Stop Switch I 1.4 S4 I 1.4 S4
Sensor I 1.5 S5 I 1.5 S5
Motor Q 4.0 MOTOR_ON Q 4.0 MOTOR_ON
Programming Examples
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingA5E00068865-02 B-3
Ladder Logic Program to control the conveyor belt
Network 1: Pressing either start switch turns the motor on.
I 1.1
I 1.3
S
Q 4.0
S1
S3
Network 2: Pressing either stop switch or opening the normally closed contact atthe end of the belt turns the motor off.
I 1.2
R
Q 4.0S2
I 1.4S4
I 1.5S5
Programming Examples
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingB-4 A5E00068865-02
Example 2: Detecting the Direction of a Conveyor Belt
The following figure shows a conveyor belt that is equipped with two photoelectricbarriers (PEB1 and PEB2) that are designed to detect the direction in which apackage is moving on the belt. Each photoelectric light barrier functions like anormally open contact.
PEB1PEB2 Q 4.1Q 4.0
Absolute and symbolic Programming
You can write a program to activate a direction display for the conveyor belt systemusing absolute values or symbols that represent the various components of theconveyor system.
You need to make a symbol table to correlate the symbols you choose withabsolute values (see the STEP 7 Online Help).
System Component Absolute Address Symbol Symbol Table
Photoelectric barrier 1 I 0.0 PEB1 I 0.0 PEB1
Photoelectric barrier 2 I 0.1 PEB2 I 0.1 PEB2
Display for movement to right Q 4.0 RIGHT Q 4.0 RIGHT
Display for movement to left Q 4.1 LEFT Q 4.1 LEFT
Pulse memory bit 1 M 0.0 PMB1 M 0.0 PMB1
Pulse memory bit 2 M 0.1 PMB2 M 0.1 PMB2
Programming Examples
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingA5E00068865-02 B-5
Ladder Logic Program for Detecting the Direction of a Conveyor Belt
Network 1: If there is a transition in signal state from 0 to 1 (positive edge) at inputI 0.0 and, at the same time, the signal state at input I 0.1 is 0, then the package onthe belt is moving to the left.
I 0.0PEB1
P
M 0.0
PMB1I 0.1
PEB2
S
Q 4.1
LEFT
Network 2: If there is a transition in signal state from 0 to 1 (positive edge) at inputI 0.1 and, at the same time, the signal state at input I 0.0 is 0, then the package onthe belt is moving to the right. If one of the photoelectric light barriers is broken, thismeans that there is a package between the barriers.
I 0.1PEB2
P
M 0.1
PMB2I 0.0
PEB1
S
Q 4.0
RIGHT
Network 3: If neither photoelectric barrier is broken, then there is no packagebetween the barriers. The direction pointer shuts off.
R
Q 4.1
LEFT
I 0.1PEB2
I 0.0PEB1
R
Q 4.0
RIGHT
Programming Examples
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingB-6 A5E00068865-02
B.3 Example: Timer Instructions
Clock Pulse Generator
You can use a clock pulse generator or flasher relay when you need to produce asignal that repeats periodically. A clock pulse generator is common in a signallingsystem that controls the flashing of indicator lamps.
When you use the S7-300, you can implement the clock pulse generator functionby using time-driven processing in special organization blocks. The example shownin the following ladder logic program, however, illustrates the use of timer functionsto generate a clock pulse. The sample program shows how to implement a free-wheeling clock pulse generator by using a timer.
Ladder Logic Program to Generate a Clock Pulse (pulse duty factor 1:1)
Network 1: If the signal state of timer T1 is 0, load the time value 250 ms into T1and start T1 as an extended-pulse timer.
T1SE
M0.2
S5T#250MS
Network 2: The state of the timer is saved temporarily in an auxiliary memorymarker.
M0.2T1
Network 3: If the signal state of timer T1 is 1, jump to jump label M001.
M001JMP
M0.2
Network 4: When the timer T1 expires, the memory word 100 is incremented by 1.
ADD_I
IN1
ENOEN
IN2
OUTMW100
1
MW100
Programming Examples
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingA5E00068865-02 B-7
Network 5: The MOVE instruction allows you to output the different clockfrequencies at outputs Q12.0 through Q13.7.
MW100
MOVE
IN OUT
EN ENO
AW12
M001
Signal Check
A signal check of timer T1 produces the following result of logic operation (RLO) foropener M0.2.
01
250 ms
As soon as the time runs out, the timer is restarted. Because of this, the signalcheck made by ––| / |–– M0.2 produces a signal state of 1 only briefly.
The negated (inverted) RLO:
01
250 ms
Every 250 ms the RLO bit is 0. The jump is ignored and the contents of memoryword MW100 is incremented by 1.
Programming Examples
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingB-8 A5E00068865-02
Achieving a Specific Frequency
From the individual bits of memory bytes MB101 and MB100 you can achieve thefollowing frequencies:
Bits of MB101/MB100 Frequency in Hz Duration
M 101.0 2.0 0.5 s (250 ms on / 250 ms off)
M 101.1 1.0 1 s (0.5 s on / 0.5 s off)
M 101.2 0.5 2 s (1 s on / 1 s off)
M 101.3 0.25 4 s (2 s on / 2 s off)
M 101.4 0.125 8 s (4 s on / 4 s off)
M 101.5 0.0625 16 s (8 s on / 8 s off)
M 101.6 0.03125 32 s (16 s on / 16 s off)
M 101.7 0.015625 64 s (32 s on / 32 s off)
M 100.0 0.0078125 128 s (64 s on / 64 s off)
M 100.1 0.0039062 256 s (128 s on / 128 s off)
M 100.2 0.0019531 512 s (256 s on / 256 s off)
M 100.3 0.0009765 1024 s (512 s on / 512 s off)
M 100.4 0.0004882 2048 s (1024 s on / 1024 s off)
M 100.5 0.0002441 4096 s (2048 s on / 2048 s off)
M 100.6 0.000122 8192 s (4096 s on / 4096 s off)
M 100.7 0.000061 16384 s (8192 s on / 8192 s off)
Signal states of the Bits of Memory MB 101
ScanCycle
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Time Valuein ms
0 0 0 0 0 0 0 0 0 250
1 0 0 0 0 0 0 0 1 250
2 0 0 0 0 0 0 1 0 250
3 0 0 0 0 0 0 1 1 250
4 0 0 0 0 0 1 0 0 250
5 0 0 0 0 0 1 0 1 250
6 0 0 0 0 0 1 1 0 250
7 0 0 0 0 0 1 1 1 250
8 0 0 0 0 1 0 0 0 250
9 0 0 0 0 1 0 0 1 250
10 0 0 0 0 1 0 1 0 250
11 0 0 0 0 1 0 1 1 250
12 0 0 0 0 1 1 0 0 250
Programming Examples
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingA5E00068865-02 B-9
Signal state of Bit 1 of MB 101 (M 101.1)
Frequency = 1/T = 1/1 s = 1 Hz
M 101.1
250 ms 0.5 s 0.75 s 1 s 1.25 s 1.5 s
T
Time01
0
Programming Examples
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingB-10 A5E00068865-02
B.4 Example: Counter and Comparison Instructions
Storage Area with Counter and Comparator
The following figure shows a system with two conveyor belts and a temporarystorage area in between them. Conveyor belt 1 delivers packages to the storagearea. A photoelectric barrier at the end of conveyor belt 1 near the storage areadetermines how many packages are delivered to the storage area. Conveyor belt 2transports packages from the temporary storage area to a loading dock wheretrucks take the packages away for delivery to customers. A photoelectric barrier atthe end of conveyor belt 2 near the storage area determines how many packagesleave the storage area to go to the loading dock. A display panel with five lampsindicates the fill level of the temporary storage area.
Display Panel
Storage areaempty
(Q 12.0)
Storage areanot empty
(Q 12.1)
Storage area 50% full
(Q 15.2)
Storage area90% full
(Q 15.3)
Storage areaFilled to capacity
(Q 15.4)
Temporarystorage area
for 100packages
Packages in Packages out
Conveyor belt 2Conveyor belt 1
Photoelectric barrier 1 Photoelectric barrier 2
I 12.0 I 12.1
Programming Examples
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingA5E00068865-02 B-11
Ladder Logic Program that Activates the Indicator Lamps on the Display Panel
Network 1: Counter C1 counts up at each signal change from “0” to “1” at input CUand counts down at each signal change from “0” to “1” at input CD. With a signalchange from “0” to ”1” at input S, the counter value is set to the value PV. A signalchange from “0” to “1” at input R resets the counter value to “0”. MW200 containsthe current counter value of C1. Q12.1 indicates “storage area not empty”.
Q 12.1
I 12.3
I 12.1
I 12.2
I 12.0 S_CUD
CD
QCU
S
PV CV
R CV_BCD
C1
MW210C#10
MW200
Network 2: Q12.0 indicates ”storage area empty”.
Q 12.1 Q 12.1
Network 3: If 50 is less than or equal to the counter value (in other words if thecurrent counter value is greater than or equal to 50), the indicator lamp for “storagearea 50% full” is lit.
Q 15.2CMP
IN1
<= 1
IN2
50
MW200
Network 4: Network 4: If the counter value is greater than or equal to 90, theindicator lamp for “storage area 90% full” is lit.
Q 15.3CMP
IN1
>= 1
IN2
MW200
90
Programming Examples
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingB-12 A5E00068865-02
Network 5: If the counter value is greater than or equal to 100, the indicator lampfor “storage area full” is lit.
Q 15.4CMP
IN1
>= 1
IN2
MW200
100
B.5 Example: Integer Math Instructions
Solving a Math Problem
The sample program shows you how to use three integer math instructions toproduce the same result as the following equation:
MW4 = ((IW0 + DBW3) x 15) / MW0
Ladder Logic Program
Network 1: Open Data Block DB1.
OPN
DB1
Network 2: Input word IW0 is added to shared data word DBW3 (data block mustbe defined and opened) and the sum is loaded into memory word MW100. MW100is then multiplied by 15 and the answer stored in memory word MW102. MW102 isdivided by MW0 with the result stored in MW4.
ADD_I
IN1
ENOEN
IN2 OUTDBW3
IW0
MW100
MUL_I
IN1
ENOEN
IN2 OUT
MW100
15 MW102
DIV_I
IN1
ENOEN
IN2 OUT
MW102
MW0 MW4
Programming Examples
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingA5E00068865-02 B-13
B.6 Example: Word Logic Instructions
Heating an Oven
The operator of the oven starts the oven heating by pushing the start push button.The operator can set the length of time for heating by using the thumbwheelswitches shown in the figure. The value that the operator sets indicates seconds inbinary coded decimal (BCD) format.
Thumbwheels for setting BCD digits
1 0 0 1 0 0 0 1X X X X 0 0 0 1
Oven
HeatQ 4.0
IW0
4 4 4
Start push button I 0.7
7....
IB1IB0 Bytes
Bits7......0 ...0
System Component Absolute Address
Start Push Button I 0.7
Thumbwheel for ones I 1.0 to I 1.3
Thumbwheel for tes I 1.4 to I 1.7
Thumbwheel for hundreds I 0.0 to I 0.3
Heating starts Q 4.0
Programming Examples
Ladder Logic (LAD) for S7-300 and S7-400 ProgrammingB-14 A5E00068865-02
Ladder Logic Program
Network 1: If the timer is running, then turn on the heater.
T1 Q 4.0
Network 2: If the timer is running, the Return instruction ends the processing here.
T1
RET
Network 3: Mask input bits I 0.4 through I 0.7 (that is, reset them to 0). These bitsof the thumbwheel inputs are not used. The 16 bits of the thumbwheel inputs arecombined with W#16#0FFF according to the (Word) And Word instruction. Theresult is loaded into memory word MW1. In order to set the time base of seconds,the preset value is combined with W#16#2000 according to the (Word) Or Wordinstruction, setting bit 13 to 1 and resetting bit 12 to 0.
WAND_W
IN1
ENOEN
IN2
OUT
W#16#FFF
IW0 MW1
WOR_W
IN1
ENOEN
IN2
OUTMW1
W#16#2000
MW2
Network 4: Start timer T1 as an extended pulse timer if the start push button ispressed, loading as a preset value memory word MW2 (derived from the logicabove).
I 0.7
SE
T1
MW2