You are on page 1of 474

ng d on g

d on g
d on g
T u T u T u
A-PDF Watermark Demo. Purchase from www.A-PDF.com to remove the watermark

4 .c om 4 .com
4. c om .
o a2 o a 2 a2 a 24
ngh n gh n g ho Contents
Preface,
ng h o
ud o udo d o
T T Product Overview Tu 1
Getting Started 2
24 .com 24 .com . c o m
2the4 S7-200 3oa24.
o a o a a
Installing
o
ngh SIMATIC
o n gh o n gh on gh
Tud Tu d PLC Concepts T ud 4
Programming Concepts,
S7-200 Programmable Controller Conventions and Features 5
om
4.cSystem Manual 4.co
m
4.co Set
S7-200 Instruction
m
6 24.
2 2 2
ng hoa g hoa g hoa g h oa
u d on donCommunicating over a Networkdon 7
T Tu T u
Hardware Troubleshooting Guide
and Software Debugging Tools 8

4 .c om 4 .co m
Position Module4
m
Creating a Program for the
.co 9
4.
o a2 oa 2 o a 2
hoa 2
ngh gh gh 10
Creating a Program for the
o n o n
Modem Module o ng
Tu d Tu d Tud
Using the USS Protocol Library to 11
Control a MicroMaster Drive
Using the Modbus Protocol 12
4 . c om 4 .c om Library
4 .c om .
2 2 2 24
ng hoa g hoa g h oa Specifications
Technical
ng
A
h o a
ud on don d o
T Tu Tu
Calculating a Power Budget B
Error Codes C
.c o m .com . c o m .
o a24 o a 24
hoa
2 4
Special Memory (SM) Bits Doa24
ngh d o ng h
d o g
nS7-200 o n gh
T u T u Order Numbers
T ud E
Execution Times for STL
Instructions F
4 .c ommanual has the order number:
This
4 . c om 4 . com .
o a2 6ES7298-8FA22-8BH0hoa2 a2
S7-200 Quick Reference
o Goa24
ng h ng n gh
Information
n gh
d o d o ud o
Tu Tu Index
T
Edition 04/2002

4 . om
A5E00157957-01
c 4. c om 4 . com .
2 a2 a2 24
ng hoa n gh o
n gho gh o a
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u

4 .c omGuidelines 4 .co m
4. c om .
o a2
Safety
o a 2 o a2 o a 24
ngh gh gh h
This manual contains notices which you should observe to ensure your own personal safety, as well as to
on on
protect the product and connected equipment. These notices are highlighted in the manual by a warning
on g
ud
triangle and are marked as follows according to the level of danger:
T T ud T u d
Danger
Danger indicates an imminently hazardous situation which, if not avoided, will result in death or serious
injury.

. co m .c o m . c o m
a24 Warning
a 24 a 2 4result in death or serious a2 4.
o ho ho ho
ngh
Warning indicates a potentially hazardous situation which, if not avoided, could
injury.
o n g o n g on g
Caution Tud Tud Tud
Caution used with the safety alert symbol indicates a potentially hazardous situation which, if not
avoided, may result in minor or moderate injury.

.co m Caution .c om . c om
a 2 4 a
Caution used without the safety 2 4 a
alert symbol indicates a potentially hazardous2 4
situation which, if not a 2 4.
o o damage. ho ho
ngh
avoided, may result in h
n g property
n g n g
NoticeTu
do T udo T udo
Notice indicates a potential situation which, if not avoided, may result in an undesirable result or state.

4 .c om Personnel
Qualified
4 . c om 4 . c om 4.
o a 2 a 2 a 2 a 2
ngh n g
defined as persons whohareoauthorized to commission, to ground,nand
Only qualified personnel should
g htootag circuits, equipment, and sys- ngho
be allowed to install and work on this equipment. Qualified persons are

T u do with established safety practices T


tems in accordance
u do
and standards.
T u do
Correct Usage
Note the following:

Warning

. c m
o This device and its components may c
. om be used for the applications described in c
. m or the
omanufacturers 4.
only the catalog

a 2 4 technical descriptions, and


a 2
only 4
in connection with devices or components 2
from
a 4 other
a 2
o hoor recommended o ho
ngh hstored,
which have been approved by Siemens.
o n g o n g o n g
T anddoperated and maintained as recommended. Tud Tud
This product can only function correctly and safely if it is transported, set up, and installed
correctly, u

Trademarks
SIMATICR, SIMATIC HMIR and SIMATIC NETR are registered trademarks of SIEMENS AG.

.c o mSome . c o
of other designations used in these documentsm are also registered trademarks; the owner’s
. c o mmay be violated
rights

a2 4 if they are used by third parties for


a 2 4
their own purposes.
a 2 4 a 2 4.
o ho ho ho
ngh o n g o n g o n g
Tud Tud Tud

.co m .co m . com


a2 4 Copyright Siemens AG 2002 All rights reserved
a 2 4 Disclaimer of Liability
a2 4 a2 4.
o gho o ho
ng h gh ng
The reproduction, transmission or use of this document or its contents is not We have checked the contents of this manual for agreement with the hardware and

don o n o
permitted without express written authority. Offenders will be liable for damages. software described. Since deviations cannot be precluded entirely, we cannot gua-

Tu
All rights, including rights created by patent grant or registration of a utility model
or design, are reserved.
Tu d Tu d
rantee full agreement. However, the data in this manual are reviewed regularly and
any necessary corrections included in subsequent editions. Suggestions for impro-
vement are welcomed.

Siemens AG
Bereich Automation and Drives

4 . com
Geschaeftsgebiet Industrial Automation Systems
Postfach 4848, D- 90327 Nuernberg
4. c om E Siemens AG 2002

4 . com .
24
Technical data subject to change.
2 a2 a2
ng hoa Siemens Aktiengesellschaft

n gh o ho
6ES7298-8FA22-8BH0

n g gh o a
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u

.c om .c om . c om 4.
o a 2 4 Preface ho a 2 4
ho a 2 4
ho a 2
ngh n g n g n g
ofT udo series
The S7-200
automation applications. Compact design, low T udand
is a line of micro-programmable logic
cost,
ocontrollers (Micro PLCs) that can controluadvariety
a powerful instruction set make theT
o
S7-200 a
perfect solution for controlling small applications. The wide variety of S7-200 models and the
Windows-based programming tool give you the flexibility you need to solve your automation problems.

. co m Audience .c o m . c o m
a 24 a 24
This manual provides information a
about installing and programming the2 4
S7-200 Micro PLCs and is a2 4.
o ho programmers, installers, and electricians o have a general knowledge of gho
ngh d o
programmable
g
designed for engineers,
n logic controllers.
d o n ghwho
d on
T u T u T u
Scope of the Manual
The information contained in this manual pertains in particular to the following products:

4 .c om 
4 . c om 4 . c om
S7-200 CPU models: CPU 221, CPU 222, CPU 224, CPU 226, and CPU 226XM
4.
oa 2 S7-200 EM 22x a 2 a 2 a 2
n g h 

STEPn g ho version 3.2, a 32-bit programming


expansion modules
n g ho n g ho

do 7--Micro/WIN Instruction Libraries and
TuSTEP

7--Micro/WIN,
T do for TP070, Version 1.0, a setTof usoftware
software package for the S7-200
uTP-Designer do
tools for customers who use an S7-200 with other components, such as the TP070 Touch Panel,
Modbus, or a MicroMaster drive

4 .c om Standards Compliance4.com 4 . c om 4.
h o a2 h o a2 meets the following standards: hoa2
The SIMATIC S7-200 series
hoa 2
ng do ngCommunity
European
 ng
(CE) Low Voltage Directive 73/23/EEC
d o o ng
TuEuropean Community (CE) EMC DirectiveT89/336/EEC
EN 61131--2:

Programmable Controllers -- u
Equipment requirements
Tud
Electromagnetic emissions standard
EN 50081--1: residential, commercial, and light industry
.co m c om
EN 50081--2: industrial environment
. .c om
a 2 4 Electromagnetica 2 4
immunity standards a 2 4 a 2 4.
o ho industrial environment ho ho
ngh do n g
EN 61000--6--2:
o n g o n g
TuUnderwriters
 Laboratories, Inc.
Tud Registration number E75310 Tud
UL 508 Listed (Industrial Control Equipment)
 Canadian Standards Association: CSA C22.2 Number 142 Certified (Process Control Equipment)
Factory Mutual Research: FM Class I, Division 2, Groups A, B, C, & D Hazardous Locations, T4A
.c o m 

. c o
and Class I, Zone 2, IIC, T4 m . c o m .
o a24 a
Refer to Appendix A for
o 24 information.
compliance
o a 24 oa 24
ngh o n gh o n gh o n gh
Tud Tud Tud

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho g iii
h o
T ud o
T udo Tu don
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

.c m
oMaritime . c om . c om
a 2 4 Approvals
a 2 4 a 2 4 a 2 4.
o oprinted, the SIMATIC S7-200 series metgthehomaritime agencies identifed ho
ngh At the time this manual h
o n
below. For the latest g was
product approvals, contact your local on
Siemens distributor or sales office. o n g
Tud
Agency
Tud Certificate Number
Tud
Lloyds Register of Shipping (LRS) 99 / 20018(E1)

. co m American Bureau of Shipping (ABS)


.c o m 01--HG20020--PDA
. c o m
24 Germanischer Lloyd (GL)
24 12 045 -- 98 HH
a24 2 4.
ng hoa Det Norske Veritas (DNV)
g hoa A--8071
gho ng ho a
Tu don
Bureau Veritas (BV)
Nippon Kaiji Kyokai (NK) Tu do
A--534
n
09051 / A2 BV

Tu d o

How to Use This Manual


.co mIf you are a first-time (novice) user of.S7-200
c omMicro PLCs, you should read the entire . c om
S7-200
.
a 2 4 Programmable Controller System 4
a 2 2 4
Manual. If you are an experienced user, refer to
a the table of contents or
a 2 4
o ho
index to find specific information.
ho ho
ngh do n
The S7-200 Programmable
g n g
do according to the following topics:Tudo
Controller System Manual is organized n g

T u T u
Chapter 1 (Product Overview) provides an overview of some of the features of the S7-200 family of
Micro PLC products.
 Chapter 2 (Getting Started) provides a tutorial for creating and downloading a sample control

4 .c om program to an S7-200.
4 . c om 4 . c om 4.
oa 2 
a 2
Chapter 3 (Installing the S7-200)
a 2
provides the dimensions and basic guidelines for installing the
a 2
ng h S7-200 CPU modules
n g ho and expansion I/O modules. ngho ng ho
4o o operation of the S7-200. o
Tud Tud Tud
 Chapter (PLC Concepts) provides information about the
 Chapter 5 (Programming Concepts, Conventions, and Features) provides information about the
features of STEP 7--Micro/WIN, the program editors and types of instructions (IEC 1131-3 or
SIMATIC), S7-200 data types, and guidelines for creating programs.

.co m 
.co m .co m
Chapter 6 (S7-200 Instruction Set) provides descriptions and examples of programming instructions
.
a 2 4 supported by the S7-200.
a 2 4 a 2 4 a 24
o ho ho o
ngh h
Chapter 7 (Communicating over a Network) provides information for setting up the different network

o n g
configurations supported by the S7-200.
o n g o ng

d
Chapter
d
Tu 8 (Hardware Troubleshooting Guide andTSoftware
u Debugging Tools) provides information
Tu d
for troubleshooting problems with the S7-200 hardware and about the STEP 7--Micro/WIN features
that help you debug your program.
Chapter 9 (Creating a Program for the Position Module) provides information about the instructions
.c o m 
. c o m
and wizard used to create a program for the EM 253 Position module.
. c o m .
o a24 
hoa
24
hoa
24
Chapter 10 (Creating a Program for the Modem Module) provides information about the instructions
oa 24
ngh d on g
d on g
and wizard used to create a program for the EM 241 Modem module.
o n gh

T u T u
Chapter 11 (Using the USS Protocol Library to Control a MicroMaster Drive) provides information
Tud
about the instructions used to create a control program for a MicroMaster drive. It also provides
information about how to configure the MicroMaster 3 and MicroMaster 4 drives.
 Chapter 12 (Using the Modbus Protocol Library) provides information about the instructions used to

4 .c om 4 . om
create a program that uses the Modbus protocol for communications.
c 4 . com 4.
2 2
Appendix A (Technical Specifications) 2
provides the technical information and data sheets about the 2
hoa a a a

S7-200 hardware. o
ng n g h n g ho n g ho
o Special
uofdthe
The other appendices
udforosuch
provide additional reference information,
udo
as descriptions of the error codes,
T
descriptions
instruction execution times.
T
Memory (SM) area, part numbers ordering S7-200 equipment, and STL T

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
iv
n gh n gho gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
Preface

4 .c om 4 .c om 4 . c om 4.
2 Additional Information 2 and Assistance 2 2
o a ho a ho a ho a
ngh n g
do about the S7-200 and STEP
Information n g
d7-o- Micro/WIN do n g
T u T u T u
In addition to this manual, STEP 7--Micro/WIN provides extensive online help for getting started with
programming the S7-200. Included with the purchase of the STEP 7--Micro/WIN software is a free
documentation CD. On this CD you can find application tips, an electronic version of this manual and other
information.
. co m .c o m . c o m
24 24 a24 2 4.
hoa a a
Online Help

ng g ho away! Pressing F1 accesses the n


Help is only a keystroke
n g hoonline help for STEP 7--Micro/WIN. ngho
extensive

u d o topics.
The online help includes useful information about o with programming the S7-200, asudwelloas
getting
u d started
T
many other T T
Electronic Manual
An electronic version of this S7-200 System Manual is available on the documentation CD. You can install

4 .c om .co m .co m
the electronic manual onto your computer so that you can easily access the information in the manual
4 4 .
2 2
while you are working with the STEP 7--Micro/WIN software.
2 24
ng hoa n gh o a
n gh o a
g h o a
u o
Tips and Tricks
d u d o u d on
T
The documentation CD includes Tips and T
Tricks, a set of application examples with sample T
programs.
Reviewing or modifying these examples can help you find efficient or innovative solutions for your own
application. You can also find the most current version of Tips and Tricks on the S7-200 Internet site.

4 .c om 4 .co
Internet: www.siemens.com/S7--200 m
4 .co m
4.
o a2 2
ho a 2
For additional information about Siemens products and services, technical support, frequently asked
oa
questions (FAQs), product updates, or application tips, refer to the following Internet addresses:
hoa 2
ngh 
do n g h
www.ad.siemens.de for general Siemenso n g
d information do n g
TuThis T u T u
Siemens Automation & Drives Internet site includes information about the SIMATIC product line
and other products available from Siemens.
 www.siemens.com/S7--200 for S7-200 product information

.com .co m .co m


The S7-200 Internet site includes frequently asked questions (FAQs), Tips and Tricks (application
.
o a24 o a 2 4
o a 2 4
examples and sample programs), information about newly released products, and product updates
o a 24
ngh gh gh h
or downloads.
o n o n on g
Tud Tu d T u d

.c o m . c o m . c o m .
o a24 hoa
24
hoa
24 oa 24
ngh d on g
d on g o n gh
T u T u Tud

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho g v
h o
T ud o
T udo Tu don
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

.c m
oTechnical .c om S7-200 Products 4.com
a 2 4 Assistance and
a 2 4
Purchasing
a 2 a 2 4.
o o or Distributor ho ho
ngh Local Siemens n g hOffice
Sales
dinoanswering any technical questions, T n g
do on the S7-200 products, or for ordering do n g
T u
For assistance foru
training
T u
S7-200 products, contact your Siemens distributor or sales office. Because your sales representatives are
technically trained and have the most specific knowledge about your operations, process and industry, as
well as about the individual Siemens products that you are using, they can provide the fastest and most
efficient answers to any problems that you might encounter.
. co m . c o m . c o m
a 2 4 Technical Services a 2 4 a 2 4 a2 4.
o o S7-200 Technical Services center is also o to help you solve any ho
ngh do
problems that you n g
The highly trained staff
might
h
of the
encounter. You can call on them 24
do n
hours
ga
havailable
day, 7 days a week:
don g
T u T u
For calls originating from within the United States of America

T u
Local time: Monday to Friday 0800 to 1900 Eastern time
Telephone: +1 800 241--4453
Fax: +1 (0) 770 740--3699
.co m E-Mail: c om
drives.support@sea.siemens.com
. . c om .
a 2 4 a 4
2the Americas outside of the USA a 2 4 a 24
o 
o
For calls originating from
o o
ngh d o
Telephone:
h
ng Monday
Local time: to Friday 0800 to 1900 Eastern g
+1 (0) 770 740--3505
d o ntimeh
d on g h
TuFax:
E-Mail:
+1 (0) 770 740--3699 Tu
drives.support@sea.siemens.com
T u
 For calls originating from Europe and Africa
Local time (Nuremberg): Monday to Friday 0700 to 1700

4 .c om Telephone:
.co m
+49 (0) 180 5050--222
4 4 .co m
4.
o a2 Fax:
E-Mail: oa 2
+49 (0) 180 5050--223
techsupport@ad.siemens.de o a 2
hoa 2
ngh o ngh
For calls originating from Asia and Australia
d d o n gh o ng
Tud

Tu Local time (Singapore):
Telephone:
Tu
Monday to Friday 0830 to 1730
+65 (0) 740--7000
Fax: +65 (0) 740--7001
E-Mail: drives.support@sae.siemens.com.sg

.co m .co m .co m .


a 2 4 a 2 4 a 2 4 a 24
o o o o
ngh o n gh o n gh on g h
Tud Tu d T u d

.c o m . c o m . c o m .
o a24 hoa
24
hoa
24 oa 24
ngh d on g
d on g o n gh
T u T u Tud

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
vi
n gh n gho g h o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u

.c om . c om . c om 4.
o a 2 4 Contents ho a 2 4
ho a 2 4
ho a 2
ngh on g o n g o n g
1
TudOverview . . . . . . . . . . . . . . . . . . . . .T. .u. .d. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .T. .u. .d 1
Product
S7-200 CPU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
S7-200 Expansion Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

.com .com om
STEP 7--Micro/WIN Programming Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
4 Communications Options . 4 ...
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4
c 4.
h o a2 ..o
Display Panels . h
a 2
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .h. .o
a 2 ....................
.............................
4
4 ho
a2
n g o n g o n g on g
2
Tu
Gettingd Started . . . . . . . . . . . . . . . . . . . . . . .
Tu
. . . . .d. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Tu 6
. . . . .d 5
Connecting the S7-200 CPU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Creating a Sample Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

.co m .co m .co m


Downloading the Sample Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
.
a 2 4 a 2 4 a 2 4
Placing the S7-200 in RUN Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
a 24
o ho ho o
ngh 3
d o g
. .d
o n g
Installing the S7-200 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
n o
13g
n
. .d 14
h
u
Guidelines
T for Installing S7-200 Devices . . . . . . . .u
T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .u
T
Installing and Removing the S7-200 Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Guidelines for Grounding and Wiring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

.c om4
. c o m . c o m
PLC Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21

a 24 a 2 4 Executes Your Control Logic . . . . . .a. .2. .4. . . . . . . . . . . . . . . . . . . . . . 22


Understanding How the S7-200
a 2 4.
o hoof the S7-200 . . . . . . . . . . . . . . . . . . . . n o o
ngh Accessing the g
n Data
do How the S7-200 Saves and Restores
. .h
. . .g ...............................
n24gh
o . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .u. .do 34
dData
T u
Understanding
T u
Storing Your Program on a Memory Cartridge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .T ..... 36
Selecting the Operating Mode for the S7-200 CPU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Using Your Program to Save V Memory to the EEPROM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

4 .com Features of the S7-200 . . . . . . .c


4
m m
. . .o. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2. .4. . .. .c. .o. . . . . . . . . . . . . . . . 39 4.
h o a2 5
ho
Programming Concepts, a 2 Conventions, and Features .
ho
. . . . a
. . . . . . . . . . . . . . . . . . . . . . . . 47
ho a 2
n g n g n g n g
dofor Designing
Guidelines
TuElements
Basic
a Micro PLC System . . . . .d
of a Program . . . . . . . . . . . . . . . T
u . . o. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. .. ..u.. ..do4849
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .T
Using STEP 7--Micro/WIN to Create Your Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Choosing Between the SIMATIC and IEC 1131--3 Instruction Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

.c o m . c o m . c o m
Understanding the Conventions Used by the Program Editors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

a24 Using Wizards To Help You


a 2 4
Create Your Control Program . . . . . . . . . .
a . .2. . 4
. . . . . . . . . . . . . . . . . . . . . . 56
a 2 4.
o o S7-200 . . . . . . . . . . . . . . . . . . . . . . . . . .g. .h. . o. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56gho
ngh d
g
Handling Errors
n inhthe
oAddresses and Initial Values in the DatauBlock
Assigning d n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .don58
oEditor
u
T the Symbol Table for Symbolic AddressingTof Variables . . . . . . . . . . . . . . . . . . . . . . . . . . .T. . .u. . 58
Using
Using Local Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Using the Status Chart to Monitor Your Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

.co m . c om . com
Creating an Instruction Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
60

a2 4 a 2 4
Features for Debugging Your Program . . . . . . . . . . . . . . . . . . . . . . . . . . . .2
a 4
........................ 60
a2 4.
o ho ho ho
ng h o n g o n g on g
Tud Tud Tud

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho vii
g h o
T ud o
T udo Tu don
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

4 6c
. om
S7-200 Instruction Set . . . . . . 4 . . .. c
om
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4 . . .. c
om
............ 61 4.
o a 2 a 2 a 2 a 2
ngh Conventions Used tog
n ho the Instructions . . . . . . . . . . . . . . .n. . g. . .h. .o. . . . . . . . . . . . . . . . . . . . . . . 63 ngho
Describe
S7-200 Memory
T u doRanges and Features . . . . . . . . . . . . .T. . u. . d . . .o................................
T u do
64
Bit Logic Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Contacts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Coils . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68

. co m .c o m . c o m
Logic Stack Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
24 24 a24
Set and Reset Dominant Bistable Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 2 4.
ng hoa g hoa g ho ng
Clock Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
n n 73 ho a
d o
Communications . . .o
Instructions . . . . . . . . . . . . . . . . . . . . . . . . . d ................................ d
74 o
Tu Read and Network Write Instructions . . .T. . u. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Tu74
Network
Transmit and Receive Instructions (Freeport) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Get Port Address and Set Port Address Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88

.co m .co m .co m


Compare Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
.
a 2 4 a 2 4 a 2 4
Comparing Numerical Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
a 24
o o o o
ngh gh gh h
Compare String . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
o n o n on g
u d u d u d
Conversion Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
T Conversion Instructions . . . . . . . . . . . . .T. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T 92
Standard
92

ASCII Conversion Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96


String Conversion Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100

4 .c om 4 . c om
Encode and Decode Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4
Counter Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . c om 105
106 4.
o a2 a 2 a 2
ho . . . . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..n.. .. g.. .. ..h.. ..o.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 106 hoa 2
ngh
SIMATIC Counter Instructions
n g ng
do Instructions . . . . . . . . . . . . . . . . . .T. . u. . d
IEC Counter
TuCounter
High-Speed
Instructions o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Tu
do
109
111
Pulse Output Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
Math Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140

4 . c om 4 . om
Add, Subtract, Multiply, and Divide Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
c 4 .c om 140
.
2 Multiply Integer to Double Integer and Divide Integer with Remainder . . . . . . . . . . . . . . . . . . . . . .
2 2 142
24
ng hoa g hoa g hoa
Numeric Functions Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
g h o a
ud on u d on
Increment and Decrement Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
u
144
d on
T T
Proportional/Integral/Derivative (PID) Loop Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Interrupt Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
T 145
155
Logical Operations Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162

.c o m . c m . c o m
Invert Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o 162
.
a24 24 24 24
AND, OR, and Exclusive OR Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163

ngh
o hoa hoa
Move Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
g g
165
gh oa
d on d on
Move Byte, Word, Double Word, or Real . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
o n
T u T u
Move Byte Immediate (Read and Write) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Block Move Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Tud166
167
Program Control Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
Conditional End . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168

4 .c om 4 . c om 4 . com
Stop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
4.
2 2 2 2
hoa a hoa a
Watchdog Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168

ng on gho on g
For--Next Loop Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
ong ho
u d u d
Jump Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
T T Tu d
172
Sequence Control Relay (SCR) Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
viii
n gh n gho g h o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
Contents

4 .c om 4 .co m
4. c om .
oa2
Shift and Rotate Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o a 2 o a2
179
o a 24
ngh gh gh h
Shift Right and Shift Left Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
on on
Rotate Right and Rotate Left Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . on 179 g
T ud T ud T
Shift Register Bit Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . u d 181
Swap Bytes Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
String Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184

. co m c m
. . ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
... c o m
Table Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o 189

a24 Add To Table . . . . . . . . 4


a 2 a 2 .................... 189
a2 4.
o h. . o
First-In-First-Out and Last-In-First-Out . . . . . . . . . . . . . . . . .
ho
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
ho
ngh MemorynFillg .................................n . . .g................................. n
192
doFind . . . . . . . . . . . . . . . . . . . . . . . . . . .T. . .u. .d. . o. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .T. . .u. .do193
g
T uTable
Timer Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
SIMATIC Timer Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
IEC Timer Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
.co m .co m .co m
Subroutine Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 .
a 2 4 a 2 4 a 2 4 a 24
o ho ho o
ngh h
7 Communicating over a Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
207
o n g o n g . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .do
ng
d
Understanding d
the Basics of S7-200 Network Communications
Tu the Communications Protocol for YourTNetwork
208
u . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .T. . .u. . 211
Selecting
Installing and Removing Communications Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
Building Your Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218

4 .c om Creating User-Defined Protocolscwith


4 . om Freeport Mode . . . . . . . . . . . . . . . . . . . . .c
4 . . .o. .m.............. 222
4.
o a 2 Using Modems and STEP a 2 7--Micro/WIN with Your Network . . . . . . . a
. . .2. . . . . . . . . . . . . . . . . . . . . . . . 224 a 2
ngh n g
Advanced Topics h. o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .g
n . .h
o
............................... 228gh
n
o
o o o
8 Tud Troubleshooting Guide and Software
Hardware Tud Debugging Tools . . . . . . . . . . . . .T. .u. .d 235
Features for Debugging Your Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
Displaying the Program Status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238

.co m .co m .co


Using a Status Chart to Monitor and Modify the Data in the S7-200 . . . . . . . . . . . . . . . . . . . . . . . . . . . . m 239
.
a 2 4 a 2 4 a 2 4
Forcing Specific Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
a 24
o ho ho o
ngh d
Hardwareo g
Troubleshooting Guide . . . . . . . . . . . . . . . .d. . o
. . . . .
g
Running Your Program for a Specified Number of Scans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
n n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .d o ng
240
241
h
9
Tu Tu
Creating a Program for the Position Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
Tu
Features of the Position Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244

.c o m . c m . c o m
Configuring the Position Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o 246
.
o a24 24 24
a Position Module . . . . . . . . . . . . . . . . . .h. . o. . .a. . . . . . . . . . . . . . . . . . . . . . . . . . 269 hoa24
Position Instructions Created by the Motion Control Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o
257

ngh
Sample Programshfor the
o
Monitoring
d ngPosition Module with the EM 253 Control
the
d o ng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .do274
Panel ng
TuCodes for the Position Module and the Position
Error Tu Instructions . . . . . . . . . . . . . . . . . . . . . . . .T. . .u. . 276
Advanced Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho g ix
h o
T ud o
T udo Tu don
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

4 .c
10
om
Creating a Program for the Modem4 . c m
oModule . . . . . . . . . . . . . . . . . . . . . . .4 . . .. c
om
. . . . . . . . . . . . 287 4.
o a 2 a 2 a 2
o . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . g. . .h. .o. . . . . . . . . . . . . . . . . . . . . . . 288 gho a 2
ngh d
Using the Modem
g
Features of the Modem
n hModule
o Expansion Wizard to Configure the Modem d n . . . . . . . . . . . . . . . . . . . . . . . . . 294don
oModule
Overview
u u
Tof Modem Instructions and Restrictions . . .T. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Tu298
Instructions for the Modem Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
Sample Program for the Modem Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303

. co mS7-200 CPUs that Support Intelligent.Modules c o m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...c. .o. . m ......... 303

a 2 4 Special Memory Location fora the2 4


Modem Module . . . . . . . . . . . . . . . . . . . . . . a ..2 4
................... 304 a2 4.
o o o ho
ngh n . . .h
Advanced Topics . . g
do Number Format . . . . . . . . . . . . .T. . u. . d . . .o
n . . .h
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .g ......................... 306
don g
T u
Messaging Telephone ................................
Text Message Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
T u
308
309
CPU Data Transfer Message Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310

11 m Using the USS Protocol Library to Control m a MicroMaster Drive . . . . . . .. c. . o. . m . . . . . . . . 311


4 .c o . c o
4 . . . . . . . . . . . . . . . . . . . . . . . . . . . .a. . 2. . .4. . . . . . . . . . . . . . . . 312 4.
o a 2 Requirements for Using the USS
a 2 Protocol
a 2
ngh g ho for Communicating with the Driven. g. . .h. .o. . . . . . . . . . . . . . . . . . . . . . . 313 ngho
Calculating the Time Required
n
Using the USS
u o
dInstructions ...........................d
u . . .o................................ do
314
u
T T
Instructions for the USS Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T 315
Sample Programs for the USS Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
USS Execution Error Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323

4 .c omConnecting and Setting Up the MicroMaster


4 . c omSeries 3 Drive . . . . . . . . . . . . . . . . . .4. ...c. .o. . m ......... 324
4.
o a 2 Connecting and Setting Up the 2
a MicroMaster Series 4 Drive . . . . . . . . . . . . . . . 2
a ................... 327
a 2
ngh 12 Using the Modbus n g ho
Protocol Library . . . . . . . . . . . . . . . . . .n . .g
ho
. . . . . . . . . . . . . . . . . . . . . . . . . 329 ng
ho
o o do
Tudfor Using the Modbus Protocol . . . . . . .T. . u. . d
Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Tu
330
Initialization and Execution Time for the Modbus Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330
Modbus Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331

.co m .co m .co


Using the Modbus Slave Protocol Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . m 332
.
a 2 4 a 2 4 a 2 4
Instructions for the Modbus Slave Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
a 24
o ho ho o
ngh A
d o n g
d o n g
Technical Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
d o ng h
GeneralT u Specifications . . . . . . . . . . . . . . . . . .T. . u. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Tu338
Technical
CPU Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
Digital Expansion Modules Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346

c o mAnalog Expansion Modules Specifications .m


c o .......................................m
c o ......... 351

a2 4. Thermocouple and RTD Expansion


a 2 . Specifications . . . . . . . . . . . . . . . 2. . .4. ... . . . . . . . . . . . . . 361
4Modules a a 2 4.
o o ho ho
ngh ghSpecifications
EM 277 PROFIBUS--DP Module Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373
EM 241 Modemo n
Module . . . . . . . . . . . . . . . . . . . .o. .n. .g............................ 385 ong
EM 253T ud Module Specifications . . . . . . . . . . . .T. . u. . d
Position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Tu
d
387
AS--Interface (CP 243--2) Module Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
Optional Cartridges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395

.co mI/O Expansion Cable . . . . . . . . . . . . ... c. . o. . .m .......................................m


o. . . . . . . . . 395
4 PC/PPI Cable . . . . . . . . . . . . . . . . .4 . ...c
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4 ............. 396 4.
o a2 . .o a 2 . .o a 2 a2
ng h
Input Simulators . . . . . .h
n g . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .h
n g ....................... 398
n g ho
o Budget . . . . . . . . . . . . . . . . . . .u. .d. .o. . . . . . . . . . . . . . . . . . . . . . . . . . . . . u
Calculating adPower o
B
Tu T T399d

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
x
n gh n gho gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
Contents

4 .c om 4 .co m
4. c om .
o a2
C Error Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
a 2 a2
403
a 24
ngh n g ho n g ho
Fatal Error Codes and Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404g
n h o
u d
Run-TimeoProgramming Problems . . . . . . . . . . . . .
u . .d. . o
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
u . .d o405
T Rule Violations . . . . . . . . . . . . . . . . . . .T. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .T. . . . . 406
Compile

D Special Memory (SM) Bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407

. co m . c o m . c o m
SMB0: Status Bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
408

a 24 a . .4
SMB1: Status Bits . . . . .2
a . .4
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2 ...................... 408
a2 4.
o ho Character . . . . . . . . . . . . . . . . . . .n. .g. .h. . o. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409 ho
ngh
SMB2: Freeport Receive
n g
o Parity Error . . . . . . . . . . . . . . . . . . . . . . . o. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . o409 n g
TudQueue Overflow . . . . . . . . . . . . . . . . . . . .T. . .u. .d. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .T. . .u. .d 409
SMB3: Freeport
SMB4:
SMB5: I/O Status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410
SMB6: CPU ID Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410

4 .c om 4 . om 4 . c om
SMB7: Reserved . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
c 410
4.
oa 2 a 2
SMB8 to SMB21: I/O Module ID and Error Registers . . . . . . . . . . . . . . . .2
a ........................ 411
a 2
n g h g hoScan Times . . . . . . . . . . . . . . . . . . . . . .n. .g. .h. . o. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412
SMW22 to SMW26:
n n g ho
o SMB29: Analog Adjustment . . . . . . . .u. .d. . o. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .u. .do412
SMB28dand
u
T
SMB30 and SMB130: Freeport Control Registers T. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .T. . . . . 412
SMB31 and SMW32: Permanent Memory (EEPROM) Write Control . . . . . . . . . . . . . . . . . . . . . . . . . . . 413
SMB34 and SMB35: Time Interval Registers for Timed Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413

4 .c om 4 .com 4 .com
SMB36 to SMB65: HSC0, HSC1, and HSC2 Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413
4.
o a 2 a
SMB66 to SMB85: PTO/PWM2 Registers . . . . . . . . . . . . . . . . . . . . . . . . . .2
o SMB186 to SMB194: Receive Message a ........................
o . . . . . . . . . . . . . . . . . . . . . . . 416gho 415
a 2
ngh d
SMW98:
n g
SMB86 to SMB94, hand n g hControl n
oErrors on the Expansion I/O Bus . . . . . . .u. .d. . o. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .u. .do417
T u T T
SMB130: Freeport Control Register (see SMB30) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417
SMB131 to SMB165: HSC3, HSC4, and HSC5 Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417
SMB166 to SMB185: PTO0, PTO1 Profile Definition Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418

.co m . c om . c om
SMB186 to SMB194: Receive Message Control (see SMB86 to SMB94) . . . . . . . . . . . . . . . . . . . . . . . 418

a 2 4 a 2 4
SMB200 to SMB549: Intelligent Module Status . . . . . . . . . . . . . . . . . . .a . .2 4
........................ 419 a 2 4.
o ho ho ho
ngh E n
S7-200 Order g . .g
Numbers . . . . . . . . . . . . . . . . . . . . . . . . .n n
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421g
T udo T udo T udo
F Execution Times for STL Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425

G S7-200 Quick Reference Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431

.c o m . c o m . c o m
a2 4 Index . . . . . . . . . . . . . . . . . . .a. .2. . 4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . a. . 2. . 4. . . . . . . . . . . . . . . . . . . . 437 a 2 4.
o ho ho ho
ngh o n g o n g o n g
Tud Tud Tud

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho g xi
h o
T ud o
T udo Tu don
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

4 .c om 4 .co m
4. c om .
oa2 o a 2 o a2 o a 24
ngh on gh on gh on g h
T ud T ud T u d

. co m .c o m . c o m
24 24 a24 2 4.
ng hoa g hoa gho ng ho a
Tu don Tu do n
Tu d o

.co m .co m .co m .


a 2 4 a 2 4 a 2 4 a 24
o o o o
ngh d o n gh
d o n gh
d on g h
Tu Tu T u

4 .c om 4 .co m
4 .co m
4.
o a2 oa 2 o a 2
hoa 2
ngh do ngh
d o n gh o ng
Tu Tu Tud

.co m .co m .com .


a 2 4 a 2 4 a 2 4 a 24
o o o o
ngh o n gh o n gh on g h
Tud Tu d T u d

.c o m . c o m . c o m .
o a24 hoa
24
hoa
24 oa 24
ngh d on g
d on g o n gh
T u T u Tud

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
xii
n gh n gho gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u

4 .c om 4 .c om 4 . c om 4.
o a 2 Product Overview a 2 a 2 a 2
ngh n g ho n g ho n g ho
do
TuS7-200 udo Tudof
o
The series of micro-programmable logicT
controllers (Micro PLCs) can control a wide variety
devices to support your automation needs.

The S7-200 monitors inputs and changes outputs as controlled by the user program, which can include

. co m o m
Boolean logic, counting, timing, complex math operations, and communications with other intelligent
.c . c o m
24 24
devices. The compact design, flexible configuration, and powerful instruction set combine to make the
a24 2 4.
hoa hoa ho ho a
S7-200 a perfect solution for controlling a wide variety of applications.

ng don
g
do n g
d ong
u
In ThisTChapter Tu Tu
S7-200 CPU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

4 .c om 4 . om 4 . c om
S7-200 Expansion Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
c
3
.
2 STEP 7–Micro/WIN Programming Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2 2 3
24
ng hoa g hoa g hoa
Communications Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
g h o a
u d on u d on u d on
Display Panels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

T T T

4 .c om 4 .co m
4 .co m
4.
o a2 oa 2 o a 2
hoa 2
ngh do ngh
d o n gh o ng
Tu Tu Tud

.co m .co m .co m .


a 2 4 a 2 4 a 2 4 a 24
o o o o
ngh o n gh o n gh on g h
Tud Tu d T u d

.c o m . c o m . c o m .
o a24 hoa
24
hoa
24 oa 24
ngh d on g
d on g o n gh
T u T u Tud

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 1
g h o
T ud o
T udo Tu don
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

4 .c om 4 .c om 4 . c om 4.
o1a 2 S7-200 CPU
a 2 a 2 a 2
ngh n g hoa microprocessor, an integrated power n g ho input circuits, and output n g ho
o housing to create a powerful Micro u
The S7-200 CPU combines
doSee Figure 1-1. After you have downloaded
supply,
o
Tudthe S7-200
circuits in a compact
your program, contains the logic required T
PLC.
Tud
to monitor and control the input and output devices
in your application.

. co m I/O LEDs
.c o m Access door:
. c o m
4.
Status LEDs:
24 24 a24
Mode selector switch (RUN/STOP)
System Fault
2
hoa hoa a
Analog adjustment potentiometer(s)

ng
RUN
g gho Expansion port (for most CPUs)
ng ho
don n
STOP

Tu
Optional cartridge:
Tu do Terminal connector Tu d o
EEPROM (removable on CPU 224, CPU 226
Real-time Clock and CPU 226XM)
Battery

.co m .co m .co m .


a 2 4 Communications port
a 2 4 a 2 4
Clip for installation on a standard (DIN) rail
a 24
o o o o
ngh gh gh g h
Figure 1-1 S7-200 Micro PLC

d o n d o n d on
Tu Tu
Siemens provides different S7-200 CPU models with a diversity of features and capabilities that help you T u
create effective solutions for your varied applications. Table 1-1 briefly compares some of the features of
the CPU. For detailed information about a specific CPU, see Appendix A.

4 .c omTable 1-1 4 . c om
Comparison of the S7-200 CPU Models
4 . c om 4.
o a2 CPUo a 2 a
hoCPU
2
hoa 2
ngh ÑÑÑÑÑÑ
h 221
udo 2048 words ÑÑÑÑÑ ÑÑÑÑÑ o ÑÑÑÑÑÑ ÑÑÑÑÑ
Feature CPU 222 CPU 224 226 CPU 226XM
Physical size (mm) ng 120.5 x 80n g ng
90 x 80 x 62 90 x 80 x 62
udwords
x 62 190 x 80 x 62 190 x 80 x 62
do
ÑÑÑÑÑÑ T
Program memory
ÑÑÑÑÑ
2048 words
ÑÑÑÑÑ
T4096
ÑÑÑÑÑÑ
4096 words
ÑÑÑÑÑ
8192 wordsTu

ÑÑÑÑÑÑ
ÑÑÑÑÑÑ
Data memory
ÑÑÑÑÑ
ÑÑÑÑÑ ÑÑÑÑÑ ÑÑÑÑÑÑ
1024 words
ÑÑÑÑÑ
1024 words 2560 words 2560 words 5120 words

m ÑÑÑÑÑ ÑÑÑÑÑÑ ÑÑÑÑÑ


Memory backup 50 hours typical 50 hours typical 190 hours typical 190 hours typical 190 hours typical

. c o ÑÑÑÑÑÑ
m
ÑÑÑÑÑ
.c o
Local on-board I/O
ÑÑÑÑÑ ÑÑÑÑÑÑ
6 In/4 Out
.c ÑÑÑÑÑ
o m8 In/6 Out 14 In/10 Out
4.
24 In/16 Out 24 In/16 Out

o a 2 4
ÑÑÑÑÑÑ
ÑÑÑÑÑÑ
a 2 4
ÑÑÑÑÑ
Expansion modules

ho
ÑÑÑÑÑ
ÑÑÑÑÑ
ÑÑÑÑÑ
0
ÑÑÑÑÑÑ
ho a 2 4
ÑÑÑÑÑ
2

ho a 2 7 7 7

ngh do ÑÑÑÑÑÑ ÑÑÑÑÑ


g
High-speed counters
n n g n g
do do
ÑÑÑÑÑÑ ÑÑÑÑÑ ÑÑÑÑÑÑÑÑÑÑÑ ÑÑÑÑÑ
Single phase 4 at 30 kHz 4 at 30 kHz 6 at 30 kHz 6 at 30 kHz 6 at 30 kHz

T u Two phase
T u 2 at 20 kHz
T u
2 at 20 kHz 4 at 20 kHz 4 at 20 kHz 4 at 20 kHz

ÑÑÑÑÑÑ
ÑÑÑÑÑÑ ÑÑÑÑÑ
Pulse outputs (DC)

ÑÑÑÑÑ
Analog adjustments ÑÑÑÑÑ
ÑÑÑÑÑ 1 ÑÑÑÑÑÑ
2 at 20 kHz

ÑÑÑÑÑÑ ÑÑÑÑÑ
2 at 20 kHz

ÑÑÑÑÑ
1
2 at 20 kHz
2
2 at 20 kHz
2
2 at 20 kHz
2

.c o m Real-time clock Cartridge


. c o m
Cartridge Built-in Built-in
c o m
Built-in
. 2 RS–485
a2 4 Communications 1 RS–485
a 2 4 1 RS–485 1 RS–485 2
a 4
RS–485
2 a 2 4.
o ports
ho ho ho
ngh Floating-point math g
n Yes
n g n g
T udosize 256 (128 in, 128 out)
Digital I/O image
T udo T udo
Boolean execution 0.37 microseconds/instruction
speed

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
2
n gh n gho gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
Product Overview Chapter 1

4 .c om 4 . c om 4 . c om 4.
o a 2 S7-200 Expansion 2
Modules
a a 2 a 2
ngh n g hoapplication requirements, the S7-200 nfamily
g o a wide variety of expansion gho1
hincludes
u d
modules. oYou can use these expansion modules touadd
To better solve your
d oadditional functionality to the S7-200 CPU.
u d on
T 1-2 provides a list of the expansion modules
Table T that are currently available. For detailed information
T
about a specific module, see Appendix A.

Table 1-2 S7-200 Expansion Modules

. co m .c o m . c o m
a 24
Expansion Modules
a 2 48 x DC In
Types
a 2 4 a2 4.
o Discrete modules
hoOutput 8 x DC Out
Input 8 x AC In
ho ho
ngh n g n g
8 x AC Out 8 x Relay
o Combination 4 x DC In / 4 x DC Outud8 ox DC In / 8 x DC Out 16 x DC In / 16 x DC uOutdon g
Tud T 8 x DC In / 8 x Relay 16 x DC In / 16 x Relay
4 x DC In / 4 x Relay T
Analog modules Input 4 x Analog In 4 x Thermocouple In 2 x RTD In
Output 2 x Analog Out

.co m .c om
Combination 4 x Analog In / 1 Analog Out
. c om .
a 2 4 Intelligent modules
a2 4Position Modem
a2 4 PROFIBUS-DP
a 24
o o o o
ngh gh gh g h
Other modules AS–Interface

d o n d o n d on
Tu Tu T u
STEP 7–Micro/WIN Programming Package
The STEP 7–Micro/WIN programming package provides a user-friendly environment to develop, edit, and

4 .c om .co m .co m
monitor the logic needed to control your application. STEP 7–Micro/WIN provides three program editors
4 4 4.
2 2 2
for convenience and efficiency in developing the control program for your application. To help you find the
2
ng hoa ngh oa
n gh o a
information you need, STEP 7–Micro/WIN provides an extensive online help system and a documentation
CD that contains an electronic version of this manual, application tips, and other useful information.
ng hoa
do d o o
Tu
Computer Requirements Tu Tud
STEP 7–Micro/WIN runs on either a personal computer or a Siemens programming device, such as a
PG 760. Your computer or programming device should meet the following minimum requirements:

.co m - .co m .co m .


a 2 4 Operating system:
a 2 4
Windows 95, Windows 98, Windows 2000,
a 2 4 a 24
o ho ho o
ngh g g g h
Windows Me (Millennium Edition), or
o n
Windows NT 4.0 (or later version) o n on
T-uAtdleast 50M bytes of free hard disk spaceTud T u d
- Mouse (recommended)

.c o m . c o m . c o m .
o a24 hoa
24
hoa
24 oa 24
ngh d on g
d on g o n gh
T u T u Tud
Figure 1-2 STEP 7–Micro/WIN

4 .c om 4 . c om 4 . com 4.
2 2 a2 2
ng hoa gho
a
gh o
ng ho a
Tu don Tu d o n
Tu d o

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho g 3
h o
T ud o
T udo Tu don
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

.c m
oInstalling .c om . c om
a 2 4 STEP 2
7–Micro/WIN
a 4 a 2 4 a 2 4.
o1 hoyouCDthrough htootheThe ho
ngh o n g
Insert the STEP 7–Micro/WIN
o n g
into the CD-ROM drive of your computer. installation wizard starts
o n g
T d installing STEP 7–Micro/WIN. Tud Tud
automatically and prompts the installation process. Refer Readme file for more
informationuabout

Tip
To install STEP 7–Micro/WIN on a Windows NT or Windows 2000 operating system, you must log in

. co m with Administrator privileges.


.c o m . c o m
24 24 a24 2 4.
ng hoa Communications Options
n g ho a
n gho n g ho a
T u do two programming options for connecting
Siemens provides
T u dyouro computer to your S7-200: a direct Tudo
connection with a PC/PPI cable, or a Communications Processor (CP) card with an MPI cable for MPI and
PROFIBUS–DP networks.

.c o m .c omthe communications port of the S7-200


The PC/PPI programming cable is the most common and economical method of connecting your
computer to the S7-200. This cable connects
. ctoo mserial
the
.
a 2 4 communications of your computer.4
a 2 The PC/PPI programming cable can also be 4
a 2 used to connect other
a 2 4
o hothe S7-200. ho ho
ngh
communications devices to

To use the MPI o n g n g n g


ud cable,
Trequired
hardware to connect at higher baud rates and
do high-speed
you must also install a CP card in your computer.
Ttouhandle Tud
The CP card provides the extra
network communications.
o
Display Panels
c m
oTD om om
4 . 200 Text Display Unit 4.c 4 . c 4.
o a 2 o a 2 a 2 a 2
ngh
The TD 200 is a 2-line, h
n g 20-character,
g ho to the S7-200. Using the ngho
text display device that can be connected
n
o
TD 200 wizard, you can
o
easily program your S7-200 to display text messages and other data pertaining to
o
Tud
your application.
Tud Tud
The TD 200 provides a low cost interface to your
application by allowing you to view, monitor, and
change the process variables pertaining to your

.co m application.
. c om .co m .
a 2 4 A separate manual describesathe 4
2 detailed a 2 4 a 24
o o o o
ngh g h
functionality and specifications
o n of the TD 200.
o n gh on g h
Tud Tu d T u d
Figure 1-3 TD 200 Text Display Unit

.c o m Touch Panel Display .com


TP070
. c o m .
a24 a 4device that
2This 24 24
hoa a
The TP070 is a touch panel display
o o o
ngh g ha means to customize g gh
can be connected to the S7-200. touch
o n
panel provides you with
on o n
Tudinterface.
your operator
T u d Tud
The TP070 can display custom graphics, slider
bars, application variables, custom user buttons,
and so forth, by means of a user-friendly touch

.co m panel.
. c om . c om
a2 4 4
2 Version
asoftware,
The optional TP–Designer for TP070, 1.0
a2 4 a2 4.
o o o ho
ng h h
ng your TP070. ng h ng
CD provides the TP Designer which is
o
required for programming
d d o d o
Tu Tu1-4 TP070 Touch Panel Unit
Figure Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
4
n gh n gho gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u

4 .c om 4 .c om 4 . c om 4.
o a 2 Getting Started a 2 a 2 a 2
ngh n g ho n g ho n g ho
do
Tu7–Micro/WIN
o
Tudyour S7-200. In just a few short steps using
o
Tuadsimple
STEP makes it easy for you to program
example, you can learn how to connect, program, and run your S7-200.

All you need for this example is a PC/PPI cable, an S7-200 CPU, and a programming device running the

. co m STEP 7–Micro/WIN programming software.


.c o m . c o m
24 24 a24 2 4.
ng hoa hoa ho ho a
ong
In This Chapter
d do n g
d ong
Tu the S7-200 CPU . . . . . . . . . . . . . . .T. . .u. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .T. . .u. . 6
Connecting
Creating a Sample Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Downloading the Sample Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

4 .c om 4 .c om .com
Placing the S7-200 in RUN Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
.
hoa
2
hoa
2 o a24 o a 24
ng g gh g h
Tu don Tu d o n
T u d on

4 .c om 4 .co m
4 .co m
4.
o a2 oa 2 o a 2
hoa 2
ngh do ngh
d o n gh o ng
Tu Tu Tud

.co m .co m .co m .


a 2 4 a 2 4 a 2 4 a 24
o o o o
ngh o n gh o n gh on g h
Tud Tu d T u d

.c o m . c o m . c o m .
o a24 hoa
24
hoa
24 oa 24
ngh d on g
d on g o n gh
T u T u Tud

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 5
g h o
T ud o
T udo Tu don
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

4 .c om 4 . c om 4 . c om 4.
o a 2 Connecting the S7-200
a 2
CPU
a 2 a 2
ngh n g hisoeasy. For this example, you only needntogconnect
ho power to your S7-200 CPU ngho
udothe communications cable betweenTyourudprogramming
o device and the S7-200 CPU. do
Connecting your S7-200

2
and then connect
T Tu
Connecting Power to the S7-200 CPU
The first step is to connect the S7-200 to a power source. Figure 2-1 shows the wiring connections for

. co meither a DC or an AC model of the S7-200


. c o m
CPU.
. c o m
a 2 4 Before you install or remove a 2 4
electrical device, ensure that the power toa 2 4 a2 4.
o o any
hopower to the S7-200 is disabled ngho
that equipment has been

ngh turned off. Always followhappropriate


n g n g
safety precautions and ensure that

udo udo udo


before attempting to install or remove the S7-200.

Warning
T T T
Attempts to install or wire the S7-200 or related equipment with power applied could cause electric
shock or faulty operation of equipment. Failure to disable all power to the S7-200 and related equipment

.co m om om
during installation or removal procedures could result in death or serious injury to personnel, and/or
.c . c
a 2 4 damage to equipment.
a 4
2precautions and ensure that power to thea 2 4 a 2 4.
o Always follow appropriateo safety o S7-200 is disabled before
ho
ngh o n or h
attempting to install g remove the S7-200 or related equipment. gh
o n o n g
Tud 24 VDC
Tud 85 to 265 VAC
Tud

4 .c om 4 .co m
4 .co m
4.
o a2 DC Installation
oa 2 AC Installation
o a 2
hoa 2
ngh do ngh
d o n gh o ng
Tu Tu Tud
Figure 2-1 Connecting Power to the S7-200 CPU

.co m .co m .co m .


o a24 ho a 2 4
ho a 2 4
o a 24
ngh g
Connecting the PC/PPI Cable
n n g on g h
S7-200T
udo a PC/PPI cable connecting the Tudo
Figure 2-2 shows
to the programming device. To connect
Programming T u d
Device
the PC/PPI cable:

1. Connect the RS-232 connector (marked

.c o m . c
“PC”) of the PC/PPI cable to theo m . c o m S7-200

.
2 4 24
communications port of the programming
24 24
ng hoa hoa
device. (For this example, connect to
g g hoa gh oa
COM 1.)
d on d on o n
2.
T u
Connect the RS-485 connector (marked
“PPI”) of the PC/PPI cable to Port 0 or T u PC/PPI cable Tud
Port 1 of the S7-200.
3. Ensure that the dipswitches of the PC/PPI ↑1 – On

4 .c om .com
cable are set as shown in Figure 2-2. ↓0 – Off

. com 4.
24 4
1 2 3 4 5 6
2 a2 2
ng hoa gh oa
gh o
ng ho a
don o n o
Figure 2-2 Connecting the PC/PPI Cable

Tu Tu d Tu d

4 . com 4. c om 4 . com .
o a2 oa2 a2 a 24
ngh
6
n gh n gho gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
Getting Started Chapter 2

4 .c om Starting STEP 7–Micro/WIN 4 .c om 4. c om 4.


o a 2 o a 2 a 2 a 2
ngh g
Click on the STEP
n h7–Micro/WIN icon to open a
n g ho n g ho
o o Navigation bar do
Tudthe navigation bar. You can use the iconsTud
new project. Figure 2-3 shows a new project.
Notice Tu 2
on the navigation bar to open elements of the
STEP 7–Micro/WIN project.

. co m o m
Click on the Communications icon in the
.c . c o m
24 24
navigation bar to display the Communications
a24 2 4.
hoa hoa ho ho a
dialog box. You use this dialog box to set up the

ng don
g
communications for STEP 7–Micro/WIN.
do n g Communications icon
d ong
Tu Tu Tu

.co m .co m Figure 2-3


.co m
New STEP 7–Micro/WIN Project
.
a 2 4 a 2 4 a 2 4 a 24
o ho ho o
ngh d n g
o project uses the default settings for udo n g
Verifying the Communications Parameters for STEP 7–Micro/WIN
d on g h
T u
The example
STEP 7–Micro/WIN and the PC/PPI cable. To T T u
verify these settings: 1.

1. Verify that the address of the PC/PPI cable

4 .c om 4 . c om
in the Communications dialog box is set
4 . c om 4.
2 to 0.
a2 for the network a2 2
hoa a
2.
h
2. Verify that the ointerface h o ho
ng o ng is set for PC/PPI cable(COM1). dong
parameter
d o ng
T3. uVerify that the transmission rate is set to Tu
9.6 kbps.
Tud 3.

If you need to change your communications

4 . c om 4 .c om
parameter settings, see Chapter 7. Figure 2-4

4 .co m
Verifying the Communications Parameters
.
2 2 2 24
ng hoa hoa
Establishing Communications with the S7-200
ng n gh o a
g h o a
d o d o
Use the Communications dialog box to connect with your S7-200 CPU:
d on
T1. uDouble-click the refresh icon in the Tu T u
Communications dialog box.
STEP 7–Micro/WIN searches for the 1.

.c o m . c m
S7-200 station and displays a CPU icon
o . c o m .
a24 24 24 24
for the connected S7-200 station.

ngh
o 2.
hoa
Select the S7-200 and click OK.
g g hoa gh oa
d on d on o n
u u Tud
If STEP 7–Micro/WIN does not find your S7-200
T
CPU, check the settings for the communications
parameters and repeat these steps.
T
After you have established communications with

.co m .co m
the S7-200, you are ready to create and
. com
a2 4 download the example program.
a 2 4 Figure 2-5

a2 4
Establishing Communications to the S7-200

a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho g 7
h o
T ud o
T udo Tu don
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

4 .c om 4 .c om 4 . c om 4.
o a 2 Creating a Sample Program
o a 2 a 2 a 2
ngh n gofh n g hoeasy it is to use n g ho
dothatThis udonetworks to create a very simple, Tudo
Entering this example a control program will help you understand how

T utimer
STEP 7–Micro/WIN.
self-starting
program uses six instructions in three
resets itself. T
2
For this example, you use the Ladder (LAD) editor to enter the instructions for the program. The following
example shows the complete program in both LAD and Statement List (STL). The network comments in

. co m o m o m
the STL program explain the logic for each network. The timing diagram shows the operation of the
.c . c
24 program.
24 a24 2 4.
ng hoa n g
Example: Sample Program
a
hofor getting started with STEP 7–Micro/WIN n g ho n g ho a
o doT33 times out after (100 x 10 ms = 1 s) Tudo
Tud Network 1
T u
//10 ms timer
//M0.0 pulse is too fast to monitor with Status view.
LDN M0.0
TON T33, +100

4 .c om 4 .c om
Network 2

4 .co m
//Comparison becomes true at a rate that is visible with
.
24
//Status view. Turn on Q0.0 after (40 x 10 ms = 0.4 s),
2 2 2
hoa hoa a a
//for a 40% OFF/60% ON waveform.

gh o h o
ng don
g LDW>=
=
T33, +40
Q0.0
d o n d on g
Tu Network 3 Tu
//T33 (bit) pulse too fast to monitor with Status view.
//Reset the timer through M0.0 after the
T u
//(100 x 10 ms = 1 s) period.
LD T33

4 .c om 4 .com
= M0.0

4 .co m
4.
2 oa2 2 2
hoa a a
Timing Diagram

gh gh o ho
ng do n d o n o ng
Tu Tu Tud

.co m .co m .co m .


a 2 4 a 2 4 a 2 4 a 24
o o o o
ngh o n gh o n gh on g h
Tud Tu d T u d

.c o m . c o m . c o m .
o a24 hoa
24
hoa
24 oa 24
ngh d on g
d on g o n gh
T u T u Tud

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
8
n gh n gho gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
Getting Started Chapter 2

4 .c om Opening the Program 4 .c om 4. c om .


o a2 o a2 Editor
o a2 o a 24
ng h h
ngSee Figure 2-6.
Click on the Program Block icon to open the
ng h g h
program o
d editor.
d o d on
Tu the instruction tree and the program Tu
Notice T u
2
editor. You use the instruction tree to insert the
LAD instructions into the networks of the program
editor by dragging and dropping the instructions

. co m c o m
from the instruction tree to the networks.
. . c o m
a 24 a 2 4 a 2 4 a2 4.
o ho
The toolbar icons provide shortcuts to the menu
ho
Program editor
ho
ngh commands.
n g
doenter and save the program, you canTudo n g n g
Tuyou
After
download the program to the S7-200. T udo
Instruction tree

.co m .co m .co m .


a 2 4 a 2 4 Figure 2-6

a 2 4
STEP 7–Micro/WIN Window

a 24
o ho ho o
ngh o n g
EnteringdNetwork 1: Starting the Timer do n g
d o ng h
TuM0.0 is off (0), this contact turns on and provides
When Tu power flow to start the timer. To enter Ttheucontact
for M0.0:

1. Either double-click the Bit Logic icon or

4 .c om 4 . c om
click on the plus sign (+) to display the bit
4 . c om 4.
2 a2Closed contact.
logic instructions.
a2 2
ng hoa h o
2. Select the Normally
ng the left mouse button and drag dong h o
ng hoa
d o o
Tud
3. Hold down
T4. uClick
the contact onto the first network.
on the “???” above the contact and
Tu
enter the following address: M0.0

om m m
5. Press the Return key to enter the address

2 4 . c for the contact.


2 4 .co 2 4 .co 24.
ng hoa ho a
To enter the timer instruction for T33:
n g Figure 2-7 h
n g o 1 a
g h o a
on
Network

do the Timers icon to display theTtimer


T1.2. uDouble-click
o
udinstructions. T u d
Select the TON (On-Delay Timer).
3. Hold down the left mouse button and drag the timer onto the first network.

.c o m 4.
o m o m
Click on the “???” above the timer box and enter the following timer number: T33
. c . c
a24 a 2
5. Press the Return key 4to enter the timer number and to move thea2 4 to the preset time (PT)
focus
a 2 4.
o parameter.ho ho ho
ngh n g
do the following value for the preset time:
6. Enter do
100 n g
do n g
T7. uPress the Return key to enter the value. T u T u

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho g 9
h o
T ud o
T udo Tu don
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

.c m
oEntering .c m
oOutput . c om
a 2 4 Network 2: 2
Turning
a 4 the On
a 2 4 a 2 4.
o o is greater than or equal to 40 (40 timesg10homilliseconds, or 0.4 seconds), the gho
ngh ghflow
When the timer value for
n
contact providesopower
d
T33
d onTo enter the Compare instruction: udon
to turn on output Q0.0 of the S7-200.
T u u
T instructions. Select the >=I instruction T
2 1. Double-click the Compare icon to display the compare
(Greater-Than-Or-Equal-To-Integer ).
2. Hold down the left mouse button and drag

.com o m o m
the compare instruction onto the second

24 24 .c . c 4.
a24
network.
a 2
ng h o 3.
hoa
Click on the “???” above the contact and
n g
enter the address for the timer value: T33 n gho ng ho a
4.
T u
Press doReturn key to enter the timer
the
T u do Tu d o
number and to move the focus to the other
value to be compared with the timer value.
5. Enter the following value to be compared

4 .c om 6. with the timer value: 40


4 .co m
4 .co m .
2 2
Press the Return key to enter the value.
2 24
ng hoa n g ho a
g
Figure 2-8 Network
n h2o a
ng h o a
d o d o d o
Tu Tu Tu
To enter the instruction for turning on output Q0.0:

1. Double-click the Bit Logic icon to display the bit logic instructions and select the output coil.
2. Hold down the left mouse button and drag the coil onto the second network.

.c om 3. .co m
Click on the “???” above the coil and enter the following address: Q0.0
.co m
24 24 2 4 2 4.
hoa oa a a
4. Press the Return key to enter the address for the coil.
h h o h o
ng n g
do 3: Resetting the TimerTuthedtimer
Entering Network o n g o ng
Tu
When the timer reaches the preset value (100) and turns Tud
bit on, the contact for T33 turns on.
Power flow from this contact turns on the M0.0 memory location. Because the timer is enabled by a
Normally Closed contact for M0.0, changing the state of M0.0 from off (0) to on (1) resets the timer.

4 . c om 4 .co m
To enter the contact for the timer bit of T33:
4 .co m .
2 2 2 24
hoa a a a
1. Select the Normally Open contact from the

gh o gh o h o
ng g
bit logic instructions.
o n o n on
Tud d d
2. Hold down the left mouse button and drag
the contact onto the third network. Tu T u
3. Click on the “???” above the contact and
enter the address of the timer bit: T33

.c o m 4.
for the contact.
. c m
Press the Return key to enter the address
o . c o m .
o a24 24
oonaM0.0: hoa
24 oa 24
ngh g h g gh
To enter the coil for turning

d on d on o n
T
1. Select u the output coil from the bit logic
instructions. T u
Figure 2-9 Network 3 Tud
2. Hold down the left mouse button and drag the output coil onto the third network.

4 .c om 4. 3.

4
m
Double-click the “???” above the coil and enter the following address: M0.0
.co 4 . com 4.
2 2
Press the Return key to enter the address for the coil.
a2 2
ng hoa gho
a
gh o
ng ho a
Tu don Tu d o n
Tu d o

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
10
n gh n gho gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
Getting Started Chapter 2

4 .c om Saving the Sample Project 4 .c om 4 . c om 4.


o a 2 a 2
o networks of instructions, you have finished a 2
oentering the program. When you save gho a 2
ngh After entering theh
d o
the program, n g
you
three
create a project that includes the
d o
S7-200n g
CPU
htype
d on
and other parameters. To save the
T u
project:
T u T u
1. Select the File > Save As menu command 2
from the menu bar.

. co m 2.
.c m
Enter a name for the project in the Save As
o . c o m
24
dialog box.
24 a24 2 4.
ng hoa 3.
hoa
Click OK to save the project.
n g n gho ng ho a
o the project, you can download the udo o
Tud to the S7-200. Tu d
After saving
program T
Figure 2-10 Saving the Example Program

4 .c om
Downloading the Sample 4 .c om
Program 4 . c om 4.
o a 2 a 2 a 2 a 2
ngh n g ho n g ho n g ho
Tip
u o 7–Micro/WIN project is associated withuda CPU
dSTEP o type (CPU 221, CPU 222, CPU 224,uCPUdo
T
Each
T T
226, or CPU 226XM). If the project type does not match the CPU to which you are connected,
STEP 7–Micro/WIN indicates a mismatch and prompts you to take an action. If this occurs, choose
“Continue Download” for this example.

4 .c om 1.
.co m
Click the Download icon on the toolbar or
4 4 .co m
4.
o a2 oa 2
select the File > Download menu
o a 2
hoa 2
ngh gh gh
command to download the program. See
o n
Figure 2-11.
o n o ng
d
T2. uClick OK to download the elements of the u
T d Tud
program to the S7-200.

If your S7-200 is in RUN mode, a dialog box

.co m .co m
prompts you to place the S7-200 in STOP mode.
.co m .
a 2 4 a 2 4
Click Yes to place the S7-200 into STOP mode.
a 2 4
Figure 2-11 Downloading the Program
a 24
o ho ho o
ngh Placing u d
the n g
oS7-200 in RUN Mode udo n g
d o ng h
T T Tu
For STEP 7–Micro/WIN to place the S7-200 CPU in RUN mode, the mode switch of the S7-200 must be
set to TERM or RUN. When you place the S7-200 in RUN mode, the S7-200 executes the program:

.c o m 1.
. c m
Click the RUN icon on the toolbar or select
o . c o m .
a24 24 24 24
the PLC > RUN menu command.

ngh
o 2.
hoa
Click OK to change the operating mode of
ng
the S7-200.
ng hoa n gh oa
d o d o o
Tu the S7-200 goes to RUN mode, the outputTu
When
LED for Q0.0 turns on and off as the S7-200
Tud
executes the program. Figure 2-12 Placing the S7-200 in RUN Mode

4 .c om 4
m
Congratulations! You have just completed your first S7-200 program.
.co 4 . com 4.
2 2 a2
You can monitor the program by selecting the Debug > Program Status menu command. 2
ng hoa gho
a
gh o
STEP 7–Micro/WIN displays the values for the instructions. To stop the program, place the S7-200 in
ng ho a
don n
STOP mode by clicking the STOP icon or by selecting the PLC > STOP menu command.
d o d o
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho g11
h o
T ud o
T udo Tu don
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

4 .c om 4 .co m
4. c om .
oa2 o a 2 o a2 o a 24
ngh on gh on gh on g h
T ud T ud T u d
2

. co m .c o m . c o m
24 24 a24 2 4.
ng hoa g hoa gho ng ho a
Tu don Tu do n
Tu d o

.co m .co m .co m .


a 2 4 a 2 4 a 2 4 a 24
o o o o
ngh d o n gh
d o n gh
d on g h
Tu Tu T u

4 .c om 4 .co m
4 .co m
4.
o a2 oa 2 o a 2
hoa 2
ngh do ngh
d o n gh o ng
Tu Tu Tud

.co m .co m .com .


a 2 4 a 2 4 a 2 4 a 24
o o o o
ngh o n gh o n gh on g h
Tud Tu d T u d

.c o m . c o m . c o m .
o a24 hoa
24
hoa
24 oa 24
ngh d on g
d on g o n gh
T u T u Tud

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
12
n gh n gho gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u

4 .c om 4 .c om 4 . c om 4.
o a 2 Installing the a 2 S7-200 a 2 a 2
ngh n g ho n g ho n g ho
do
TuS7-200 udoYou can use the mounting holes to attach
Tinstall. Tud
o
The equipment is designed to be easy to the
modules to a panel, or you can use the built-in clips to mount the modules onto a standard (DIN) rail. The
small size of the S7-200 allows you to make efficient use of space.

. co m o m
This chapter provides guidelines for installing and wiring your S7-200 system.
.c . c o m
24 24 a24 2 4.
ng hoa hoa ho ho a
ong
In This Chapter
d do n g
d ong
Tu for Installing S7-200 Devices . . . . .T. . .u. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .T. . .u. . 14
Guidelines
Installing and Removing the S7-200 Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Guidelines for Grounding and Wiring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

4 .c om 4 .c om .com .
2 2 24 24
ng hoa g hoa g h o a
g h o a
u d on u d on u d on
T T T

4 .c om 4 .co m
4 .co m
4.
o a2 oa 2 o a 2
hoa 2
ngh do ngh
d o n gh o ng
Tu Tu Tud

.co m .co m .co m .


a 2 4 a 2 4 a 2 4 a 24
o o o o
ngh o n gh o n gh on g h
Tud Tu d T u d

.c o m . c o m . c o m .
o a24 hoa
24
hoa
24 oa 24
ngh d on g
d on g o n gh
T u T u Tud

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 13
gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

4 .c om 4 .c om 4 . c om 4.
o a 2 Guidelines for Installing
a 2
S7-200 Devices
a 2 a 2
ngh You can install an n g hoeither on a panel or on a standard rail,nandghyouocan orient the S7-200 either n g ho
o S7-200
o o
Tudvertically.
horizontally or
Tud Tud
Separate the S7-200 Devices from Heat, High Voltage, and Electrical Noise
As a general rule for laying out the devices of your system, always separate the devices that generate
3 .comhigh voltage and high electrical noise.from
c o m
the low-voltage, logic-type devices such as o
. c them
S7-200.

a 2 4 When configuring the layout a 2 4S7-200 inside your panel, consider the heat-generating
a 2 4 a2 4.
o o in the cooler areas of your cabinet.ghOperating
of the
o any electronic device in a gho
devices and

ngh d
high-temperatureo g hdevices
locate the electronic-type
n
environment will reduce the time to
d
failure. o n d on
Consider
u u u
Talso the routing of the wiring for the devicesTin the panel. Avoid placing low voltage signal wires
T
and communications cables in the same tray with AC power wiring and high-energy, rapidly-switched DC
wiring.

.c m Adequate Clearance.for
oProvide c m
oCooling . c om .
a 2 4 a 2 4 and Wiring
a 2 4 a 2 4
o o for natural convection cooling. For allowhatoleast 75you ho
ngh 25h
S7-200 devices are designed proper cooling, must provide a

o n
clearance of at least g mm above and below the devices. Also, n
o g mm of depth.
o n g
Tip T u d T u d T u d
For vertical mounting, the maximum allowable ambient temperature is reduced by 10° C. Mount the
S7-200 CPU below any expansion modules.

4 .c omWhen planning your layout for the4S7-200


. c m allow enough clearance for the wiring
osystem, 4 . c om and
4.
o a 2 a 2
communications cable connections. For additional flexibility in configuring the 2
a layout of the S7-200 system,
a 2
ngh n g ho
use the I/O expansion cable.
n g ho ng ho
o o o
Tud Tud Tud
ÓÓÓÓÓÓ
Clearance 35 mm

m Ó ÓÓ
1 mm
7.5 mm

. c om ÓÓÓÓÓÓ . c o Ó ÓÓ .c om DIN Rail


.
ng hoa
2 4 25 mm

ÓÓÓÓÓÓ
o ng h o a2 4
Ó
Ó ÓÓ
ÓÓ o ng h o a2 4
75 mm

on g h o a 24
Tud
Ó TÓÓ
u d T u d
ÓÓÓÓÓÓ Front of the
enclosure
Mounting
surface

ÓÓÓÓÓÓ
Vertical Panel Mounting

.c o m . c o m . c o m .
ngh
o a24 ÓÓÓÓÓÓ
ngh
o a 24
ngh
Horizontal DIN Rail Mounting with Optional
Expansion Cable (limit one per system)
o a 24 Side View

n gh oa 24
T u do T u do Tud
o
Figure 3-1 Mounting Methods, Orientation, and Clearance

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
14
n gh n gho g h o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
Installing the S7-200 Chapter 3

4 .c om Power Budget 4 . c om 4 . c om 4.
o a 2 a 2
o an internal power supply that providesgpower a 2 a 2
ngh All S7-200 CPUsh
and othero g have
24nVDC n ho for the CPU, the expansion modules,ngho
T u d user power requirements.
T u do T u do
The S7-200 CPU provides the 5 VDC logic power needed for any expansion in your system. Pay careful
attention to your system configuration to ensure that your CPU can supply the 5V power required by your
selected expansion modules. If your configuration requires more power than the CPU can supply, you
must remove a module or select a CPU with more power capability. Refer to Appendix A for information
. co m .c o m . c o m
about the 5 VDC logic budget supplied by your S7-200 CPU and the 5 VDC power requirements of the 3 .
o a 24 24 a24
expansion modules. Use Appendix B as a guide for determining how much power (or current) the CPU
oa a24
ngh h
can provide for your configuration.
n g n g ho gh o
u d oon the expansion modules, or for other urequirements.
All S7-200 CPUs also provide a 24 VDC sensor
d
supply o supply
that can
d on
24 VDC for input points, for relay
u
T
coil power T If your power requirements T
exceed
budget of the sensor supply, then you must add an external 24 VDC power supply to your system. Refer
the

to Appendix A for the 24 VDC sensor supply power budget for your particular S7-200 CPU.

om m m
If you require an external 24 VDC power supply, ensure that the power supply is not connected in parallel

2 4 .c 2 4 .co 2 4 .co
with the sensor supply of the S7-200 CPU. For improved electrical noise protection, it is recommended
24.
hoa a a a
that the commons (M) of the different power supplies be connected.

gh o gh o h o
ng Warning
d o n d o n d on g
Tu Tu
Connecting an external 24 VDC power supply in parallel with the S7-200 24 VDC sensor supply can
T u
result in a conflict between the two supplies as each seeks to establish its own preferred output voltage
level.
The result of this conflict can be shortened lifetime or immediate failure of one or both power supplies,

4 .c om 4 . om
death or serious injury to personnel, and/or damage to equipment.
4 . om
with consequent unpredictable operation of the PLC system. Unpredictable operation could result in
c c 4.
o a 2 a 2 a 2 a 2
ngh n g ho
The S7-200 DC sensor supply and any external power supply
n g ho
should provide power to different points.
ng ho
o do o
Tudand Removing the S7-200
Installing TuModules Tud
The S7-200 can be easily installed on a standard DIN rail or on a panel.

.co m Prerequisites .c om .c om
a 2 4 a 2 4 a 2 4 a 2 4.
o ho that the power to any related equipment
Before you install or remove
hhaso been turned off.
any electrical device, ensure that the power to that equipment has been
ho
ngh g
turned off. Also, ensure
n n g n g
T udo
Warning T udo T udo
Attempts to install or remove S7-200 or related equipment with the power applied could cause electric
shock or faulty operation of equipment.
Failure to disable all power to the S7-200 and related equipment during installation or removal

.c o m c o m c o m
procedures could result in death or serious injury to personnel, and/or damage to equipment.
. .
a2 4 a 2
Always follow appropriate 4 precautions and ensure that powerato2the4S7-200 is disabled before
safety
a 2 4.
ho hoor remove S7-200 CPUs or related equipment.
attempting to install ho ho
ng n g n g
o that whenever you replace or installuandS7-200
o device you use the correct moduleuordo n g
Tudensure
Always
equivalent device. T T
Warning

.co m . c om . com
If you install an incorrect module, the program in the S7-200 could function unpredictably.

a2 4 a 2 4 a 2 4 a2 4.
Failure to replace an S7-200 device with the same model, orientation, or order could result in death or
o hodevice with the same model, and be sure
serious injury to personnel, and/or damage to equipment.
o and position it correctly. ho
ng h Replace ann
o g
S7-200
o n g horient
to
on g
Tud Tud Tud

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 15
gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

.c m
oMounting .c om . c om
a 2 4 Dimensions
a 2 4 a 2 4 a 2 4.
o o modules include mounting holesgtohfacilitate
o installation on panels. ho
ngh The S7-200 CPUs and h
do
Refer to Table 3-1 n g
for
expansion
the mounting dimensions.
do n do n g
T
Table 3-1
u Mounting Dimensions
T u T u
9.5 mm* * Minimum spacing

.com .com m between modules when


3 A
. c o hard-mounted

a 24
4 mm

a 24 B
a24 a2 4.
gh o g h o gho ho
n don do n Mounting holes
d o
(M4 or No. 8)ng
Tu Tu Tu
96 mm 88 mm 80 mm

.co m .co m .co m .


a 2 4 a 2 4 a 2 4 a 24
o o oB o
ngh d o
4 mmn gh 4 mm
d o n gh A
d on gh
Tu
S7-200 Module Tu Width A T u
Width B
CPU 221 and CPU 222 90 mm 82 mm
CPU 224 120.5 mm 112.5 mm

4 .c om CPU 226 and CPU 226XM 4 . c om 4 . c omm


196 m 188 mm
4.
h o a2 Expansion modules:
o a
8-point DC
h
2and Relay I/O (8I, 8Q, 4I/4Q, 2 AQ)
h o a 2 46 mm 38 mm
hoa 2
ng Expansion modules: g16-point digital I/O (8I/8Q), Analog I/O (4AI, 4AI/1AQ),
d o n RTD, Thermocouple, PROFIBUS, AS-Interface, d o ng 71.2 mm 63.2 mm
o ng
Tu 8-point AC (8I and 8Q), Position, and u
TModem Tud
Expansion modules: 32-point digital I/O (16I/16Q) 137.3 mm 129.3 mm

.co m
Installing a CPU or Expansion Module
.co m .co m .
a 2 4 a 2 4
Installing the S7-200 is easy! Just follow these steps.
a 2 4 a 24
o ho ho o
ngh d o
Panel Mountingn g
d o n g
d o ng h
Tu drill, and tap the mounting holes (M4 orTAmerican
1. Locate,
dimensions in Table 3-1.
u Standard number 8), using the Tu
2. Secure the module(s) to the panel, using the appropriate screws.

.c o m 3. . c o m . c o m
If you are using an expansion module, connect the expansion module ribbon cable into the
.
a24 24 24 24
expansion port connector under the access door.

ngh
o g hoa ghoa gh oa
on
DIN Rail Mounting
d d on o n
1.
2.
u
Secure the rail to the mounting panel every 75 mm.
T T u Tud
Snap open the DIN clip (located on the bottom of the module) and hook the back of the module onto
the DIN rail.

om om om
3. If you are using an expansion module, connect the expansion module ribbon cable into the

2 4 .c . c
expansion port connector under the access door.
2 4 2 4 . c 2 4.
hoa a
hosecurely onto the rail. To avoid damage a
omodule, press on the tab of the ho a
4. Rotate the module down to the DIN rail and snap the clip closed. Carefully check that the clip has
toh
ng mountingo n g
fastened the module
n g the
hole instead of pressing directly on the front ofothe module. on g
Tud Tud Tud

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
16
n gh n gho g h o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
Installing the S7-200 Chapter 3

4 .c om 4 .co m
4. c om .
o a2 Tip
a 2 a2 a 24
ngh g ho g ho ng
Using DIN rail stops could be helpful if your S7-200 is in an environment with high vibration potential or if
n n h o
d o
the S7-200 has been installed vertically.
d o d o
u system is in a high-vibration environment,Tuthen panel-mounting the S7-200 will provideTaugreater
Tyour
If
level of vibration protection.

. co m Removing a CPU or Expansion


.c o m Module
. c o m 3 .
a 2 4 To remove an S7-200 CPU
a 2 4or expansion module, follow these steps:
a 2 4 a24
o o o o
ngh 1. Remove
d o n gh
power from the S7-200.
o n gh on gh
Tuexpansion Tudto make this job easier. Tud
2. Disconnect all the wiring and cabling that is attached to the module. Most S7-200 CPU and
modules have removable connectors
3. If you have expansion modules connected to the unit that you are removing, open the access cover
door and disconnect the expansion module ribbon cable from the adjacent modules.

.co m 4.
c om
Unscrew the mounting screws or snap open the DIN clip.
. . c om
a 2 4 a
5. Remove the module.2 4 a 2 4 a 2 4.
o ho ho ho
ngh Removing n g
doand Reinstalling the Terminal n g
o Connector
dBlock do n g
T u T u T u
Most S7-200 modules have removable connectors to make installing and replacing the module easy.
Refer to Appendix A to determine whether your S7-200 module has removable connectors. You can order
an optional fan-out connector for modules that do not have removable connectors. See Appendix E for

om om om
order numbers.

4 .c 4 . c 4 . c 4.
o a2 a
To Remove the Connector 2
ho door to gain access to the connector. ho a 2
hoa 2
ngh 1. Open the
ngconnector
do a small screwdriver in the notch in T n g
do of the connector. ng
T2.3. uInsert theumiddle
T udo
Remove the terminal connector by prying the screwdriver away from the S7-200 housing. See
Figure 3-2.

.co m .co m .co m .


a 2 4 a 2 4 a 2 4 a 24
o o o o
ngh o n gh o n gh on g h
Tud Tu d T u d

.c o m . c o m . c o m .
o a24 hoa
24
hoa
24 oa 24
ngh d o ng d on g o n gh
Tu Removing the Connector
Figure 3-2
T u Tud
To Reinstall the Connector

4 .c om 1.
.
Open the connector door.
4 c om 4 . c om 4.
2 2 2 2
hoa a
ho base. ho a ho a
2. Align the connector with the pins on the unit and align the wiring edge of the connector inside the

ng d
g
rim of the
n connector
n
o down firmly to rotate the connector untiludit snaps g
o into place. Check carefully to ensureuthatd n
othe g
T3. uPress T
connector is properly aligned and fully engaged. T

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 17
gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

4 .c om 4 .c om 4 . c om 4.
o a 2 Guidelines for Grounding
a 2 and Wiring
a 2 a 2
ngh n g ho of all electrical equipment is important
n gtoh
o
n g ho
o
Proper grounding and wiring
udo for your application and the S7-200.
help ensure the optimum operation
o
Tudand to provide additional electrical noiseTprotection
of your system
Tud
Prerequisites
Before you ground or install wiring to any electrical device, ensure that the power to that equipment has
3 .combeen turned off. Also, ensure that the.power
c o mto any related equipment has been turned
. c o m
off.

a 2 4 a 2 4electrical codes when wiring the S7-200aand


2 4related equipment. a2 4.
o gho according to all applicable national
Ensure that you follow all applicable
olocal standards. Contact your ho
ngh Install and operate all equipment
ton
local authoritieso n g hspecific
and
n g
ud udo udo
determine which codes and standards apply to your case.

Warning
T T T
Attempts to install or wire the S7-200 or related equipment with power applied could cause electric
shock or faulty operation of equipment. Failure to disable all power to the S7-200 and related equipment

.co m om om
during installation or removal procedures could result in death or serious injury to personnel, and/or
.c . c
a 2 4 damage to equipment.
a 4
2precautions and ensure that power to thea 2 4 a 2 4.
o Always follow appropriateo safety o S7-200 is disabled before
ho
ngh n or h
attempting to install g remove the S7-200 or related equipment. gh
do into consideration as you design theTgrounding n n g
Always T usafety
take udo and wiring of your S7-200 system.Tudo
Electronic control devices, such as the S7-200, can fail and can cause unexpected operation of the
equipment that is being controlled or monitored. For this reason, you should implement safeguards that
are independent of the S7-200 to protect against possible personal injury or equipment damage.

4 .c om Warning 4 . c om 4 . c om 4.
o a 2 a 2 a 2 a 2
ngh
Control devices can
n g ho operations could result in death ornserious
fail in
equipment. Such unexpected
an unsafe condition, resulting in
hoinjury to personnel, and/or
unexpected
g
operation of controlled
ng ho
u do
damage to equipment.
T T u do T udo
Use an emergency stop function, electromechanical overrides, or other redundant safeguards that are
independent of the S7-200.

.co m
Guidelines for Isolation
.c om . c om
a 2 4 a 2 4
S7-200 AC power supply boundaries
a 2
and I/O boundaries to AC circuits are rated41500 VAC. These
a 2 4.
o hobeen examined and approved as providing hsafeo separation between AC line ngho
ngh g g
isolation boundaries have
o n n
udo o
and low voltage circuits.
Tudcircuits connected to an S7-200, such T
All low voltage as 24V power, must be supplied from an approvedTud
source that provides safe isolation from AC line and other high voltages. Such sources include double
insulation as defined in international electrical safety standards and have outputs that are rated as SELV,
PELV, Class 2, or Limited Voltage according to various standards.

.c o m . c o m . c o m .
o a24 Warning
hoa
24
hoa
24 oa 24
ngh gh
Use of non-isolated or single insulation supplies to supply low voltage circuits from an AC line can result
on g on g n
do
in hazardous voltages appearing on circuits that are expected to be touch safe, such as
u d
communications circuits and low voltage sensor wiring.
T T u d T u
Such unexpected high voltages could result in death or serious injury to personnel, and/or damage to
equipment.
Only use high voltage to low voltage power converters that are approved as sources of touch safe,

.c o m limited voltage circuits. . c om . com


a2 4 a2 4 a2 4 a2 4.
ho h o gh o ho
ng d o ng d o n d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
18
n gh n gho g h o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
Installing the S7-200 Chapter 3

4 .c om Guidelines for Grounding 4 .c omS7-200 4 . c om 4.


o a 2 a 2 the
a 2 a 2
ngh g hareo grounded
The best way to ground
n your application is to ensure that all theh
n g o connections of your S7-200 and gho
common
should be connected directly to theon
d o for your system. d o
Tud
related equipment to a single point. This single point
T u
earth ground
T u
For improved electrical noise protection, it is recommended that all DC common returns be connected to
the same single-point earth ground. Connect the 24 VDC sensor supply common (M) to earth ground.

. co m o m o m
All ground wires should be as short as possible and should use a large wire size, such as 2 mm2
.c . c 3 .
o a 24 (14 AWG).
o a 24 o a24 o a24
ngh protectiveo n gh devices.
When locating grounds, remember to consider safety
o n gh
grounding requirements and the proper operation
o
of
n gh
Tud Tud Tud
interrupting

Guidelines for Wiring the S7-200


When designing the wiring for your S7-200, provide a single disconnect switch that simultaneously

.co m .co m .co m


removes power from the S7-200 CPU power supply, from all input circuits, and from all output circuits.
Provide overcurrent protection, such as a fuse or circuit breaker, to limit fault currents on supply wiring.
.
a 2 4 a 2 4 a 2 4
You might want to provide additional protection by placing a fuse or other current limit in each output
a 24
o ho ho o
ngh h
circuit.

Install d o n g surge suppression devices for anyd o n g o ng


Tu
appropriate
Tu
wiring
Tu d
that could be subject to lightning surges.

Avoid placing low-voltage signal wires and communications cables in the same wire tray with AC wires
and high-energy, rapidly switched DC wires. Always route wires in pairs, with the neutral or common wire
paired with the hot or signal-carrying wire.

4 .c om .co m .co m
Use the shortest wire possible and ensure that the wire is sized properly to carry the required current. The
4 4 4.
o a2 oa 2
ho a 2
connector accepts wire sizes from 2 mm2 to 0.3 mm2 (14 AWG to 22 AWG). Use shielded wires for
hoa 2
ngh h
optimum protection against electrical noise. Typically, grounding the shield at the S7-200 gives the best
o n g n g n g
do power supply, include an overcurrent do
results.

Tud
When Tuexternal
wiring input circuits that are powered by an Tuprotection
device in that circuit. External protection is not necessary for circuits that are powered by the 24 VDC
sensor supply from the S7-200 because the sensor supply is already current-limited.

4 . c om 4 .co m
4 .co m
Most S7-200 modules have removable connectors for user wiring. (Refer to Appendix A to determine if
.
24
your module has removable connectors.) To prevent loose connections, ensure that the connector is
2 2 2
hoa a a a
seated securely and that the wire is installed securely into the connector. To avoid damaging the

ng g ho g ho ng
connector, be careful to not over-tighten the screws. The maximum torque for the connector screw is
n n h o
d o
0.56 N-m (5 inch-pounds).
d o
u prevent unwanted current flows in your Tinstallation, d
u the S7-200 provides isolation boundaries o
Thelp
To Tu at
certain points. When you plan the wiring for your system, you should consider these isolation boundaries.
Refer to Appendix A for the amount of isolation provided and the location of the isolation boundaries.
Isolation boundaries rated less than 1500VAC must not be depended on as safety boundaries.

.c o m . c o m . c o m .
o a24 Tip
hoa
24
hoa
24 oa 24
ngh gh
For a communications network, the maximum length of the communications cable is 50 m without using
on g on g
a repeater. The communications port on the S7-200 is non-isolated. Refer to Chapter 7 for more
o n
u d
information.
T T u d Tud

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 19
gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

.c m
oGuidelines . c om . c om
a 2 4 for Suppression
a 2 4 Circuits
a 2 4 a 2 4.
o holoads hodue ho
ngh n
turns off. Suppression g
You should equip inductive
do suppression circuits limit the electrical
circuits protect your outputs from
dnoise
prematuren g
with suppression circuits to limit voltage
failure
rise when the control output
o generated when switching inductive udo
to high inductive switching n g
currents. Inuaddition, u
loads. T T T
Tip

3 .com The o m depends on the application, and you


effectiveness of a given suppression circuit
.c . c o mverify it for
must

a 2 4 use in the application. a 2 4


your particular use. Always ensure that
a 2 4
all components used in your suppression circuit are rated for
a2 4.
o ho ho ho
ngh n g
o Relays That Control DC Loadsudo
dand n g
don g
DC Outputs
T u T T
The DC outputs have internal protection that is adequate for most applications. Since the relays can be
u
used for either a DC or an AC load, internal protection is not provided.

Figure 3-3 shows a sample suppression circuit


.c o m .c o m
for a DC load. In most applications, the addition
A B (optional)

. c om .
a2 4 of a diode (A) across the inductive4
a2 load is
a2 4 A – I1N4001 diode or equivalent

a 24
ho h o
suitable, but if your application requires faster
h o B – 8.2 V Zener for DC Outputs
h o
ng ngBeaddition g Load g
Output 36 V Zener for Relay Outputs
turn-off times, then the
d o of a Zener diode
d o nInductive
Point

d on
T u for the amount of current in your Tu
(B) is recommended.
diode properly
sure to size your Zener DC
T u
output circuit. Figure 3-3 Suppression Circuit for a DC Load

.c omAC Outputs and Relays That Control AC Loads


. c othatmis adequate for most applications. Since
. c om
a 2 4 a 2
used for either a DC or an AC load,4
The AC outputs have internal protection
internal protection is not provided.
a 2 4 the relays can be
a 2 4.
o hosuppression circuit ho MOV ho
ngh Figure 3-4 shows n
d
g
oIn most applications, the addition udo
a sample n g
d o ng
T u
for an AC load.
of a metal oxide varistor (MOV) will limit the peak T T u
voltage and provide protection for the internal
Output
S7-200 circuits. Ensure that the working voltage Point
of the MOV is at least 20% greater than the AC Inductive Load

.com nominal line voltage.


.com .co m .
o a24 o a24 Figure 3-4
2 4
Suppression Circuit for a AC Load
o a o a 24
ngh o n gh o n gh on g h
Tud Tu d T u d

.c o m . c o m . c o m .
o a24 hoa
24
hoa
24 oa 24
ngh d on g
d on g o ngh
T u T u Tud

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
20
n gh n gho g h o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u

4 .c om 4 .co m
4. c om .
o a2 PLC Concepts oa 2 o a2 o a 24
ngh n g h n gh on g h
T udo T ud o
The basic function of the S7-200 is to monitor field inputs and, based on your control logic, turn on or off T u d
field output devices. This chapter explains the concepts used to execute your program, the various types
of memory used, and how that memory is retained.

. co m .c o m . c o m
a 2 4 In This Chapter a24 a 2 4 a2 4.
o ho ho ho
ngh o n
UnderstandinggHow the S7-200 Executes Your Control Logic
o n g ................................
on22g
Tud the Data of the S7-200 . . . . . . . . . . . T. . .u. .d. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .T. . .u. .d 24
Accessing
Understanding How the S7-200 Saves and Restores Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Storing Your Program on a Memory Cartridge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

.co m .co m .co m


Selecting the Operating Mode for the S7-200 CPU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
.
a 2 4 a 2 4 a 2 4
Using Your Program to Save V Memory to the EEPROM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
a 24
o o o o
ngh gh gh h
Features of the S7-200 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
n n g
Tu d o
Tu d o
Tu don

4 .c om 4 .co m
4 .co m
4.
o a2 oa 2 o a 2
hoa 2
ngh do ngh
d o n gh o ng
Tu Tu Tud

.co m .co m .co m .


a 2 4 a 2 4 a 2 4 a 24
o o o o
ngh o n gh o n gh on g h
Tud Tu d T u d

.c o m . c o m . c o m .
o a24 hoa
24
hoa
24 oa 24
ngh d on g
d on g o n gh
T u T u Tud

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 21
gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

4 .c om 4 .c om 4. c om 4.
o a 2 Understanding How the
a 2
S7-200 Executes Your Control
o through the control logic in your program, a 2 Logic
a 2
ngh n g hcycles n g horeading and writing data. n g ho
udo udo udo
The S7-200 continuously

T T
The S7-200 Relates Your Program to the Physical Inputs and Outputs
T
The basic operation of the S7-200 is very simple: Start_PB E_Stop M_Starter

. co m- o m
The S7-200 reads the status of the inputs.
.c . c o m
24 -
2in4logic.
The program that is stored the S7-200 uses these 24 2 4.
oa a a a
M_Starter Motor

g h o
ghupdates the data.
inputs to evaluate the control As the program
gh o ho
n 4 o n
runs, the S7-200
d writes the data to the outputs. Tud o n d ong
- TuS7-200
The Output
Tu
Motor Starter
Figure 4-1 shows a simple diagram of how an electrical
relay diagram relates to the S7-200. In this example, the
Input
state of the switch for starting the motor is combined with the
om om om
Start / Stop Switch

2 4 .c 2 4 .c
states of other inputs. The calculations of these states then
determine the state for the output that goes to the actuator
2 4 . c 24 .
ng hoa which starts the motor.
ng hoa ng
Figure 4-1 a Inputs and Outputs
hoControlling g h o a
d o d o d on
TuExecutes Its Tasks in a ScanTCycle
The S7-200 u
The S7-200 executes a series of tasks repetitively. This cyclical execution of tasks is called the scan
T u
cycle. As shown in Figure 4-2, the S7-200 performs most or all of the following tasks during a scan cycle:

.c om- . c om
Reading the inputs: The S7-200 copies the state of
. c om
24 4
the physical inputs to the process-image input register.
a2in the program: The a2 4 Writes to the outputs
2 4.
ng hoa -
h o
Executing the control logic
ng the instructions of the program anddong
S7-200 executes h o
ng hoa
theo
stores d o
Tu Tu Tud
values in the various memory areas. Perform the CPU Diagnostics

- Processing any communications requests: The Process any


Communications Requests
S7-200 performs any tasks required for
communications.

4 . c om - c om
Executing the CPU self-test diagnostics: The S7-200
4 . 4 .co
Execute the Program mScan Cycle .
2 2
ensures that the firmware, the program memory, and
2 24
ng hoa hoa
any expansion modules are working properly.
ng n gh o a
g h o a
-
d o
Writing to the outputs: The values stored in the
d o Reads the inputs

d on
Tu
process-image output register are written to the
physical outputs. Tu Figure 4-2 S7-200 Scan Cycle T u
The execution of the scan cycle is dependent upon whether the S7-200 is in STOP mode or in RUN
mode. In RUN mode, your program is executed; in STOP mode, your program is not executed.

.c o m . c o m . c o m .
o a24 hoa
24
hoa
24 oa 24
ngh d on g
d on g o n gh
T u T u Tud

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
22
n gh n gho gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
PLC Concepts Chapter 4

4 .c om 4 .co m
4. c om .
oa2
Reading the Inputs
o a 2 o a2 o a 24
ngh gh gh h
Digital inputs: Each scan cycle begins by reading the current value of the digital inputs and then writing
on
these values to the process-image input register.
on o ng
ud
T inputs: The S7-200 does not update analog
Analog ud d
Tufiltering
T inputs as part of the normal scan cycle unless
of analog inputs is enabled. An analog filter is provided to allow you to have a more stable signal. You can
enable the analog filter for each analog input point.

. co m .c m . c o m
When analog input filtering is enabled for an analog input, the S7-200 updates that analog input once per
o
24 24 a24 4.
scan cycle, performs the filtering function, and stores the filtered value internally. The filtered value is then
2
hoa hoa a
supplied each time your program accesses the analog input.

ng n g is not enabled, the S7-200 reads then g hofothe analog input from the physical ngho4
o
When analog
moduledeach
filtering
o value
o
Tu time your program accesses the analog Tudinput. Tud
Tip
Analog input filtering is provided to allow you to have a more stable analog value. Use the analog input

.co m . c om . c om
filter for applications where the input signal varies slowly with time. If the signal is a high-speed signal,

4.
then you should not enable the analog filter.

a 2 4 Do not use the analoga 2 4


filter a
with modules that pass digital information 2
or 4
alarm indications in the analog a 2
o ho analog filtering for RTD, Thermocouple, handoAS-Interface Master modules. ngho
ngh g g
words. Always disable

do n do n do
T u
Executing the Program T u T u
During the execution phase of the scan cycle, the S7-200 executes your program, starting with the first
instruction and proceeding to the end instruction. The immediate I/O instructions give you immediate

om m m
access to inputs and outputs during the execution of either the program or an interrupt routine.

4 .c 4 .co 4 .co 4.
o a2 oa 2 o a 2
If you use interrupts in your program, the interrupt routines that are associated with the interrupt events are
hoa 2
ngh gh gh
stored as part of the program. The interrupt routines are not executed as part of the normal scan cycle, but
n n
are executed when the interrupt event occurs (which could be at any point in the scan cycle).
o o o ng
Tu d Tu d Tud
Processing Any Communications Requests
During the message-processing phase of the scan cycle, the S7-200 processes any messages that were
received from the communications port or intelligent I/O modules.

.co m .c om .c om
a 2 4 a 4
Executing the CPU Self-test Diagnostics 4
2 cycle, the S7-200 checks for properooperation
a 2 of the CPU, for memory a 2 4.
o During this phase ofo
ho
ngh theh h
the scan
areas, and for g g g
do n status of any expansion modules.
do n do n
T u
Writing to the Digital Outputs T u T u
At the end of every scan cycle, the S7-200 writes the values stored in the process-image output register to
the digital outputs. (Analog outputs are updated immediately, independently from the scan cycle.)

.c o m . c o m . c o m .
o a24 hoa
24
hoa
24 oa 24
ngh d on g
d on g o n gh
T u T u Tud

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 23
gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

4 .c om 4 .c om 4 . c om 4.
o a 2 Accessing the Data of the
a 2 S7-200
a 2 a 2
ngh The S7-200 storesn g ho in different memory locations thatnhave
g o addresses. You can
hunique n g ho
udothe memory address that you want toofaccess.
udoThis allows your program to have direct o
information
explicitly identify
access T to the information. Table 4-1 shows the range T Tud
integer values that can be represented by the
different sizes of data.

Table 4-1 Decimal and Hexadecimal Ranges for the Different Sizes of Data

. co m Representation .c o m . c o m
24 4
Byte (B)
2
Word (W) Double Word (D)
24 2 4.
g h oa Unsigned Integer
hoa
0 to 255 0 to 65,535
o a
0 to 4,294,967,295
ghFFFF ho a
n 4 d o ng 0 to FF 0 to FFFF
n
0 to FFFF
o ong
Tu
Signed Integer –128 to +127
80 to 7F
Tud –2,147,483,648
–32,768 to +32,767
8000 to 7FFF
to +2,147,483,647
8000 0000 to 7FFF FFFF
Tu d
Real Not applicable Not applicable +1.175495E–38 to +3.402823E+38 (positive)
IEEE 32-bit Floating Point –1.175495E–38 to –3.402823E+38 (negative)

.c o m .c o m . c m
oarea .
a 2 4 To access a bit in a memory area,4
a 2 you
2 4
specify the address, which includes the memory
a identifier, the
a 2 4
o o Figure 4-3 shows an example ofaddress ho(I =ainput, ho
ngh Inhthis example, the memory area and byte
byte address, and the bit number. accessing bit (which is also called
n g
“byte.bit” addressing).
followed by ad o (“.”) to separate the bit address (bit 4).udo n g and 3 = byte 3) are
o n g
Tu Tud
period
T
I 3 . 4
Process-image Input (I) Memory Area
Bit of byte, or bit number:

4 .c om 4 . c om
bit 4 of 8 (0 to 7)
Byte 0
7 6 5 4 3 2 1 0

4 .co m
4.
2 2
Period separates the
2 2
ng hoa g h oa byte address from the bit Byte 1
gh o a
g hoa
don Byte address: byte 3 (the n n
number Byte 2
d o o
Tu Tu Tud
Byte 3
fourth byte) Byte 4
Memory area identifier Byte 5

Figure 4-3 Byte.Bit Addressing

.co m .c om .c om
a24 a 2 4 a 2 4 a 2 4.
o o To access a byte, word, or double word hofodata in the memory, you must ngho
ngh hformat.
You can access data in most memory areas (V, I, Q, M, S, L, and SM) as bytes, words, or double words by
n g
using the byte-address
n g
T
data size udo in aandwaythesimilar
specify the address
designation,
to specifying the address
starting byte address ofT the
doforword,
ubyte, a bit. This includes an area identifier, do
or double-word value, as shownTuin
Figure 4-4.

Data in other memory areas (such as T, C, HC, and the accumulators) are accessed by using an address

.c o mformat that includes an area identifier and am


. c o device number.
. c o m .
o a24 o a 24 o a 24 oa 24
ngh o n gh o n gh o n gh
Tud Tud Tud

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
24
n gh n gho gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
PLC Concepts Chapter 4

4 .c om 4 .co mV W 100
4. c om .
o a2
V B 100
o a 2
Byte address Byte address
o a2
V D 100
Byte address
o a 24
ngh gh gh g h
Access to a byte size Access to a word size Access to a double word size

on Area identifier
on
Area identifier Area identifier
on
T ud MSB
7
LSB
0
T ud T u d
VB100 VB100
MSB = most significant bit
LSB = least significant bit
Most significant byte Least significant byte

.com o m o m
MSB LSB

24 24 byte.c . c 4.
a24
VW100 15 VB100 8 7 VB101 0

o a o a a 2
ng h ngh
Most significant
n gho Least significant byte
n g ho4
o MSB
o VB102 LSB
o
Tud VD100 31 VB100 24 23
Tud
VB101 16 15 8 7 VB103
Tud 0

Figure 4-4 Comparing Byte, Word, and Double-Word Access to the Same Address

.co m .c om . c om
a 2 4 Accessing Data in the
a 2 4Memory Areas
a 2 4 a 2 4.
o o ho ho
ngh n g hInput n g
do samples the physical input points atTtheudbeginning
Process-Image Register: I
o of each scan cycle and writes these o n
dvalues
g
Theu u
T S7-200
T
to the process-image input register. You can access the process-image input register in bits, bytes, words,
or double words:

Bit: I[byte address].[bit address] I0.1

4 .c om Byte, Word, or Double Word:


4 . c o m
I[size][starting byte address]
4 . c o m IB4
4.
o a 2 a 2
o Register: Q o a 2 oa 2
ngh
Process-ImagehOutput h h
n g n g n g
T
the udoofoutput
At the end
physical points. You can access the T udo stored
the scan cycle, the S7-200 copies the values
process-image
in the process-image output registero
T udor to
output register in bits, bytes, words,
double words:

Bit: Q[byte address].[bit address] Q1.1

.co m Byte, Word, or Double Word:


.c om
Q[size][starting byte address]
.c om
QB5

a 2 4 a
Variable Memory Area:2 4V a 2 4 a 2 4.
o ho to store intermediate results of operations
hobeing performed by the control logic inngho
ngh You can use Vg
n memory
o You can also use V memory to store other n
dodata
g pertaining to your process or task. You o
Tudthe V memory area in bits, bytes, words,Torudouble Tud
your program. can
access words:

Bit: V[byte address].[bit address] V10.2


Byte, Word, or Double Word: V[size][starting byte address] VW100

.c o m . c o m . c o m .
a24 24 24 24
Bit Memory Area: M

ngh
o hoa hoa
You can use the bit memory area (M memory) as control relays to store the intermediate status of an
g g gh oa
on on n
operation or other control information. You can access the bit memory area in bits, bytes, words, or double
d d o
Tud
words:
T u T u
Bit: M[byte address].[bit address] M26.7
Byte, Word, or Double Word: M[size][starting byte address] MD20

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 25
gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

4 .c omTimer Memory Area: T 4.com 4 . c om 4.


o a 2 a 2
o are associated with a timer: gho a 2 a 2
ngh
The S7-200 provides
10 ms, or 100 ms.n g hvariables
timers that count increments of time in resolutions
n
(time-base increments) of 1 ms,
n g ho
o Two
do of time counted by the timer. Tudo
Tudvalue: this 16-bit signed integer stores the
- Current Tuamount
- Timer bit: this bit is set or cleared as a result of comparing the current and the preset value. The
preset value is entered as part of the timer instruction.

. co mYou access both of these variables by using


.c o mthethetimer address (T + timer number). Access
. c o mto either the

a 2 4 timer bit or the current value is


a 2 4word operands access the current value.aAs24shown in Figure 4-5, the
dependent on instruction used: instructions with bit operands access
a2 4.
o o accesses the timer bit, while thegMove
the timer bit, while instructions with
hoWord instruction accesses the ngho
ngh 4 current value ofo
d n
Normally Open Contact
the
ghinstruction
timer.
do n do
Format:
T u T[timer number]
T u T24
T u

om m Value T0 om
I2.1 MOV_W T3

4 .c EN
.c oCurrent Timer Bits
. c .
2 24 a2
T0 4 24
hoa hoa o o a
T3 IN OUT VW200

ng ng
T1
h
g T2
T1
g h
d o T2
d on d on
Tu Accesses the current value u u
T3 T3
15 (MSB)
T 0 (LSB)
Accesses the timer bit T

Figure 4-5 Accessing the Timer Bit or the Current Value of a Timer

4 .c om 4 . c om 4 . c om 4.
o a 2 Counter Memory Area: C a 2
otypes of counters that count each low-to-high a 2
otransition event on the counter oa 2
ngh g h
The S7-200 provides three
n n g h
ocounts up only, one type counts down uonly,doand one type counts both up and down. Two o ng h
Tudassociated with a counter: Tud
input(s): one type
variables are
T
- Current value: this 16-bit signed integer stores the accumulated count.
- Counter bit: this bit is set or cleared as a result of comparing the current and the preset value. The

.com .co m .co m


preset value is entered as part of the counter instruction.
.
o a24 o a 2 4
o a 2 4
You access both of these variables by using the counter address (C + counter number). Access to either
o a 24
ngh gh gh h
the counter bit or the current value is dependent on the instruction used: instructions with bit operands
o n o n
access the counter bit, while instructions with word operands access the current value. As shown in
on g
Tud Tu d
Figure 4-6, the Normally Open Contact instruction accesses the counter bit, while the Move Word
instruction accesses the current value of the counter. T u d
Format: C[counter number] C24

.c o m . c o m . c o m .
a24 24 24 24
I2.1 MOV_W C3
Current Value Counter Bits
o hoa hoC0a oa
EN

ngh g g gh
C0

don on n
C3 IN OUT VW200
C1
d C1
o
Tu 15 (MSB)
T u
C2
C3 0 (LSB)
C2
C3
Tud
Accesses the current value Accesses the counter bit

om m om
Figure 4-6 Accessing the Counter Bit or the Current Value of a Counter

2 4 .c 2 4 .co 4 . c 4.
hoa a a2 a2
ng gho gh o
ng ho
Tu don Tu d o n
Tu d o

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
26
n gh n gho gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
PLC Concepts Chapter 4

4 .c om 4 .co m
4. c om .
o a2
High-Speed Counters: HC
o a 2 o a2 o a 24
ngh gh gh h
The high-speed counters count high-speed events independent of the CPU scan. High-speed counters
on on
have a signed, 32-bit integer counting value (or current value). To access the count value for the
on g
ud ud
high-speed counter, you specify the address of the high-speed counter, using the memory type (HC) and
T T
the counter number (such as HC0). The current value of the high-speed counter is a read-only value and T u d
can be addressed only as a double word (32 bits).

Format: HC[high–speed counter number] HC1

24 .com 24 .com . c o m
4.
h o a Accumulators: AC
h o a ho a24
The accumulators are read/write devices that can be used like memory. For example, you can use a
ho4
2
ng don
g
do n g
accumulators to pass parameters to and from subroutines and to store intermediate values used in a
don g
Tu Tu
calculation. The S7-200 provides four 32-bit accumulators (AC0, AC1, AC2, and AC3). You can access
the data in the accumulators as bytes, words, or double words. Tu
The size of the data being accessed is determined by the instruction that is used to access the
accumulator. As shown in Figure 4-7, you use the least significant 8 or 16 bits of the value that is stored in

.co m .co m .co m


the accumulator to access the accumulator as bytes or words. To access the accumulator as a double
.
a 2 4 word, you use all 32 bits.
a 2 4 a 2 4 a 24
o o o o
ngh gh gh g h
For information about how to use the accumulators within interrupt subroutines, refer to the Interrupt
o n
Instructions in Chapter 6.
d d o n d on
Tu
Format: Tu
AC[accumulator number] T
AC0
u

4 .c om 4 . c om AC2 (accessed as a byte)


4 . c om MSB
7
LSB

4.
0

2 2 2 2
ng hoa g h oa g hoa g hoa
Tu don T u d on
Tud
o n
AC1 (accessed as a word) MSB LSB

om om om
15 8 7 0

2 4 . c 2 4 .c 2 4 .c
Most significant Least significant

24.
hoa hoa hoa a
Byte 1 Byte 0
h o
ng d on g
d on g
d on g
T u T u
AC3 (accessed as a double word) T u
MSB LSB
31 24 23 16 15 8 7 0
Most significant Least significant

.c o m .com
Byte 3 Byte 2
.com
Byte 1 Byte 0
.
o a24 o a 24 o a 24 oa 24
ngh Figure 4-7
o n gh the Accumulators
Accessing
on g h
o n gh
Tud T u d Tud

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 27
gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

4 .c omSpecial Memory: SM 4 . c om 4 . c om 4.
o a 2 a 2 a 2 a 2
ngh
The SM bits provide
can use these bitsn tog
a
hoand control some of the special functions
means for communicating information between
n g hof o
the CPU and your program. You
n g ho
that turns on d othe first scan cycle, a bit that toggles at aufixed
select
o or a bit that shows the status of math
the S7-200 CPU, such as: a bit
o
Tu forinstructions.
or operational (For more information about TthedSM rate,
bits, see Appendix D.) You can accessTuthed
SM bits as bits, bytes, words, or double words:

Bit: SM[byte address].[bit address] SM0.1

. co mByte, Word, or Double Word: o m byte address]


SM[size][starting
.c . c o mSMB86
a 2 4 a 2 4 a 2 4 a2 4.
o ho ho ho
ngh 4
Local Memory Area: L
o n
The S7-200 provides g o n
64 bytes of local memory of which 60 can be g
used as scratchpad memory or for
on g
Tudparameters to subroutines.
passing formal
Tud Tud
Tip
If you are programming in either LAD or FBD, STEP 7–Micro/WIN reserves the last four bytes of local

.co m .co m
recommended that you do not use the last four bytes of L memory.
.co m
memory for its own use. If you program in STL, all 64 bytes of L memory are accessible, but it is
.
a 2 4 a 2 4 a 2 4 a 24
o o o o
ngh gh gh g h
Local memory is similar to V memory with one major exception. V memory has a global scope while L

d o n d o n
memory has a local scope. The term global scope means that the same memory location can be
d on
Tu Tu T u
accessed from any program entity (main program, subroutines, or interrupt routines). The term local scope
means that the memory allocation is associated with a particular program entity. The S7-200 allocates
64 bytes of L memory for the main program, 64 bytes for each subroutine nesting level, and 64 bytes for
interrupt routines.

4 .c omThe allocation of L memory for the main o


4 . c m cannot be accessed from subroutines
program
4 . c orm
ointerrupt
from interrupt
4.
o a 2 another subroutine. Likewise,a 2
routines. A subroutine cannot access the
a 2
L memory allocation of the main program, an routine, or
a 2
ngh n g ho
program or of a subroutine.
an
n g ho
interrupt routine cannot access the L memory allocation of the main
ng ho
T u
The allocationdofoL memory is made by the S7-200 onTanuas-needed
do basis. This means that while theTudo
main portion of the program is being executed, the L memory allocations for subroutines and interrupt
routines do not exist. At the time that an interrupt occurs or a subroutine is called, local memory is
allocated as required. The new allocation of L memory might reuse the same L memory locations of a

.co m different subroutine or interrupt routine.


.co m .com .
a 2 4 a 2 4 a 2 4
The L memory is not initialized by the S7-200 at the time of allocation and might contain any value. When
a 24
o o o o
ngh gh gh h
you pass formal parameters in a subroutine call, the values of the parameters being passed are placed by
n n
the S7-200 in the appropriate L memory locations of the called subroutine. L memory locations, which do
o o on g
Tud Tu d u d
not receive a value as a result of the formal parameter passing step, will not be initialized and might
contain any value at the time of allocation. T
Bit: L[byte address].[bit address] L0.0
Byte, Word, or Double Word: L[size] [starting byte address] LB33

.c o m . c o m . c o m .
o a24 hoa
24
hoa
24 oa 24
ngh d on g
d on g o n gh
T u T u Tud

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
28
n gh n gho gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
PLC Concepts Chapter 4

4 .c om 4 .co m
4. c om .
o a2
Analog Inputs: AI
o a 2 o a2 o a 24
ngh gh gh h
The S7-200 converts an analog value (such as temperature or voltage) into a word-length (16-bit) digital
on on
value. You access these values by the area identifier (AI), size of the data (W), and the starting byte
on g
ud ud
address. Since analog inputs are words and always start on even-number bytes (such as 0, 2, or 4), you
T T
access them with even-number byte addresses (such as AIW0, AIW2, or AIW4). Analog input values are T u d
read-only values.

Format: AIW[starting byte address] AIW4

24 .com 24 .com . c o m
4.
h o a Analog Outputs: AQ
h o a ho a24
The S7-200 converts a word-length (16-bit) digital value into a current or voltage, proportional to the digital a
ho4
2
ng don
g
do n g
do
value (such as for a current or voltage). You write these values by the area identifier (AQ), size of the data n g
Tu Tu
(W), and the starting byte address. Since analog outputs are words and always start on even-number
bytes (such as 0, 2, or 4), you write them with even-number byte addresses (such as AQW0, AQW2, or Tu
AQW4). Analog output values are write-only values.

Format: AQW[starting byte address] AQW4

4 .c om 4 .c om 4 . c om 4.
oa 2 Sequence Control Relay
a 2 (SCR) Memory Area: S
o to organize machine operations or steps a 2 a 2
n g h g hsegmentation
SCRs or S bits are
SCRs allown
used
n g hointo equivalent program segments.
can access the S bits as bits, bytes, words,ng
ho
o logical
o
of the control program. You
o
Tud words.
or double
Tud Tud
Bit: S[byte address].[bit address] S3.1
Byte, Word, or Double Word: S[size][starting byte address] SB4

4 .c om Format for Real Numbers 4 . c om 4 . c om 4.


o a 2 Real (or floating-point)a 2 a 2 a 2
ngh n
described in theg ho 754–1985 standard. See Figureng4-8.hReal
numbers
ANSI/IEEE
o numbers are accessed in
are represented as 32-bit, single-precision numbers, whose format is
ng ho
T do lengths.
double-word
u T u do T u do
For the S7-200, floating point numbers are MSB LSB
31 30 23 22 0
accurate up to 6 decimal places. Therefore, you
S Exponent Mantissa
can specify a maximum of 6 decimal places

om om
when entering a floating-point constant.
m
Sign

2 4 . c 2 4 .c Figure 4-8
4 .co
Format of a Real Number
2 24.
ng hoa n g hoa
Accuracy when Calculating Real Numbers
n g ho a
ng h o a
d o d o d o
Tu results. This can occur if the numbersTdiffer
Calculations
inaccurate
u by 10 to the power of x, where x > 6. Tu
that involve a long series of values including very large and very small numbers can produce

For example: 100 000 000 + 1 = 100 000 000

.c o m . c o m . c o m .
o a24 hoa
24
hoa
24 oa 24
ngh d on g
d on g o n gh
T u T u Tud

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 29
gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

.c m
oFormat . c om . c om
a 2 4 for Strings
a 2 4 a 2 4 a 2 4.
o o asoa byte. The first byte of the string ho
ngh n
of g hstring,
A string is a sequence of
the
characters,
which
with each character being storedh
o have a length of 0 to 254 characters, uplusdthe
dcan
defines the length is the number of n
characters. g
o length byte, so the maximum length foruado
Figure 4-9 shows the format for a n g
T u
string. A string
string is 255 bytes. T T

. co m Length Character 1
.c o m
Character 2 Character 3 Character 4 ...
. c o m
Character 254

24 24Byte 2 a24 Byte 254 2 4.


oa hoa a
Byte 0 Byte 1 Byte 3 Byte 4

g
n 4h g gho ng ho
don do n o
Figure 4-9 Format for Strings

Tu Tu Tu d
Specifying a Constant Value for S7-200 Instructions
You can use a constant value in many of the S7-200 instructions. Constants can be bytes, words, or
.c o m .c om as binary numbers, which can then4.becrepresented
om in 4.
double words. The S7-200 stores all constants

a 2 4 2
decimal, hexadecimal, ASCII, or real
a 4 2
number (floating point) formats. See Table 4-2.
a a 2
o hoof Constant Values ho ho
ngh n g n g n g
udo Format udo udo
Table 4-2 Representation

Decimal
T
Representation
[decimal value]
T
Sample
20047
T
Hexadecimal 16#[hexadecimal value] 16#4E4F

.c om Binary 2#[binary number]


. c om 2#1010_0101_1010_0101
.co m
24 ASCII
24
’[ASCII text]’
2
’Text goes between single quotes.’ 4 2 4.
ng hoa Real
g h oa 754–1985
ANSI/IEEE +1.175495E–38 (positive)o
g h a
–1.175495E–38 (negative)
g hoa
Tip Tu
don T udo
n
T udo
n
The S7-200 CPU does not support “data typing” or data checking (such as specifying that the constant
is stored as an integer, a signed integer, or a double integer). For example, an Add instruction can use
the value in VW100 as a signed integer value, while an Exclusive Or instruction can use the same value

.co m in VW100 as an unsigned binary value.


.co m .com .
a 2 4 a 2 4 a 2 4 a 24
o o o o
ngh o n gh o n gh on g h
Tud Tu d T u d

.c o m . c o m . c o m .
o a24 hoa
24
hoa
24 oa 24
ngh d on g
d on g o n gh
T u T u Tud

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
30
n gh n gho gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
PLC Concepts Chapter 4

4 .c om Addressing the Local and 4 .c om 4 . c om 4.


o a 2 a 2 Expansion I/O
a 2 a 2
ngh g ho by theexpansion
The local I/O provided
n g hoof theYou
CPU provides a fixed set of I/O addresses.
n can add I/O points to the
n g ho
T u doof the points of the module are determined
S7-200 CPU
addresses
by connecting I/O modules
T u dbyothe type of I/O and the position of theTmodule
to the right side CPU, forming an I/O
doin
chain.
u
The

the chain, with respect to the preceding input or output module of the same type. For example, an output
module does not affect the addresses of the points on an input module, and vice versa. Likewise, analog
modules do not affect the addressing of digital modules, and vice versa.

. co m .c o m . c o m
24
Tip
24 a24 2 4.
hoa hoa ho a
ho4
Digital expansion modules always reserve process-image register space in increments of eight bits (one

ng don
g
do n g
byte). If a module does not provide a physical point for each bit of each reserved byte, these unused bits
cannot be assigned to subsequent modules in the I/O chain. For input modules, the unused bits in
don g
Tu Tu
reserved bytes are set to zero with each input update cycle.
Analog expansion modules are always allocated in increments of two points. If a module does not
Tu
provide physical I/O for each of these points, these I/O points are lost and are not available for
assignment to subsequent modules in the I/O chain.

.co m .co m .co m .


a 2 4 a 2 4 a 2 4
Figure 4-10 provides an example of the I/O numbering for a particular hardware configuration. The gaps in
a 24
o o
the addressing (shown as gray italic text) cannot be used by your program.
o o
ngh d o n gh
d o n gh
d on g h
Tu CPU 224 4 In / 4 Out 8 In Tu 41 Analog In
Analog Out
8 Out TIn
4 Analog u
1 Analog Out

I0.0 Q0.0 Module 0 Module 1 Module 2 Module 3 Module 4

4 .c om I0.1
I0.2
Q0.1
Q0.2
I2.0

.com
Q2.0 I3.0 AIW0 AQW0 Q3.0

.com
AIW8 AQW4

4.
24 24
I2.1 Q2.1 I3.1 AIW2 AQW2 Q3.1 AIW10 AQW6

2 I0.3 Q0.3 I2.2 Q2.2 I3.2 AIW4 Q3.2 AIW12


2
hoa a a a
I0.4 Q0.4
I0.5
gh o Q0.5
I2.3 Q2.3 I3.3 AIW6
h o Q3.3 AIW14
ho
ng g g
I2.4 Q2.4 I3.4 Q3.4
I0.6

do n Q0.6 I2.5 Q2.5 I3.5

d on Q3.5
o n
Tud
I0.7 Q0.7 I2.6 Q2.6 I3.6 Q3.6

Tu T u
I1.0 Q1.0 I2.7 Q2.7 I3.7 Q3.7
I1.1 Q1.1
I1.2 Q1.2 Expansion I/O
I1.3 Q1.3
I1.4 Q1.4
I1.5 Q1.5

.co m I1.6
I1.7
Q1.6
Q1.7
.co m .co m .
a 2 4 Local I/O
a 2 4 a 2 4 a 24
o hoI/O Addresses for Local and Expansion I/On(CPUh224)o o
ngh o n g o g on g h
Tud Tud d
Figure 4-10
Sample

T u

.c o m . c o m . c o m .
o a24 hoa
24
hoa
24 oa 24
ngh d on g
d on g o n gh
T u T u Tud

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 31
gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

.c m
oUsing .c om of the S7-200 Memory . c om
a 2 4 Pointers for Indirect
a 2 4Addressing
a 2 4 Areas
a 2 4.
o Indirect addressing useshao oare double word memory ho
ngh n
locations that containg
do or accumulator registers (AC1, AC2,
the address of another memory location. n
Youg honly
pointer to access the data in memory. Pointers
doas pointers. To create a pointer, youTmust
can use V memory locations,
do n g
L memory u u u
T locations,
T AC3)
use the Move Double Word instruction to move the address of the indirectly addressed memory location to
the pointer location. Pointers can also be passed to a subroutine as a parameter.

The S7-200 allows pointers to access the following memory areas: I, Q, V, M, S, T (current value only),
. co m . c
and C (current value only). You cannot use o mindirect addressing to access an individual o
. c bitm
or to access AI,

a 2 4 AQ, HC, SM, or L memory


2
areas.
a 4 a 2 4 a2 4.
o ghdatao in a memory address, you create a npointer ho ho
ngh 4 n
To indirectly access the
ampersand (&) o the memory location to be addressed. Theoinput
goperand
to that location by entering an
n g
precededT udan ampersand (&) to signify that the address
with
and
T udof a memory location, instead of its contents,
of the instruction must be
T udo
is to be moved into the location identified in the output operand of the instruction (the pointer).

Entering an asterisk (*) in front of an operand for an instruction specifies that the operand is a pointer. As

.co m .co m
shown in Figure 4-11, entering *AC1 specifies that AC1 is a pointer to the word-length value being
.co
referenced by the Move Word (MOVW) instruction. In this example, the values stored in both VB200 and m .
a 2 4 a
VB201 are moved to accumulator AC0. 2 4 a 2 4 a 24
o o o o
ngh d o n gh
d o n gh
d on g h
T
V199 u AC1
address of VW200 Tu
MOVD &VW200, AC1 T u
V200 12 Creates the pointer by moving the address of VB200 (address of the initial
byte for VW200) to AC1.
V201 34

om m m
V202 56 AC0

2 4 .c V203 78
24 .co
1234 MOVW *AC1, AC0
2 4 .co 2 4.
hoa oa a a
Moves the word value pointed to by AC1 to AC0.

gh gh o ho
ng Figure 4-11
n
Creating and Using a Pointer
do d o n o ng
Tu Tu
As shown in Figure 4-12, you can change the value of a pointer. Since pointers are 32-bit values, use
Tud
double-word instructions to modify pointer values. Simple mathematical operations, such as adding or
incrementing, can be used to modify pointer values.

.co m .co m .co m .


a 2 4 AC1
a 2 4 a 2 4 a 24
o V199
o o o
ngh gh gh h
address of VW200 MOVD &VW200, AC1
V200 12
o n o n
Creates the pointer by moving the address of VB200 (address of
on g
Tu35d46 d d
VW200’s initial byte) to AC1.

Tu u
V201

V202
AC0

1234 MOVW *AC1, AC0


T
V203 Moves the word value pointed to by AC1 (VW200) to AC0.
78

.c o m V199
AC1

. c o m
address of VW202 +D +2, AC1
. c o m .
a24 24 24 24
V200 12

hoa a a
Adds 2 to the accumulator to point to the next word location.

o AC0
MOVW *AC1, AC0ho o
ngh ng g gh
V201 34

on n
5678
d o d o
Tud
V202 56 Moves the word value pointed to by AC1 (VW202) to AC0.
V203
T u7 8 T u
Figure 4-12 Modifying a Pointer

.co m .co m . com


a2 4 Tip
a 2 4 a2 4 a2 4.
o gho o ho
ng h gh
Remember to adjust for the size of the data that you are accessing: to access a byte, increment the

don d o n
pointer value by 1; to access a word or a current value for a timer or counter, add or increment the
d ong
Tu Tu Tu
pointer value by 2; and to access a double word, add or increment the pointer value by 4.

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
32
n gh n gho gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
PLC Concepts Chapter 4

4 .c omSample Program for Using an Offset to4Access


. c om 4 . c om 4.
o a 2 a 2 Data in V Memory
o to the address VB0. You then increment gthehpointer a 2
o by an offset stored in VD1004. LD10 gho a 2
ngh
This example uses LD10 as ah
o n g
then points to another address
pointer
in V memory (VB0 + offset). The value storedn
o on
in the V memory address pointed to by LD10 is then

T u
copied to VB1900.d T u
By changing the value in VD1004, you can access dany V memory location.
T u d
Network 1 //How to use an offset to read the value of any VB location:
//
//1. Load the starting address of the V memory to a pointer.

. co m .c o m . c o m
//2. Add the offset value to the pointer.

24 24 LD
//3. Copy the value from the V memory location (offset) to VB1900.

a24 2 4.
hoa hoa a
SM0.0

ng g MOVD &VB0, LD10


gho g ho4
Tu don +D VD1004, LD10

Tu
MOVB *LD10, VB1900 do n
Tu don

.co m .co m .co m .


a 2 4 a 2 4 a 2 4 a 24
o o o o
ngh d o n gh
d o n gh
d on g h
Tu Tu T u
Sample Program for Using a Pointer to Access Data in a Table
This example uses LD14 as a pointer to a recipe stored in a table of recipes that begins at VB100. In this example, VW1008

.c omstores . c o mrecipe in the table is 50 bytes long, you multiply


the index to a specific recipe in the table. If each
c o
recipe. By adding the offset to the pointer, you can.access
m
the index by 50 to obtain

a 2 4 from the table. In this example, the a 2 4is copied to the 50 bytes that start at VB1500.a24 the individual recipe
the offset for the starting address of a specific
a 2 4.
o ho
recipe
o ho
ngh o n g Network 1 //How to transferg
// – Each o n ahrecipe from a table of recipes:
ng
Tud //T–u
drecipe is 50 bytes long.
The index parameter (VW1008) identifies the recipe T udo
// to be loaded.
//
//1. Create a pointer to the starting address of the recipe table.

.co m .co m //2.


//3.
.co m
Convert the index of the recipe to a double-word value.
Multiply the offset to accommodate the size of each recipe.
.
a 2 4 a 2 4 //4.
a 2 4
Add the adjusted offset to the pointer.
a 24
o o o o
ngh gh gh h
//5. Transfer the selected recipe to VB1500 through VB1549.

o n LD SM0.0
o n on g
Tud MOVD
ITD Tu
&VB100, LD14
VW1008, LD18
d T u d
*D +50, LD18
+D LD18, LD14
BMB *LD14, VB1500, 50

.c o m . c o m . c o m .
o a24 hoa
24
hoa
24 oa 24
ngh d on g
d on g o n gh
T u T u Tud

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 33
gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

4 .c om 4 .c om 4. c om 4.
o a 2 Understanding How the
o a 2
S7-200 Saves and Restores
a 2
Data
a 2
ngh n g ah
variety of safeguards to ensure that your n g hothe program data, and the n g ho
u datao for your S7-200 are properly retained.udo udo
The S7-200 provides program,
configurationd
T
The S7-200 provides a super capacitor that
T T
S7-200 CPU
maintains the integrity of the RAM after power RAM:
maintained by the super capacitor EEPROM:
has been removed. Depending on the model of and the optional battery cartridge permanent storage

. co m o m
the S7-200, the super capacitor can maintain the
.c . c o m
24 RAM for several days.
24
Program block

a24 2 4.
oa oa user-selected a
Program block

g
n 4h permanently all ofn g hprogram,
The S7-200 provides an EEPROM to store
System block

n gho System block


ng ho
dothe configuration data. do o
your
uand
data areas,
T
V memory

Tu
M memory
Data block

M memory Tu d
The S7-200 also supports an optional battery (permanent area)
cartridge that extends the amount of time that the Timer and Counter
Forced values
current values
RAM can be maintained after power has been

.co m .co m
removed from the S7-200. The battery cartridge Forced values
.co m .
a 2 4 a 2 4
provides power only after the super capacitor has
a 2 4 a 24
o been drained.
o o o
ngh d o n gh n gh
Figure 4-13 Storage Areas of the S7-200 CPU
d o d on g h
Tu
Downloading and Uploading the Elements of Your Project Tu T u
Your project consists of three elements: the Program block
program block, the data block (optional), and the System block

omFigure 4-14 shows how a project is4downloaded


om om
Data block: up to the maximum
system block (optional). V memory range

4 .c . c 4 . c 4.
h o a2 to the S7-200.
h o a2 h o a2 hoa 2
ng nga project, the elements of a ng g
S7-200 CPU

d o d o o n
Tud
When you download Program block

Tu project are stored in the the RAM Tu


downloaded
area. The S7-200 also automatically copies the
System block Program block
System block
Data block
Program block

System block
V memory
user program, data block, and the system block Data block
to the EEPROM for permanent storage. M memory

om om om
M memory

2 4 . c 2 4 .c Timer and Counter


2 4 .c (permanent area)

24.
hoa hoa hoa a
current values Forced values

h o
ng d o ng on
Forced values

d
g
d on g
T u T u RAM EEPROM
T u
Figure 4-14 Downloading a Project to the S7-200

Figure 4-15 shows how a project is uploaded

.c o mfrom the S7-200. . c o m . c o m Program block


.
4 24computer, the 24 24
System block Data block

2
hoa
When you upload a project toayour a a
o
gh block and the data o
gh S7-200 CPU gh o
ng S7-200 uploads the system
n
and uploads theoprogram
block from the RAM
o n o n
T thedEEPROM.
block fromu
Tud Program block
System block Program block
Tud
System block
V memory

om om om
Data block

2 4 .c 2 4 . c M memory

2 4 . c M memory
2 4.
hoa a hoa a
(permanent area)

gho ho
Timer and Counter
current values

ng ng ng
Forced values
n
T udo T u d o
Forced values

RAM EEPROM Tu d o
Figure 4-15 Uploading a Project from the S7-200

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
34
n gh n gho gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
PLC Concepts Chapter 4

4 .c om Saving the Retentive M4Memory .c om Area on Power Loss 4.com .


o a2 a2 a2S7-200 CPU a 24
h If you configuredh theofirst 14 bytes of bit memory h o h o
ng d o ngto be retentive, these bytes are dong
(MB0 to MB13)
d on g
Tuthe S7-200saved
permanently
that
to the EEPROM in the event u
loses power. T Program block T u
Program block
System block
System block
As shown in Figure 4-16, the S7-200 moves V memory
these retentive areas of M memory to the Data block

. co m EEPROM.
.c o m . c o m
MB0 to MB13

4.
M memory (if configured as M memory

24 2 4 a2 4
retentive) (permanent area)
2
hoa hoa o a
ho4
The default setting for the first 14 bytes of

ng g h
Timer and Counter
Forced values

ong g
M memory is to be non-retentive. The default current values

d on don
Tud
disables the save that normally occurs when you
T u
power off the S7-200. Forced values
RAM Tu
EEPROM

Figure 4-16 Saving the M Memory on Power Loss

.co m Restoring Data After Power . c m


oOn . c om
a 2 4 a 2 4
restores the program block and the system a 2 4 a 2 4.
o hoAlso at power on, the S7-200 checksnthe
At power on, the S7-200
o to verify that the super capacitor gho
block from the EEPROM memory, as

ngh shown in Figure


d
successfully n g 4-17.
oareasmaintained d
the data stored in RAM memory.
g hRAM
oIf the RAM was successfully maintained,udtheon
T u
retentive of RAM are left unchanged. T u T
The retentive and non-retentive areas of V memory are restored from the corresponding data block in the
EEPROM. If the contents of the RAM were not maintained (such as after an extended power failure), the

om m m
S7-200 clears the RAM (including both the retentive and non-retentive ranges) and sets the Retentive

4 .c .co .co
Data Lost memory bit (SM0.2) for the first scan cycle following power on, and then copies the data stored
4 4 4.
o a2 in the EEPROM to the RAM.
oa 2 o a 2
hoa 2
ngh do ngh
d o n gh o ng
Tu S7-200 CPU Tu Tud
Program block
Program block If the program data was successfully
System block

.co m Program block

.co
System block m System block

.co m
maintained, copies the data block to the
non-retentive areas of V memory in RAM.
.
a 2 4 V memory

a 2 4
Data block
M memory
Data block

a 2 4 a 24
o o hoIfcopies o
ngh gh h
M memory Forced values M memory

o n n g
(permanent area)
o
the program data was NOT maintained,
the data block and M memory
o ng
Tud d d
Timer and Counter

Tu Tu
Forced values (MB0 to MB13), if defined as retentive.
current values Sets all other
non-retentive areas
Forced values of memory to 0

RAM EEPROM

.c o m Figure 4-17
. c o m
Restoring Data after Power On
. c o m .
o a24 hoa
24
hoa
24 oa 24
ngh d on g
d on g o n gh
T u T u Tud

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 35
gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

4 .c om 4 .c om 4. c om 4.
o a 2 Storing Your Program
o
on
a 2 a Memory Cartridge
a 2 a 2
ngh n ganhoptional memory cartridge that providesn
ag ho EEPROM storage for your n g ho
o stores the following elements on theumemory
The S7-200 supports
program. Thed o portable
udo
Tu
block, the
S7-200
system block, and the forced values. T d cartridge: the program block, theTdata
You can copy your program to the memory cartridge from the RAM only when the S7-200 is powered on
and in STOP mode and the memory cartridge is installed. You can install or remove the memory cartridge

. co m while the S7-200 is powered on.


.c o m . c o m
24 24 a24 2 4.
g h oa Caution
g
a
hcanodamage the memory cartridge or thenreceptacle
g ho on the S7-200 CPU. g ho a
n 4 n
Electrostatic discharge
o a grounded conductive pad and/or wear
dwith o on
TuStore
Make contact
cartridge. Tuda grounded wrist strap when you handleTtheud
the cartridge in a conductive container.

To install the memory cartridge, remove the plastic slot cover from the S7-200 CPU and insert the memory

om om om
cartridge in the slot. The memory cartridge is keyed for proper installation.

4 .c 4 .c 4 . c 24 .
ho a2 Copying Your Program htoothea2Memory Cartridge h o a2 h o a
ng After installing then
d o g cartridge, use the
memory
d o ng d on g
Tu
following procedure to copy the program:
Tu System block Memory
Cartridge
Program block
Data block
Forced values
T u
1. Put the S7-200 CPU in STOP mode.
2. If the program has not already been S7-200 CPU

4 .c om program.
4 . om
downloaded to the S7-200, download the
c Program block
4 .co m
4.
a2 a2toMemory 2 2
Program block

o 3.
o
Select the PLC > Program System block
o a hoa
ngh h gh
System block
Cartridge menu
o n gmemory cartridge.
command copy the
o
V memory
n o ng
Tud4-18 shows the elements of the d Tud
Data block
program to the
Figure
CPU memory that are stored on the
TuM memory M memory
(permanent area)
Timer and Counter
memory cartridge. current values
Forced values

4. Optional: Remove the memory cartridge

.co m .c om
and replace the cover on the S7-200.
Forced values
.co mEEPROM .
a24 4 4 24
RAM
2 2
ngh
o
n g hoa n gh o a
Figure 4-18 Copying to a Memory Cartridge
g h o a
d o
uProgram d o d on
Restoring T
the from a Memory CartridgeTu T u
To transfer the program from a memory cartridge to the S7-200, you must cycle the power to the S7-200
with the memory cartridge installed.

.c o m Notice . c o m . c o m
a2 4 a 2
Powering on an S7-200 CPU with 4a blank memory cartridge or a memory acartridge
2 4 that was a 2 4.
o omodel of S7-200 CPU could cause an error. oMemory cartridges that were ho
ngh g hmodel g hmodel g
programmed by a different
programmed by an n n
dotrue. For example, memory cartridgesTthatuwere
unot
opposite is
lower
do programmed by a CPU 221 or CPUT222udo
number CPU can be read by a higher number CPU. However, the

can beTread by a CPU 224, but memory cartridges that were programmed by a CPU 224 are rejected by
a CPU 221 or CPU 222.
Remove the memory cartridge and turn the power on for the S7-200. After power on, the memory

.co m .co m
cartridge can then be inserted and reprogrammed, if required.
. com
a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
36
n gh n gho gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
PLC Concepts Chapter 4

4 .c om 4 .co m
4. c om .
oa2 2
As shown in Figure 4-19, the S7-200 performs
a a2 a 24
ho ho o
Program block
the following tasks after you cycle power with the
ngh h
System block

n g
memory cartridge installed:
n g Data block
Memory

on g
dtheo contents of the memory cartridge Tudo
Cartridge

T1. uIfdiffer
Forced values

T u d
from the contents of the EEPROM, S7-200 CPU
the S7-200 clears the RAM. Program block
Program block
System block
2. The S7-200 copies the contents of the
. co m .c o m . c o m Program block System block

4.
memory cartridge to the RAM. V memory System block

24 3. The S7-200 copies2 4program block, the 24 Data block Data block
2
hoa a a a
the
gh o gh o M memory
Forced values
M memory
ho4
ng g
system block, and the data block to the
o n
EEPROM. o n (permanent area)

don
Tud Tud
Timer and CounterAll other areas

Tu
current values of memory are Forced values
set to 0.

Forced values
RAM EEPROM

4 .c om 4 .c om 4 .co m
Figure 4-19 Restoring from a Memory Cartridge
.
2 2 2 24
ng hoa g hoa gh o a
g h o a
don
Tu the Operating Mode for the
Selecting Tu S7-200 CPU d o n
T u d on
The S7-200 has two modes of operation: STOP mode and RUN mode. The status LED on the front of the
CPU indicates the current mode of operation. In STOP mode, the S7-200 is not executing the program,

4 .c om program.
4 . c om 4 . c om
and you can download a program or the CPU configuration. In RUN mode, the S7-200 is running the

4.
o a2 a 2
hounder athemode switch for changing the modeo a 2 oa 2
ngh htoofmanually select the operating mode:ngh
- The S7-200 provides operation. You can use the mode
g
switchn(located n g
front access door of the S7-200)
o the mode switch to STOP mode stopsuthe
TutodRUN mode starts the execution of the T
setting doexecution of the program; setting the T
program; and setting the mode switch to TERM
moded o
u switch
(terminal)
mode does not change the operating mode.
If a power cycle occurs when the mode switch is set to either STOP or TERM, the S7-200 goes

.com .c om .c om
automatically to STOP mode when power is restored. If a power cycle occurs when the mode switch

a 2 4 is set to RUN, the S7-200 goes to RUN mode when power is restored.
a 2 4 a 2 4 a 2 4.
o o
- STEP 7–Micro/WIN allows you to change the operating
hoset the mode switch on the S7-200 tongho
mode of the online S7-200. To enable the
ngh softwareg
n toh
n g
change the operating mode, you must manually
do TERMbuttons o or PLC > RUN menu commands or theudo
Tuassociated Tuthedoperating mode.
either or RUN. You can use the PLC > STOP
on the toolbar to change T
- You can insert the STOP instruction in your program to change the S7-200 to STOP mode. This
allows you to halt the execution of your program based on the program logic. For more information

.c o m . c m
about the STOP instruction, see Chapter 6.
o . c o m .
o a24 hoa
24
hoa
24 oa 24
ngh d on g
d on g o n gh
T u T u Tud

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 37
gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

4 .c om 4 . c om 4 . c om 4.
o a 2 Using Your Program to
a 2
Save V Memory to the EEPROM
a 2 a 2
ngh n g howord, or double word) stored in any nlocation
g hoof the V memory area to the n g ho
o
You can save a value
EEPROM. A d
(byte,
o scan time by a maximum of 5 ms. Theudo
Tu Save-to-EEPROM
value written Tudvalue
operation typically increases
by the Save operation overwrites any previous
the
T
stored in the V memory area of the
EEPROM.
The Save-to-EEPROM operation does not update the data in the memory cartridge.

4 .com Tip 24 .c o m . c o m
4 and 1,000,000 4.
h o a2 a
Since the number of Saveooperations a 2
ho the EEPROM can wear
h that only necessary values are saved.ngOtherwise,
to the EEPROM is limited (100,000 minimum,
ho a2
ng 4 typical), you should g
out and the d n ensure
o can fail. Typically, you should perform uSaveooperations at the occurrence of specific udon g
uoccur T d
CPU
eventsT that rather infrequently. T
For example, if the scan time of the S7-200 is 50 ms and a value was saved once per scan, the
EEPROM would last a minimum of 5,000 seconds, which is less than an hour and a half. On the other
hand, if a value were saved once an hour, the EEPROM would last a minimum of 11 years.

4 .c om 4 .c om 4 . c om 4.
o a 2 a 2 a 2 a 2
ngh
Copying V Memory
n g ho
to the EEPROM
n ag
ho n g ho
T do Special Memory Word 32 (SMW32)
Special Memory Byte
area of theu
EEPROM.
T u do the address location of the value that
31 (SMB31) commands the S7-200 to copy
stores
value in V memory to the V memory
T uis do
to be copied. Figure 4-20 shows the format of SMB31 and SMW32.

Use the following steps to program the S7-200 to save or SMB31


Size of value to be
7 0
write a specific value in V memory:
om 1. m m saved:

c .co .co
sv 0 0 0 0 0 s1 s0 00 – byte

4 . 4 4 01 – byte
4.
a2 2 2 2
Load the V memory address of the value to be saved
oa a a
10 – word

o in SMW32.
o 11 – double word
ho
ngh gh gh
Save to EEPROM:

2.
o n
Load the size of the data in SM31.0 and SM31.1, as
o n
0 = No
1 = Yes The CPU resets
o ng
Tu d
shown in Figure 4-20.
Tu d SM31.7 after each
save operation.
Tud
3. Set SM31.7 to 1.
SMW32
At the end of every scan cycle, the S7-200 checks SM31.7; 15 V memory address 0

.co m .co
EEPROM. The operation is complete when the S7-200
m
if SM31.7 equals 1, the specified value is saved to the
.c om
Specify the V memory address as an offset from V0.
.
a 2 4 resets SM31.7 to 0.
a 2 4 4
a2 and SMW32 a 24
o o o
Figure 4-20 SMB31
o
ngh Do not change then
d o
h
value
d
h
g in V memory until the save operationoisncomplete.
g
d on g h
Tu
Sample Program: Copying V Memory to the EEPROM
Tu T u
This example transfers VB100 to the EEPROM. On a rising edge of I0.0, if another transfer is not in progress, it loads the address
of the V memory location to be transferred to SMW32. It selects the amount of V memory to transfer (1=Byte; 2=Word; 3=Double

.c o m o m o
Word or Real). It then sets SM31.7 to have the S7-200 transfer the data at the end of the scan.
. c . c m
a2 4 The S7-200 automatically resets SM31.7
2
when
a 4
the transfer is complete.
a 2 4 a 2 4.
o ho hoa V memory location (VB100) ho
ngh g g g
Network 1 //Transfer

o n o n//to the EEPROM


do n
Tud LD udI0.0
T
EU T u
AN SM31.7
MOVW +100, SMW32
MOVB 1, SMB31

.co m .co m S SM31.7, 1


. com
a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
38
n gh n gho gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
PLC Concepts Chapter 4

4 .c om 4 .c om 4. c om 4.
o a 2 Features of the S7-200
a 2 a 2 a 2
ngh The S7-200n g hoseveral special features that allow youngto hcustomize
o how the S7-200 functions to gho
u d
better fit o application.
provides
your
u d o u d on
T T T
The S7-200 Allows Your Program to Immediately Read or Write the I/O
The S7-200 instruction set provides instructions that immediately read from or write to the physical I/O.

. co m .c o m . c o m
These immediate I/O instructions allow direct access to the actual input or output point, even though the
.
24 24 a24
image registers are normally used as either the source or the destination for I/O accesses.
24
ng hoa gh
The corresponding o a
process-image input register location
tonaccess an input point. The corresponding o
is
n not o
gh output register location is updated
modified when you use an immediate
n
o
gh 4
a
o o
Tud when you use an immediate instruction Tud to access an output point. Tud
instruction process-image
simultaneously

Tip
The S7-200 handles reads of analog inputs as immediate data, unless you enable analog input filtering.

.co m om
When you write a value to an analog output, the output is updated immediately.
.c . c om
a 2 4 a 2 4 a 2 4 a 2 4.
o o
It is usually advantageous
ho for using the image registers: ngho
to use the process-image register rather than to directly access inputs or
ngh outputs duringg
n thehexecution of your program. There are three
dosampling of all inputs at the start of the n g reasons
dosynchronizes and freezes the values ofTthe o
dinputs
T-uThe T u
scan u
for the program execution phase of the scan cycle. The outputs are updated from the image register
after the execution of the program is complete. This provides a stabilizing effect on the system.
- Your program can access the image register much more quickly than it can access I/O points,

4 .c om 4 . c om
allowing faster execution of the program.
4 . c om 4.
o a 2 a 2
- I/O points are bit entities and must be accessed as bits or bytes, 2
obytes, words, or double words. Thus, the a but you can access the image
o registers provide additional a 2
ngh
register as h
n g bits,
n g himage ng ho
o
flexibility.
o o
Tud Tud
The S7-200 Allows Your Program to Interrupt the Scan Cycle
Tud
If you use interrupts, the routines associated with each interrupt event are stored as part of the program.
The interrupt routines are not executed as part of the normal scan cycle, but are executed when the

.co m c om
interrupt event occurs (which could be at any point in the scan cycle).
. . c om
a 2 4 Interrupts are servicedaby2
4 a 2 4 a 2 4.
o htheoInterrupt instructions in Chapter 6 fornmore o
the S7-200 on a first-come-first-served basis within their respective priority
ho
ngh o n g
assignments. See
o g hinformation.
o n g
Tud Tud Tud

.c o m . c o m . c o m .
o a24 hoa
24
hoa
24 oa 24
ngh d on g
d on g o n gh
T u T u Tud

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 39
gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

.c m
oThe .c omProcessing Time for Communications . c om
a 2 4 S7-200 Allows You to
a 2 4
Allocate
a 2 4 a 2 4.
o ho ho ho
ngh
Tasks
n g n g n g
T
requests udareoassociated
You can configure
that T udoor for
a percentage of the scan cycle to be dedicated
with a RUN mode edit compilation
processing the communications
execution status. (Run mode editT udo
and
execution status are options provided by STEP 7–Micro/WIN to make debugging your program easier.) As
you increase the percentage of time that is dedicated to processing communications requests, you
increase the scan time, which makes your control process run more slowly.

. co mThe default percentage of the scan dedicated


.c o mto . c o m
a 24 a 24 is set to
processing communications requests
a 24 a2 4.
o o o ho
ngh 4 ghfor processing the gh
10%. This setting was chosen to provide a 1.

o n
reasonable compromise
d status operations while o n ong
Tutheand
compilation
minimizing impact to your control process. Tud d
Tu2.
You can adjust this value by 5% increments up to
a maximum of 50%. To set the scan cycle
time-slice for background communications:

.co m .co m .co m .


a 2 4 1.
2 4
Select the View > Component >
a a 2 4 a 24
o ho ho o
ngh h
System Block menu command and click
n g
on the Background Time tab.
o n g on g
2.
T thedproperties for the communications
Editu
T u do T u d
background time and click OK.
3. Download the modified system block to the
S7-200.

.c om . c o m . c om
Figure 4-21 Communications Background Time

a 2 4 The S7-200 Allows You


ato2 4
Set the States of Digital Outputs
a 2 4for Stop Mode
a 2 4.
o o allows you to determine whether to set ostate of the digital output points gho
ngh to known valueso
d n g h
The output table of the S7-200
n g hthe
o the outputs in the state they were in on
isd
part of the system block that is downloadedud
upon a transition to the STOP mode, or to leave
before the u to the STOP mode. The output tableu
T transition
T
and stored in the S7-200 and applies only to the digital outputs.
T
1. Select the View > Component >

.co m System Block menu command and click


on the Output Table tab.
.c om .c om 1.
.
a 2 4 4
2 last state,
atheir a2 4 a 24
o 2.
o
To freeze the outputs in
o 2.
o
ngh select the Freezeh
d o g values to the outputs,
ntable Outputs check box.
d o ng h
d
3. on g h
Tuthe output table values by clicking the Tu u
3. To copy the
enter
checkbox for each output bit you want to
T
set to On (1) after a run-to-stop transition.
(The default values of the table are all

.c o m zeroes.)
. c o m . c o m .
o a24 4.
a 24
Click OK to save your selections.
o o a 24 oa 24
ngh 5.
S7-200. on
gh
Download the modified system block to the
o n gh o n gh
Tud Tud Tud
Figure 4-22 Configuring the Output Table

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
40
n gh n gho gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
PLC Concepts Chapter 4

4 .c om The S7-200 Allows You4to.cDefine om Memory to Be Retained 4 . c om 4.


o a 2 a 2 a 2 on Loss of Power
a 2
You can define uphtoosix retentive ranges to select the areas of h o you want to retain through power gho
ngh d
cycles. You n g
oonly the retentive timers (TONR) can beuretained.
can define ranges of addresses in the
d n
following g memory
o The default
memory
d
areas to be retentive: V, M, C, andoT.n
For u u
MT T T
timers, setting for the first 14 bytes of
Memory is to be non-retentive.
Only the current values for timers and counters can be retained: the timer and counter bits are not
retentive.
. co m .c o m . c o m
24 Tip 24 a24 2 4.
ng hoa g hoa gho
Changing the range MB0 to MB13 to be retentive enables a special feature that automatically saves
g
a
ho4
don
these locations to the EEPROM on power down.
Tu Tu do n
Tu don
To define the retentive memory:

1. Select the View > Component > 1.

.co m .c om
System Block menu command and click
on the Retentive Ranges tab. . c om .
a 2 4 4
2memory to be retained a2 4 24
o oofapower
2. Select the ranges of
o o a
ngh h h h
2.
followingg
d o n the modified system block to the dong
loss and click OK.
d on g
TuS7-200. Tu u
3. Download
T

4 .c om 4 .co m
4 .co m
4.
o a2 oa 2
ho a 2
hoa 2
ngh do ngh n g
do 4-23 Retentive Memory o ng
Tu TuFigure Tud
The S7-200 Allows You to Filter the Digital Inputs
The S7-200 allows you to select an input filter that defines a delay time (selectable from 0.2 ms to

.co m .co m .co m


12.8 ms) for some or all of the local digital input points. This delay helps to filter noise on the input wiring
.
a 2 4 a 2 4
that could cause inadvertent changes to the states of the inputs.
a 2 4 a 24
o o o o
ngh gh gh h
The input filter is part of the system block that is
o n
downloaded and stored in the S7-200. The
o n o n1.g
Tud
default filter time is 6.4 ms. As shown in
Figure 4-24, each delay specification applies to Tu d Tu d
groups of input points.
2.
To configure the delay times for the input filter:

.c o m . c o m . c o m .
a24 24 24 24
1. Select the View > Component >

ngh
o hoa
System Block menu command and click
g g hoa gh oa
on on n
on the Input Filters tab.
d d o
T u
2. Enter the amount of delay for each group
of inputs and click OK. T u Tud
3. Download the modified system block to the
S7-200.

.co m .co m . com


a2 4 a 2 4 a2 4
Figure 4-24 Configuring the Input Filters
a2 4.
o gho o ho
ng h Tip
don d o n gh
d ong
Tu Tu Tu
The digital input filter affects the input value as seen by instruction reads, input interrupts, and pulse
catches. Depending on your filter selection, your program could miss an interrupt event or pulse catch.
The high speed counters count the events on the unfiltered inputs.

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 41
gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

.c m
oThe .c othem . c om
a 2 4 S7-200 Allows You
ato2 4
Filter Analog Inputs
a 2 4 a 2 4.
o to o o The filtered value is the ho
ngh The S7-200 allows you h
o n g select software filtering on individual analogh
o n g inputs.
o n g
Tuddeadband) is the same for all analog inputs Tufordwhich filtering is enabled. Tud
average value of a preselected number of samples of the analog input. The filter specification (number of
samples and

The filter has a fast response feature to allow large changes to be quickly reflected in the filter value. The
filter makes a step function change to the latest analog input value when the input exceeds a specified
change from the current value. This change, called the deadband, is specified in counts of the digital value
. co m of the analog input.
.c o m . c o m
24 24 a24 2 4.
g h oa hoa
The default configuration is to enable filtering for
g gho ho a
n 4 don
all analog inputs.
do n d ong
1.
1. Tu
Select the View > Component >
System Block menu command and click
Tu Tu
on the Analog Input Filters tab.
2.
2. Select the analog inputs that you want to

.co m .co
filter, the number of samples, and them .co m .
a 2 4 deadband.
a 2 4 a 2 4 a 24
o ho ho o
ngh g g gh
3. Click OK.
n
Downloadothe modified system block to the o n on
Tud Tud d
4.
S7-200. T u

4 .c om 4 .co m
4
Figure 4-25 Analog Input Filter.co m
4.
o a2 oa 2
ho a 2
hoa 2
ngh Tip
n g h n g ng
words.T udodisable
Do not use the
Always
o or alarm indications in the analog o
Tud and AS-Interface Master modules. Tud
analog filter with modules that pass digital information
analog filtering for RTD, Thermocouple,

The S7-200 Allows You to Catch Pulses of Short Duration


.co mThe S7-200 provides a pulse catch feature
.c om .c om 4.
which can be used for some or all of the local digital input

a 2 4 2 4
points. The pulse catch feature allows
a 2 4
you to capture high-going pulses or low-going
a pulses that are of
a 2
o such a short duration that o
haochange in state of the input is ho
ngh h When pulse catch is enabled for an ninput,
they would not always be seen when the S7-200 reads the digital inputs at the
beginning of the scang g g
n cycle.
n
udoand
latched and held
of time T
is caught Tud
othat a pulse which lasts for a short period
until the next input cycle update. This ensures
held until the S7-200 reads the inputs. Tud
o
You can individually enable the pulse catch
operation for each of the local digital inputs.

.c o mTo access the pulse catch configuration


. c o m
screen:
. c o m 1.
.
a24 a 24 > 24 24
ngh
o
n
o
h command and click
1. Select the View > Component
gmenu g hoa 2.
gh oa
o don o n
System Block

TudPulse Catch Bits tab.


on the
2. Click the corresponding check box and
Tu Tud
click OK.
3. Download the modified system block to the

.co m S7-200.
.co m . com
a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu
Figure 4-26 Pulse Catch
Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
42
n gh n gho g h o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
PLC Concepts Chapter 4

4 .c om 4 .co m
4. c om .
oa2 2 a2
Figure 4-27 shows the basic operation of the S7-200 with and without pulse catch enabled.
o a a 24
ngh n gh n g ho g h o
ud o Scan cycle
udoNext scan cycle u d on
T Input update
T Input update
T
Physical Input

. co m .c o m . c o m
24 Output from pulse catch
24 a24
The S7-200 misses this pulse because the input turned
2 4.
hoa oa a
on and off before the S7-200 updated the process-image

ng g h
Disabled
gho
input register
g ho4
on do n don
Tud Enabled Tu The S7-200 catches the pulse on the physicalTinputu
Figure 4-27 Operation of the S7-200 with the Pulse Catch Feature Enabled and Disabled

.co m . c o m . c o m
a 2 4 Because the pulse catch 2
a 4 a 2 4
function operates on the input after it passes through the input filter, you must
a 2 4.
o adjust the input filtero
ho Figure 4-28 shows a block diagramngho
ngh hcircuit.
time so that the pulse is not removed by the filter.
of the digitaln
o g
input
o n g o
Tud Tud Tud
Optical Digital Input Pulse
Input to S7-200
Isolation Filter Catch

4 .c om External
Digital Input
4 . c om Pulse Catch Enable
4 . c om 4.
o a 2 a 2
o Circuit a 2 a 2
ngh g hInput
Figure 4-28 Digital
n n g ho ng ho
T u do T u do T u do
Figure 4-29 shows the response of an enabled pulse catch function to various input conditions. If you
have more than one pulse in a given scan, only the first pulse is read. If you have multiple pulses in a
given scan, you should use the rising/falling edge interrupt events. (For a listing of interrupt events, see

.co m Table 6-44.)


.co m .co m .
a 2 4 a 2 4 a 2 4 a 24
o ho oNext scan cycle o
ngh g gh g h
Scan cycle
o n o n on
Tud Input to pulse catch Tu d u d
Input update Input update
T
Output from pulse catch

.c o m Input to pulse catch


. c o m . c o m .
a24 24 24 24
Output from pulse catch
o oa hoa oa
ngh g h
donOutput from pulse catch
Input to pulse catch
d on g o n gh
Tu T u Tud
Figure 4-29 Responses of the Pulse Catch Function to Various Input Conditions

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 43
gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

.c m
oThe .c m
oProtection . c om .
a2 4 S7-200 Provides 4
a2password Table 4-3 RestrictinghAccess
Password 4
a2to the S7-200 a 24
h o h o o h o
ng d o ng access to specific
All models of the S7-200
protection for restricting
provide
d o ng d on g
functions. u u u
CPU Function Level 1 Level 2 Level 3
T T
Read and write user data Access
Allowed
Access
Allowed
T
Access
Allowed
A password authorizes access to the functions
Start, stop, and restart the
and memory: without a password, the S7-200
CPU
provides unrestricted access. When it is

. co m .c o m
password protected, the S7-200 limits all Read and write the
. c o m
24 24
restricted operations according to the time-of-day clock
a24 2 4.
g h oa g hoa
configuration provided when the password was
ho
Upload the user program,
g
Access Access Password
ho a
n 4 installed.
don do n
data, and the CPU
Allowed Allowed required

d ong
Tu Tu Tu
configuration
The password is not case sensitive.
Download to the CPU Access Password
Allowed required
As shown in Table 4-3, the S7-200 provides Get the execution status
three levels of access restriction. Each level

om om m
allows certain functions to be accessible Delete the program block,

2 4 .c .c
without a password. For all three levels of
2 4
data block, or system block

2 4 .co 24 .
hoa hoa a a
access, entering the correct password provides Force data or execute the
access to all of the functions. The default
gh o h o
ng g g
single/multiple scan

don o n on
condition for the S7-200 is level 1 (no

Tud d
Copy to the memory
T u
restriction).
cartridge
T u
Entering the password over a network does not Write outputs in STOP mode
compromise the password protection for the
S7-200.

4 .c omHaving one user authorized to access


4 . c om functions does not authorize other
restricted
4 . c om
users to access those
4.
o a 2 functions. Only one user is
a 2
allowed unrestricted access to the S7-200 at a
a 2
time.
a 2
ngh n g ho n g ho ng ho
Tip
After you u
T dothe password, the authorization level T
enter foruthat
o remains effective for up to one udo
dpassword T
minute after the programming device has been disconnected from the S7-200. Always exit
STEP 7-Micro/WIN before disconnecting the cable to prevent another user from accessing the privileges
of the programming device.

.co m .co m .co m .


a 2 4 2 4
Configuring a Password for the S7-200
a a 2 4 a 24
o o o o
ngh gh gh h
The System Block dialog box (Figure 4-30)
o n
allows you to configure a password for the
o n on g
Tud Tu d u d
S7-200: 1.
T
1. Select the View > Component >
System Block menu command to display 2.

.c o m the Password tab.


. c m
the System Block dialog box and click on
o . c o m .
a24 24of access for 24 24
3.

o 2.
a
Select the appropriate level
o hoa oa
ngh the S7-200.
d o n h
gthe
d on g o ngh
Tud
3. Enter and verify password.
4. TuOK.
Click T u
5. Download the modified system block to the
S7-200.

.co m .co m . com


a2 4 a 2 4 a2
Figure 4-30 Creating a Password 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
44
n gh n gho g h o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
PLC Concepts Chapter 4

4 .c om 4 .co m
4. c om .
o a2 o a 2
Recovering from a Lost Password
o a2 o a 24
ngh gh gh h
If you forget the password, you must clear the memory of the S7-200 and reload your program. Clearing
on on
the memory puts the S7-200 in STOP mode and resets the S7-200 to the factory-set defaults, except for
on g
ud ud
the network address, baud rate, and the time-of-day clock. To clear your program in the S7-200:
T1. T T u d
Select the PLC > Clear menu command to display the Clear dialog box.
2. Select all three blocks and confirm your action by clicking OK.

. co m 3. o m o m
If a password had been configured, STEP 7–Micro/WIN displays a password-authorization dialog
.c . c
24 24 a24
box. To clear the password, enter CLEARPLC in the password-authorization dialog box to continue
2 4.
ng hoa n g hoa does not remove the program fromnag
ho
the Clear All operation. (The CLEARPLC password is not case sensitive.)
n g
a
ho4
o the password along with the program,
The Clear All operation
o memory cartridge. Since the memory
o
Tudthestores
cartridge
remove lost password. Tudyou must also reprogram the memory cartridge
Tud to
Warning

.co m .c om . c om
Clearing the S7-200 memory causes the outputs to turn off (or in the case of an analog output, to be

a 2 4 frozen at a specific value).


a 2 4 a 2 4 a 2 4.
o oto the equipment. If you had configured the
If the S7-200 is connected to equipment when you clear the memory,
o state” for the outputs to be different gho
changes in the state of the outputs

ngh from theo


d
g h
can be transmitted
n
factory settings, changes in the outputs couldo
d n g h “safe
cause unpredictable operation of your
d on
T u
equipment, which in turn could cause death orT u
serious injury to personnel, and/or damage toT u
equipment.
Always follow appropriate safety precautions and ensure that your process is in a safe state before
clearing the S7-200 memory.

4 .c om The S7-200 Provides Analog 4 . c om Adjustment Potentiometers 4 . c om 4.


o a 2 a 2 a 2 a 2
ngh adjust thesen g ho potentiometers
The analog adjustment are located under the fronto
n g hareaccess cover of the module. You can
stored in bytes of Special Memory ng
ho
(SMB).d o read-only values can be used by theuprogram
potentiometers
o
to increase or decrease values that
doa
u These
Tcurrent
the T or dchangingforthea variety
value for a timer or a counter, entering TuUse
of functions, such as updating
preset values, or setting limits.
small screwdriver to make the adjustments: turn the potentiometer clockwise (to the right) to increase the
value, and counterclockwise (to the left) to decrease the value.

4 . c om 4 .co m
4 .co m
SMB28 holds the digital value that represents the position of analog adjustment 0. SMB29 holds the digital
.
2 value that represents the position of analog adjustment 1. The analog adjustment has a nominal range of
2 2 24
hoa a a a
0 to 255 and a repeatability of ±2 counts.

ng n g ho n g ho ng h o
d o d o d o
Tu T1u //Read analog adjustment 0 (SMB28). Tu
Sample Program for Referencing the Value Entered with the Analog Adjustment Potentiometers
Network
//Save the value as an integer in VW100.
LD I0.0

.c o m . c o m BTI SMB28, VW100

. c o m
a24 a 24 Network 2
a 2
//Use the integer value4(VW100) as a preset for a timer. a 2 4.
o ho ho ho
ngh g g g
LDN Q0.0
o n TON
do
T33, VW100 n do n
Tud T
Network 3
u T u
//Turn on Q0.0 when T33 reaches the preset value.
LD T33
= Q0.0

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 45
gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

.c m
oThe . c om . c om
a 2 4 S7-200 Provides 2 4
High-speed
a I/O
a 2 4 a 2 4.
o ho ho ho
ngh n g
do integrated high-speed counter functions
High-Speed Counters n g
dothat count high speed external eventsTudo n g
T
The S7-200u provides
T u
without degrading the performance of the S7-200. See Appendix A for the rates supported by your CPU
model. Each counter has dedicated inputs for clocks, direction control, reset, and start, where these
functions are supported. You can select different quadrature modes for varying the counting rate. For more

. co m .c m
information on high-speed counters, see Chapter 6.
o . c o m
a 2 4 High-Speed Pulse Output a 2 4 a 2 4 a2 4.
o ho pulse outputs, with outputs Q0.0nand o generating either a ho
ngh 4 The S7-200 supportsg
do
high-speed pulse n
train
high-speed
output (PTO) or pulse width
do
modulation
g hQ0.1
(PWM).
don g
T u T u T u
The PTO function provides a square wave (50% duty cycle) output for a specified number of pulses (from
1 to 4,294,967,295 pulses) and a specified cycle time (in either microsecond or millisecond increments
either from 50 µs to 65,535 µs or from 2 ms to 65,535 ms). You can program the PTO function to produce

.co m .co m .co m


either one train of pulses or a pulse profile consisting of multiple trains of pulses. For example, you can
use a pulse profile to control a stepper motor through a simple ramp up, run, and ramp down sequence or
.
a 2 4 a 2 4 a 2 4
more complicated sequences. The pulse profile can consist of up to 255 segments with a segment
a 24
o ho ho o
ngh h
corresponding to the ramp up or run or ramp down operation.
o n g o n g o ng
T
pulse width
d
uspecified in either microsecond or millisecond
The PWM function d
uincrements. The cycle time has a range either
provides a fixed cycle time with a variable
T
duty
u d
cycle output, with the cycle time and the
T
from 50 µs to 65,535 µs or from 2 ms to 65,535 ms. The pulse width time has a range either from 0 µs to
65,535 µs or from 0 ms to 65,535 ms. When the pulse width is equal to the cycle time, the duty cycle is
100 percent and the output is turned on continuously. When the pulse width is zero, the duty cycle is 0

4 .c om 4 . om
percent and the output is turned off.
c 4 . c om 4.
h o a2 h o a2 pulse output instruction, see Chapter
For more information on the high-speed
h o a26. hoa 2
ng d o ng d o ng o ng
Tu Tu Tud

.co m .co m .co m .


a 2 4 a 2 4 a 2 4 a 24
o o o o
ngh o n gh o n gh on g h
Tud Tu d T u d

.c o m . c o m . c o m .
o a24 hoa
24
hoa
24 oa 24
ngh d on g
d on g o ngh
T u T u Tud

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
46
n gh n gho g h o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u

4 .c om 4 .c om 4. c om 4.
o a 2 Programming a 2 Concepts, 2
Conventions,
a a 2
ngh n g ho n g ho n g ho
udo
andTFeatures Tud
o
Tud
o
The S7-200 continuously executes your program to control a task or process. You use STEP 7–Micro/WIN

.com m m
to create this program and download it to the S7-200. STEP 7–Micro/WIN provides a variety of tools and
.c o . c o 4.
24 24 a24
features for designing, implementing, and debugging your program.
a 2
ng h o
n g hoa n g ho ng ho a
d
In This Chaptero d o d o
Tu Tu Tu 48
Guidelines for Designing a Micro PLC System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Basic Elements of a Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

4 .c om 4 . om 4 . c om
Using STEP 7–Micro/WIN to Create Your Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
c
51
.
2 Choosing Between the SIMATIC and IEC 1131–3 Instruction Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2 2 24 53

ng hoa n
o a Used by the Program Editors . . . o . . .a
gTohHelp You Create Your Control Programo.n. .g. .h. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . on56gh
Understanding the Conventions .......................... 54 o a
o
Using Wizards

Tud Errors in the S7-200 . . . . . . . . . . . . . . T. . .u. .d. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .T. . .u. .d 56


Handling
Assigning Addresses and Initial Values in the Data Block Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Using the Symbol Table for Symbolic Addressing of Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58

4 .c om 4 . c om 4 . c om
Using Local Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Using the Status Chart to Monitor Your Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
59
4.
2 2 2 2
ng hoa forn
Features o Debugging
a a
gho Your Program . . . . . . . . . . . . . . o. . .n. .g. .h. . o. . . . . . . . . . . . . . . . . . . . . . . . . . . . . on60gho
Creating an Instruction Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 a
Tud Tud Tud

.co m .co m .co m .


a 2 4 a 2 4 a 2 4 a 24
o o o o
ngh o n gh o n gh on g h
Tud Tu d T u d

.c o m . c o m . c o m .
o a24 hoa
24
hoa
24 oa 24
ngh d on g
d on g o n gh
T u T u Tud

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 47
gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

4 .c om 4 . c om 4. c om 4.
o a 2 Guidelines for Designing
a 2 a Micro PLC System
o designing a Micro PLC system. The following a 2 a 2
ngh n g hfor n g ho general guidelines can apply to ngho
o Of course, you must follow the directives
There are many methods
many designd o and do
Tu projects.
the accepted Tud of your own company’s procedures T
practices of your own training and location.
u
Partition Your Process or Machine

. co mDivide your process or machine into .sections


c o mthat have a level of independence from.ceach o mother. These
a 2 4 partitions determine the
2
boundaries
a 4of resources.
between controllers and influence the
2 4
functional
a
description
a 2 4.
o ho
specifications and the assignment
ho ho
ngh do n g n g n g
Create theuFunctional
T Specifications
T udo T udo
Write the descriptions of operation for each section of the process or machine. Include the following topics:
5 I/O points, functional description of the operation, states that must be achieved before allowing action for
each actuator (such as solenoids, motors, and drives), description of the operator interface, and any

. c o m . c o
interfaces with other sections of the processmor machine. . c om
a 2 4 a 2 4 a 2 4 a 2 4.
o o o o
ngh h h h
Design the Safety Circuits
n g n g n g
producing u
T do requiring
Identify equipment
unexpected startup or change in the operationu
T ofd
odevices can fail in an unsafe manner, o
machinery. Where unexpected or incorrectud
hard-wired logic for safety. Control
T
operation of the machinery could result in physical injury to people or significant property damage,
consideration should be given to the use of electro-mechanical overrides which operate independently of
the S7-200 to prevent unsafe operations. The following tasks should be included in the design of safety

4 .c om - circuits:

4 .co m
4 .co m
4.
o a2 oa 2 a 2
Identify improper or unexpected operation of actuators that could be hazardous.
ho and determine how to hoa 2
ngh -

d o
detect these
g h thatindependently
Identify the conditions
nconditions of the S7-200.
d o g
would assure the operation is not hazardous,
n d o ng
- T u T u T u
Identify how the S7-200 CPU and I/O affect the process when power is applied and removed, and
when errors are detected. This information should only be used for designing for the normal and
expected abnormal operation, and should not be relied on for safety purposes.

4 . c om -
independent of the S7-200.
4 . om 4 . om
Design manual or electro-mechanical safety overrides that block the hazardous operation
c c 4.
o a 2 Provide appropriateo a 2information from the independent circuitsoato 2the S7-200 so that the a 2
ngh
-
n g
program and any hoperator interfaces have necessary information.
status
n g h n g ho
o o of the process. o
-
Tudany other safety-related requirements forTsafe
Identify udoperation Tud
Specify the Operator Stations

.c o m . c m . c o m
Based on the requirements of the functional specifications, create drawings of the operator stations.
o 4.
Include the following items:

a2 4 a 2 4 of each operator station in relation to athe2process


4 or machine a 2
o - Overview showing
hofothe devices, such as display, switches,ng
the location o ho
ngh o n g hlights, n g
udoCPU or expansion module o
- Mechanical

Tud drawings with the associated I/O of theTS7-200 Tud


layout and for the operator station
- Electrical

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
48
n gh n gho gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
Programming Concepts, Conventions, and Features Chapter 5

4 .c om Create the Configuration 4 .c om 4 . c om 4.


o a 2 a 2 Drawings
a 2 a 2
ngh g ho
Based on the requirements
n g
of the functional specification, create
n
o
hconfiguration drawings of the control
n g ho
do
equipment. Include
T-uOverview
the following items:
T u do T u do
showing the location of each S7-200 in relation to the process or machine
- Mechanical layout of the S7-200 and expansion I/O modules (including cabinets and other
equipment)

. co m .c o m . c o m
4.
- Electrical drawings for each S7-200 and expansion I/O module (including the device model
24 24 a24 2
hoa hoa a
numbers, communications addresses, and I/O addresses)

ng g gho ng ho
IfT
don
Create a List of Symbolic Names (optional)
uchoose to use symbolic names for addressing,
you
do n
Tu d
Tu create a list of symbolic names for the absolute
o
addresses. Include not only the physical I/O signals, but also the other elements to be used in your
program. 5
4 .c om
Basic Elements of a Program
4 .c om 4 . c om 4.
o a 2 o a 2 a 2 a 2
ngh
A program block h
program andnany g is composed of executable code and comments.
n g hoThe executable code consists of a main ho
is compiled and downloaded to the S7-200;ng
u do comments are not. You can use theTorganizational
the program
T u do elements (main program, subroutines,
subroutines or interrupt routines. The code

T u doand
interrupt routines) to structure your control program.

The following example shows a program that includes a subroutine and an interrupt routine. This sample
program uses a timed interrupt for reading the value of an analog input every 100 ms.

4 .c om 4 . c om 4 .co m
4.
o a2 o aof2a Program
Example:Basic Elements
ho a 2
hoa 2
ngh M
do ng h n 1g //On first scan, call subroutine 0.
do SM0.1
Network
do ng
TNI u
A
TuLD
CALL SBR_0 T u
S Network 1 //Set the interval to 100 ms

.co m B
.co m .co m
//for the timed interrupt.
.
a 2 4 R
0
a 2 4 a 2 4
//Enable interrupt 0.
a 24
o o LD
o
SM0.0
o
ngh o n gh MOVB
o n gh 100, SMB34
on g h
Tud d d
ATCH INT_0, 10

Tu ENI
T u

.c o m . c o m . c o m .
o a24 hoa
24
hoa
24 oa 24
ngh I
d on g
d o ng //Sample the Analog Input 4.
Network 1
d on gh
T
N
T
u u
T MOVW AIW4,VW100
LD SM0.0 T u
0

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 49
gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

.c m
oMain .c om . c om
a 2 4 Program
a 2 4 a 2 4 a 2 4.
o ho contains hisoapplication. ho
ngh o n g
The main body of the program
o n g
the instructions that control your The S7-200 executes
o n g
Tud Tud Tud
these instructions sequentially, once per scan cycle. The main program also referred to as OB1.

Subroutines
These optional elements of your program are executed only when called: by the main program, by an

. co m .c m . c o m
interrupt routine, or by another subroutine. Subroutines are useful in cases where you want to execute a
o
24
function repeatedly. Rather than rewriting the logic for each place in the main program where you want the
24 a24 2 4.
hoa hoa a
function to occur, you can write the logic once in a subroutine and call the subroutine as many times as

ng n g n gho
needed during the main program. Subroutines provide several benefits:
ng ho
d o d o d o
Tu Tu Tu
- Using subroutines reduces the overall size of your program.
- Using subroutines decreases your scan time because you have moved the code out of the main
5 program. The S7-200 evaluates the code in the main program every scan cycle, whether the code
is executed or not, but the S7-200 evaluates the code in the subroutine only when you call the

.co m .co m .co m


subroutine, and does not evaluate the code during the scans in which the subroutine is not called.
.
a 2 4 -
a 2 4 a 2 4
Using subroutines creates code that is portable. You can isolate the code for a function in a
a 24
o o o
subroutine, and then copy that subroutine into other programs with little or no rework.
o
ngh Tip
d o n gh
d o n gh
d on g h
Tu Tu
Using V memory addresses can limit the portability of your subroutine, because it is possible for V
memory address assignment from one program to conflict with an assignment in another program.
T u
Subroutines that use the local variable table (L memory) for all address assignments, by contrast, are
highly portable because there is no concern about address conflicts between the subroutine and

4 .c om 4 .co m
another part of the program when using local variables.
4 .co m
4.
o a2 oa 2
ho a 2
hoa 2
ngh Interrupt Routinesgh
do n n g ng
Taupre-defined
These optional
to handle udoeventevents.
elements of your program react to specific interrupt
interrupt event. Whenever theT specified
You design an interrupt routinedo
occurs, the S7-200 executes Ttheu
interrupt routine.

The interrupt routines are not called by your main program. You associate an interrupt routine with an

.co m .co m .co m


interrupt event, and the S7-200 executes the instructions in the interrupt routine only on each occurrence
.
a 2 4 of the interrupt event.
a 2 4 a 2 4 a 24
o o o o
ngh Tip
o n gh o n gh on g h
Tud d d
Because it is not possible to predict when the S7-200 might generate an interrupt, it is desirable to limit
Tu
the number of variables that are used both by the interrupt routine and elsewhere in the program. T u
Use the local variable table of the interrupt routine to ensure that your interrupt routine uses only the
temporary memory and does not overwrite data used somewhere else in your program.

.c o m between your main program and the c


. m routines. These techniques are described
. c o m
There are a number of programming techniques you can use to ensure that data is correctly shared
o
a2 4 with the Interrupt
a
instructions. 2 4 interrupt
a 2 4 in Chapter 6
a 2 4.
o ho ho ho
ngh n g n g n g
Other Elements
T udo of the Program T udo T udo
Other blocks contain information for the S7-200. You can choose to download these blocks when you
download your program.

.co mSystem Block .co m . com


a2 4 System
a 2 4 a2 4
The system block allows you to configure different hardware options for the S7-200.
a2 4.
o gho o ho
ng h gh
Block

Data Block
don d o n d ong
Data
Tu stores the values for different variablesT(Vumemory) used by your program. You can T
The data block
the data block to enter initial values for the data.
useu
Block

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
50
n gh n gho gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
Programming Concepts, Conventions, and Features Chapter 5

4 .c om 4 .c om 4. c om 4.
o a 2 Using STEP 7–Micro/WIN
a 2 to Create Your Programs
a 2 a 2
ngh n g ho double-click on the STEP 7–Micro/WINn g ho icon, or select the Start > SIMATICn> gho
o
To open STEP 7–Micro/WIN,
o 5-1, the STEP 7–Micro/WIN projectuwindow o
TudMicroWIN
STEP 7
provides
3.2 menu command. As shown ind
u Figure
Tyour
a convenient working space for creating control program. T d
The toolbars provide buttons for shortcuts to frequently used menu commands. You can view or hide any
of the toolbars.

. co m .c o m . c o m
24
The navigation bar presents groups of icons for
24 a24 2 4.
hoa hoa a
accessing different programming features of

ng g
STEP 7–Micro/WIN.
n n gho ng ho
udand o tree displays all of the project udo d o
Tu
The instruction
T
objects the instructions for creating your T
control program. You can drag and drop
individual instructions from the tree into your
program, or you can double-click an instruction to
5
.co m .co m
insert it at the current location of the cursor in the
.co m .
a 2 4 program editor.
a 2 4 a 2 4 Program Editor
a 24
o o o o
ngh gh gh g h
The program editor contains the program logic
o n
and a local variable table where you can assign
d d o n Instruction tree
d on
Tu
symbolic names for temporary local variables.
Subroutines and interrupt routines appear as Tu Navigation bar
T u
tabs at the bottom of the program editor window.
Click on the tabs to move between the

om m om
subroutines, interrupts, and the main program. Figure 5-1 STEP 7–Micro/WIN

4 .c 4 . c o 4 . c 4.
o a 2 (STL), and Functiono a 2Diagram (FBD). With some restrictions,oprograms
STEP 7–Micro/WIN provides three
a 2 written(LAD),
editors for creating your program: Ladder Logic Statement List
a 2
ngh n g
program editors can
Block
h be viewed and edited with the other program
n g h editors. in any of these
n g ho
do do do
Program
Editor

T u
Features of the STL Editor T u T u
The STL editor displays the program as a text-based language. The STL editor allows you to create
control programs by entering the instruction mnemonics. The STL editor also allows you to create

.co m .co m .co m


programs that you could not otherwise create with the LAD or FBD editors. This is because you are
.
a 2 4 a 2 4 a 2 4
programming in the native language of the S7-200, rather than in a graphical editor where some
a 24
o ho ho
restrictions must be applied in order to draw the diagrams correctly. As shown in Figure 5-2, this
o
ngh Theu
n g
do executes each instruction in the Tudo n g
text-based concept is very similar to assembly language programming.
d on g h
T S7-200
order dictated by the program, from top to T u
LD I0.0 //Read one input
bottom, and then restarts at the top.
A I0.1 //AND with another input
STL uses a logic stack to resolve the control = Q1.0 //Write value to output 1

.c o m . c o m
logic. You insert the STL instructions for handling
. c o m .
2 4 the stack operations.
24 Figure 5-2
24
Sample STL Program
24
ng hoa g h
Consider these main
a when you select the STL editor: hoa
opoints
ng gh oa
d oisnmost appropriate for experienced programmers.
d o o n
-uSTL
T
-
Tu Tud
STL sometimes allows you to solve problems that you cannot solve very easily with the LAD or FBD
editor.

4 .c om -

- 4
m
You can only use the STL editor with the SIMATIC instruction set.
.co 4 . com 4.
2 2 a2
While you can always use the STL editor to view or edit a program that was created with the LAD or
2
ng hoa gho
a o
FBD editors, the reverse is not always true. You cannot always use the LAD or FBD editors to
gh ng ho a
don n
display a program that was written with the STL editor.
d o d o
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 51
gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

.c m
oFeatures . c om . c om
a 2 4 of the LAD Editor
a 2 4 a 2 4 a 2 4.
o oprogram as a graphical representationgsimilarhofrom ho
ngh The LAD editor displaysh
n g the
doinput conditions that in turn enable logical
Ladder programs allow the program to emulate the flow of n
electric current
to electrical wiring diagrams.
do conditions. A LAD program includesTaudo
a power source through a n g
T u
series of logical
T u output
left power rail that is energized. Contacts that are closed allow energy to flow through them to the next
element, and contacts that are open block that energy flow.

The logic is separated into networks. The

. co m .
program is executed one network at a time,
c o mfrom . c o m
a 24 left to right and then top to
2an4example of a
bottom
a as dictated by
a 24 a2 4.
o o o ho
ngh ngh instructions are gh
the program. Figure 5-3 shows
LAD program. The various
represented d byo o n ong
Tuforms. Tud Tu d
graphic symbols and include
three basic

5 Contacts represent logic input conditions such as


switches, buttons, or internal conditions.

4 . c omCoils 4 . c om
usually represent logic output results such
4 . c om .
o a2 internal output conditions.oa
2
as lamps, motor starters, interposing relays, or
o a2 o a 24
ng h h
ng instructions, such as ng h g h
Boxes represent
d o additional
u or math instructions. d o d on
timers, T counters, Tu5-3 Sample LAD Program
Figure
T u
Consider these main points when you select the LAD editor:

- Ladder logic is easy for beginning programmers to use.


m
o - om om
24.c 4 . c 4 . c 4.
Graphical representation is easy to understand and is popular around the world.

o a The LAD editor can o a 2 a 2


o instruction sets. oa 2
ngh h h h
- be used with both the SIMATIC and IEC 1131–3
n g
o use the STL editor to display a program n g
ocreated with the SIMATIC LAD editor. udo ng
Tud Tud
- You can always

Features of the FBD Editor


T
The FBD editor displays the program as a graphical representation that resembles common logic gate

.co m that appear as box instructions.


.c om .co m
diagrams. There are no contacts and coils as found in the LAD editor, but there are equivalent instructions
.
a 2 4 4
aof2an FBD a 2 4 a 24
o Figure 5-4 shows an exampleo o o
ngh program.
d o ng h
d o n gh
d on g h
FBD doesu
T not use the concept of left and right
power rails; therefore, the term “power flow” is
Tu T u
used to express the analogous concept of control
flow through the FBD logic blocks. Figure 5-4 Sample FBD Program

.c o mThe logic “1” path through FBD elements. c o m


is called power flow. The origin of a power.c o m
a2 4 a 2
destination of a power flow output 4can be assigned directly to an operand. a24 flow input and the
a 2 4.
o ho from the connections between thesenbox o ho
ngh The program logicn is g
o as an AND box) can be used to enable
d(such
derived g hinstructions.
o instruction (such as a timer) to udo
That is, the output from n g
Tunecessary
one instruction
create the Tudallows
control logic. This connection concept
another
T
you to solve a wide variety of logic
problems.

Consider these main points when you select the FBD editor:

4 .c om - . c om . c om
The graphical logic gate style of representation is good for following program flow.
4 4 4.
2 2 with both the SIMATIC and IEC 1131–3 2 2
ng hoa - The FBD editor cano
n g
bea
used
h the STL editor to display a program created
n g o
hwithainstruction sets.
n g ho a
- o o o
Tud Tud Tud
You can always use the SIMATIC FBD editor.

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
52
n gh n gho gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
Programming Concepts, Conventions, and Features Chapter 5

4 .c om 4 .c om 4 . c om 4.
o a 2 Choosing Between
a 2
the SIMATIC and IEC 1131–3
a 2
Instruction Sets
a 2
ngh n g ho basic instructions, but there are usually
g o differences from vendor to vendor in gho
hsmall
u d o operation, and so forth. Over the lastuseveral
Most PLCs offer
appearance,
similar
d n
o years, the International Electrotechnicaludon
T
Commission (IEC) has developed an emergingT Taspects of
global standard that specifically relates to many
PLC programming. This standard encourages different PLC manufacturers to offer instructions that are the
same in both appearance and operation.

. co m o m o m
Your S7-200 offers two instruction sets that allow you to solve a wide variety of automation tasks. The IEC
.c . c
24 24 a24
instruction set complies with the IEC 1131–3 standard for PLC programming, and the SIMATIC instruction
2 4.
hoa hoa ho ho a
set is designed specifically for the S7-200.

ng Tip
don
g
do n g
d ong
Tu Tu Tu
When STEP 7–Micro/WIN is set to the IEC mode, it displays a red diamond 〈♦) in the Instruction Tree
beside the instructions that are not defined by the IEC 1131–3 standard.

There are a few key differences between the SIMATIC instruction set and the IEC instruction set:
5
.co m .co m .co m .
a 2 4 -
a 2 4 a 2 4
The IEC instruction set is restricted to those instructions that are standard among PLC vendors.
a 24
o o o
Some instructions that are normally included in the SIMATIC set are not standard instructions in the
o
ngh d o gh
d o n gh
IEC 1131–3 specification. These are still available for use as non-standard instructions, but if you
n
use them, the program is no longer strictly IEC 1131–3 compatible.
d on g h
u u u
T- Some IEC box instructions accept multipleTdata formats. This practice is often referred toTas
overloading. For example, rather than have separate ADD_I (Add Integer) and ADD_R (Add Real),
math boxes, the IEC ADD instruction examines the format of the data being added and
automatically chooses the correct instruction in the S7-200. This can save valuable program design

4 .c om time.
4 . c om 4 . c om 4.
o a2 - When you use the 2
a a 2
IEC instructions, the instruction parameters are
o such as a signed integer versus angunsigned automatically checked for the
o integer. For example, an error gho a 2
ngh
proper datahformat, hthat
n ifg n expected a bit value (on/off). This n
o helps to minimize programming syntax
results
d o
you try to enter an integer value for an instruction
d o
T ufeature
T u errors.
Consider these points when you select either the SIMATIC or the IEC instruction set:
Tud
- SIMATIC instructions usually have the shortest execution times. Some IEC instructions might have

.co m longer execution times.


.co m .co m .
a 2 4 -
a 2 4 a 2 4
Some IEC instructions, such as timers, counters, multiply, and divide, operate differently than their
a 24
o o o o
ngh gh gh h
SIMATIC counterparts.
- o n o n on g
Tud d d
You can use all three program editors (LAD, STL, FBD) with the SIMATIC instruction set. You can
Tu
use only the LAD and FBD program editors for IEC instructions.
T u
- The operation of the IEC instructions is standard for different brands of PLCs, and the knowledge
about creating an IEC-compliant program can be leveraged across PLC platforms.

.c o m -
. c m . c o m
While the IEC standard defines fewer instructions than are available in the SIMATIC instruction set,
o .
a24 24 24 24
you can always include SIMATIC instructions in your IEC program.

ngh
o -
hoa hoa
IEC 1131–3 specifies that variables must be declared with a type, and supports system checking of
g g gh oa
d on
data type.
d on o n
T u T u Tud

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 53
gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

4 .c om 4 . c om 4 . c om .
o a2 Understanding the
o a2
Conventions Used by the Program
o a2 Editors
o a 24
ng h h h
g the following conventions in all of theoprogram
nuses ng editors: g h
d o
STEP 7–Micro/WIN
d d on
- AT #u
in front of a symbol name (#var1) indicates T uthe symbol is of local scope.
that T u
- For IEC instructions, the % symbol indicates a direct address.
- The operand symbol “?.?” or “????” indicates that an operand configuration is required.

. co mLAD programs are divided into segments. c o m c o m of


called networks. A network is an ordered .arrangement
a 2 4 a 2
contacts, coils, and boxes that are4all connected to form a complete circuit:ano2short
4 circuits, no open a 2 4.
o o flow conditions exist. STEP 7–Micro/WIN hoallows ho
ngh
circuits, and no reverseh
n g power
n g you to create comments
n g
Tuand
segmenting docommenting your program.
for your LAD program

Tud
o
on a network-by-network basis. FBD programming uses the network concept for

Tud
o
STL programs do not use networks; however, you can use the NETWORK keyword to segment your
5 program.

. c m
oConventions Specific to the .LAD c om . c om
a 2 4 a 2 4 Editor
2
F4, F6, and F9 keys on your keyboard toaaccess
4 a 2 4.
o houses the following conventions: ngho
In the LAD editor, you can use the contact, box, and coil
ho
ngh instructions. The LADgeditor
n
do “–––>>” is an open circuit or a required do flow connection. o n g
- Theu
T symbol Tupower Tud
- The symbol “ ” indicates that the output is an optional power flow for an instruction that can be
cascaded or connected in series.

.c om- . c om
The symbol “>>” indicates that you can use power flow.
. c om
a 24 a 4
2 FBD Editor a 2 4 a 2 4.
o Conventions Specificoto the
hoto access AND, OR, and box ngho
ngh In the FBD editor, n g h
doFBD editor uses the following conventions:
you
o n g
can use the F4, F6, and F9 keys on your keyboard
o
TuThe
instructions.
-
Tud Tud
The symbol “–––>>” on an EN operand is a power flow or operand indicator. It can also depict an
open circuit or a required power flow connection.

4 . c om -
cascaded or connected in series.
4 . om 4 . om
The symbol “ ” indicates that the output is an optional power flow for an instruction that can be
c c .
2 a“>>”2indicate that you can use LogicalhNOT a2 24
ng hoa - The symbols “<<” and
ng h o g o
nCondition g h o a
either a value or
d o power flow.
d o d on
-
Tu condition of the operand or power flowTis u Immediate
Negation
inverted
bubbles: The logical NOT condition or
T u
shown by the small circle on the input. In Figure 5-5, Condition
Q0.0 is equal to the NOT of I0.0 AND I0.1. Negation

.c o m . c o m
bubbles are only valid for Boolean signals, which can
be specified as parameters or power flow. Figure 5-5
. c o m
FBD Conventions
.
o a24 -
hoa
24
hoa
24
Immediate indicators: As shown in Figure 5-5, the FBD editor displays an immediate condition of a
oa 24
ngh d on g
d on g
Boolean operand with a vertical line on the input to an FBD instruction. The immediate indicator
o ngh
Tud
causes an immediate read from the specified physical input. Immediate operators are only valid for
T u
physical inputs. T u
- Box with no input or output: A box with no input indicates an instruction that is independent of power
flow.

.co m Tip . c om . c om
a2 4 a
The number of operands can be 2 4 a 2 4
expanded up to 32 inputs for AND and OR instructions. To add or
a2 4.
o subtract operand tics, useothe “+” and “–” keys on your keyboard.
ho ho
ng h o n g h
o n g on g
Tud Tud Tud

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
54
n gh n gho g h o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
Programming Concepts, Conventions, and Features Chapter 5

4 .c om General Conventions of4.Programming


c om 4 . c om 4.
o a 2 a 2 for an S7-200
a 2 a 2
ngh n g ho n g ho n g ho
do IN) is a Boolean input for boxes in LAD doFBD. Power flow must be present at this dofor
EN/ENO Definition
T u
EN (Enable
T u and
T uinput
the box instruction to be executed. In STL, the instructions do not have an EN input, but the top of stack
value must be a logic “1” for the corresponding STL instruction to be executed.

ENO (Enable Out) is a Boolean output for boxes in LAD and FBD. If the box has power flow at the EN

. co m c o m c o m
input and the box executes its function without error, then the ENO output passes power flow to the next
. .
24 24 a24
element. If an error is detected in the execution of the box, then power flow is terminated at the box that
2 4.
ng hoa generated the error.
g hoa gho ng ho a
don do n
In STL, there is no ENO output, but the STL instructions that correspond to the LAD and FBD instructions
Tu Tu
with ENO outputs do set a special ENO bit. This bit is accessible with the AND ENO (AENO) instruction
Tu d o
and can be used to generate the same effect as the ENO bit of a box.

Tip
5
.co m .co m .co m
The EN/ENO operands and data types are not shown in the valid operands table for each instruction
.
a 2 4 a 2 4 a 2 4
because the operands are the same for all LAD and FBD instructions. Table 5-1 lists these operands
a 24
o o o
and data types for LAD and FBD. These operands apply to all LAD and FBD instructions shown in this
o
ngh manual.
d o n gh
d o n gh
d on g h
Tu
Table 5-1 Tu
EN/ENO Operands and Data Types for LAD and FBD T u
Program Editor Inputs/Outputs Operands Data Types
LAD EN, ENO Power Flow BOOL

4 .c om FBD EN, ENO


4 .com
I, Q, V, M, SM, S, T, C, L
.com BOOL
4.
hoa
2
h oa2 ho a24 hoa 2
ng n g
Conditional/Unconditional
In LADd
Inputs
o FBD, a box or a coil that is dependentuupon n g
o flow is shown with a connection touany o n g
Tu and
element T d power
on the left side. A coil or box that is independent T ddirectly
of power flow is shown with a connection
to the left power rail. Table 5-2 shows an example of both a conditional and an unconditional input.

Table 5-2 Representation of Conditional and Unconditional Inputs

.com .c om .c omFBD 4.
a24 4 4
Power Flow LAD

o a 2 a 2 a 2
ngh n g ho
Instruction that is dependent on power flow (conditional)

n g ho n g ho
o o o
Tud that is independent of power flow (unconditional)
Instruction Tud Tud

.c o m Instructions without Outputs


. c o m . c o m .
a24 24 24 24
Boxes that cannot cascade are drawn with no Boolean outputs. These include the Subroutine Call, Jump,
o hoa hoa oa
and Conditional Return instructions. There are also ladder coils that can only be placed on the left power

ngh d on g
d on g
rail. These include the Label, Next, Load SCR, Conditional SCR End, and SCR End instructions. These
o n gh
Tud
are shown in FBD as boxes and are distinguished with unlabeled power inputs and no outputs.
T u T u
Compare Instructions
The compare instruction is executed regardless of the state of power flow. If power flow is false, the output
is false. If power flow is true, the output is set depending upon the result of the compare. SIMATIC FBD,
.co m .co m . com 4.
IEC Ladder, and IEC FBD compare instructions are shown as boxes, although the operation is performed

a2 4 as a contact.
a 2 4 a2 4 a2
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 55
gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

4 .c om 4 .c om 4. c om 4.
o a 2 Using Wizards To Help
a 2
You Create Your Control 2
Program
a a 2
ngh n g ho wizards to make aspects of your programming
n g ho easier and more automatic. In ngho
udo that have an associated wizardTareuidentified
do by the following Instruction Wizard o
STEP 7–Micro/WIN provides
Chapter 6, instructions
icon: T Tud
Instruction

.com m m
Wizard

4 Handling Errors in the S7-200 .c o . c o 4.


o a 2 a 24 a24 a 2
ngh n g ho n g ho n g ho
o o o
Tud by an error by selecting the PLC > Information Tud menu command. Tud
The S7-200 classifies errors as either fatal errors or non-fatal errors. You can view the error codes that
were generated

5 Figure 5-6 shows the PLC Information dialog box


that displays the error code and the description

.c o mof the error.


.c om . c om
a 2 4 2 4
The Last Fatal field shows the previous
a
fatal error
a 2 4 a 2 4.
o hoif the RAM is
code generated by the S7-200. This value is
ho ho
ngh retained over power g
n cycles
n g n g
T
all memory uofdtheoS7-200is cleared
retained. This location either whenever
is cleared or if the RAM T udo T udo
is not retained after a prolonged power outage.
The Total Fatal field is the count of fatal errors

om m m
generated by the S7-200 since the last time the

4 .c .co
S7-200 had all memory areas cleared. This value
4 4 .co 4.
o a2 oa 2
is retained over power cycles if the RAM is
o a 2
hoa 2
ngh gh gh
retained. This location is cleared whenever all
o n
memory of the S7-200 is cleared, or when the
o n o ng
Tu d
RAM is not retained after a prolonged power
outage. Tu d Tud
Appendix C lists the S7-200 error codes, and
Appendix D describes the special memory (SM)

.co m .co m
bits, which can be used for monitoring errors.
.co m .
a 2 4 a 2 4 a 2 4 a 24
o o o o
ngh d o n gh
d
Figure 5-6o n gh
PLC Information Dialog Box
d on g h
TuErrors
Non-Fatal Tu T u
Non-fatal errors are those indicating problems with the construction of the user program, with the
execution of an instruction in the user program, and with expansion I/O modules. You can use

.c o m . c o m . c o m
STEP 7–Micro/WIN to view the error codes that were generated by the non-fatal error. There are three
.
a24 24 24 24
basic categories of non-fatal errors.

o o a o a oa
ngh Program-compileg
o n h
errors
d the download is aborted and an errorTcode o n gh o n gh
Turule,
The S7-200 compiles
compilation
the program as it downloads. If the
udis generated. (A program that was already
S7-200 detects that the program violates a
Tud
downloaded to the S7-200 would still exist in the EEPROM and would not be lost.) After you correct your
program, you can download it again. Refer to Appendix C for a list of compile rule violations.

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
56
n gh n gho gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
Programming Concepts, Conventions, and Features Chapter 5

4 .c om 4 .co m
4. c om .
o a2
I/O errors
o a 2 o a2 o a 24
ngh gh gh h
At startup, the S7-200 reads the I/O configuration from each module. During normal operation, the S7-200
on on
periodically checks the status of each module and compares it against the configuration obtained during
on g
ud ud u d
startup. If the S7-200 detects a difference, the S7-200 sets the configuration error bit in the module error
T T T
register. The S7-200 does not read input data from or write output data to that module until the module
configuration again matches the one obtained at startup.

The module status information is stored in special memory (SM) bits. Your program can monitor and

.com o m o m
evaluate these bits. Refer to Appendix D for more information about the SM bits used for reporting I/O

24 24 .c . c 4.
a24
errors. SM5.0 is the global I/O error bit and remains set while an error condition exists on an expansion
a 2
o hoa ho ho a
module.

ng h n g n g ng
d o d o d o
Tuprogram can create error conditions while Tbeing
u executed. These errors can result from T u
Program execution errors
Your improper use
of an instruction or from the processing of invalid data by an instruction. For example, an indirect-address
pointer that was valid when the program compiled could be modified during the execution of the program 5
to point to an out-of-range address. This is an example of a run-time programming problem. SM4.3 is set

.co m .co m .co m


upon the occurrence of a run-time programming problem and remains set while the S7-200 is in RUN
.
a 2 4 a 2 4 a 2 4
mode. (Refer to Appendix C for the list of run-time programming problems). Program execution error
a 24
o o o
information is stored in special memory (SM) bits. Your program can monitor and evaluate these bits. o
ngh n gh n gh ng
Refer to Appendix D for more information about the SM bits used for reporting program execution errors.
d o d o d o
h
TuS7-200 does not change to STOP mode when
The Tuit detects a non-fatal error. It only logs the Tevent
u in SM
memory and continues with the execution of your program. However, you can design your program to
force the S7-200 to STOP mode when a non-fatal error is detected. The following sample program shows
a network of a program that is monitoring two of the global non-fatal error bits and changes the S7-200 to

4 .c om 4 . om
STOP whenever either of these bits turns on.
c 4 . c om 4.
o a2 Sample Program: Logica
ho
2
for Detecting a Non-Fatal Error Condition
o a 2
hoa 2
ngh o n g Network 1
o n orh
//When an I/O errorg a run-time error occurs, go to STOP mode
o ng
Tud LD
O
SM5.0
SM4.3 T u d T u d
STOP

.co m .co m .co m .


a 2 4 a 2 4 a 2 4 a 24
o ho ho o
ngh Fatal Errors
d o n g
d o n g
program. Depending upon the severity dof o
ng h
Tuerror, it can render the S7-200 incapable ofTperforming
u any or all functions. The objectiveTforuhandling
Fatal errors cause the S7-200 to stop the execution of your the
fatal
fatal errors is to bring the S7-200 to a safe state from which the S7-200 can respond to interrogations
about the existing error conditions. When a fatal error is detected, the S7-200 changes to STOP mode,
turns on the System Fault LED and the STOP LED, overrides the output table, and turns off the outputs.

.c o m o m o m
The S7-200 remains in this condition until the fatal error condition is corrected.
. c . c
a24 Once you have made the2
a 4 to correct the fatal error condition,ause24one of the following methods to
changes
a 2 4.
o ho ho ho
ngh g g g
restart the S7-200:
n
dothe power off and then on. n n
T--uTurn T udo T udo
Change the mode switch from RUN or TERM to STOP.
- Select the PLC > Power-Up Reset menu command from STEP 7–Micro/WIN to restart the S7-200.

.co m .co m
This forces the S7-200 to restart and clear any fatal errors.
. com
a2 4 a 2 4 a2 4
Restarting the S7-200 clears the fatal error condition and performs power-up diagnostic testing to verify
a2 4.
o gho ho
that the fatal error has been corrected. If another fatal error condition is found, the S7-200 again sets the
ho
ng h d o d o g
fault LED, indicating that an error still exists. Otherwise, the S7-200 begins normal operation.
n n d on g
Tutheerrorerrorconditions
Some
view Tuof errorsof communication.
can render the S7-200 incapable
code from the S7-200. These types Tuthe
In these cases, you cannot
indicate hardware failures that require
S7-200 to be repaired; they cannot be fixed by changes to the program or clearing the memory of the
S7-200.

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 57
gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
S7-200 Programmable Controller System Manual

4 .c om 4 .c om 4. c om 4.
o a 2 Assigning Addresses and
a 2 Initial Values in the Data
a 2
Block Editor
a 2
ngh n g hoyou to make initial data assignmentsntogVhmemory
o (variable memory) only.
n g ho
You can make o
The data block editor allows
udassignments udofoV memory. Comments are optional.Tudo
to bytes, words, or double words
Data T
The data block editor is a free-form text editor;
Block
T
that is, no specific fields are defined for particular
types of information. After you finish typing a line

. co m o m
and press the Enter key, the data block editor
.c . c o m
24 24
formats the line (aligns columns of addresses,
a24 2 4.
hoa hoa ho ho a
data, comments; capitalizes V memory

ng don
g
addresses) and redisplays it. The data block
editor assigns an appropriate amount of V
do n g
d ong
Tu
memory based on your previous address
allocations and the size (byte, word, or double
Tu Tu
5 word) of the data value(s). Figure 5-7 Data Block Editor

.c o mThe first line of the data block must have anm


.c o c o
An implicit address assignment is made by.the
mcan have
explicit address assignment. Subsequent lines

a 2 4 a 4 address assignment, or type a line that


explicit or implicit address assignments.
type multiple data values after a2 single
a 2 4 only data values.
contains
editor when you
a 2 4.
o ho hocommas, tabs, or spaces to ho
ngh o
The data block editor n g o
accepts uppercase or lowercase letters andn g
allows
o n g
Tud between addresses and data values.
serve as separators
Tud Tud
Using the Symbol Table for Symbolic Addressing of Variables

.c omThe symbol table allows you to define and m


. c o o m name
edit the symbols that can be accessed by the symbolic
. c
a 2 4 for system-defined symbols that2
a 4 can use in your program. The symbol atable24is also referred to as the
anywhere in your program. You can create
you
multiple symbol tables. There is also a tab in the symbol table
a 2 4.
o global variable table. ho
Symbol

ho ho
ngh
Table

n g n g ng
u dothe operands of the instructions in yourTprogram
You can identify
T u do absolutely or symbolically. An absoluteT u do
reference uses the memory area and bit or byte location to identify the address. A symbolic reference
uses a combination of alphanumeric characters to identify the address.

For SIMATIC programs, you make global symbol

. c o massignments by using the symbol table. Form


.c o IEC
.c om .
a2 4 4
programs, you make global symbol assignments
a2 a2 4 a 24
h o o
by using the global variable table.
h h o h o
ng d o
To assign a symbolntogan address: d o ng d on g
Tuon the Symbol Table icon in the
1. Click Tu T u
navigation bar to open the symbol table. Figure 5-8 Symbol Table

2. Enter the symbol name (for example, Input1) in the Symbol Name column. The maximum symbol

.c o m length is 23 characters.
. c o m . c o m
a2 4 a 2 4 I0.0) in the Address column.
3. Enter the address (for example,
a 2 4 a 2 4.
ho o table, enter a value in the Data Type
hvariable o or select one from the
hcolumn ho
ng n g
4. For an IEC global
listbox.do do n g
do n g
T u T u T
You can create multiple symbol tables; however, you cannot use the same string more than once as a
u
global symbol assignment, neither within a single table nor among several tables.

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
58
n gh n gho gh o
ud o udo u d on
T T T
ng d on g
d on g
d on g
T u T u T u
Programming Concepts, Conventions, and Fe