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 Features Chapter 5

4 .c om 4 .c om 4. c om .
o a2 Using Local Variables
o a2 o a2 o a 24
ng h h
glocal variable table of the
You can usenthe ng h g h
d o d o d on
Tu to an individual subroutine or interrupt Tu
program
unique
editor to assign variables that are
T u
routine. See Figure 5-9.
Local variables can be used as parameters that

.com o m o m
are passed in to a subroutine and they increase

24 24 .c . c 4.
a24
the portability or reuse of a subroutine.
a 2
ng h o g hoa g o Variable Table
hLocal ng ho a
don n
Figure 5-9

u udo Tu d o
Using T
the Status Chart to Monitor T
Your Program
A status chart allows you to monitor or modify the values of the process variables as your S7-200 runs the 5
.co m .c om . c om
control program. You can track the status of program inputs, outputs, or variables by displaying the current

4.
values. The status chart also allows you to force or change the values of the process variables.

a 2 4 Status
Chart
a 2 4 charts in order to view elements from a 2 4 a 2
o o
You can create multiple status
o different portions of your program.
o
ngh n g h
To accessothe status chart, select the View > Component n g h
o > Status Chart menu command or click o n g h
TudChart icon in the navigation bar. Tud Tud
the
Status

When you create a status chart, you enter


addresses of process variables for monitoring.

om m m
You cannot view the status of constants,

4 .c .co
accumulators, or local variables. You can display
4 4 .co 4.
o a2 oa 2
a timer or counter value either as a bit or as a
o a 2
hoa 2
ngh gh gh
word. Displaying the value as a bit shows the
n
status of the timer or counter bit; displaying the
o o n o ng
Tu d
value as a word shows the timer or counter
value.
d
TuFigure 5-10 Status Chart Tud
To build a status chart and monitor the variables:

4 . c om 1.

4
m
Enter the address for each desired value in the Address field.
.co 4 .co m .
2 2.
2
Select the data type in the Format column.
2 24
ng hoa 3.
g ho a
g ho a
ng
To view the status of the process variables in your S7-200, select the Debug > Chart Status menu
n n h o a
d o
command.
d o d o
T4. uTo continuously sample the values, or to T u a single read of the status, click the button
perform Tuon the
toolbar. The Status Chart also allows you to modify or force values for the different process
variables.

.c o m . c m . c m
You can insert additional rows in your Status Chart by selecting the Edit > Insert > Row menu command.
o o .
o a24 Tip
hoa
24
hoa
24 oa 24
ngh d on g
d on g
You can create multiple status charts to divide the variables into logical groups so that each group can
o n gh
Tud
be viewed in a shorter and separate status chart.
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 59
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 Creating an Instruction
a 2
Library
a 2 a 2
ngh n g hoyou either to create a custom library ofninstructions,
g ho or to use a library created ngho
uelse.o See Figure 5-11. udo udo
STEP 7–Micro/WIN allows
by someone d
T T
To create a library of instructions, you create standard STEP 7–Micro/WIN subroutine and interrupt
T
routines and group them together. You can hide the code in these routines to prevent accidental changes
or to protect the technology (know-how) of the author.

. co mTo create an instruction library, perform. c o m . c o m


a 2 4 a 2 4 the following tasks:
a 2 4 a 2 4.
o oa standard STEP 7–Micro/WIN ho ho
ngh
1. Write the programhas
n g n g n g
udintoosubroutines or interrupt routines. Tudo do
project and put the function to be included in the
T
library Instruction Library Tu
2. Ensure that all V memory locations in the subroutines
5 or interrupt routines have been assigned a symbolic
name. To minimize the amount of V memory that the

. c m
o 3. Rename .c om
library requires, use sequential V memory locations.
. c om .
a 2 4 the subroutines or 4
a 2 interrupt routines to the
a 2 4 a 2 4
o hoto appear in the instruction ho ho
ngh
names that you want
library. n g n g n g
T
4. Select u dtheoFile > Create Library menu commandTtoudo T u do
compile the new instruction library.

For more information about creating libraries, refer to the

4 .c omUse the following procedure to access


4 . om
online help for STEP 7–Micro/WIN.
c 4 . c om 4.
o a 2 a 2 an instruction in an
a 2 a 2
ngh
instruction library:
ng ho g hoInstruction Tree with Libraries
Figure 5-11
n ng ho
o do the File > Add Libraries menu Tudo
TudLibraries directory to the instruction treeTbyuselecting
1. Add the
command.
2. Select the specific instruction and insert it into your program (as you would any standard
instruction).

.co m .co m .co m


If the library routine requires any V memory, STEP 7–Micro/WIN prompts you when the project is
.
a 2 4 a 2 4 a 2 4
compiled to assign a block of memory. Use the Library Memory Allocation dialog box to assign
a 24
o ho ho o
ngh h
blocks of memory.
n g n g on g
do
TuDebugging
Features for Your ProgramTudo T u d
STEP 7–Micro/WIN provides the following features to help you debug your program:

- Bookmarks in your program to make it easy to move back and forth between lines of a long

.c o m program.
. c o m . c o m
a2 4 -
a 2
Cross Reference table allow4you to check the references used in youraprogram.
2 4 a 2 4.
ho o you to make small changes to yourgprogram
hallows ho with minimal disturbance to ngho
ng -
n g
RUN-mode editing
n
o controlled by the program. You can alsouddownload
o the program block when you are udo
Tudin RUN mode.
the process
editing T T
For more information about debugging your program, refer to Chapter 8.

.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
60
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 S7-200 Instruction
a 2 Set a 2 a 2
ngh n g ho n g ho n g ho
do
Tuchapter do
Tuinstruction udo
This describes the SIMATIC and IEC 1131 set for the S7-200 Micro PLCs. T

. co m
In This Chapter
. c o m . c o m
a 2 4 a 2
Conventions Used to Describe 4 the Instructions . . . . . . . . . . . . . . . . . . .a. .2. .4. . . . . . . . . . . . . . . . . . . . . . 63 a2 4.
o ho and Features . . . . . . . . . . . . . . . . .n. .g. .h. . o. . . . . . . . . . . . . . . . . . . . . . . . . . . . . n64gho
ngh n
S7-200 Memory g Ranges
doInstructions . . . . . . . . . . . . . . . . . . . . . . T. . .u. .d. . o. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .T. . .u. .do66
TuContacts
Bit Logic
......................................................................... 66
Coils . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Logic Stack Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70

.co m .co m .co


Set and Reset Dominant Bistable Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . m 72
.
a 2 4 a 2 4 a 2 4
Clock Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
a 24
o ho ho o
ngh d o n g
Read and Network Write Instructions . .d o n g o
74
n
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .d 74
g
Communications Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . h
TuTransmit and Receive Instructions (Freeport)Tu. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .T. . .u. . 79
Network

Get Port Address and Set Port Address Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88


Compare Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89

4 .c om .co m .co m
Comparing Numerical Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4 4 4.
89

o a2 oa 2
ho a 2
Compare String . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
hoa 2 91

ngh g h g g
Conversion Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
n
doConversion
Standard Conversion Instructions . . . . . . . . . . . . . . o n n
d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. .. ..u.. ..do9296
TuASCII . . .u
Instructions . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .T
String Conversion Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Encode and Decode Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105

.co m .co m .co m


Counter Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
.
a 2 4 a 2 4 a 2 4
SIMATIC Counter Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
a 24
o ho ho o
ngh h
IEC Counter Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
o n g o n g
High-Speed Counter Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . o ng 111
d d d
TuOutput Instruction . . . . . . . . . . . . . . . . . . . T. . .u. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .T. . .u. . 125
Pulse
Math Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
Add, Subtract, Multiply, and Divide Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140

.c o m . c o m
Multiply Integer to Double Integer and Divide Integer with Remainder . . . . . . . . . . . . . . . . . . . . . .
. c o m 142
.
a24 24 24 24
Numeric Functions Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143

ngh
o hoa hoa
Increment and Decrement Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ng ng n
144
gh oa
u d o u d o
Proportional/Integral/Derivative (PID) Loop Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
u d o155 145

T
Interrupt Instructions . . . . . . . . . . . . . . . . . . . . . . T
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Logical Operations Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
T
. . . . .
162
Invert Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162

.co m . c om . c om
AND, OR, and Exclusive OR Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
.
a2 4 a 2 4 a 2 4
Move Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
a2 4
o ho Double Word, or Real . . . . . . . . . . . .. ..g.. ..h.. .. o.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 166 ho
ng h
Move Byte, Word, 165
n g Immediate (Read and Write) . . . . . . . . . . . .n n g
doMove Instructions . . . . . . . . . . . . . . . T. . .u. .d. . o. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .T. . .u. .do167
Move Byte

TuBlock

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 61
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 omProgram Control Instructions . . . .4. ... c. . o. . .m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4 . ... c


om 4.
o a 2 Conditional End . . . .o a 2 a 2 ............. 168
a 2
ngh ..g
. .n
Stop . . . . .o
h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. ..n.. .. g.. .. ..h.. ..o.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 168
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .o 168 ong
ho
T udReset . . . . . . . . . . . . . . . . . . . . . . . . . . . .T. . u. . d
Watchdog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Tu
d
168
For–Next Loop Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
Jump Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172

. co m .c m
Sequence Control Relay (SCR) Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
o . c o m 173

a 24 a 24 a 2 4. . . . . . . . . . . . . . . . 179
Shift and Rotate Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
a2 4.
o ho
Shift Right and Shift Left Instructions . . . . . . . . . . . . . . . . . . . . . . . .
ho
. . . . . . . . . .
ho
ngh n gRotate Left Instructions . . . . . . . . . . . . . . . .n . .g n g
udo Bit Instruction . . . . . . . . . . . . . . . . . .T. . u. . d o u181do
Rotate Right and ............................ 179

T
Shift Register ...................................
Swap Bytes Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
T 183
String Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184

om m m
Table Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189

4 .c Add To Table . . . . . . . . . . . . . . . ... c o . . . . ... c


4 . . . . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..a.. .. 2 o
4 . . . . . . . . . . . . . 189 4.
o6a2 o a 2 o a 2
ho
First-In-First-Out and Last-In-First-Out ................... 190

ng h Memory Fill . . . g
n . . .h. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .g
n . . .h ......................... 192
n g
Table u
T do. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .T. . u. . d
Find . . .o ................................
T u do
193
Timer Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
SIMATIC Timer Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
IEC Timer Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201

4 .c om .co m .co m
Subroutine Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4 4
203
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
62
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .c om 4 . c om 4.
o a 2 Conventions Used
ato 2 Describe the Instructions
a 2 a 2
ngh n g ha otypical description for an instruction andnpoints
g hoto the different areas used to describengho
do table o o
Figure 6-1 shows
and its operation. The illustration of thedinstruction dSTL.
Tuoperand
the instruction
The Tu and showsshows
lists the operands for the instruction Tuareas
the format in LAD, FBD, and
the valid data types, memory
and sizes for each operand.
EN/ENO operands and data types are not shown in the instruction operand table because the operands

.com o m o m
are the same for all LAD and FBD instructions.
4 .c
4are power flow and are BOOL data types. 4. c 4.
h o a2 - For LAD: EN and ENO
a 2
hoand ENO are I, Q, V, M, SM, S, T, C, L,norgpower a 2
ho flow and are BOOL data types. ngho a2
n g - For FBD:
n g EN
udo
TDescription T udo T udo
of the instruction STL instruction LAD and FBD instructions
and operands

.co m .co m .co m


a 2 4 List of the error conditions24
a a 2 4 6a 2 4.
o ando o gho
ngh
that affect ENO h
on
bits affected g any SM
o n gh o n
T u d Tu d Tud

4 .c om 4 .co m
4 .co m
4.
o a2 oa 2 o a 2
hoa 2
ngh o n gtheh o n gh o ng
ud
Operands
Tinstruction
for
Tu d Tud
Valid data types

.co m .co m .co m .


a 2 4 a 2 4 Valid memory areas and sizes for
a 2 4 a 24
o o o o
ngh gh gh h
the operands

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 o g Descriptions
nInstruction d on g o n gh
Tud
Figure 6-1
Tu 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 63
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 S7-200 Memory Ranges
a 2
and Features
a 2 a 2
ngh andg
Memory Ranges n
ho n g ho n g ho
Table 6-1
o Features for the S7-200 CPUs
o o
Tud CPU 221 TCPUud224 Tud
ÑÑÑÑÑÑÑÑ ÑÑÑÑÑ ÑÑÑÑÑÑ ÑÑÑÑÑ ÑÑÑÑÑÑ ÑÑÑÑÑ
Description CPU 222 CPU 226 CPU 226XM

ÑÑÑÑÑÑÑÑ ÑÑÑÑÑ ÑÑÑÑÑÑ ÑÑÑÑÑ ÑÑÑÑÑÑ ÑÑÑÑÑ


User program size 2 Kwords 2 Kwords 4 Kwords 4 Kwords 8 Kwords

ÑÑÑÑÑÑÑÑ ÑÑÑÑÑ ÑÑÑÑÑÑ ÑÑÑÑÑ ÑÑÑÑÑÑ ÑÑÑÑÑ


User data size 1 Kwords 1 Kwords 2.5 Kwords 2.5 Kwords 5 Kwords

o m o m
Process-image input register I0.0 to I15.7
o m I0.0 to I15.7 I0.0 to I15.7 I0.0 to I15.7 I0.0 to I15.7

a 2 4ÑÑÑÑÑÑÑÑ
. c
ÑÑÑÑÑ a 2ÑÑÑÑÑÑ
4 . c
ÑÑÑÑÑ
Process-image output register
ÑÑÑÑÑÑ
a 2 4 ÑÑÑÑÑ
. c
Q0.0 to Q15.7
a 2 4.
Q0.0 to Q15.7 Q0.0 to Q15.7 Q0.0 to Q15.7 Q0.0 to Q15.7

ngh
o
ÑÑÑÑÑÑÑÑ ÑÑÑÑÑho ÑÑÑÑÑÑ
Analog inputs (read only)
g ÑÑÑÑÑ ÑÑÑÑÑÑ
g ho
––
ÑÑÑÑÑ ho
AIW0 to AIW30
g
AIW0 to AIW62 AIW0 to AIW62 AIW0 to AIW62

ÑÑÑÑÑÑÑÑ Tud ÑÑÑÑÑ


o n
ÑÑÑÑÑÑ ÑÑÑÑÑ
Tud ÑÑÑÑÑÑ
o n
ÑÑÑÑÑ o n
Analog outputs (write only) –– AQW0 to AQW30 AQW0 to AQW62 AQW0 to AQW62 AQW0 to AQW62

Tud
ÑÑÑÑÑÑÑÑ ÑÑÑÑÑ ÑÑÑÑÑÑ ÑÑÑÑÑ ÑÑÑÑÑÑ ÑÑÑÑÑ
Variable memory (V) VB0 to VB2047 VB0 to VB2047 VB0 to VB5119 VB0 to VB5119 VB0 to VB10239

ÑÑÑÑÑÑÑÑ ÑÑÑÑÑ ÑÑÑÑÑÑ ÑÑÑÑÑ ÑÑÑÑÑÑ ÑÑÑÑÑ


Local memory (L)1 LB0 to LB63 LB0 to LB63 LB0 to LB63 LB0 to LB63 LB0 to LB63

ÑÑÑÑÑÑÑÑ ÑÑÑÑÑ ÑÑÑÑÑÑ ÑÑÑÑÑ ÑÑÑÑÑÑ oÑÑÑÑÑ


Bit memory (M) M0.0 to M31.7 M0.0 to M31.7 M0.0 to M31.7 M0.0 to M31.7 M0.0 to M31.7

m Special Memory (SM)


m m
SM0.0 to SM179.7 SM0.0 to SM299.7 SM0.0 to SM549.7 SM0.0 to SM549.7 SM0.0 to SM549.7

6 2 4ÑÑÑÑÑÑÑÑ
.c
o ÑÑÑÑÑÑÑÑ
o
ÑÑÑÑÑ ÑÑÑÑÑÑ
Read only
2 4 . c o
ÑÑÑÑÑ ÑÑÑÑÑÑ 2 4 . c
SM0.0 to SM29.7
ÑÑÑÑÑ 4.
SM0.0 to SM29.7
2
SM0.0 to SM29.7 SM0.0 to SM29.7 SM0.0 to SM29.7

a
ÑÑÑÑÑho ÑÑÑÑÑÑ
a
ÑÑÑÑÑ ÑÑÑÑÑÑ
ho a
ÑÑÑÑÑ ho a
Timers 256 (T0 to T255) 256 (T0 to T255) 256 (T0 to T255) 256 (T0 to T255) 256 (T0 to T255)

ngh g g g
ÑÑÑÑÑÑÑÑ Tud ÑÑÑÑÑ
n
ÑÑÑÑÑÑ ÑÑÑÑÑ
Tud ÑÑÑÑÑÑ
n
ÑÑÑÑÑ n
Retentive on-delay 1 ms T0, T64 T0, T64 T0, T64 T0, T64 T0, T64
o o o
Tud
ÑÑÑÑÑÑÑÑ ÑÑÑÑÑ ÑÑÑÑÑÑ ÑÑÑÑÑ ÑÑÑÑÑÑ ÑÑÑÑÑ
10 ms T1 to T4, and T1 to T4, and T1 to T4, and T1 to T4, and T1 to T4, and
T65 to T68 T65 to T68 T65 to T68 T65 to T68 T65 to T68

ÑÑÑÑÑÑÑÑ ÑÑÑÑÑ ÑÑÑÑÑÑ ÑÑÑÑÑ ÑÑÑÑÑÑ ÑÑÑÑÑ


100 ms T5 to T31, and T5 to T31, and T5 to T31, and T5 to T31, and T5 to T31, and
T69 to T95 T69 to T95 T69 to T95 T69 to T95 T69 to T95

ÑÑÑÑÑÑÑÑ ÑÑÑÑÑ ÑÑÑÑÑÑ om ÑÑÑÑÑ ÑÑÑÑÑÑ oÑÑÑÑÑ


On/Off delay 1 ms T32, T96 T32, T96 T32, T96 T32, T96 T32, T96

om m
ÑÑÑÑÑÑÑÑ ÑÑÑÑÑ ÑÑÑÑÑÑ ÑÑÑÑÑ ÑÑÑÑÑÑ ÑÑÑÑÑ
10 ms T33 to T36, and T33 to T36, and T33 to T36, and T33 to T36, and T33 to T36, and

4 . c 4 . c 4 .
T97 to T100c T97 to T100
4. T97 to T100 T97 to T100 T97 to T100

o ÑÑÑÑÑÑÑÑ
a 2
ÑÑÑÑÑho ÑÑÑÑÑÑ
a 2
ÑÑÑÑÑ
100 ms

ÑÑÑÑÑÑ
ho a 2
T37 to T63, and

ÑÑÑÑÑ a 2
T37 to T63, and
ho
T37 to T63, and T37 to T63, and T37 to T63, and

ngh ÑÑÑÑÑÑÑÑ udoÑÑÑÑÑ ÑÑÑÑÑÑ ÑÑÑÑÑ


udo ÑÑÑÑÑÑ ÑÑÑÑÑ
T101 to T255 T101 to T255 T101 to T255 T101 to T255 T101 to T255
n g n g n g
udo
Counters C0 to C255 C0 to C255 C0 to C255 C0 to C255 C0 to C255

ÑÑÑÑÑÑÑÑ T ÑÑÑÑÑ ÑÑÑÑÑÑ


High-speed counters
ÑÑÑÑÑ
T ÑÑÑÑÑÑ
HC0, HC3, HC4,
ÑÑÑÑÑ
T HC0, HC3, HC4, HC0 to HC5 HC0 to HC5 HC0 to HC5

ÑÑÑÑÑÑÑÑ ÑÑÑÑÑ ÑÑÑÑÑÑ ÑÑÑÑÑ ÑÑÑÑÑÑ ÑÑÑÑÑ


and HC5 and HC5

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


Sequential control relays (S) S0.0 to S31.7 S0.0 to S31.7 S0.0 to S31.7 S0.0 to S31.7 S0.0 to S31.7

ÑÑÑÑÑÑÑÑ ÑÑÑÑÑ ÑÑÑÑÑÑ ÑÑÑÑÑ ÑÑÑÑÑÑ ÑÑÑÑÑ


Accumulator registers AC0 to AC3 AC0 to AC3 AC0 to AC3 AC0 to AC3 AC0 to AC3

. c o m .c o . c o m
4.
Jumps/Labels 0 to 255 0 to 255 0 to 255 0 to 255 0 to 255

o ÑÑÑÑÑÑÑÑ ÑÑÑÑÑho ÑÑÑÑÑÑ ÑÑÑÑÑ ÑÑÑÑÑÑ ÑÑÑÑÑ


a 2 4 a
Call/Subroutine2 4 a 2
0 to 634 0 to 63
a 2 0 to 63 0 to 63 0 to 127

ho ho
ngh ÑÑÑÑÑÑÑÑ
ÑÑÑÑÑÑÑÑ udoÑÑÑÑÑ
n g
ÑÑÑÑÑ ÑÑÑÑÑÑ
Interrupt routines

ÑÑÑÑÑÑ ÑÑÑÑÑ
do ÑÑÑÑÑÑ
ÑÑÑÑÑ
Positive/negative transitions
T T u
n g 0 to 127

ÑÑÑÑÑÑ
256 ÑÑÑÑÑ
ÑÑÑÑÑ
T u do n g
0 to 127
256
0 to 127
256
0 to 127
256
0 to 127
256

ÑÑÑÑÑÑÑÑ ÑÑÑÑÑ ÑÑÑÑÑÑ ÑÑÑÑÑ ÑÑÑÑÑÑ ÑÑÑÑÑ


PID loops 0 to 7 0 to 7 0 to 7 0 to 7 0 to 7
Ports Port 0 Port 0 Port 0 Port 0, Port 1 Port 0, Port 1
1 LB60 to LB63 are reserved by STEP 7–Micro/WIN, version 3.0 or later.

.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
64
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2
Table 6-2
o a 2
Operand Ranges for the S7-200 CPUs
a2
oCPU 224, CPU 226 o a 24
ngh gh gh g h
Access Method CPU 221 CPU 222 CPU 226XM
on on on
ud ud d
Bit access (byte.bit) I 0.0 to 15.7 0.0 to 15.7 0.0 to 15.7 0.0 to 15.7

T Q 0.0 to 15.7 T
0.0 to 15.7 0.0 to 15.7 T
0.0 to 15.7 u
V 0.0 to 2047.7 0.0 to 2047.7 0.0 to 5119.7 0.0 to 10239.7
M 0.0 to 31.7 0.0 to 31.7 0.0 to 31.7 0.0 to 31.7
SM 0.0 to 179.7 0.0 to 299.7 0.0 to 549.7 0.0 to 549.7

. co m .c o m . c o m
4.
S 0.0 to 31.7 0.0 to 31.7 0.0 to 31.7 0.0 to 31.7

24 2 4 a2 4 2
hoa hoa a
T 0 to 255 0 to 255 0 to 255 0 to 255
C 0 to 255 0 to 255
h o 0 to 255 0 to 255
ho
ng d on g L 0.0 to 59.7 0.0 to 59.7
ong 0.0 to 59.7 0.0 to 59.7
ong
T u
Byte access
QB
IB 0 to 15
0 to 15
Tud
0 to 15
0 to 15
0 to 15
0 to 15
0 to 15
0 to 15
Tu d
VB 0 to 2047 0 to 2047 0 to 5119 0 to 10239
MB 0 to 31 0 to 31 0 to 31 0 to 31

4 .c om SMB

4 .c om
0 to 179 0 to 299 0 to 549
.com
0 to 549

4.
2 2 a24 6 2
SB 0 to 31 0 to 31 0 to 31 0 to 31

ng hoa g hoa L 0 to 63 0 to 63
gh o0 to 63 0 to 255
gho
a
don n n
AC 0 to 3 0 to 3 0 to 3 0 to 255
d o o
Tu
Word access
QW
IW 0 to 14
0 to 14 Tu
0 to 14
0 to 14
0 to 14
0 to 14
0 to 14
0 to 14 Tud
VW 0 to 2046 0 to 2046 0 to 5118 0 to 10238
MW 0 to 30 0 to 30 0 to 30 0 to 30

4 .c om SMW

4
SW . c om
0 to 178
0 to 30
0 to 298
0 to 30
0 to 548

4
0 to 30 . c om 0 to 548
0 to 30
4.
2 oa2 2 2
hoa hoa hoa
T 0 to 255 0 to 255 0 to 255 0 to 255

ng o ngh C 0 to 255 0 to 255


o ng 0 to 255 0 to 255
o ng
Tud u d Tud
LW 0 to 58 0 to 58 0 to 58 0 to 58
AC
AIW
0 to 3
None
T
0 to 3
0 to 30
0 to 3
0 to 62
0 to 3
0 to 62
AQW None 0 to 30 0 to 62 0 to 62

om om om
Double word access ID 0 to 12 0 to 12 0 to 12 0 to 12

2 4 . c QD
2 4 .c
0 to 12 0 to 12 0 to 12
2 4 .c 0 to 12
24.
hoa hoa hoa a
VD 0 to 2044 0 to 2044 0 to 5116 0 to 10236

h o
ng ng g g
MD 0 to 28 0 to 28 0 to 28 0 to 28

Tud o SMD
SD
0 to 176
0 to 28
0 to 296

Tu
0 to 28
don 0 to 546
0 to 28
0 to 546
0 to 28
T u d on
LD 0 to 56 0 to 56 0 to 56 0 to 56
AC 0 to 3 0 to 3 0 to 3 0 to 3
HC 0, 3, 4, 5 0, 3, 4, 5 0 to 5 0 to 5

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

.com .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 65
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 Bit Logic Instructions
o a2 o a2 o a 24
ng h g h gh g h
Contacts don on on
Tu T ud T u d
Standard Contacts
The Normally Open contact instructions (LD, A, and O) and
Normally Closed contact instructions (LDN, AN, ON) obtain the

. co m c o m
referenced value from the memory or from the process-image
. . c o m
24 24
register. The standard contact instructions obtain the referenced
a24 2 4.
ng hoa hoa
value from the memory (or process-image register if the data type is
g gho ng ho a
don n
I or Q).

Tu Tu do
The Normally Open contact is closed (on) when the bit is equal to 1,
Tu d o
and the Normally Closed contact is closed (on) when the bit is equal
to 0. In FBD, inputs to both the And and Or boxes can be expanded
to a maximum of 32 inputs. In STL, the Normally Open instructions

.co m .co m
Load, AND, or OR the bit value of the address bit to the top of the
stack, and the Normally Closed instructions Load, AND, or OR the
.co m .
6 2 4 2 4 2 4 24
oa a a a
logical NOT of the bit value to the top of the stack.

n g h n g ho n g ho g h o
Immediate Contacts
u o does not rely on the S7-200 scanucycle
dcontact doto u d on
T
An immediate
T
update; it updates immediately. The Normally Open Immediate T
contact instructions (LDI, AI, and OI) and Normally Closed
Immediate contact instructions (LDNI, ANI, and ONI) obtain the

om om om
physical input value when the instruction is executed, but the

4 .c . c
process-image register is not updated.
4 4 . c 4.
h o a2 The Normally Open Immediate
h o aand2contact is closed (on) when the
h o a2 hoa 2
ng physical input
d o ngwhen the physical input point (bit) is 0.dThe
point (bit) is 1, the Normally Closed
ng
Immediate
o o ng
Tud
contact is closed (on)
u instructions immediately Load, AND, orTOR
TOpen
Normally u the
physical input value to the top of the stack, and the Normally Closed
instructions immediately Load, AND, or OR the logical NOT of the
value of the physical input point to the top of the stack.

.co mNOT Instruction .c om .c om .


a 2 4 4
aon2the top a2 4 a 24
o o
The Not instruction (NOT) changes the state of power flow input
o o
ngh from 1 to 0). on
d
g
(that is, it changes the h
value of the stack from 0 to
d
1
o ng
or h
d on g h
PositiveTuand Negative Transition InstructionsTu T u
The Positive Transition contact instruction (EU) allows power to flow for one scan for each off-to-on
transition. The Negative Transition contact instruction (ED) allows power to flow for one scan for each

.c o m . c o m . c o m
on-to-off transition. For the Positive Transition instruction, detection of a 0-to-1 transition in the value on
.
a24 24 24 24
the top of the stack sets the top of the stack value to 1; otherwise, it is set to 0. For a Negative Transition

hoa hoa a
instruction, detection of a 1-to-0 transition in the value on the top of the stack sets the top of the stack
o o
ngh g g gh
value to 1; otherwise, it is set to 0.

d on d on o n
u u
For run-time editing (when you edit your program in RUN mode), you must enter a parameter for the
T T
Positive Transition and Negative Transition instructions. Refer to Chapter 5 for more information about Tud
editing in RUN mode.

.c o mTable 6-3

. c om
Valid Operands for the Bit Logic Input Instructions

. com
a2 4 Inputs/Outputs Data Type
4 Operands
a2 I, Q, V, M, SM, S, T, C, L, Power Flowhoa2 4 a2 4.
ho Bit
h o
BOOL
ho
ng Bit (immediate)
d o ngBOOL I
d o ng d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
66
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
o a2 Tip
o a 2 o a2 o a 24
ngh gh gh g h
Because the Positive Transition and Negative Transition instructions require an on-to-off or an off-to-on
on on
transition, you cannot detect an edge-up or edge-down transition on the first scan. During the first scan,
on
T ud T ud
the S7-200 sets the state of the bit specified by these instructions. On subsequent scans, these
instructions can then detect transitions for the specified bit. T u d
Example: Contact Instructions

24 .com 24 .c o m 1
Network
. c o m
//N.O. contacts I0.0 AND I0.1 must be on (closed) to activate
4.
h o a hoa ho a24
//Q0.0. The NOT instruction acts as an inverter.
//In RUN mode, Q0.0 and Q0.1 have opposite logic states.
ho a2
ng don
g LD I0.0
do n g
d ong
Tu A
=
NOT
I0.1
Q0.0 Tu Tu
= Q0.1
Network 2 //N.O. contact I0.2 must be on or N.C. contact I0.3 must be off

4 .c om 4 .c om .co m
//to activate Q0.2. One or more parallel LAD branches
4 4.
2 2 2
//(OR logic inputs) must be true to make the output active.
6 2
ng hoa g hoa LD I0.2
gh o a
gho
a
don n on
ON I0.3
d o d
Tu u u
= Q0.2
Network 3 T//A positive Edge Up input on a P contact or a negative
T Edge
//Down input on a N contact outputs a pulse with a 1 scan cycle
//duration. In RUN mode, the pulsed state changes of Q0.4 and
//Q0.5 are too fast to be visible in program status view.

4 .c om 4 . c om 4 .co m
//The Set and Reset outputs latch the pulse in Q0.3 and
//make the state change visible in program status view.
4.
o a2 oa2 LD I0.4
o a 2
hoa 2
ngh do ngh LPS

d o n gh o ng
Tud
EU
Tu S
=
Q0.3, 1
Q0.4 Tu
LPP
ED
R Q0.3, 1

.com .com = Q0.5


.co m .
o a24 ho1 a24 o a 2 4
o a 24
ngh g gh g h
Timing Diagram
o n
Network
o n on
Tud Tu d T u d

.c o m Network 2
. 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
Network 3

.com .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 67
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
oCoils .co m . c om .
a2 4 a 2 4 a2 4 a 24
o ho ho o
ngh Output
n g
do (=) writes the new value for theToutput n g on g h
Tuinstruction
The Output
the process-image
udobit to
register. When the Output instruction is T u d
executed, the S7-200 turns the output bit in the process-image
register on or off. For LAD and FBD, the specified bit is set equal to
power flow. For STL, the value on the top of the stack is copied to

. co m the specified bit.


.c o m . c o m
24 24 a24 2 4.
ng hoa Output Immediate
g hoa gho ng ho a
don do n o
The Output Immediate instruction (=I) writes the new value to both

Tu Tu
the physical output and the corresponding process-image register
location when the instruction is executed. Tu d
When the Output Immediate instruction is executed, the physical
output point (Bit) is immediately set equal to power flow. For STL,

.co m .co m
the instruction immediately copies the value on the top of the stack
.co m .
6 2 4 4
to the specified physical output bit (STL). The “I” indicates an
2 2 4 24
g hoa o a
immediate reference; the new value is written to both the physical
gh
output and the corresponding process-image register location when
gho a
g h o a
n d o n
the instruction is executed. This differs from the non-immediate
d o n d on
Tu Tu
references, which write the new value to the process-image register
only.
T u
Set and Reset

.c omThe Set (S) and Reset (R) instructions set m


. c o (turn on) or reset (turn off)
. c om
a2 4 4
the specified number of points (N), starting at the specified address
a21 to 255 points. a2 4 a 2 4.
h o o
(Bit). You can set or reset from
h h o ho
ng o gspecifies either a timer bit (T) or counterobitng
nresets
If the Reset instruction
d o ng
u
(C), the instruction
currentT Tudthe
the timer or counter bit and clears
value of the timer or counter. Tud
Error conditions that set ENO = 0
H 0006 (indirect address)

.co mH 0091 (operand out of range) . c om . c om


a 2 4 a 2 4 a 2 4 a 2 4.
o o Immediate ho ho
ngh
Set Immediate and h
n g Reset
n g n g
off) theT udoof points
The Set Immediate
number T
(N), starting at specified address
doYousetcan(turn
and Reset Immediate instructions immediately
u(Bit). on) or immediately reset (turndo
Tu
set or reset from 1 to 128 points
immediately.
The “I” indicates an immediate reference; when the instruction is executed, the new value is written to

.c o m . c m . c m
both the physical output point and the corresponding process-image register location. This differs from
o o
the non-immediate references, which write the new value to the process-image register only.
.
a24 = 02
Error conditions that set ENO a
4 24 24
ngh
o
n gh o g hoa gh oa
H 0006 (indirect address)
o on o n
Tud out of range)
H 0091 (operand
T u d Tud
Table 6-4 Valid Operands for the Bit Logic Output Instructions

.c o m Inputs/Outputs Data Type

.I,cQ,o
m
Operands

. com
a2 4 Bit BOOL
BOOL a2
4 V, M, SM, S, T, C, L
a2 4 a2 4.
ho Bit (immediate)
h o Q
h o ho
ng N
d o ngBYTE IB, QB, VB, MB, SMB, SB, LB,n
d o g*VD, *LD, *AC, Constant
AC,
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
68
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
S7-200 Instruction Set Chapter 6

4 .c omExample: Coil Instructions 4 .c om 4 . c om 4.


o a 2 a 2 a 2 a 2
ngh n g ho Network 1 //Output g hSM,bitoT,values
instructions assign
n to external I/O (I, Q)
n g ho
o udo udo
Tud
//and internal memory (M, C, V, S, L).
LD
=
I0.0
Q0.0
T T
= Q0.1
= V0.0

. co m .c o m //Set a sequential group of 6 bits to a value of 1. m


Network 2
. c obits to set.
a 24 a 2 4 //The program status indicator
a
for 2
Set 4
//Specify a starting bit address and how many
is ON when the value
a2 4.
o ho LD I0.1 //of the first bit (Q0.2)nisg1. ho ho
ngh o n g n g
Tud S Q0.2, 6
T udo T udo
Network 3 //Reset a sequential group of 6 bits to a value of 0.
//Specify a starting bit address and how many bits to reset.
//The program status indicator for Reset is ON when the value

.co m m
LD.coI0.2
//of the first bit (Q0.2) is 0.

.co m
a 2 4 4
a2 R Q0.2, 6 a 2 4 6a 2 4.
o o o gho
ngh d o n gh Network 4

d o n gh
//Sets and resets 8 output bits (Q1.0 to Q1.7) as a group.
o n
Tud
LD I0.3
Tu LPS
A I0.4
Tu
S Q1.0, 8
LPP

om m8 om
I0.5A

4 .c 4 . c o R
Q1.0,
4 . c 4.
o a 2 a 2 a 2
Network 5 //The Set and Reset instructions perform the function of a latched relay.
a 2
ngh ng ho //To isolate the Set/Reset bits,o
//another assignmentn g h makeIn thissureexample,
they are not overwritten by
ng ho
o udo bits (Q1.0 to Q1.7) as a group.
instruction. Network 4 sets and
o
Tud //resets eight output
//In RUNT mode, Network 5 can overwrite the Q1.0 bit value and Tud
//control the Set/Reset program status indicators in Network 4.
LD I0.6
= Q1.0

4 . c omTiming Diagram 4 .co m


4 .co m .
o a2 o a 2 o a 2 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 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 69
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
oLogic .c om . c om .
a2 4 Stack Instructions
a2 4 a2 4 a 24
h o h o h o h o
ng AND Load
d o ng d o nandg d on g
secondT
u
The AND Load
TuThe result
instruction (ALD) combines the values in the
levels of the stack using a logical AND operation.
first
T u
is loaded in the top of stack. After the ALD is executed, the stack
depth is decreased by one.

. co mOR Load .c o m . c o m
a 24 The OR Load instruction (OLD)2
a 4 the values in the first and a24
combines
a2 4.
o second levels of the stack,o
ho ho
ngh hstack. After the OLD is executed, the stack
using a logical OR operation. The result
is loaded in the topnofgthe n g ng
o o o
Tud by one.
depth is decreased
Tud Tu d
Logic Push
The Logic Push instruction (LPS) duplicates the top value on the stack and pushes this value onto the

.co m .co m
stack. The bottom of the stack is pushed off and lost.
.co m .
6 2 4 2 4 2 4 24
g hoa Logic Read
gh o a
gh o a
g h o a
n d o n d o n
The Logic Read instruction (LRD) copies the second stack value to the top of stack. The stack is not
d on
Tu Tu u
pushed or popped, but the old top-of-stack value is destroyed by the copy.
T
Logic Pop
The Logic Pop instruction (LPP) pops one value off of the stack. The second stack value becomes the

4 .c om new top of stack value.

4 .co m
4 .co m
4.
o a2 AND ENO
oa 2 a 2
hbitowith the top of the stack to hoa 2
ngh generate the d
ng h (AENO) performs a logical AND of thenENO
The AND ENO instruction
o effect as the ENO bit of a box in LADuordFBD. g
o The result of the AND operation is theudo ng
ofu
same
new topT stack. T T
ENO is a Boolean output for boxes in LAD and FBD. If a box has power flow at the EN input and is
executed without error, the ENO output passes power flow to the next element. You can use the ENO as

.co m .co m .co m


an enable bit that indicates the successful completion of an instruction. The ENO bit is used with the top of
.
a 2 4 a 2 4 a 2 4
stack to affect power flow for execution of subsequent instructions. STL instructions do not have an EN
input. The top of the stack must be a logic 1 for conditional instructions to be executed. In STL there is
a 24
o o o o
ngh gh gh g h
also no ENO output. However, the STL instructions that correspond to LAD and FBD instructions with
o n o n
ENO outputs set a special ENO bit. This bit is accessible with the AENO instruction. on
Tud
Load Stack
Tu d T u d
The Load Stack instruction (LDS) duplicates the stack bit (N) on the stack and places this value on top of
the stack. The bottom of the stack is pushed off and lost.

.c o m . c o m . c o m .
o a24 hoa
24
hoa
24 oa 24
ngh gh
Table 6-5 Valid Operands for the Load Stack Instruction

on gData Type g
N T u d
Inputs/Outputs
BYTE
Operands
Constant (0 to 8) Tu
don Tud
o n

.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
70
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2 o 2 o a2
As shown in Figure 6-2, the S7-200 uses a logic stack to resolve the control logic. In these examples, “iv0”
a
to “iv7” identify the initial values of the logic stack, “nv” identifies a new value provided by the instruction,
o a 24
ngh n gh n gh
and “S0” identifies the calculated value that is stored in the logic stack.
o o on g h
TALD ud Before After OLD T ud
Before After LDS Before T u d
After
AND the top iv0 S0 OR the top two iv0 S0 Load Stack iv0 iv3
two stack iv1 iv2 stack values iv1 iv2 iv1 iv0
values

. co m iv2

.
iv3

c o m iv2 iv3

. c o m iv2 iv1

24
iv3

24
iv4 iv3 iv4

24
iv3 iv2

2 4.
hoa hoa oa ho a
iv4 iv5 iv4 iv5 iv4 iv3

ng g gh ng
don on
iv5 iv6 iv5 iv6 iv5 iv4

o
Tud d
iv6 iv7 iv6 iv7 iv6 iv5

TuS0 = iv0 AND iv1


iv7
iv8
iv8
x1 S0 = iv0 OR iv1
iv7
iv8
iv8
x1
iv7
iv8 2
Tuiv6
iv7

LPS Before After LRD Before After LPP Before After

4 .c om Logic Push iv0

4
iv0

.c om Logic Read iv0 iv1

.com
Logic Pop iv0 iv1

4.
2 24 6
iv1
2
iv0 iv1 iv1 iv1 iv2
2
hoa hoa o a
gho
a
iv2 iv1 iv2 iv2 iv2 iv3

ng g g h
on on n
iv3 iv2 iv3 iv3 iv3 iv4

d d o
u u Tud
iv4 iv3 iv4 iv4 iv4 iv5
T iv5 iv4 T iv5 iv5 iv5 iv6
iv6 iv5 iv6 iv6 iv6 iv7
iv7 iv6 iv7 iv7 iv7 iv8

om .com om
iv8 2 iv7 iv8 iv8 iv8 x1

2 4 .c The value is unknown2 (it4 4 . c 4.


hoa
1
2
h o aof a Logic Push or a Load Stack instruction, value
After the execution
could be either a 0 or a 1).
h o ais2lost.
iv8
hoa 2
ng d o g
nOperations d o ng o ng
Tu
Figure 6-2 of the Logic Stack
Tu
Instructions
Tud
Example: Logic Stack Instructions

4 . c om 4 .c om Network 1
4 .co m .
2 2 LD I0.0
2 24
ng hoa ng hoa LD

n gh
I0.1
o a
g h o a
on
LD I2.0
d o d
A o I2.1
d
Tu Tu OLD
ALD
T u
= Q5.0
Network 2

.c o m . c o m LD I0.0
. c o m .
a24 24 24 24
LPS

o hoa hoa oa
LD I0.5

ngh d on g
d
O
o g
nQ7.0 I0.6
o n gh
Tud
ALD

T u Tu =
LRD
LD I2.1
O I1.3
ALD

.com .co m = Q6.0


. com
a2 4 a 2 4 LPP
a2 4 a2 4.
o gho
A I1.0
o ho
ng h don
=

d o n gh Q3.0

d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 71
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
oSet .c omInstructions . c om .
a2 4 and Reset Dominant 4
aa2latch where the set dominates. If the hoa2
Bistable 4 a 24
h o h o h o
ng The Set Dominant
set (S1) and d o
resetn(R)gsignals are both true, the output (OUT)dois n
Bistable is g
true. d on g
TuDominant Bistable is a latch where the resetTdominates.
The Reset
u T u
If the set (S) and reset (R1) signals are both true, the output (OUT)
is false.

. co mThe Bit parameter specifies the Boolean . c o m that is set or


parameter
. c o m
a 24 reset. The optional output
a 24
reflects the signal state of the Bit
a 24 a2 4.
o parameter. o o ho
ngh o n gtruthh tables for the sample program. ongh ong
Tud Tud d
Table 6-7 shows the
Tu

.co mTable 6-6 . c om . c om


Valid Operands for the Set Dominant Bistable and Reset Dominant Bistable Instructions
.
6 2 4 4
a2 Operands a2 4 24
g hoa Inputs/Outputs
o
Data Types
h h o h o a
n S1, R
d o ngBOOL d o ng
I, Q, V, M, SM, S, T, C, Power Flow
d on g
Tu
S, R1, OUT BOOL I, Q, V, M, SM, S, T, C,u
T L, Power Flow T u
Bit BOOL I, Q, V, M, S

.c om Example: Set and Reset Dominant Bistable


. c o m
Instructions
. c om
a2 4 4
a2 Set I0.0
Timing Diagram
a2 4 a 2 4.
h o h o h o ho
ng d o ng d o ng o ng
Tu Reset I0.1 Tu Tud
SR Q0.0

.co m .co RSm Q0.1 .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 Instruction
Table 6-7

. c m
Truth Table for the Set and Reset Dominant Bistable Instructions
o . c o m .
2 4 24 S1 R
24 Out (Bit)
24
ng hoa hoa
Set Dominant Bistable instruction (SR)
g
0
g1 hoa
0 Previous state
gh oa
d on 0
don 0
o n
T u 1 Tu 0 1 Tud
1 1 1
Instruction S R1 Out (Bit)

.co m Reset Dominant Bistable instruction (RS).com 0 0


. c m state
oPrevious
a2 4 a 24 0 1
a2 4 0
a2 4.
o o h0 o ho
ng h gh g ng
1 1
o n n
do 1 o
Tud Tu Tu d
1 0

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
72
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .c om 4. c om .
o a2 Clock Instructions
o a2 o a2 o a 24
ng h h
ng Clock and Set Real-Time ng h g h
d o
Read Real-Time
d o
Clock
d on
TuRead Real-Time Clock (TODR) instructionTreads
The
u the current T u
time and date from the hardware clock and loads it in an 8-byte
Time buffer starting at address T. The Set Real-Time Clock (TODW)
instruction writes the current time and date to the hardware clock,

. co m o m
beginning at the 8-byte Time buffer address specified by T.
.c . c o m
24 4time values in BCD format (for example,a24
2Figure 2 4.
hoa a a
You must code all date and
h o ho ho
ng g g ng
16#97 for the year 1997). 6-3 shows the format of the Time
buffer (T). n
do (TOD) clock initializes the following o n o
Tutime-of-day
The Tud date and time Tu d
after extended power outages or when memory has been lost:
Date: 01–Jan–90

4 .c om Time:
Day of Week:
00:00:00
4
Sunday.c om 4 . c om 4.
2 2 =0 a2 6 2
ng hoa Error conditions thato
h
ngaddress)
H 0006 (indirect
aENO
set
ng h o
n gho
a
d o d o o
Tu (TOD data error) Set Real-Time Clock only Tu
H 0007
H 000C (clock not present)
Tud

4 .c om Table 6-8

4 . om
Valid Operands for the Clock Instructions
c 4 . c om 4.
2 Inputs/Outputs
2 Data Types
Operands
2 *AC 2
ng hoa T
ng h oaBYTE
ng h o a*LD,
IB, QB, VB, MB, SMB, SB, LB, *VD,
ng hoa
do d o o
Tu T T+1
Tu
T+2 T+3 T+4 T+5 T+6
Tud
T+7
Year: Month: Day: Hours: Minutes: Seconds: 0 Day of Week:
00 to 99 01 to 12 01 to 31 00 to 23 00 to 59 00 to 59 0 to 7*

.co m .co m .co*T+7m 1=Sunday, 7=Saturday


.
a 2 4 a 2 4 a 2 4 0 disables the day of week.

a 24
o hofothe 8-Byte Time Buffer (T) ho o
ngh Figure 6-3
g
Format
n n g on g h
T udo T udo T u d
Tip
The S7-200 CPU does not perform a check to verify that the day of week is correct based upon the
date. Invalid dates, such as February 30, could be accepted. You should ensure that the date you enter

.c o m is correct.
. c o m . c o m
a24 a
Do not use the TODR/TODW 2 4 instruction in both the main program anda in4
2 an interrupt routine. A
a 2 4.
o ho ho that two simultaneous accesses tongho
ngh
TODR/TODW instruction in an interrupt routine that attempts to execute while another TODR/TODW
instruction n g g
process cannot be executed. SM4.3 is setnindicating
dowere attempted (non-fatal error 0007).Tudo do
is in

T u
the clock
T u
The time-of-day clock in the S7-200 uses only the least significant two digits for the year, so for the year
2000, the year is represented as 00. The S7-200 PLC does not use the year information in any way.
However, user programs that use arithmetic or compares with the year’s value must take into account

.co m .co m
the two-digit representation and the change in century.
. com
a2 4 a 2 4
Leap year is correctly handled through year 2096.
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 73
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 Communications
a2
Instructions
o o a2 o a 24
ng h h
ngNetwork Write Instructions ng h g h
Network Read d oand d o d on
Tu Tu
The Network Read instruction (NETR) initiates a communications
T u
operation to gather data from a remote device through the specified
port (PORT), as defined by the table (TBL). The Network Write

. co m .c m
instruction (NETW) initiates a communications operation to write
o . c o m
24
data to a remote device through the specified port (PORT), as
24 a24 2 4.
hoa oa a
defined by the table (TBL).

ng n g
Error conditions that set hENO = 0:
n gho ng ho
u doaddress)
H 0006 (indirect
T T u do Tu d o
H If the function returns an error and sets the E bit of table status byte (see
Figure 6-4)

.c o mfrom a remote station, and the Network


. ominstruction can write up
The Network Read instruction can read up to 16 bytes of information
c Write
. c om .
6a2 4 to 16 bytes of information to a
a 2 4
remote station.
a 2 4 a 24
ho h o h o h o
ng d o
instructions in the
g ofbutNetwork
nprogram,
You can have any number Read and Network Write
d o
only a maximum of eight Networkng d on g
Read andTuNetwork Write instructions can be activatedTatuany one
time. For example, you can have 4 Network Read and 4 Network
T u
Write instructions, or 2 Network Read and 6 Network Write
instructions, active at the same time in a given S7-200.

4 .c omYou .
can use the Network Read/Network
4 c mInstruction Wizard to configure the counter.
oWrite 4 . c m
omenu
To start the
4.
o a 2 Network Read/Network Write
a 2
Instruction Wizard, select the Tools >
a 2
Instruction Wizard command
a 2
ngh
Instruction

n g ho
and then select Network Read/Network Write from the Instruction Wizardo
n g h window. ng ho
doOperands for the Network Read and Network doInstructions udo
Wizard

Table 6-9
T uValid T uWrite T
Inputs/Outputs Data Type Operands
TBL BYTE VB, MB, *VD, *LD, *AC

4 . c om PORT BYTE

4 .c om
Constant for CPU 221, CPU 222, CPU 224:
for CPU 226 and CPU 226XM:
4 .c
0
o m
0 or 1
.
2 2 2 24
ng hoa g hoa g hoa g h o a
ud on u d on u d on
T T T

.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
74
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2 2 a2
Figure 6-4 describes the table that is referenced by the TBL parameter, and Table 6-10 lists the error
o a a 24
ngh
codes.
n gh n g ho g h o
ud o Done (functionu
o completed):
dbeen u d on
T
Byte
Offset 7 0
D
A
T has
Active (function has been queued):
0 = not done
0 = not active
T
1 = done
1 = active
0 D A E 0 Error code E Error (function returned an error): 0 = no error 1 = error
1 Remote station address Remote station address: the address of the PLC whose data is to be accessed.

4 .com 2
c o m
Pointer to the data
. c o mpointer to the data that
Pointer to the data area in the remote station: an.indirect
4 is to be accessed. 4 4.
h o a2 3
4
ho
2
area in the
a
remote station a 2
o that are to be accessed in the remote gho
hof data a2
n g 5
o n g
(I, Q, M, or V) Data length: the number of n
o g
bytes
on
6 ud Data length u d u d
station (1 to 16 bytes).
T7 Data byte 0
T
Receive or transmit data area. 1 to 16 bytes reserved for the data.
T
8 Data byte 1 For a Network Read instruction, stores the values that were read from the
remote station when the instruction was executed.

.co m .c om tom
For a Network Write instruction, stores the valueso
c
station when the instruction is executed. 4. 4.
22 Data byte 15 be sent to the remote

a 2 4 a 2 4 a 2 6a 2
o ho for the Network Read and Network Write ho ho
ngh Figure 6-4
o n g
TBL Parameter
o n g Instructions
o n g
Tud Tud Tud
Table 6-10 Error Codes for the TBL Parameter
Code Definition

4 .c om 0 No error.
4 . c om 4 . c om 4.
o a 2 1
2
Time-out error: Remote station not responding.
a a 2 a 2
ngh
2
g hoParity, framing, or checksum error in the nresponse.
Receive error:
n g ho ng ho
o udor oNetwork Write o
T4udQueue overflow error: More than 8 NetworkTRead u d
3 Offline error: Collisions caused by duplicate station addresses or failed hardware.
T
instructions have been activated.
5 Protocol violation: Attempt to execute a Network Read or Network Write instruction without enabling the PPI
Master Mode in SMB30 or SMB130.

4 . c om 6
.co m
Illegal parameter: TBL parameter contains an illegal or invalid value.
4 4 .co m .
2 7
2 2
No resource: Remote station is busy. (An upload or a download sequence is in process.)
24
ng hoa 8
n g ho a
Layer 7 error: Application protocol violation
n g ho a
g h o a
o
Message error: Wrong data address or incorrect datao on
TA touFdNot used. (Reserved) Tud d
9 length
T u
Figure 6-5 shows an example to illustrate the utility of the Network Read and Network Write instructions.

.c o m . c m . c m
For this example, consider a production line where tubs of butter are being filled and sent to one of four
o o
boxing machines (case packers). The case packer packs eight tubs of butter into a single cardboard box.
.
o a24 hoa
24
hoa
24
A diverter machine controls the flow of butter tubs to each of the case packers. Four S7-200s control the
oa 24
ngh gh
case packers, and an S7-200 with a TD 200 operator interface controls the diverter.

on g on g o n
T u d 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 75
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 .co m
4. c om .
o a2
Case Packer #1
Station 2
o
Station 3 2
Case Packer #2
a
Case Packer #3
Station 4
Case Packer #4
Station 5
o a2
Diverter
Station 6 TD 200 Station 1
o a 24
ngh on gh on gh on g h
T ud T ud T u d
VB100 Control VB100 Control VB100 Control VB100 Control VB200 Rcv VB300 Xmt
VW101 Status VW101 Status VW101 Status VW101 Status Buffers Buffers

. co m .c o m . c o m
24 24 a24 2 4.
ng hoa g hoa Control
gho ng ho a
don n
VB100 f e e e 0 g b t VB200 Receive buffer VB300 Transmit buffer

do o
Station 2 Station 2

Tu
VB101 Number of
Status MSB

Tu
VB210 Receive buffer
Station 3
VB310 Transmit buffer
Station Tu d
VB102 cases packed VB220 Receive buffer VB320 Transmit buffer
LSB Station 4
Station 4
VB230 Receive buffer VB330 Transmit buffer

.co m t Out of butter tubs to pack; t=1, out of butter tubs


.co m Station 5

.co m
Station

.
6 2 4 b Box supply is low; b=1, must add boxes in the
2 4 2 4 24
g hoa next 30 minutes

g ho a
g ho a
g h o a
n g
n n
Glue supply is low; g=1, must add glue in the next 30 minutes
d oidentifying the type of fault experienced udo d on
f T u
eee error code
Fault indicator; f=1, the case packer has detected an T
error T u
Figure 6-5 Example of the Network Read and Network Write Instructions

4 .c omFigure 6-6 shows the receive buffer4(VB200)


. c omand transmit buffer (VB300) for accessing
4 . c othemdata in 4.
o a 2 station 2. The S7-200 uses aa 2 a 2 a 2
ngh n
continuous basis fromg hoof the case packers. Each time a case
each
Network
n g hohas packed 100 cases, the
Read instruction to read the control and
packer
status information on a
ng ho
diverter notesd o and sends a message to clear the status o using a Network Write instruction. udo
Tud
this word
Tu T
Receive Buffer for reading from Case Packer #1 Transmit Buffer for clearing the count of Case Packer #1
7 0 7 0

.co m VB200 D A E 0 Error Code


.co m VB300 D A E
.co
0
m
Error Code
.
a 2 4 VB201 Remote station address = 2
a 2 4 VB301

a 2 4
Remote station address = 2
a 24
o VB202
o
Pointer to the VB302
o Pointer to the
o
ngh VB203

o n gh data area
o n gh
VB303 data area
on g h
Tud Tu d u d
VB204 in the VB304 in the
VB205 Remote station = (&VB100) VB305 Remote station = (&VB101) T
VB206 Data length = 3 bytes VB306 Data length = 2 bytes
VB207 Control VB307 0

.c o m VB208 Status (MSB)


Status (LSB)
. c o m VB308

. c
0
o m .
4 4 24 24
VB209

2 afor2the Network Read/Write Example


ng hoa Figure 6-6 Sample TBLh
g o
Data
g h oa gh oa
d on 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
76
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
S7-200 Instruction Set Chapter 6

4 .c omExample: Network Read and Network 4 . c om 4 . c om 4.


o a 2 a 2 Write Instructions
a 2 a 2
ngh n g ho Network 1
n
//Onh
g ofirst scan, enable the PPI master mode gho
the

u d o o
LD ud SM0.1
/and clear all receive and transmit buffers.
u d on
T T 2, SMB30
MOVB
T
FILL +0, VW200, 68

. co m .c o m Network 2
o m
//When the NETR Done bit (V200.7) is set
. c
24 24 a24
//and 100 cases have been packed:
2 4.
hoa hoa a
//1. Load the station address of case packer #1.

ng g gho //2. Load a pointer to the data in the remote station.


ng ho
don do n o
//3. Load the length of data to be transmitted.

Tu Tu
//4. Load the data to transmit.
//5. Reset the number of cases packed Tu d
// by case packer #1
LD V200.7
AW= VW208, +100

.co m .co m MOVB 2, VB301


.co m
a 2 4 a 2 4 MOVD &VB101, VD302
a 2 4 6a 2 4.
o o MOVB 2, VB306
o gho
ngh d o n gh MOVW

d o n gh
+0, VW307
o n
Tud
NETW VB300, 0

Tu Tu
Network 3 //When the NETR Done bit is set, save the control
//data from case packer #1.
LD V200.7

4 .c om 4 .com
MOVB VB207, VB400

4 .co m
4.
2 oa2 2 2
ng hoa ngh n gh o a
ng hoa
do d o o
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 77
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, continued 4 . c om 4.
o a 2 a 2
Example: Network Read and Network Write Instructions
a 2 a 2
ngh n g ho Network 4 //If not theh
n g oscan and there are no errors:
first
n g ho
o oLoad a pointer to the data in the remote station.
//1. Load the station address of case packer #1.
do
Tud Tud//2.
//3. Load the length of data to be received. T u
//4. Read the control and status data
// in case packer #1.

. co m .c o mAN
LDN SM0.1

. c o m
4.
V200.6
24 2 4 AN V200.5
a24 2
ng hoa g hoa MOVB 2, VB201
gho ng ho a
don n
MOVD &VB100, VD202

Tu
MOVB
NETR Tu do
3, VB206
VB200, 0 Tu d o

.co m .co m .co m .


6 2 4 2 4 2 4 24
g hoa gh o a
gh o a
g h o a
n d o n d o n d on
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 .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
78
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
S7-200 Instruction Set Chapter 6

4 .c om Transmit and Receive 4Instructions


.c om (Freeport) 4. c om .
o a2 o a2 o a2 o a 24
ng h g h g h g h
datau oninstruction
The Transmit
bydmeans o
(XMT) is used in Freeport mode to
d ntransmit d on
T of the communications port(s).
Tu
The Receive instruction (RCV) initiates or terminates the receive
T u
message function. You must specify a start and an end condition for
the Receive box to operate. Messages received through the

. co m o m
specified port (PORT) are stored in the data buffer (TBL). The first
.c . c o m
24 24
entry in the data buffer specifies the number of bytes received.
a24 2 4.
ng hoa Error conditions thato
n g h aENO = 0
set
n gho ng ho a
o
H 0006 (indirect
ud(simultaneous
address)
Transmit/Receive on port 0) Tu
do d o
HT0009 Tu
H 000B (simultaneous Transmit/Receive on port 1)
H Receive parameter error sets SM86.6 or SM186.6

.co m .co
H S7-200 CPU is not in Freeport mode m .co m
a 2 4 a 2 4 a 2 4 6a 2 4.
o o for the Transmit and Receive Instructionsgho gho
ngh Table 6-11
d o n g
Valid hOperands
d on o n
T u
Inputs/Outputs
TBL
Data Type
BYTE
Operands
T u
IB, QB, VB, MB, SMB, SB, *VD, *LD, *AC
Tud
PORT BYTE Constant for CPU 221, CPU 222, CPU 224: 0
for CPU 226 and CPU 226XM: 0 or 1

4 .c om 4 .co m
4 .co m
4.
o a2 oa 2 o a 2
For more information about using Freeport mode, see the section Creating User-Defined Protocols with
hoa 2
ngh gh gh
Freeport Mode on page 222 in Chapter 7.

o n o n o ng
Tu d Tu d
Using Freeport Mode to Control the Serial Communications Port
Tud
You can select the Freeport mode to control the serial communications port of the S7-200 by means of the
user program. When you select Freeport mode, your program controls the operation of the
communications port through the use of the receive interrupts, the transmit interrupts, the Transmit

.co m .co m .co m


instruction, and the Receive instruction. The communications protocol is entirely controlled by the ladder
program while in Freeport mode. SMB30 (for port 0) and SMB130 (for port 1 if your S7-200 has two ports) .
a 2 4 a 2 4
are used to select the baud rate and parity.
a 2 4 a 24
o o o o
ngh o n gh o n gh
The Freeport mode is disabled and normal communications are re-established (for example, programming
on g h
Tud
device access) when the S7-200 is in STOP mode.
Tu d
In the simplest case, you can send a message to a printer or a display using only the Transmit (XMT)
T u d
instruction. Other examples include a connection to a bar code reader, a weighing scale, and a welder. In
each case, you must write your program to support the protocol that is used by the device with which the

.c o m o m
S7–200 communicates while in Freeport mode.
. c . c o m
a24 Freeport communications2
a 4possible only when the S7-200 is in RUN
are
a 2 4 Enable the Freeport mode
mode.
a 2 4.
o ofo ho0) or SMB130 (Port 1). While in Freeport ho
ngh
by setting a valueh
n g g
01 in the protocol select field of SMB30 (Port
n n g
T u do
mode, communications
T u do
with the programming device are not possible.
T u do
Tip
Freeport mode can be controlled using special memory bit SM0.7, which reflects the current position of
the operating mode switch. When SM0.7 is equal to 0, the switch is in TERM position; when SM0.7 = 1,

.co m .co m . com


the operating mode switch is in RUN position. If you enable Freeport mode only when the switch is in

a2 4 RUN position, you can use the programming device to monitor or control the S7-200 operation by
a 2 4
changing the switch to any other position.
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 79
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 omChanging PPI Communications 4 .c om 4 . c om 4.


o a 2 a 2 to Freeport Mode
a 2
o parity, and number of data bits. Figuregh6-7odescribes the Freeport control a 2
ngh
SMB30 and SMB130
n g hrate,
configure the communications ports, 0 and
n
1 respectively, for Freeport operation and
n g ho
o
provide selection of baud
o o
Tudbit is generated for all configurations. Tud
byte. One stop
Tud
MSB LSB
7 0
bbb: Freeport baud rate

.com o m o m
p p d b b b m m 000 = 38,400 baud

24 24 .c . c 4.
a24
001 = 19,200 baud
a SMB30 = Port 0
2
o hoa ho ho a
010 = 9,600 baud

ng h SMB130 = Port 1
ng
011 = 4,800 baud
n g ng
d o
u no parity
100 =
do
2,400 baud
d o
pp:
T
Parity
00 =
select 101 =
110 = Tu
1,200 baud
115.2 kbaud1
1 Tu
S7-200 CPUs version 1.2 or later
support the 57.6 kbaud and
01 = even parity 111 = 57.6 kbaud1
10 = no parity 115.2 kbaud rates.
mm: Protocol selection
11 = odd parity

.co m d: Data bits per character


.co m00 =
01 =
PPI/slave mode
Freeport protocol
.co m .
6 2 4 0=
2 4
8 bits per character 10 = PPI/master mode
2 4 24
g hoa 1=
g ho a
7 bits per character 11 =
ho a
Reserved (defaults to PPI/slave mode)
g g h o a
n SMo
n o n on
Tud Tud u d
Figure 6-7 Control Byte for Freeport Mode (SMB30 or SMB130)
T
Transmitting Data

.c omThe Transmit instruction lets you send.caobuffer


m of one or more characters, up to a maximum
. c o mof 255.
a 2 4 Figure 6-8 shows the format of 2
a the4Transmit
a 2 4 a 2 4.
o ho ho ho
ngh
Count M E S S A G E
buffer.
n g
o is attached to the transmit o n g Characters of the message
o ng
If an interruptd
complete
u routine
Tevent, the S7-200 generates an Tud Number of bytes to transmit (byte field)Tud
interrupt (interrupt event 9 for port 0 and interrupt
event 26 for port 1) after the last character of the
buffer is sent.

. c o m . c o m . c otom
Figure 6-8 Format for the Transmit Buffer

a 2 4 2
You can make transmissions without
a 4 2 4
using interrupts (for example, sending a message
a
a printer) by
a 2 4.
o ghoinstruction to generate a BREAK condition
monitoring SM4.5 or SM4.6 to signal when transmission is complete.
hosetting the number of characters ngho
ngh You can use theo n
d executing the Transmit instruction. This
Transmit n g
do a BREAK condition on the line forTudo
by
to zero anduthen u
T T generates
16-bit times at the current baud rate. Transmitting a BREAK is handled in the same manner as transmitting
any other message, in that a Transmit interrupt is generated when the BREAK is complete and SM4.5 or
SM4.6 signals the current status of the Transmit operation.

.c o mReceiving Data . c o m . c o m
a2 4 a 2 4 a buffer of one or more characters,aup2to4a maximum of 255. a 2 4.
o The Receive instruction
ho of the Receive
lets you receive
ho ho
ngh o n g o n g n g
buffer. Tud Tud udo
Figure 6-9 shows the format Count
Start
M E S S A G E
End
Char

Characters of the message


T Char

If an interrupt routine is attached to the receive


message complete event, the S7-200 generates Number of bytes received (byte field)

.co m . c om
an interrupt (interrupt event 23 for port 0 and
. c om 4.
interrupt event 24 for port 1) after the last

a2 4 2 4
character of the buffer is received.
a a 2 4
Figure 6-9 Format for the Receive Buffer
a2
o howithout using interrupts by monitoringnSMB86 ho(port 0) or SMB186 (port 1). This ngho
ng h n g
You can receive messages g
owhen the Receive instruction is inactiveuordhasobeen terminated. It is zero when a receive o
Tud Tud
byte is non-zero
is in progress. T

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
80
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2 2 a2
As shown in Table 6-12, the Receive instruction allows you to select the message start and message end
a a 24
ngh n g ho n g ho
conditions, using SMB86 through SMB94 for port 0 and SMB186 through SMB194 for port 1.
ng h o
Tip do d o d o
Tureceive message function is automaticallyTterminated
The
u in case of an overrun or a parity error.
TuYou
must define a start condition and an end condition (maximum character count) for the receive message
function to operate.

. co m .c o m . c o m
24
Table 6-12
24
Bytes of the Receive Buffer (SMB86 to SMB94, and SM1B86 to SMB194)

a24 2 4.
ng hoa Port 0
g hoa
Port 1 Description
gho ng ho a
don do n o
SMB86 SMB186 Receive message status byte MSB LSB

Tu Tu
7

n r e 0 0 t
d
Tcu p
0

n: 1= Receive message function terminated: user issued disable command.


r: 1= Receive message function terminated: error in input parameters

.co m .1c
om . c om
or missing start or end condition.
.
a 2 4 a 2 4 = e:
End character received.
a 2 4 6a 2 4
o ho t:c: 11 == Receive ho timer expired. ho
ngh
message function terminated:
n g n gterminated: maximum character count achieved. ng
udo o terminated: a parity error. udo
Receive message function

T p 1=
T
Receive messageudfunction T
SMB87 SMB187 Receive message control byte MSB LSB
7 0

en sc ec il c/m tmr bk 0

4 .c om 4 .co m
en: 0 =Receive message function is disabled.
4 .co m
4.
o a2 oa 2 1 =Receive message function is enabled.
o a 2
hoa 2
ngh gh gh g
The enable/disable receive message bit is checked each time

do n o n
the RCV instruction is executed.
d o n
Tu Tu
sc: 0 =Ignore SMB88 or SMB188.
1 =Use the value of SMB88 or SMB188 to detect start of message. Tud
ec: 0 =Ignore SMB89 or SMB189.
1 =Use the value of SMB89 or SMB189 to detect end of message.

4 . c om 4 . o
=Use
mtheSMW90
il:
0 =Ignore
1c
or SMW190.
value of SMW90 or SMW190 to detect an
4 .c olinemcondition.
idle
4.
o a2 a 2 a 2 a 2
ho ho ho
c/m: 0 =Timer is an inter-character timer.

ngh o n g 1 =Timer is a message timer.

do n g n g
Tud T
1 =Terminate receive ifu
tmr: 0 =Ignore SMW92 or SMW192.
the time period in SMW92 or SMW192 is exceeded.T udo
bk: 0 =Ignore break conditions.
1 =Use break condition as start of message detection.

.c o m SMB88 SMB188

. c m
Start of message character.
o . c o m .
a24 24 24 24
SMB89 SMB189 End of message character.

ngh
o SMW90
g
nSMW192 hoa
SMW190
hoa
Idle line time period given in milliseconds. The first character received after idle line time
g gh oa
on n
has expired is the start of a new message.
d o d o
Tu u Tud
SMW92 Inter-character/message timer time-out value given in milliseconds. If the time period is
T
exceeded, the receive message function is terminated.
SMB94 SMB194 Maximum number of characters to be received (1 to 255 bytes). This range must be set to
the expected maximum buffer size, even if the character count message termination is not

.co m .co
used.
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 oa2 a2 a 24
ngh n gh n gho 81
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 omStart and End Conditions for4the .c o m


4 . c om 4.
o a 2 a 2 Receive Instruction
a 2 a 2
ngh
The Receive instruction
the message start n g hoconditions.
uses the bits of the receive message control
n g ho
byte (SMB87 or SMB187) to define
n g ho
udo o o
and end

Tip T Tud Tud


If there is traffic present on the communications port from other devices when the Receive instruction is
executed, the receive message function could begin receiving a character in the middle of that

. co m .c m . c o m
character, resulting in a possible parity error and termination of the receive message function. If parity is
o 4.
not enabled the received message could contain incorrect characters. This situation can occur when the
24 24 a24
start condition is specified to be a specific start character or any character, as described in item 2. and 2
ng hoa item 6. below.
g hoa gho ng ho a
Tu don Tu do n
The Receive instruction supports several message start conditions. Specifying a start condition
involving a break or an idle line detection avoids this problem by forcing the receive message function to
Tu d o
synchronize the start of the message with the start of a character before placing characters into the
message buffer.

4 .c om 1. 4
m
The Receive instruction supports several start conditions:
.co 4 .co m .
o6a2 o 2 o a 2
Idle line detection: The idle line condition is defined as a quiet or idle time on the transmission line.
a o a 24
ng h gh gh
A receive is started when the communications line has been quiet or idle for the number of
n n g h
milliseconds specified in SMW90 or SMW190. When the Receive instruction in your program is
d o d o d on
Tu Tu u
executed, the receive message function initiates a search for an idle line condition. If any characters
are received before the idle line time expires, the receive message function ignores those
characters and restarts the idle line timer with the time from SMW90 or SMW190. See Figure 6-10.
T
After the idle line time expires, the receive message function stores all subsequent characters
received in the message buffer.

4 .c om .co m .co m
The idle line time should always be greater than the time to transmit one character (start bit, data
4 4 4.
o a2 oa 2
ho a 2
bits, parity and stop bits) at the specified baud rate. A typical value for the idle line time is three
hoa 2
ngh h
character times at the specified baud rate.
n g
o line detection as a start condition for binary n g
oprotocols, protocols where there is not a o ng
Tud start character, or when the protocol specifies
Tud a minimum time between messages. Tud
You use idle
particular
Setup: il = 1, sc = 0, bk = 0, SMW90/SMW190 = idle line timeout in milliseconds

4 . c om Characters
4 .c om Characters
4 .co m .
2 2 2 24
ng hoa hoa
ng Restarts the idle time n g
a
hFirsto character placed in the g h o a
d o do d on
Tu instruction is executed:
Receive Tu
Idle time is detected:
message buffer
T u
starts the idle time starts the Receive Message function

.c o m Figure 6-10

. c m
Using Idle Time Detection to Start the Receive Instruction
o . c o m .
2 4 24 24 24
ng hoa 2.
hoa hoa
Start character detection: The start character is any character which is used as the first character of
g g gh oa
on on
a message. A message is started when the start character specified in SMB88 or SMB188 is
d d o n
u u Tud
received. The receive message function stores the start character in the receive buffer as the first
T T
character of the message. The receive message function ignores any characters that are received
before the start character. The start character and all characters received after the start character
are stored in the message buffer.

4 .c om same character.
4 . om 4 . om
Typically, you use start character detection for ASCII protocols in which all messages start with the
c c 4.
2 =2 2 2
ng hoa n g
character ho a
Setup: il = 0, sc
n g ho a
1, bk = 0, SMW90/SMW190 = don’t care, SMB88/SMB188 = start
n g ho a
o o o
Tud Tud Tud

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
82
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2
3.
o a 2 o a2
Idle line and start character: The Receive instruction can start a message with the combination of an
idle line and a start character. When the Receive instruction is executed, the receive message
o a 24
ngh n gh n gh on
function searches for an idle line condition. After finding the idle line condition, the receive message
o o g h
T ud T ud T u d
function looks for the specified start character. If any character but the start character is received,
the receive message function restarts the search for an idle line condition. All characters received
before the idle line condition has been satisfied and before the start character has been received
are ignored. The start character is placed in the message buffer along with all subsequent
characters.

. co m .c o m . c o m
4.
The idle line time should always be greater than the time to transmit one character (start bit, data
24 24 a24
bits, parity and stop bits) at the specified baud rate. A typical value for the idle line time is three
2
ng hoa hoa
character times at the specified baud rate.
g gho ng ho a
Tu don do n d o
Typically, you use this type of start condition when there is a protocol that specifies a minimum time
Tu
between messages, and the first character of the message is an address or something which Tu
specifies a particular device. This is most useful when implementing a protocol where there are
multiple devices on the communications link. In this case the Receive instruction triggers an
interrupt only when a message is received for the specific address or devices specified by the start

.co m character.
.co m .co m
a 2 4 Setup:
a 2 4 a 2 4
il = 1, sc = 1, bk = 0, SMW90/SMW190 > 0, SMB88/SMB188 = start character
6a 2 4.
o o o gho
ngh gh gh
4. Break detection: A break is indicated when the received data is held to a zero value for a time
o n o n o
greater than a full character transmission time. A full character transmission time is defined as the
d d n
Tu Tu Tud
total time of the start, data, parity and stop bits. If the Receive instruction is configured to start a
message on receiving a break condition, any characters received after the break condition are
placed in the message buffer. Any characters received before the break condition are ignored.
Typically, you use break detection as a start condition only when a protocol requires it.

4 .c om Setup: . c om . c om
il = 0, sc = 0, bk = 1, SMW90/SMW190 = don’t care, SMB88/SMB188 = don’t care
4 4 4.
o a 2 a 2 a 2 a 2
ngh n g hoa break condition, and then a specificnstart
5. Break and a start character: The Receive instruction can
g
beo in that sequence. After the gho
configured
hcharacter, to start receiving characters

u
after receiving
d
break o for the specified start character. If anyudon
o condition, the receive message functionudlooks
T character but the start character is received,
T the receive message function restarts the T search for an
break condition. All characters received before the break condition has been satisfied and before
the start character has been received are ignored. The start character is placed in the message
buffer along with all subsequent characters.

.co m Setup:
.co m
il = 0, sc = 1, bk = 1, SMW90/SMW190 = don’t care,
.co m .
a 2 4 a 2 4
SMB88/SMB188 = start character
a 2 4 a 24
o o o o
ngh 6.
o n gh n gh
Any character: The Receive instruction can be configured to immediately start receiving any and all
o on g h
Tud d d
characters and placing them in the message buffer. This is a special case of the idle line detection.
Tu
In this case the idle line time (SMW90 or SMW190) is set to zero. This forces the Receive
instruction to begin receiving characters immediately upon execution.
T u
Setup: il = 1, sc = 0, bk = 0, SMW90/SMW190 = 0, SMB88/SMB188 = don’t care

.c o m . c o m . c o m
Starting a message on any character allows the message timer to be used to time out the receiving
.
a24 24 24 24
of a message. This is useful in cases where Freeport is used to implement the master or host
o hoa hoa oa
portion of a protocol and there is a need to time out if no response is received from a slave device

ngh d on g
d on g
within a specified amount of time. The message timer starts when the Receive instruction executes
o n gh
Tud
because the idle line time was set to zero. The message timer times out and terminates the receive
T u T u
message function if no other end condition is satisfied.
Setup: il = 1, sc = 0, bk = 0, SMW90/SMW190 = 0, SMB88/SMB188 = don’t care
c/m = 1, tmr = 1, SMW92 = message timeout in milliseconds

.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 83
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 omThe Receive instruction supports several


4 .c m
oways 4 . c ocanmbe terminated 4.
o a 2 a 2 a 2
to terminate a message. The message
a 2
ngh n g ho The end character is any characterngwhich
on one or a combination of the following:
hois used to denote the end of the ngho
T doAfter finding the start condition, the Receive
1. End character
u
message.
detection:
T u o
dinstruction T
checks each character received u do
to see if it matches the end character. When the end character is received, it is placed in the
message buffer and the receive is terminated.
Typically, you use end character detection with ASCII protocols where every message ends with a

. co m c o m c o m
specific character. You can use end character detection in combination with the intercharacter timer,
. .
24 24
the message timer or the maximum character count to terminate a message.
a24 2 4.
ng hoa Setup: ech=o
n g
a
1, SMB89/SMB189 = end character
n g ho n g ho a
o timer: The intercharacter time is theutimedomeasured from the end of one characterudo
Tustopd bit) to the end of the next character (theTstop
2. Intercharacter
(the T
bit). If the time between characters (including
the second character) exceeds the number of milliseconds specified in SMW92 or SMW192, the
receive message function is terminated. The intercharacter timer is restarted on each character
received. See Figure 6-11.

.co m .co m .co


You can use the intercharacter timer to terminate a message for protocols which do not have a
m .
6 2 4 2 4 2 4 24
oa a a a
specific end-of-message character. This timer must be set to a value greater than one character

g h gh o gh o
time at the selected baud rate since this timer always includes the time to receive one entire
g h o
n o n
character (start bit, data bits, parity and stop bits).
d d o n d o n
u u
T can use the intercharacter timer in combination
You T with the end character detection and the T u
maximum character count to terminate a message.
Setup: c/m = 0, tmr = 1, SMW92/SMW192 = timeout in milliseconds

4 .c om 4 .co m
4 .co m
4.
a2 2 2 2
Characters Characters

o oa o a hoa
ngh do ngh
d o n gh o ng
Tu Restarts the intercharacter
timer
TuThe intercharacter timer expires:
Terminates the message and generates the
Tud
Receive Message interrupt

om m m
Figure 6-11 Using the Intercharacter Timer to Terminate the Receive Instruction

2 4 . c 2 4 .co 2 4 .co 24.


ng hoa 3.
n gh o a
n gh o a
Message timer: The message timer terminates a message at a specified time after the start of the
g h o a
o o
message. The message timer starts as soon as the start condition(s) for the receive message
on
Tud Tu d
function have been met. The message timer expires when the number of milliseconds specified in
SMW92 or SMW192 have passed. See Figure 6-12. T u d
Typically, you use a message timer when the communications devices cannot guarantee that there
will not be time gaps between characters or when operating over modems. For modems, you can

.c o m . c m . c m
use a message timer to specify a maximum time allowed to receive the message after the message
o o .
a24 24 24 24
has started. A typical value for a message timer would be about 1.5 times the time required to

hoa hoa a
receive the longest possible message at the selected baud rate.
o o
ngh d on g
d on g
You can use the message timer in combination with the end character detection and the maximum
o n gh
u u Tud
character count to terminate a message.
T Setup: T
c/m = 1, tmr = 1, SMW92/SMW192 = timeout in milliseconds

.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
84
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4 . c om .
oa2 o a 2
Characters
o a2
Characters
o a 24
ngh on gh on gh on g h
T ud Start of the message: T ud The message timer expires: T u d
Starts the message timer Terminates the message and generates the
Receive Message interrupt

. co m Figure 6-12
.c m
Using the Message Timer to Terminate the Receive Instruction
o . c o m
24 24 a24 2 4.
ng hoa 4.
hoa ho
Maximum character count: The Receive instruction must be told the maximum number of
g g ng ho a
don do n o
characters to receive (SMB94 or SMB194). When this value is met or exceeded, the receive

Tu Tu
message function is terminated. The Receive instruction requires that the user specify a maximum
Tu
character count even if this is not specifically used as a terminating condition. This is because the
d
Receive instruction needs to know the maximum size of the receive message so that user data
placed after the message buffer is not overwritten.

4 .c om 4 .co m
4 .co m
The maximum character count can be used to terminate messages for protocols where the
message length is known and always the same. The maximum character count is always used in
4.
2 2 2 6 2
hoa a a a
combination with the end character detection, intercharacter timer, or message timer.
gh o gh o gho
ng 5.
n n
Parity errors: The Receive instruction is automatically terminated when the hardware signals a
d o d o o n
Tu Tu Tud
parity error on a received character. Parity errors are only possible if parity is enabled in SMB30 or
SMB130. There is no way to disable this function.
6. User termination: The user program can terminate a receive message function by executing another
Receive instruction with the enable bit (EN) in SMB87 or SMB187 set to zero. This immediately

4 .c om 4 . om
terminates the receive message function.
c 4 . c om 4.
o a2 a
Using Character Interrupt2 Control to Receive Data
o in protocol support, you can alsogreceive a 2
ho data using character interrupt control. hoa 2
ngh n g hflexibility
To allow complete
o received generates an interrupt. Theudreceived n
o of character do n g
Tud(if enabled) is placed in SM3.0 just prior toTexecution
Each character is placed in SMB2, and the parity
status the interrupt routine attached toT ureceive
the
character event. SMB2 is the Freeport receive character buffer. Each character received while in Freeport
mode is placed in this location for easy access from the user program. SMB3 is used for Freeport mode
and contains a parity error bit that is turned on when a parity error is detected on a received character. All

.com .co m .co m


other bits of the byte are reserved. Use the parity bit either to discard the message or to generate a
.
a 2 4 a 2 4
negative acknowledgement to the message.
a 2 4 a 24
o o o o
ngh gh gh h
When the character interrupt is used at high baud rates (38.4 kbaud to 115.2 kbaud), the time between
o n o n
interrupts is very short. For example, the character interrupt for 38.4 kbaud is 260 microseconds, for
on g
Tud Tu d
57.6 kbaud is 173 microseconds, and for 115.2 kbaud is 86 microseconds. Ensure that you keep the
interrupt routines very short to avoid missing characters, or else use the Receive instruction. T u d
Tip

.c o m . c m . c m
SMB2 and SMB3 are shared between Port 0 and Port 1. When the reception of a character on Port 0
o o
results in the execution of the interrupt routine attached to that event (interrupt event 8), SMB2 contains
.
o a24 hoa
24
hoa
24
the character received on Port 0, and SMB3 contains the parity status of that character. When the
oa 24
ngh gh
reception of a character on Port 1 results in the execution of the interrupt routine attached to that event
on g on g
(interrupt event 25), SMB2 contains the character received on Port 1 and SMB3 contains the parity
o n
u d
status of that character.
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 85
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
Example: Transmit and Receive Instructions 4.
c om 4. c om 4.
o a 2 a 2 a 2 a 2
ngh
M
n g ho Network 1 //This program receivesh
n g o of characters until
a string
n g ho
A
I
T u do T u
//The messagedois then transmitted back to the sender. Tudo
//a line feed character is received.

N LD SM0.1 //On the first scan:


MOVB 16#09, SMB30 //1. Initialize Freeport:
// – Select 9600 baud.

. co m .c o m // – Select 8 data bits.

. c o m
4.
// – Select no parity.
24 24 MOVB 16#B0, SMB87 //2.
a24
Initialize RCV message control byte:
2
ng hoa g hoa //
gho
– RCV enabled.

ng ho a
don n
// – Detect end of message character.

Tu Tu do
//
//
– Detect idle line condition as the message
start condition. Tu d o
MOVB 16#0A, SMB89 //3. Set end of message character
// to hex OA (line feed).
MOVW +5, SMW90 //4. Set idle line timeout

.co m MOVBom
.c 100, SMB94
//
//5.
to 5 ms.

.co m
Set maximum number of characters
.
6 2 4 4
a2 ATCH // to 100.
2 4 24
g hoa gh o INT_0, 23 //6.
gh o a
Attach interrupt 0
g h o a
n d o n //
d o n to the Receive Complete event.
d on
Tu Tu u
ATCH INT_2, 9 //7. Attach interrupt 2

ENI
//
//8.
to the Transmit Complete event.
Enable user interrupts.
T
RCV VB100, 0 //9. Enable receive box with buffer at VB100.

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
86
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
S7-200 Instruction Set Chapter 6

4 .c omExample: Transmit and Receive Instructions,


4 .c m
ocontinued 4 . c om 4.
o a 2 a 2 a 2 a 2
ngh
I
n g ho Network 1
g
//Receive complete
n hointerrupt routine: n g ho
N
T
T u do T doattach a 10 ms timer to trigger a transmit and
//1. If receive
//uthen
status shows receive of end character,

T u do
return.
0 //2. If the receive completed for any other reason,
// then start a new receive.
LDB= SMB86, 16#20

. co m .c o m MOVB 10, SMB34

. c o m
4.
ATCH INT_1, 10
24 24 CRETI
a24 2
ng hoa g hoa NOT
gho ng ho a
don n
RCV VB100, 0

Tu Tu do Tu d o

.co m .co m .co m


a 2 4 a 2 4 a 2 4 6a 2 4.
o o ho gho
ngh d o n gh n g
doTimer interrupt: o n
I
N Tu Network 1 u
T//10-ms
//1. Detach timer interrupt. Tud
T //2. Transmit message back to user on port.
1 LD SM0.0

om m m
DTCH 10

4 .c 4 .co XMT VB100, 0


4 .co 4.
o a2 oa 2 o a 2
hoa 2
ngh do ngh
d o n gh o ng
Tu Tu Tud
I Network 1 //Transmit Complete interrupt:
N //Enable another receive.

.co m T
.c m
oLD SM0.0
.co m .
a 2 4 2
a2 4 RCV VB100, 0
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 87
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
oGet .c m
oAddress . c om .
a2 4 Port Address and
a2
Set 4
Port Instructions
a2 4 a 24
h o h o h o h o
ng nginstruction (GPA) reads the station address
The Get Port Address
d o d o nofg d on g
addressT u in ADDR.
the S7-200 CPU
specified Tu
port specified in PORT and places the value in the
T u
The Set Port Address instruction (SPA) sets the port station address
(PORT) to the value specified in ADDR. The new address is not

. co m o m
saved permanently. After a power cycle, the affected port returns to
.c . c o m
24 24
the last address (the one that was downloaded with the system
a24 2 4.
hoa hoa a
block).

ng g gho ng ho
don do n o
Error conditions that set ENO = 0:

Tu
H 0006 (indirect address)
Tu Tu d
H 0004 (attempted to perform a Set Port Address instruction in an interrupt
routine)

.co m .co m .co m .


6 2 4 2 4 2 4 24
g hoa gh o a
gh o a
g h o a
n Table 6-13
d o n d o n
Valid Operands for the Get Port Address and Set Port Address Instructions
d on
Tu
Inputs/Outputs Data Type Operands Tu T u
ADDR BYTE IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *LD, *AC, Constant
(A constant value is valid only for the Set Port Address instruction.)

.c om PORT BYTE
. c om
Constant for CPU 221, CPU 222, CPU 224:
. c
0m
o
24 24 for CPU 226 and CPU 226XM:
24
0 or 1
2 4.
ng hoa g h oa g hoa g hoa
Tu don T u d on
Tud
o n

.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
88
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .c om 4. c om .
o a2 Compare Instructions
o a2 o a2 o a 24
ng h g h
nNumerical ng h g h
d o
Comparing Values
d o d on
Tucompare instructions are used to compareTtwouvalues:
The T u
IN1 = IN2 IN1 >= IN2 IN1 <= IN2
IN1 > IN2 IN1 < IN2 IN1 <> IN2

. co m .c o m . c o m
24
Compare Byte operations are unsigned.
24 a24 2 4.
hoa hoa a
Compare Integer operations are signed.

ng
Compare Double Word operations are signed.
g gho ng ho
don do n o
Compare Real operations are signed.

Tu Tu
For LAD and FBD: When the comparison is true, the Compare Tu d
instruction turns on the contact (LAD) or output (FBD).
For STL: When the comparison is true, the Compare instruction

.co m .c om
Loads, ANDs, or ORs a 1 with the value on the top of the stack
. c om
a 2 4 (STL).
4
2 instructions, you can use variousoa2
acompare 4 6a 2 4.
o o gho
ngh h hthe
When you use the IEC
data types for g g
same d o n o n
the inputs. However, both input values must be of
o n
Tu Tud Tud
data type.

Notice

4 .c om . om
immediately stop the execution of your program:
4 4 . om
The following conditions are fatal errors and cause your S7-200 to
c c 4.
o a2 a2is encountered (any Compare hoa2
H Illegal indirect address
instruction) ho hoa 2
ngh d o ng d o ng o ng
Tud
H Illegal
Tu(Compare Real instruction) Tu
real number (for example, NAN) is encountered

To prevent these conditions from occurring, ensure that you


properly initialize pointers and values that contain real numbers
before executing compare instructions that use these values.

.co m .co m
Compare instructions are executed regardless of the state of .co m .
a 2 4 power flow.
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 24
oa for the Compare Instructions oa 24 oa 24
ngh Table 6-14 Valid h

d
g
on Type
Operands

d on g h
o n gh
u u Tud
Inputs/Outputs Operands
T IN2
IN1, BYTE IB, QB, VB, MB,TSMB, SB, LB, AC, *VD, *LD, *AC, Constant
INT IW, QW, VW, MW, SMW, SW, T, C, LW, AC, AIW, *VD, *LD, *AC, Constant
DINT ID, QD, VD, MD, SMD, SD, LD, AC, HC, *VD, *LD, *AC, Constant

4 .c om REAL
4 . cID, mVD, MD, SMD, SD, LD, AC, *VD, *LD, *AC,.cConstant
oQD, 4 om 4.
2 BOOL 2
a2 2
hoa a a
Output (or OUT) I, Q, V, M, SM, S, T, C, L, Power Flow
h o h o ho
ng d o ng d o ng d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 89
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 Example: Compare Instructions 4.com 4 . c om 4.


o a 2 a 2 a 2 a 2
ngh n g ho Network 1
g o potentiometer 0 to vary
hvalue.
//Turn analog adjustment
n n g ho
o disoactive when the SMB28 value is less than Tudo
Tud
//the SMB28 byte
u
T//Q0.0
//or equal to 50.
//Q0.1 is active when the SMB28 value is greater than
//or equal to 150.
//The status indicator is on when the comparison is true.

. co m .c LDm
o . c o m
24 24 LPS
I0.0

a24 2 4.
ng hoa g hoa AB<= SMB28, 50
gho ng ho a
don n
= Q0.0

Tu
LPP
AB>= Tu
SMB28, 150
do Tu d o
= Q0.1

Network 2 //Load V memory addresses with low values

4 .c om 4 .c om 4 .co m
//that make the comparisons false and that turn
.
24
//the status indicators off.
6a2 2 2
ng ho g hoa LD I0.1
gh o a
g h o a
don n on
MOVW –30000, VW0
MOVD
d o
–200000000, VD2
d
Tu MOVR
Tu
1.012E–006, VD6
T u
Network 3 //Load V memory addresses with high values
//that make the comparisons true and that turn

4 .c om 4 . c oLDm I0.2
//the status indicators on.

4 .co m
4.
o a2 oa2 MOVW +30000, VW0
o a 2
hoa 2
ngh gh gh g
MOVD –100000000, VD2

do n MOVR 3.141593, VD6


d o n o n
Tu Network 4
u Integer Word comparison tests to find if
T//The Tud
//VW0 > +10000 is true.
//Uses program constants to show the different

.co m .c om .co
//stored in programmable memory like: m
//data types. You can also compare two values

.
a 2 4 4
a2 LD
//VW0 > VW100
a 2 4 a 24
o o o o
ngh gh gh h
I0.3

o n LPS
o n on g
Tud Tud u d
AW> VW0, +10000
=
LRD
Q0.2 T
AD< –150000000, VD2
= Q0.3

.c o m . c
LPP
o m . c o m .
a24 24 24 24
AR> VD6, 5.001E–006

hoa hoa a
= Q0.4
o o
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
90
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2 Compare String
o a 2 o a2 o a 24
ngh n gh n
The Compare String instruction compares two strings of ASCII
o o gh on g h
T ud
characters:
IN1 = IN2 IN1 <> IN2 T ud T u d
When the comparison is true, the Compare instruction turns the
contact (LAD) or output (FBD) on, or the compare instruction Loads,

. co m c o m
ANDs or ORs a 1 with the value on the top of the stack (STL).
. . c o m
24 24 a24 2 4.
ng hoa g hoa gho ng ho a
don n
Notice

Tu Tu do
The following conditions are fatal errors and cause your S7-200 to
immediately stop the execution of your program: Tu d o
H Illegal indirect address is encountered (any compare
instruction)

4 .c om 4 . om
H A string with a length greater than 254 characters is
c
encountered (Compare String instruction)
4 . c om 4.
2 2address and length are such that it willoa2 6 2
ng hoa n
not fit in the h o a
H A string whose starting
gspecified memory area (Compare Stringongh n gho
a
o
ud these conditions from occurring, ensure d you o
Tud
instruction)
Tprevent
To Tuthat
properly initialize pointers and memory locations that are intended
to hold ASCII strings prior to executing compare instructions that
use these values. Ensure that the buffer reserved for an ASCII

4 .c om .co m
string can reside completely within the specified memory area.
4 4 .co m
4.
o a2 oa 2
Compare instructions are executed regardless of the state of
o a 2
hoa 2
ngh gh gh
power flow.
o n o n o ng
Tu d
Table 6-15 Tu d
Valid Operands for the Compare String Instructions Tud
Inputs/Outputs Type Operands
IN1, IN2 BYTE (String) VB, LB, *VD, *LD, *AC

.com Output (OUT) BOOL


.co m
I, Q, V, M, SM, S, T, C, L, Power Flow
.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 91
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 Conversion Instructions
o a2 o a2 o a 24
ng h h
ng Instructions n gh g h
d o
Standard Conversion
ud o d on
Tu Conversions
Numerical T T u
The Byte to Integer (BTI), Integer to Byte (ITB), Integer to Double
Integer (ITD), Double Integer to Integer (DTI), Double Integer to Real

. co m o m
(DTR), BCD to Integer (BCDI) and Integer to BCD (IBCD)
.c . c o m
24 24
instructions convert an input value IN to the specified format and
a24 2 4.
hoa hoa ho ho a
stores the output value in the memory location specified by OUT. For

ng don
g
example, you can convert a double integer value to a real number.
You can also convert between integer and BCD formats.
do n g
d ong
Tu
Round and Truncate Tu Tu
The Round instruction (ROUND) converts a real value IN to a
double integer value and places the rounded result into the variable

.co m specified by OUT.


. c om . c om .
6 2 4 4
2 converts aportion a2 4 24
oa awhole-number a
The Truncate instruction (TRUNC) real number IN into a

g h double integer and placesh o


the of the result h o h o
n d o ng by OUT.
into the variable specified
d o ng d on g
Segment Tu Tu T u
The Segment instruction (SEG) allows you to generate a bit pattern
that illuminates the segments of a seven-segment display.

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
Table 6-16
Tu d
Valid Operands for the Standard Conversion Instructions
T u d
Inputs/Outputs Data Type Operands

.c o m IN BYTE
o m
IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *LD, *AC, Constant
. c . c o m .
a24 24 24 24
WORD, INT IW, QW, VW, MW, SMW, SW, T, C, LW, AIW, AC, *VD, *LD, *AC, Constant
o oaID, QD, VD, MD, SMD, SD, LD, HC, AC,g*VD,h*LD,
oa*AC, Constant oa
ngh h gh
DINT

o n g
REAL ID, QD, VD, MD, SMD, SD, LD,
o
AC, n *AC, Constant
*VD, *LD,
o n
OUT
d
Tu BYTE d
TLB,uAC, *VD, *LD, *AC
IB, QB, VB, MB, SMB, SB, Tud
WORD, INT IW, QW, VW, MW, SMW, SW, T, C, LW, AC, *VD, *LD, *AC
DINT, REAL ID, QD, VD, MD, SMD, SD, LD, AC, *VD, *LD, *AC

.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
92
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2 o a 2
Operation of the BCD to Integer and Integer to BCD Instructions
o a2 o a 24
ngh gh gh g h
The BCD to Integer instruction (BCDI) converts the binary-coded Error conditions that set ENO = 0
on on H SM1.6 (invalid BCD) on
ud ud d
decimal value IN to an integer value and loads the result into the
T T
variable specified by OUT. The valid range for IN is 0 to 9999 BCD.
H 0006 (indirect address)T u
The Integer to BCD instruction (IBCD) converts the input integer
value IN to a binary-coded decimal and loads the result into the SM bits affected:
variable specified by OUT. The valid range for IN is 0 to 9999 H SM1.6 (invalid BCD)

. co m integer.
.c o m . c o m
24 24 a24 2 4.
ng hoa g h
Operation of the
a Integer to Real Instruction ho
oDouble
ng
nInteger to Real instruction (DTR) convertsdao32-bit, ng ho a
d o d o
Tu integer IN into a 32-bit real number andTplaces
u the result into Tu
The Double Error conditions that set ENO = 0
signed H 0006 (indirect address)
the variable specified by OUT.

4 .c om 4
m
Operation of the Double Integer to Integer Instruction
.co 4 .co m
4.
2 2
The Double Integer to Integer instruction (DTI) converts the double
2
Error conditions that set ENO = 0
6 2
ng hoa o a
integer value IN to an integer value and places the result into the
n gh
variable specified by OUT.
n gh o aH SM1.1 (overflow)

n gho
a
d o d o H 0006 (indirect address)
o
Tu Tu
If the value that you are converting is too large to be represented in
the output, then the overflow bit is set and the output is not affected.
SM bits affected:
H SM1.1 (overflow)
Tud
Operation of the Integer to Double Integer Instruction

4 .c om 4 .co m
The Integer to Double Integer instruction (ITD) converts the integer
4 .co m
Error conditions that set ENO = 0
4.
2 2 2 2
hoa oa o aH 0006 (indirect address)
hoa
value IN to a double integer value and places the result into the

ng o ngh
variable specified by OUT. The sign is extended.
o n gh o ng
Tu d
Operation of the Byte to Integer Instruction Tu d Tud
The Byte to Integer instruction (BTI) converts the byte value IN to an Error conditions that set ENO = 0
integer value and places the result into the variable specified by H 0006 (indirect address)

.com om
OUT. The byte is unsigned, therefore there is no sign extension.
. c .c om
a 2 4 a 4
2 to Byte Instruction a 2 4 a 2 4.
o Operation of theo
htooa Error conditions that set ENO = 0 ngho
ngh h instruction (ITB) converts the word value
Integer
n g n g
byteu
T doand places the result into the variableTspecified
The Integer
value
to Byte
u do by OUT. H SM1.1 (overflow) Tudo
IN

Values 0 to 255 are converted. All other values result in overflow


H 0006 (indirect address)
and the output is not affected.
SM bits affected:

.c o m . c o m . c m
H SM1.1 (overflow)
o .
o a24 Tip
hoa
24
hoa
24 oa 24
ngh d on g
d on g
To change an integer to a real number, use the Integer to Double Integer instruction and then use the
o n gh
Tud
Double Integer to Real instruction.
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 93
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 omOperation of the Round and4Truncate . c omInstructions 4 . c om 4.


o a 2 a 2
o converts the real-number value INghError a 2
o conditions that set ENO = 0 a 2
ngh g hand
The Round instruction (ROUND)
n n n g ho
T u
specified by do If the fraction portion is 0.5 or greater,
to a double integer
OUT.
value places the result into the
T
o
thednumber
variable
u
H SM1.1 (overflow)
H 0006 (indirect address) T u do
is rounded up.
The Truncate instruction (TRUNC) converts a real-number value IN SM bits affected:
into a double integer and places the result into the variable specified H SM1.1 (overflow)

. co m c o m
by OUT. Only the whole number portion of the real number is
. . c o m
24 24
converted, and the fraction is discarded.
a24 2 4.
ng hoa If the value that you areh
output, then theo n
a
o is not a valid real number or is tooghlarge
g converting n
o to be represented in the
n g ho a
o o
Tud Tud Tud
overflow bit is set and the output is not affected.

Example: Standard Conversion Instructions


Network 1 //Convert inches to centimeters:

.co m .co m .co


//2. Convert the value to a real number. m
//1. Load a counter value (inches) into AC1.

.
6 2 4 2 4 2 4
//3. Multiply by 2.54 (convert to centimeters).
24
g hoa gh o a
gh o a
//4. Convert the value back to an integer.
g h o a
n d o n LD I0.0
d o n d on
Tu ITD
DTR
MOVR
Tu
C10, AC1
AC1, VD0
VD0, VD8
T u
*R VD4, VD8
ROUND VD8, VD12

4 .c om 4 . c m 2 //Convert a BCD value to an integer


oNetwork 4 . c om 4.
o a2 oa2 LD o a 2
hoa 2
ngh h h
I0.3

do ng BCDI AC0
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 24
oaand Round hoa
24 oa 24
ngh Double Word Integer toh

d
g
on Count = 101 inches
Real

d o ng BCD to Integer
o n gh
C10
VD0
T u101
101.0 Count (as a real number)
T u AC0 1234
BCDI
Tud
VD4 2.54 2.54 constant (inches to centimeters) AC0 04D2

.co m VD8 256.54


.co m
256.54 centimeters as real number
. com
a2 4 VD12 257
a 2 4
257 centimeters as double integer
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
94
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2 o a 2
Operation of the Segment Instruction
o a2 o a 24
ngh gh gh h
To illuminate the segments of a seven-segment display, the Segment instruction (SEG) converts the
on on
character (byte) specified by IN to generate a bit pattern (byte) at the location specified by OUT.
on g
T ud T ud
The illuminated segments represent the character in the least Error conditions that setT
u d
ENO = 0
significant digit of the input byte. Figure 6-13 shows the H 0006 (indirect address)
seven-segment display coding used by the Segment instruction.

. co m . c o m . c o m
a 24 (IN) Segment
a 24 (OUT) (IN) 24
a Segment (OUT)
a2 4.
gho gho ho8 ho
LSD Display –gfe dcba LSD Display – g f e d c b a
n 0on o n g n g
Tud1
0011
0000
1111
0110 Tuda 9
0 1 1
0110 T
1 1 1
0 1u
1
11
do
1

2 0101 1011 f g b A 0111 0111


3 0100 1111 B 0111 1100

om om
e c

2 4 .c 4
4 .
0110
c 0110

20 1 1 0 1 1 0 1 d
C
D 24
.com0 0 1 1 1001
6 2 4.
hoa hoa a a
5 0101 1110
o
gh E gho
ng 6
7o
ng 0111 1101
n 0111 1001
n
T u d 0000 0111
T udo F 0111
Tud
0001o
Figure 6-13 Coding for a Seven-Segment Display

4 .c om 4 . c om 4 .co m
4.
a2 oa2 Network 1 2 2
Example: Segment Instruction
o o a hoa
ngh gh gh g
05 6D

do n LD I1.0
d o n SEG
o n
Tu Tu Tud
VB48 AC1
SEG VB48, AC1

(display character)

.com .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 95
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
oASCII .c om . c om .
a2 4 Conversion
a2 4
Instructions
a2 4 a 24
h o h o o
the hexadecimal values 30 to 39, and 41 toh46. h o
ng d o ng
Valid ASCII characters are
d o ng d on g
Tu between ASCII and HexadecimalTValues
Converting u
The ASCII to Hexadecimal instruction (ATH) converts a number LEN
T u
of ASCII characters, starting at IN, to hexadecimal digits starting at
OUT. The Hexadecimal to ASCII instruction (HTA) converts the

. co m o m
hexadecimal digits, starting with the input byte IN, to ASCII
.c . c o m
24 24
characters starting at OUT. The number of hexadecimal digits to be
a24 2 4.
hoa hoa ho ho a
converted is specified by length LEN.

ng don
g
The maximum number of ASCII characters or hexadecimal digits
do n g
d ong
Tu
that can be converted is 255.
Error conditions that set ENO = 0
Tu Tu
H SM1.7 (illegal ASCII) ASCII to Hexadecimal only

.c o mHH 0006 (indirect address)


.c om .co m .
6a2 4 0091 (operand out of range)
a 2 4 a 2 4 a 24
ho SM bits affected:
h o gh o h o
ng H SM1.7 (illegal ASCII)g
d on d o n d on g
u
T Numerical Values to ASCII
Converting Tu T u
The Integer to ASCII (ITA), Double Integer to ASCII (DTA), and Real
to ASCII (RTA) instructions convert integer, double integer, or real

4 .c om number values to ASCII characters.

4 .co m
4 .co m
4.
o a2 oa 2
ho a 2
hoa 2
ngh ng h
doOperands for the ASCII Conversion Instructions n g ng
Table 6-17 uValid
T T udo Tud
o
Inputs/Outputs Data Type Operands
IN BYTE IB, QB, VB, MB, SMB, SB, LB, *VD, *LD, *AC

om om om
INT IW, QW, VW, MW, SMW, SW, T, C, LW, AC, AIW, *VD, *LD, *AC, Constant

2 4 . c DINT
4 .c 4 .c
ID, QD, VD, MD, SMD, SD, LD, AC, HC, *VD, *LD, *AC, Constant
24.
hoa
REAL
h o a2ID, QD, VD, MD, SMD, SD, LD, AC, *VD,h*LD,oa*AC,2Constant h o a
ng LEN, FMT
d o g
nBYTE IB, QB, VB, MB, SMB, SB, LB, AC,n
d o g *LD, *AC, Constant
*VD,
d on g
OUT
Tu BYTE IB, QB, VB, MB, SMB, SB,u
T LB, *VD, *LD, *AC T u
Operation of the Integer to ASCII Instruction

c o m o m
The Integer to ASCII instruction (ITA) converts
c o
an integer word IN to Error conditions that
c m set ENO = 0

a2 4. an array of ASCII characters.


a
The .
conversion precision to the right2of4the decimal, and whether the
format FMT specifies the H 0006
a 2 4.
(indirect address)
a 2 4.
o o as a comma or a period. The resultingghoH
ho
ngh h8 consecutive Illegal format
n g
decimal point is to be shown
n n g
Tu
The array
do
conversion is placed in bytes beginning
of ASCII characters is always 8 characters.T
udo
with OUT. H nnn > 5

Tud
o
Figure 6-14 describes the format operand for the Integer to ASCII instruction. The size of the output buffer
is always 8 bytes. The number of digits to the right of the decimal point in the output buffer is specified by

.co m .co m om
the nnn field. The valid range of the nnn field is 0 to 5. Specifying 0 digits to the right of the decimal point
. c
a2 4 a 2 4 a2 4
causes the value to be displayed without a decimal point. For values of nnn bigger than 5, the output
a2 4.
o gho o
buffer is filled with ASCII spaces. The c bit specifies the use of either a comma (c=1) or a decimal point
ho
ng h d o n gh
(c=0) as the separator between the whole number and the fraction. The upper 4 bits must be zero.
don d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
96
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2 o 2 o a2
Figure 6-14 shows examples of values that are formatted using a decimal point (c=0) with three digits to
a
the right of the decimal point (nnn=011). The output buffer is formatted according to the following rules:
o a 24
ngh on gh on gh on g h
ud ud d
- Positive values are written to the output buffer without a sign.
T- T
Negative values are written to the output buffer with a leading minus sign (–). T u
- Leading zeros to the left of the decimal point (except the digit adjacent to the decimal point) are
suppressed.

. co m -
.c o m . c o m
4.
Values are right-justified in the output buffer.
24 24 a24 2
ng hoa FMT
g hoa gho Out Out Out Out Out Out Out Outng ho a
T70 u60
MSB
don 5 4 3 2 1
LSB
0
o n
Tud in=–123
in=12
+1 +2 +3 +4 +5 +6
0 . T0 u1
do+72
0 0 c n n n – 0 . 1 2 3
c = comma (1) or decimal point (0) in=1234 1 . 2 3 4
nnn = digits to right of decimal point in = –12345 – 1 2 . 3 4 5

.co m .co m .co m


a 2 4 Figure 6-14
2 4
FMT Operand for the Integer to ASCII (ITA) Instruction
a a 2 4 6a 2 4.
o o o gho
ngh d o n gh
d o n gh o n
Tu
Operation of the Double Integer to ASCII Instruction
Tu Tud
The Double Integer to ASCII (DTA) instruction converts a double Error conditions that set ENO = 0
word IN to an array of ASCII characters. The format operand FMT H 0006 (indirect address)
specifies the conversion precision to the right of the decimal. The

4 .c om 4 . c o m
resulting conversion is placed in 12 consecutive bytes beginning
H nnn.>
4 c 5
om
H Illegal format

4.
o a 2 with OUT.
a 2 a 2 a 2
ngh g hobuffer is always 12 bytes.
The size of the output
n n g ho n g ho
u
Figure d o describes the format operand for the Double
6-15 u d oInteger to ASCII instruction. The numberuofddigits
o
T T T
to the right of the decimal point in the output buffer is specified by the nnn field. The valid range of the nnn
field is 0 to 5. Specifying 0 digits to the right of the decimal point causes the value to be displayed without
a decimal point. For values of nnn bigger than 5, the output buffer is filled with ASCII spaces. The c bit
specifies the use of either a comma (c=1) or a decimal point (c=0) as the separator between the whole

.co m c om
number and the fraction. The upper 4 bits must be zero.
. . c om
a 2 4 a 2 4 a 2 4 a 2 4.
o ho
Figure 6-15 shows examples
hoaccording to the following rules: ngho
of values that are formatted using a decimal point (c=0) with four digits to the

ngh n g
right of the decimal g
point (nnn=100). The output buffer is formatted
do values are written to the output buffer n
o a sign.
T--uPositive T udwithout T udo
Negative values are written to the output buffer with a leading minus sign (–).
- Leading zeros to the left of the decimal point (except the digit adjacent to the decimal point) are

.c o m suppressed.
. c o m . c o m .
a24 24 24 24
- Values are right-justified in the output buffer.

ngh
o g hoa hoa
ngOut Out Out Out Out Out Out Out OutdoOutn gh oa
FMT
u d on d o
TMSB
7 6 5 4 3 2 1
LSB
0
Tu +1 +2 +3 +4 +5 +6 +7 +8 +9Tu+10 +11
Out Out

in=–12 – 0 . 0 0 1 2
0 0 0 0 c n n n
in=1234567 1 2 3 . 4 5 6 7
c = comma (1) or decimal point (0)

4 .c om 4 . om
nnn = digits to right of decimal point
c 4 . com 4.
2 a2for the Double Integer to ASCII (DTA) Instruction a2 2
ng hoa ng h o
Figure 6-15 FMT Operand

ng h o
ng ho a
d o 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 97
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 omOperation of the Real to ASCII 4 . c om 4 . c om 4.


o a 2 a 2 Instruction
a
o (RTA) converts a real-number value INghError 2
o conditions that set ENO = 0 a 2
ngh g hformat
The Real to ASCII instruction
n n n g ho
T u
precision to doright of the decimal, whether the decimal
to ASCII characters.
the
The FMT specifies the
T u dois H nnn > 5
conversion
point
H 0006 (indirect address)
T u do
shown as a comma or a period, and the output buffer size.
H ssss < 3
The resulting conversion is placed in an output buffer beginning with
H ssss< number of characters in OUT
OUT.

. co mThe number (or length) of the resulting.cASCII


o mcharacters is the size of the output buffer
. c o m
a 2 4 specified to a size ranging from2
a 415 bytes or characters.
3 to
a 2 4 and can be
a2 4.
o o by the S7-200 supports a maximum ofg7hsignificant
o digits. Attempting to ho
ngh n
The real-number formatg hused n n g
T u thano 7 significant digits produces a rounding
display mored
T do
uerror. T udo
Figure 6-16 describes the format operand (FMT) for the RTA instruction. The size of the output buffer is
specified by the ssss field. A size of 0, 1, or 2 bytes is not valid. The number of digits to the right of the
decimal point in the output buffer is specified by the nnn field. The valid range of the nnn field is 0 to 5.

.co m .co m .co m


Specifying 0 digits to the right of the decimal point causes the value to be displayed without a decimal
.
6 2 4 4 4
point. The output buffer is filled with ASCII spaces for values of nnn bigger than 5 or when the specified
2 2 24
g hoa g
a
g ho a
output buffer is too small to store the converted value. The c bit specifies the use of either a comma (c=1)
ho h o a
ng
or a decimal point (c=0) as the separator between the whole number and the fraction.
n d o n d o n d o
Figure 6-16
the rightT
u also shows examples of values that are
Tuof six bytes (ssss=0110). The output bufferTisu
formatted
of the decimal point (nnn=001) and a buffer size
using a decimal point (c=0) with one digit to

formatted according to the following rules:

- Positive values are written to the output buffer without a sign.

4 .c om - . c om
Negative values are written to the output buffer with a leading minus sign (–).
4 4 . c om 4.
o a 2 o a 2 a 2 a 2
ngh
- Leading zeros to the left
suppressed. gh
n
of
n g ho
the decimal point (except the digit adjacent to the decimal point) are
ng ho
o o udo
-
Tudto the right of the decimal point are rounded
Values
of the decimal point. Tutodfit in the specified number of digits to theTright
- The size of the output buffer must be a minimum of three bytes more than the number of digits to
the right of the decimal point.

.co m- .co
Values are right-justified in the output buffer.
m .co m .
a 2 4 a 2 4 a 2 4 a 24
o o o o
ngh FMT
o n gh o n gh Out Out Out Out Out Out
on g h
MSB

7
ud
6 T5 4 3 2 1
LSB

0 Tu d
in = 1234.5 1
T
+1 +2 +3 +4 +5
2 3 4 .
u d
5
s s s s c n n n
in = –0.0004 0 . 0
ssss = size of output buffer in = –3.67526 – 3 . 7

.c o m c = comma (1) or decimal point (0)


nnn = digits to right of decimal point
. c o m . c o m
in = 1.95 2 . 0
.
o a24 Figure 6-16
o a
FMT Operand for the2Real4to ASCII (RTA) Instruction 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
98
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2 2
Example: ASCII to Hexadecimal Instruction
o a a2 a 24
ngh n gh Network 1
n g ho g h o
ud o I3.2o on
T d VB40, 3 d
LD
ATH uVB30, u
T T

. co m . c o m . c o m
a 24
‘3’ ‘E’ ‘A’
4 3E
2ATH Note: The X indicates2 4the “nibble” (half of a byte) is 2 4.
gho
33

g h oa
45 41 Ax

g ho
unchanged.
a that
g ho a
n d on
VB30 VB40
o n on
T u Tud Tud
Example: Integer to ASCII Instruction
Network 1 //Convert the integer value at VW2

.co m .co m m
//to 8 ASCII characters starting at VB10,
.co
a 2 4 a 2 4 //using a format of 16#0B

a 2 4
//(a comma for the decimal point, 6a 2 4.
o o o gho
ngh gh gh
//followed by 3 digits).

d o n LD
o
I2.3
d n o n
Tu ‘ ’ ‘ ’ ‘1’
T‘2’ u
ITA VW2, VB10, 16#0B
‘,’ ‘3’ ‘4’ ‘5’
Tud
12345 ITA 20 20 31 32 2C 33 34 35
VW2 VB10 VB11 ...

4 .c om .co m .co m
4.
2 24 2 4 2
ng hoa Example: Real toh
ng
o aInstruction
ASCII
n g ho a
ng hoa
d o Network 1 o //Convert the real value at VD2 o
Tu Tud //to 10 ASCII characters starting at VB10,Tud
//using a format of 16#A3
//(a period for the decimal point,
//followed by 3 digits).

4 . c om 4 .c om LD I2.3

4 .c‘4’o m .
24
RTA VD2, VB10, 16#A3
2 2‘ ’ ‘ ’ 2
ng hoa ng RTA hoa 20 ‘ ’ ‘1’

n
‘2’
gh
‘3’
o a ‘.’ ‘5’ ‘0’
g h o a
on
123.45 20 20 31 32 33 2E 34 35 30
d o d o d
TuVD2 VB10 VB11 ...
Tu 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 99
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
oString . c om . c om .
a2 4 Conversion 4
a2 to String
Instructions
a2 4 a 24
h o h o h o h o
ng Converting
d ng(ITS), Double Integer to String (DTS), dandoReal
Numerical
o
Values
ng d on g
u instructions convert integers, double integers,
The Integer to
T(RTS)
to String
String
Tu or real T u
number values (IN) to an ASCII string (OUT).

Operation of the Integer to String

. co mThe Integer to String instruction (ITS).cconverts


o m an integer word IN to . c o m
a 24 an ASCII string with a length of 2
a 4to the rightThe
8 characters. format (FMT)
a 24 a2 4.
o o o ho
ngh h is to be shown as a comma or a period.ngh
specifies the conversion precision of the decimal, and
o
whether the decimal
The resultingd
nisgpoint
written to 9 consecutive bytes startingdatoOUT. d ong
See theT
u string
section, format for strings in Chapter 4 for more Tuinformation. Tu
Error conditions that set ENO = 0
H 0006 (indirect address)

.co mH 0091 (operand out of range) .c om . c om .


6 2 4 a2 4 a2 4 24
g hoa H Illegal format (nnn > 5)
h o h o h o a
n o
Figure 6-17 describes
d ngthe format operand for the Integer todString
o ng d on g
instruction.u
T The
The number Ttheuoutput
length of the output string is always 8 characters.
of digits to the right of the decimal point in T u
buffer is specified by the nnn field. The valid range of the nnn field is
0 to 5. Specifying 0 digits to the right of the decimal point causes the

om m m
value to be displayed without a decimal point. For values of nnn

4 .c .co
greater than 5, the output is a string of 8 ASCII space characters.
4 4 .co 4.
o a2 oa 2
The c bit specifies the use of either a comma (c=1) or a decimal
o a 2
hoa 2
ngh gh gh
point (c=0) as the separator between the whole number and the
o n
fraction. The upper 4 bits of the format must be zero.
o n o ng
Tu d Tu
Figure 6-17 also shows examples of values that are formatted usingd Tud
a decimal point (c= 0) with three digits to the right of the decimal
point (nnn = 011).The value at OUT is the length of the string.

The output string is formatted according to the following rules:

. c m ombuffer without a sign.


o - Positive values are written to4the.coutput .c om
a 2 4 a 2 a 2 4 a 2 4.
o howritten to the output buffer with a leading ho sign (–). ho
ngh
- Negative values are minus
n g n g
o to the left of the decimal point (exceptudtheodigit adjacent to the decimal point) are udo n g
Tud
- Leading zeros
suppressed. T T
- Values are right-justified in the output string.

.c o m Table 6-18
o m
Valid Operands for the Instructions That Convert Numerical Values to Strings
. c . c o m .
a24 24 24 24
Inputs/Outputs Data Type Operands
o oa hoa oa
ngh g h ng gh
IN BYTE (String) VB, LB, *VD, *LD, *AC

Tu donINT DINT
d o
IW, QW, VW, MW, SMW, SW, T, C, LW, AIW, *VD, *LD, *AC, Constant
ID, QD, VD, MD, SMD,T uLD, AC, HC, *VD, *LD, *AC, Constant
SD, Tud
o n
REAL ID, QD, VD, MD, SMD, SD, LD, AC, *VD, *LD, *AC, Constant
INDX, FMT BYTE IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *LD, *AC, Constant

.co m OUT . c om
BYTE (String) VB, LB, *VD, *LD, *AC
. com
a2 4 4
a2ID, QD, VD, MD, SMD, SD, LD, AC, *VD,h*LD,oa*AC2
INT 4
IW, QW, VW, MW, SMW, SW, T, C, LW, AC, AQW, *VD, *LD, *AC
a2 4.
o o ho
ng h h
DINT, REAL

d o ng d o ng d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
100
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2
FMT
o a 2 a2
Out Out Out Out Out Out Out Out Out
o o a 24
ngh 4 g3h2 1 gh h
MSB LSB +1 +2 +3 +4 +5 +6 +7 +8
7 6
n 5 0
n on g
udo 0 c n n o in=12 8 0. . 0 1 2

T
0 0 0
c = comma (1) or decimal point (0)
n
T ud in=–123
in=1234
8
8 1
0. .
.
1
2
2
3
3
4 T u d
nnn = digits to right of decimal point in = –12345 8 – 1 2 . 3 4 5

. co m Figure 6-17

.c m
FMT Operand for the Integer to String Instruction
o . c o m
24 24 a24 2 4.
ng hoa Operation ofgthe
n h a Integer to String
oDouble
n g ho ng ho a
Theu do Integer to String instruction (DTS) converts
T Double udoa double Tu d
Error conditions that set ENO = 0 o
integer IN to an ASCII string with a length of 12T
characters. The H 0006 (indirect address)
format (FMT) specifies the conversion precision to the right of the
H 0091 (operand out of range)
decimal, and whether the decimal point is to be shown as a comma
or a period. The resulting string is written to 13 consecutive bytes H Illegal format (nnn > 5)

.co m .co m
starting at OUT. For more information, see the section that describes
.co m
a 2 4 2
the format for strings in Chapter 4.
a 4 a 2 4 6a 2 4.
o o o gho
ngh gh gh
Figure 6-18 describes the format operand for the Integer to String instruction. The length of the output
o n o n
string is always 8 characters. The number of digits to the right of the decimal point in the output buffer is
d d o n
Tu Tu
specified by the nnn field. The valid range of the nnn field is 0 to 5. Specifying 0 digits to the right of the
decimal point causes the value to be displayed without a decimal point. For values of nnn greater than 5, Tud
the output is a string of 12 ASCII space characters. The c bit specifies the use of either a comma (c=1) or
a decimal point (c=0) as the separator between the whole number and the fraction. The upper 4 bits of the

om m m
format must be zero.

4 .c 4 .co 4 .co 4.
a2 2 2 2
Figure 6-18 also shows examples of values that are formatted using a decimal point (c= 0) with four digits
o oa o a
to the right of the decimal point (nnn = 100). The value at OUT is the length of the string. The output string
hoa
ngh ngh
is formatted according to the following rules:
do d o n gh o ng
T-uPositive values are written to the output buffer
Tu without a sign. Tud
- Negative values are written to the output buffer with a leading minus sign (–).
- Leading zeros to the left of the decimal point (except the digit adjacent to the decimal point) are

.co m suppressed.
.co m .co m .
a 2 4 -
2 4
Values are right-justified in the output string.
a a 2 4 a 24
o o ho o
ngh o n gh o n g on g h
Tud Out OutdOut d
FMT
MSB
7 6 5 4 3 2 1
LSB
0 in=12
Tu+1 +2 Out+3 Out+4 Out+5 Out+6 Out+7 Out+8
12 . – 0 . 0 0
T1
u
Out Out Out Out
+9 +10 +11 +12
2
0 0 0 0 c n n n in=–1234567 12 1 2 3 . 4 5 6 7

.c o m c = comma (1) or decimal point (0)


nnn = digits to right of decimal point
. c o m . c o m .
2 4 24 24 24
ng hoa Figure 6-18
hoa
FMT Operand for the Double Integer to String Instruction
g ghoa gh oa
d on 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 101
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 omOperation of the Real to String 4 . c om 4 . c om 4.


o a 2 a 2
o (RTS) converts a real value IN to an ghError a 2
o conditions that set ENO = 0 a 2
ngh g h(FMT)
The Real to String instruction
n n n g ho
the right ofu
o whether the decimal point is to beushown
ddecimal,
ASCII string. The format specifies the conversion
do as H 0091 (operand out of range) Tudo
precision to H 0006 (indirect address)
T the
T
a comma or a period and the length of the output string.
H Illegal format:
The resulting conversion is placed in a string beginning with OUT. nnn > 5
The length of the resulting string is specified in the format and can ssss < 3

. co m c o m
be 3 to 15 characters. For more information, see the section that
. . c o m
ssss < number of characters

24 24
describes the format for strings in Chapter 4.
a24
required
2 4.
ng hoa The real-number formath
n g used
a
o by the S7-200 supports a maximum ofg7hsignificant
n
o digits. Attempting to
n g ho a
T u do
display more than the 7 significant digits produces a
do
rounding
T u
error.
T u do
Figure 6-19 describes the format operand for the Real to String instruction. The length of the output string
is specified by the ssss field. A size of 0, 1, or 2 bytes is not valid. The number of digits to the right of the
decimal point in the output buffer is specified by the nnn field. The valid range of the nnn field is 0 to 5.

.co m .co m .co m


Specifying 0 digits to the right of the decimal point causes the value to be displayed without a decimal
point. The output string is filled with ASCII space characters when nnn is greater than 5 or when the
.
6 2 4 2 4 2 4
specified length of the output string is too small to store the converted value. The c bit specifies the use of
24
g hoa gh o a
gh o a
either a comma (c=1) or a decimal point (c=0) as the separator between the whole number and the
g h o a
n fraction.
d o n d o n d o n
u u
T also shows examples of values that are formatted
Figure 6-19 u
T using a decimal point (c= 0) with oneTdigit
to the right of the decimal point (nnn = 001) and a output string length of 6 characters (ssss = 0110). The
value at OUT is the length of the string. The output string is formatted according to the following rules:

om -
om
Positive values are written to the output buffer without a sign.
om
o a 24.c -

theo
a 2 4 . c
a 2 4 .
Negative values are written to the output buffer with a leading minus sign (–). c
a 2 4.
ngh
- Leading zeros to h
n g g ho to the decimal point) are
left of the decimal point (except the digit adjacent
n ng ho
o
suppressed. o udo
- Tudto the right of the decimal point are rounded
Values
of the decimal point.
Tutodfit in the specified number of digits to theTright
- The size of the output string must be a minimum of three bytes more than the number of digits to the

.co m right of the decimal point.


.co m .co m .
a 2 4 -
2 4
Values are right-justified in the output string.
a a 2 4 a 24
o ho ho o
ngh FMT
do n g
d o n g Out Out Out Out Out Out Out do
ng h
MSB
7
T u
6 5 4 3 2 1 0
LSB
Tu in=1234.5 6 +11 +22 +33 +44 +5. T+65u
s s s s c n n n in= –0.0004 6 0. . 0
ssss = length of output string in= –3.67526 6 – 3 . 7

.c o m c = comma (1) or decimal point (0)

. c o m in = 1.95
. c o m 6 2 . 0
.
2 4 2Real4to String Instruction
nnn = digits to right of decimal point

24 24
hoa o a o a oa
Figure 6-19 FMT Operand for the

ng 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
102
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2 o a 2
Converting Substrings to Numerical Values
o a2 o a 24
ngh gh gh g h
The Substring to Integer (STI), Substring to Double Integer (STD),
on on
and Substring to Real (STR) instructions convert a string value IN, on
T ud T ud
starting at the offset INDX, to an integer, double integer or real
number value OUT. T u d
Error conditions that set ENO = 0
H 0006 (indirect address)

. co m .c o m . c o m
24
H 0091 (operand out of range)
24 a24 2 4.
ng hoa H 009B (index = 0)
g hoa gho ng ho a
don n
H SM1.1 (overflow)

Tu Tu do
The Substring to Integer and Substring to Double Integer convert Tu d o
strings with the following form: [spaces] [+ or –] [digits 0 – 9]
The Substring to Real instruction converts strings with the following

4 .c om form:
4 . om
[spaces] [+ or –] [digits 0 – 9] [. or ,] [digits 0 – 9]
c 4 . c om 4.
2 2 setThe
to 1, which starts the conversion with 2 6 2
hoa astring. oa a
The INDX value is normally
ofo
ng
the first characterh
g
obenused
values to start
the INDX value can be set to other
the conversion at different points within the n g h
oisstring. o n gho
Thisu d
can u
when the input string contains text d
that not part
Tud
ofTthe number to be converted. For example, if T the input string is
“Temperature: 77.8”, you set INDX to a value of 13 to skip over the
word “Temperature: ” at the start of the string.

4 .c om 4 .co m
The Substring to Real instruction does not convert strings using
scientific notation or exponential forms of real numbers. The
4 .co m
4.
2 2 2 2
hoa oa o a hoa
instruction does not produce an overflow error (SM1.1) but converts

ng o ngh o n gh
the string to a real number up to the exponential and then terminates
o ng
d d
the conversion. For example, the string ‘1.234E6’ converts without
Tu
errors to a real value of 1.234. Tu Tud
The conversion is terminated when the end of the string is reached or when the first invalid character is
found. An invalid character is any character which is not a digit (0 – 9).

4 . c om 4 .co m
4 .co m
The overflow error (SM1.1) is set whenever the conversion produces an integer value that is too large for
.
2 the output value. For example, the Substring to Integer instruction sets the overflow error if the input string
2 2 24
hoa o a o a o a
produces a value greater than 32767 or less than –32768.

ng o n gh o n gh
The overflow error (SM1.1) is also set if no conversion is possible when the input string does not contain a
on g h
Tud Tu d
valid value. For example, if the input string contains ‘A123’, the conversion instruction sets SM1.1
(overflow) and the output value remains unchanged. T u d
Table 6-19 Valid Operands for the Instructions That Convert Substrings to Numerical Values

.c o m Inputs/Outputs
o
Data Type
. c m
Operands
. c o m
a24 IN
a 2 4
BYTE (string)
IB, QB, VB, MB, SMB, SB, LB, *VD, *LD,
a 2 4
*AC, Constant
a 2 4.
o o o *LD, *AC, Constant ho
ngh g hBYTE g h*VD, g
INDX VB, IB, QB, MB, SMB, SB, LB, AC,
OUT do
n BYTE (string) VB, IB, QB, MB, SMB,d
n
oLB, *VD, *LD, *AC, Constant o n
Tu TuSMW, SW, T, C, LW, AC, AQW, *VD, *LD, *AC Tud
SB,
INT VW, IW, QW, MW,
DINT, REAL VD, ID, QD, MD, SMD, SD, LD, AC, *VD, *LD, *AC

.com .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 103
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 Valid Input Strings 4 .c om Valid Input Strings 4 . c om 4.


o a 2 for Integer and Double Integer a2
o Integer a 2 a 2
ho ho
for Real Numbers Invalid Input Strings

ngh n g
o‘123’
Input String hOutput
d‘123’o
Input String n g
Output Real Input String
o n g
Tud‘–00456’ 123
–456 T u
‘–00456’
123.0
–456.0
‘A123’ud
T ‘ ’
‘123.45’ 123 ‘123.45’ 123.45 ‘++123’
‘+2345’ 2345 ‘+2345’ 2345.0 ‘+–123

. co m ‘000000123ABCD’ 123

. c o m ‘00.000000123’

. c o m
0.000000123 ‘+ 123’

24 4 Input Strings
2Invalid 24 2 4.
hoa a a a
Figure 6-20 Examples of Valid and

gh o gh o ho
ng d o n o n ong
Tu
Example: ud and Real
TInteger
String Conversion: Substring to Integer, Double Tu d
Network 1 //Converts the numeric string to an integer.
//Converts the numeric string to a double integer.
//Converts the numeric string to a real.

.co m .c m
oLD I0.0
.co m .
6 2 4 4
a2 STD 2 4 24
oa a a
STI VB0,7,VW100

g h gh o VB0,7,VD200
gh o g h o
n d o n STR VB0,7,VD300
d o n d on
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 VB0 Tu VB11 Tud
11 ’T’ ’e’ ’m’ ’p’ ’ ’ ’ ’ ’9’ ’8’ ’.’ ’6’ ’F’

After executing the network:

.com VW100 (integer) = 98


.co m .co m .
o a24 a 2 4
VD200 (double integer) = 98
o o a 2 4
o a 24
ngh gh gh g h
VD300 (real) = 98.6
o n o n on
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
104
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
S7-200 Instruction Set Chapter 6

4 .c om Encode and Decode Instructions 4 .c om 4. c om .


o a2 o a2 o a2 o a 24
ng h g h
ninstruction ng h g h
on
Encode
d o (ENCO) writes the bit numberdofothe least d
Tu bit set of the input word IN into the least
The Encode
significant Tusignificant T u
“nibble” (4 bits) of the output byte OUT.

Decode

. co m .c o m . c o m
4.
The Decode instruction (DECO) sets the bit in the output word OUT
24 24 a24 2
hoa hoa a
that corresponds to the bit number represented by the least

ng g gho
significant “nibble” (4 bits) of the input byte IN. All other bits of the
ng ho
don do n o
output word are set to 0.

Tu
SM Bits and ENO Tu Tu d
For both the Encode and Decode instructions, the following
conditions affect ENO.

.co m .co
Error conditions that set ENO = 0 m .co m
a 2 4 H 0006 (indirect address)
a 2 4 a 2 4 6a 2 4.
o o for the Encode and Decode Instructionsgho gho
ngh d n g hOperands
o Data Types Operands
Table 6-20 Valid
d on o n
T u
Inputs/Outputs
IN BYTE
T u
IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *LD, *AC, Constant
Tud
WORD IW, QW, VW, MW, SMW, SW, T, C, LW, AC, AIW, *VD, *LD, *AC, Constant

4 .c om OUT BYTE

4
WORD . om
IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *LD, *AC
c 4 c
IW, QW, VW, MW, SMW, SW, T, C, LW, AC, AQW, .*VD,
m*AC
o*LD, 4.
o a 2 a 2 a 2 a 2
ngh ng ho n g ho ng ho
o o o
Tud Decode and Encode Instructions Tud
Example: Tud
Network 1 //AC2 contains error bits.
//1. The DECO instruction sets the bit in VW40
// that corresponds to this error code.

.co m .co m .co m


//2. The ENCO instruction converts
.
a 2 4 a 2 4 a 2 4
// the least significant bit set to an error code
a 24
o o o
// that is stored in VB50.
o
ngh o n gh LD
o n gh
I3.1
on g h
Tud Tu d u d
DECO AC2, VW40
ENCO AC3, VB50 T

.c o m . c o m3 15 9
. c o m 0
.
a24 24 24 24
AC2 AC3 1000 0010 0000 0000

ngh
o g hoa DECO
g hoa ENCO
gh oa
don VW40 0000 0000 0000 1000 donVB50 n
15 3 0

o
Tud
9
Tu Tu

.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 105
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 Counter Instructions
o a2 o a2 o a 24
ng h h
ngInstructions n gh g h
u d o
SIMATIC Counter
ud o u d on
CountT
Up Counter T T
The Count Up instruction (CTU) counts up from the current value
each time the count up (CU) input makes the transition from off to

. co m .c m
on. When the current value Cxx is greater than or equal to the
o . c o m
24
preset value PV, the counter bit Cxx turns on. The counter is reset
24 a24 2 4.
hoa hoa a
when the Reset (R) input turns on, or when the Reset instruction is

ng g
executed. The counter stops counting when it reaches the
gho ng ho
Tu don
maximum value (32,767).
STL operation : Tu do n
Tu d o
H Reset input: Top of stack
H Count Up input: Value loaded in the second stack location

.co mCount Down Counter .c om . c om .


6 2 4 4
2 counts down from the current oa2 4 24
g hoa The Count Down instruction
value of that counterg h o a
(CTD)
time the count down (CD) input makes gh g h o a
n the transitiond o noffeach
to on. When the current value Cxx is d onto d on
u
0, the counter
from
u equal
T bit Cxx turns on. The counter resets theTcounter bit T u
Cxx and loads the current value with the preset value PV when the
load input LD turns on. The counter stops upon reaching zero, and
the counter bit Cxx turns on.

4 .c omSTL operation: 4 . c om 4 . c om 4.
h o a2 H Load input: Top of stack
h o a2in the second stack location. h o a2 hoa 2
ng H Count Down
d ng
input:
o
Value loaded
d o ng o ng
CountT u Counter
Up/Down Tu Tud
The Count Up/Down instruction (CTUD) counts up each time the count up (CU) input makes the
transition from off to on, and counts down each time the count down (CD) input makes the transition from
off to on. The current value Cxx of the counter maintains the current count. The preset value PV is

.co m om
compared to the current value each time the counter instruction is executed.
.c . c om
a 2 4 Upon reaching maximum value2
a 4
(32,767), the next rising edge at the count up2
a 4
input causes the current
a 2 4.
o ominimum value (–32,768). On reachinggtheho ho
ngh
count to wrap around toh
next rising edgeoatn gcount
the
the
o
down input causes the current countn to
minimum value (–32,768), the
wrap around to the maximum value o n g
(32,767). ud
T Tud Tud
When the current value Cxx is greater than or equal to the preset value PV, the counter bit Cxx turns on.
Otherwise, the counter bit turns off. The counter is reset when the Reset (R) input turns on, or when the
Reset instruction is executed. The CTUD counter stops counting when it reaches PV.

.c o mSTL operation: . c o m . c o m .
o a24 H Reset input: Top of stack
o a 24 o a 24 oa 24
ngh n ghloaded in the second stack location ongh
H Count Down input: Value
o
d Value loaded in the third stack location Tud o n gh
Tuinput:
H Count Up
Tud
Table 6-21 Valid Operands for the SIMATIC Counter Instructions
Inputs/Outputs Data Types Operands

.c o m . c om(C0 to C255) . c om
a2 4 Cxx WORD
BOOL a2
4 Constant

a 2 4 a2 4.
o CU, CD, LD, R
ho
I, Q, V, M, SM, S, T, C, L, Power Flow
ho ho
ng h PV
o n gINT IW, QW, VW, MW, SMW, SW, LW,
o n gT, C, AC, AIW, *VD, *LD, *AC, Constant
on g
Tud Tud Tud

4 . com 4. c om 4 . com .
o a2 oa2 a2 a 24
ngh
106
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2 Tip
o a 2 o a2 o a 24
ngh gh gh g h
Since there is one current value for each counter, do not assign the same number to more than one
on on
counter. (Up Counters, Up/Down Counters, and Down counters with the same number access the same
on
T ud
current value.)
T ud T u d
When you reset a counter using the Reset instruction, the counter bit is reset and the counter current
value is set to zero. Use the counter number to reference both the current value and the counter bit of
that counter.

. co m .c o m . c o m
a24 a 2
Table 6-22 Operations of the 4Counter Instructions a 2 4 a2 4.
o ho o ho
ngh Type
n g
Operation
o increments the current value.
Counter Bit gh
n Power Cycle/First Scan
do bit turns on when: Counter bit is off. Tudo n g
TudCU
CTU
Current value continues to increment
Theu
T counter
Current value >= Preset Current value can be retained. 1
until it reaches 32,767.
CTUD CU increments the current value. The counter bit turns on when: Counter bit is off.

4 .c om Current value continues.toc


4 om Current value >= Preset 4.Current
CD decrements the current value.
c om value can be retained.
4.
1

oa 2 decrement untila 2 increment or


a 2 6a 2
ho the current value until The counternbitgturnshoon when: Counter bit is off. ho
the counter is reset.

n g h n g n g
CTD
o
CD decrements
o =0 o
Tud udvalue Tud
the current value reaches 0. 1

1
TCurrent Current value can be retained.

You can select that the current value for the counter be retentive. See Chapter 4 for information about memory retention
for the S7-200 CPU.

4 .c om . c om
Example: SIMATIC Count Down Counter Instruction
4 4 . c om 4.
o a2 oa2 Network 1
//with I0.1 off, ho
a
//Count down counter C12 current value counts from 3 to 0
hoa 2
ngh o ngh n g
doOn loads countdown preset value 3 Tudo
//I0.0 Off–on decrements C1 current value ng
Tud LD
T
I0.0
u
//I0.1

LD I0.1
CTD C1, +3

.co m .c om
Network 2
.co m
//C1 bit is on when counter C1 current value = 0
.
a 2 4 a 2 4 a 2 4 a 24
o o LD C1
o o
ngh gh gh g h
= Q0.0
o n o n on
Tud Tu d T u d
Timing Diagram

.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 107
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 Example: SIMATIC Count Up/Down4Counter


. c m
oInstruction 4 . c om .
o a2 o a2 a2 a 24
h h up o
//I0.0 counts h h o
ng d o ng Network 1

d o
//I0.1 ng down
counts
d on g
Tu LD
TI0.0u//I0.2 resets current value to 0 T u
LD I0.1
LD I0.2

. co m .c o m CTUD C48, +4
. c o m
a 24 a 24 Network 2
a 2 4C48 turns on C48 bit
//Count Up/Down counter
a2 4.
o ho o >= 4 ho
ngh g g hvalue g
//when current
o n o n on
Tud TQ0.0ud Tud
LD C48
=

.co m Timing Diagram .co m .co m .


6 2 4 2 4 2 4 24
g hoa gh o a
gh o a
g h o a
n d o n d o n d on
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
108
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
S7-200 Instruction Set Chapter 6

4 .c om IEC Counter Instructions 4 .c om 4. c om .


o a2 o a2 o a2 o a 24
ng h ng h g h
nvalue g h
on
Up Counter
d o d o d
Tu
The Count
the preset value (PV) on the rising edges of theT
u
Up instruction (CTU) counts up from the current
Count Up (CU)
to
T u
input. When the current value (CV) is greater than or equal to the
preset value, the counter output bit (Q) turns on. The counter resets
when the reset input (R) is enabled. The Up Counter stops counting

. co m when it reaches the preset value.


.c o m . c o m
24 24 a24 2 4.
ng hoa Down Counter
g hoa gho ng ho a
don do n o
The Count Down instruction (CTD) counts down from the preset

Tu Tu
value (PV) on the rising edges of the Count Down (CD) input. When
the current value (CV) is equal to zero, the counter output bit (Q) Tu d
turns on. The counter resets and loads the current value with the
preset value when the load input (LD) is enabled. The Down
Counter stops counting when it reaches zero.

.co m .c om . c om
a 2 4 Up/Down Counter 4
a2 (CTUD) counts up or down fromhtheoa2 4 6a 2 4.
o The Count Up/Downoinstruction
gho
ngh current value
Count d o
h
g on the rising edges of the Count Up o(CU)ngor
n(CD)
(CV)
o n
Tu Tudis equal to zero, Tud
Down input. When the current value is equal to preset,
the up output (QU) turns on. When the current value
the down output (QD) turns on. The counter loads the current value
with the preset value (PV) when the load (LD) input is enabled.
Similarly, the counter resets and loads the current value with 0 when

4 .c om 4 .co m
the reset (R) is enabled. The counter stops counting when it reaches
4 .co m
4.
a2 2 2 2
preset or 0.
o oa ho a hoa
ngh n g h n g ng
udo o o
Table 6-23 Valid Operands for the IEC Counter Instructions
Operands ud
T
Inputs/Outputs
Cxx
Data Types
CTU, CTD, CTUD
T
Constant (C0 to C255)
Tud
CU, CD, LD, R BOOL I, Q, V, M, SM, S, T, C, L, Power Flow

4 . c om PV INT

4 .c omI, Q, V, M, SM, S, L 4 .co m


IW, QW, VW, MW, SMW, SW, LW, AC, AIW, *VD, *LD, *AC, Constant
.
2 Q, QU, QD BOOL
2 2 24
ng hoa CV
ng hoINTa gh o a
IW, QW, VW, MW, SW, LW, AC, *VD, *LD, *AC
n g h o a
d o d o d on
Tu
Tip Tu T u
Since there is one current value for each counter, do not assign the same number to more than one
counter. (Up Counters, Down Counters, and Up/Down Counters access the same current value.)

.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 109
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 Example: IEC Counter Instructions4.com 4. c om .


o a2 o a2Timing Diagram o a2 o a 24
ng h ng h ng h g h
d o d o d on
Tu Tu u
I4.0
CU – Up

I3.0
T
CD – Down

I2.0

. co m .c o m
R – Reset

. c o m
24 24 I1.0
a24 2 4.
hoa hoa ho ho a
LD – Load

ng don
g
do n g
d ong
Tu Tu
4 4 4

Tu
4
VW0 3 3 3
CV –
Current Value 2 2
1
0 0

om m m
Q0.0

6a2 4 .c 2 4 .coQU – Up

2 4 .co 24 .
ho o a Q0.1
o a o a
gh gh h
QD – Down

ng d o n d o n d on g
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 .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
110
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .c om 4. c om .
o a2 High-Speed Counter
o a2 Instructions
o a2 o a 24
ng h g h
nCounter ng h g h
High-Speed
d o Definition
d o d on
TuHigh-Speed Counter Definition instruction (HDEF)
The Tu selects the
operating mode of a specific high-speed counter (HSCx). The mode
T u
selection defines the clock, direction, start, and reset functions of the
high-speed counter.

. co m .c o m . c o m
24 24
You use one High-Speed Counter Definition instruction for each
a24 2 4.
hoa hoa a
high-speed counter.

ng g gho ng ho
don n
Error conditions that set ENO = 0

Tu
H 0003 (input point conflict)
Tu do Tu d o
H 0004 (illegal instruction in interrupt)
H 000A (HSC redefinition)

.co m High-Speed Counter .com . c om


a 2 4 4
a2(HSC) instruction configures and controls a2 4 6a 2 4.
o o o gho
ngh h h
The High-Speed Counter
the high-speedg
d o nThecounter, d o ng
based on the state of the HSC special
o n
Tu Tu Tud
memory bits. parameter N specifies the high-speed counter
number.
The high-speed counters can be configured for up to twelve different modes of operation. See Table
6-25.

4 .c om 4 .co m
4 .co m
Each counter has dedicated inputs for clocks, direction control, reset, and start, where these functions
are supported. For the two-phase counters, both clocks can run at their maximum rates. In quadrature 4.
o a2 oa 2 o a 2
modes, you can select one times (1x) or four times (4x) the maximum counting rates. All counters run at
hoa 2
ngh n gh
maximum rates without interfering with one another.
o
d that set ENO = 0 d o n gh o ng
Tuconditions
Error
H 0001 (HSC before HDEF)
Tu Tud
H 0005 (simultaneous HSC/PLS)

.co m Table 6-24


c om
Valid Operands for the High-Speed Counter Instructions
. .co m .
a 2 4 Inputs/Outputs
a2 4
Data Types
Operands
a 2 4 a 24
o o BYTE o o
ngh n gh
HSC, MODE
o
Constant
o n gh on g h
Tud
N WORD Constant
Tu d T u d
Refer to the Tips and Tricks on the documentation CD for programs that use high-speed counters. See
Tip 4 and Tip 29.

.c o m
Tips and Tricks

. c o m . c o m
High-speed counters count high-speed events that cannot be controlled at S7-200 scan rates. The
.
2 4 24 24
maximum counting frequency of a high-speed counter depends upon your S7-200 CPU model. Refer to
24
ng hoa hoa
Appendix A for more information.
g g hoa gh oa
d on d on o n
u
Tip
T T u
CPU 221 and CPU 222 support four high-speed counters: HSC0, HSC3, HSC4, and HSC5. These Tud
CPUs do not support HSC1 and HSC2.
CPU 224, CPU 226, and CPU 226XM support six high-speed counters: HSC0 to HSC5.

.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 111
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 omTypically, a high-speed counter is 4 .c om 4 . c omat a constant 4.


o a 2 a 2 used
a 2
as the drive for a drum timer, where a shaft rotating
a 2
ngh counts per revolutiong
n ho
speed is fitted with an incremental
and
n g
a reset pulse that occurs once per revolution.
o clock(s) and the reset pulse
shaft encoder. The shaft encoder provides
hThe a specified number of
n g ho
u o provide the inputs to the high-speed
from the shaftdencoder
u o
dcounter. u do
T T T
The high-speed counter is loaded with the first of several presets, and the desired outputs are activated
for the time period where the current count is less than the current preset. The counter is set up to provide
an interrupt when the current count is equal to preset and also when reset occurs.

. co mAs each current-count-value-equals-preset-value


.c o m interrupt event occurs, a new preset . c o m and the
4.
is loaded

a 2 4 next state for the outputs is set.


a 2 4
When the reset interrupt event occurs, the
2
first
a 4
preset and the first output
a2
o ho ho ho
ngh
states are set, and the cycle is repeated.
n g n g n g
control T udo occur
Since the interrupts
of high-speed operations can be implementedT
do ratesminor
at a much lower rate than the counting
urelatively
with
of the high-speed counters, precise
impact to the overall PLCT udo
scan
cycle. The method of interrupt attachment allows each load of a new preset to be performed in a separate
interrupt routine for easy state control. (Alternatively, all interrupt events can be processed in a single
interrupt routine.)

.co m .co m .co m .


6 2 4 2 4
Understanding the Different High-Speed Counters
2 4 24
g hoa gh o a
gh o a
All counters function the same way for the same counter mode of operation. There are four basic types of
g h o a
n d o n d o n
counters: single-phase counter with internal direction control, single-phase counter with external direction
d on
Tu Tu
control, two-phase counter with 2 clock inputs, and A/B phase quadrature counter. Note that every mode
is not supported by every counter. You can use each type: without reset or start inputs, with reset and T u
without start, or with both start and reset inputs.

- When you activate the reset input, it clears the current value and holds it clear until you deactivate

4 .c om reset.
4 .co m
4 .co m
4.
2 - 2 2 2
hoa oa a a
When you activate the start input, it allows the counter to count. While start is deactivated, the

ng n g h n g ho
current value of the counter is held constant and clocking events are ignored.
ng ho
If reset iso o and the current value is not changed.do
-
IfT
d activated while start is inactive, the resetinput
theustart input becomes active while the resetT uisdignored
is active, the current value is cleared. Tu
Before you use a high-speed counter, you use the HDEF instruction (High-Speed Counter Definition) to
select a counter mode. Use the first scan memory bit, SM0.1 (this bit is turned on for the first scan and is
then turned off), to call a subroutine that contains the HDEF instruction.

4 . c om 4 . c om 4 .c om 4.
o a 2 Programming a High-Speed a 2 Counter a 2 a 2
ngh You can use the HSCn g ho Wizard to configure the counter.nThe
Instruction g o uses the following
hwizard n g ho
Instruction T
direction. To
doand
ustart
information: type
T
the HSC Instruction Wizard, select the
o current value, and initial countingudo
dcounter
uTools
mode of counter, counter preset value,
Tand
> Instruction Wizard menu command
Wizard
then select HSC from the Instruction Wizard window.

To program a high-speed counter, you must perform the following basic tasks:

.c o m- Define the counter and mode.


. c o m . c o m .
o a24 -
hoa
Set the control byte. 24
hoa
24 oa 24
ngh -
o ng
Set the current value (starting value).
d d on g o n gh
- Tuthe preset value (target value).
Set T u Tud
- Assign and enable the interrupt routine.
- Activate the high-speed counter.

4 .c om 4 .co m
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
112
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2 2
Defining Counter Modes and Inputs
a a2 a 24
ngh ho ho
Use the High-Speed Counter Definition instruction to define the counter modes and inputs.
n g n g ng h o
u d o d o d o
Tbeuused for two different functions, but any input
Tunot
Table 6-25 shows the inputs used for the clock, direction control, reset, and start functions associated with
Thigh-speed
the counters. The same input cannot
being used by the present mode of its high-speed counter can be used for another purpose. For example,
if HSC0 is being used in mode 1, which uses I0.0 and I0.2, I0.1 can be used for edge interrupts or for
HSC3.

. co m .c o m . c o m
24 Tip
24 a24 2 4.
ng hoa hoa ho
Note that all modes of HSC0 always use I0.0 and all modes of HSC4 always use I0.3, so these points
g g ng ho a
don n
are never available for other uses when these counters are in use.

Tu Tu do Tu d o
Table 6-25 Inputs for the High-Speed Counters
Mode Description Inputs
HSC0 I0.0 I0.1 I0.2

4 .c om 4 .c om
HSC1 I0.6
4
I0.7
. c m
oI0.2 I1.1
4.
2 2 a2 6 2
hoa hoa o gho
a
HSC2 I1.2 I1.3 I1.1 I1.2

ng g g h
d on HSC3 I0.1
o n o n
T u HSC4
HSC5
TuI0.3d
I0.4
I0.4 I0.5
Tud
0 Single-phase counter with internal Clock
direction control

4 .c om 1

4 . c om Clock

4 . c om
Reset

4.
2 2
2 Clock
2 Reset Start
2
ng hoa 3
h
Single-phase
g
a with external
ocounter Clock
g h oa
Direction
g hoa
don
direction control
on Direction o n
Tud Tud
4 Clock Reset
u
T5 Clock Direction Reset Start
6 Two-phase counter with 2 clock inputs Clock Up Clock Down
7 Clock Up Clock Down Reset

.com 8
.co m Clock Up Clock Down
.coReset m Start
.
a 2 4 9
a 2 4
A/B phase quadrature counter Clock A Clock B
a 2 4 a 24
o o hoB o
ngh 10
o n gh Clock A
Clock Ado
n g
Clock Reset
on g h
T11ud Tu Clock B Reset
u d
Start
T

.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 113
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 omExamples of HSC Modes 4.com 4 . c om 4.


o a 2 a 2 a 2 a 2
ngh
The timing diagrams
n
in
g ho
Figure 6-21 through Figure 6-25 show how
n ho
each
g counter functions according to
n g ho
mode.
o udo udo
Tud T
Current value loaded to 0, preset loaded to 4, counting direction set to up.
T
Counter enable bit set to enabled.
PV=CV interrupt generated

. co m .c o mDirection changed within interrupt routine.com


24
1
24 24 2 4.
hoa a a a
Clock 0
1 h
o gh o ho
ng Internal ng
o o n ong
ud 0
TDirection
Control Tud Tu d
4
(1 = Up)
3 3
2 2

4 .c om Counter 1
4 .c om 1
4 .co m .
24
Current
6a2 2 0
2
hoa a–1 a
Value 0
ho gh o h o
ng don
g
d o n d on g
TuOperation Example of Modes 0, 1, or 2
Figure 6-21
Tu T u

om m m
Current value loaded to 0, preset loaded to 4, counting direction set to up.

2 4 .c 24 .co
Counter enable bit set to enabled.
2 4 .co 2 4.
hoa oa a a
PV=CV interrupt generated

g1 h gh o ho
ng g
PV=CV interrupt generated and

do n o n
Direction Changed interrupt generated
d o n
TuClock 0 Tu Tud
External 1
Direction
Control 0

.co m (1 = Up)
.co m 5
.co m .
a 2 4 a 2 4 4 4
a 2 4 a 24
o o h2o o
ngh gh h
3 3

o n n g on g
do
2

Tud d
Counter
Current
Value
0
1
Tu 1
T u
Figure 6-22 Operation Example of Modes 3, 4, or 5

.c o m . c o m . c o m .
2 4 24 24 24
ng hoa g hoa ghoa gh oa
d on 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
114
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2 o 2 o a2
When you use counting modes 6, 7, or 8, and rising edges on both the up clock and down clock inputs
a
occur within 0.3 microseconds of each other, the high-speed counter could see these events as
o a 24
ngh n gh n gh
happening simultaneously. If this happens, the current value is unchanged and no change in counting
o o on g h
T ud T ud
direction is indicated. As long as the separation between rising edges of the up and down clock inputs is
greater than this time period, the high-speed counter captures each event separately. In either case, no T u d
error is generated and the counter maintains the correct count value.

. co m .c m . c o m
Current value loaded to 0, preset loaded to 4, initial counting direction set to up.
o
a24 a
Counter enable bit set to enabled.
24 PV=CV interrupt generated 24
a a2 4.
o ho hointerrupt generated and ho
ngh Countng1
o 0 n g
PV=CV
o Direction Changed interrupt generated udon g
TudUp
Clock Tud T
Count 1
Down

.co m Clock 0
.co m .co m
a 2 4 a 2 4 5
a 2 4 6a 2 4.
o o o gho
ngh d o n gh 4

d o n g4h o n
Tu Tu Tud
3 3
2 2
Counter 1 1
Current
Value 0

4 .c om 4 .co m
4 .co m
4.
2 Figure 6-23
2
Operation Example of Modes 6, 7, or 8
2 2
ng hoa ngh oa
n g ho a
ng hoa
o o to 3, initial counting direction set to up. udo
Tud Current value loaded to 0,T udloaded
preset
Counter enable bit set to enabled.
T
PV=CV interrupt PV=CV interrupt generated and
Direction Changed interrupt generated

.co m Phase A 1
.co m generated

.co m .
a 2 4 Clock 0
a 2 4 a 2 4 a 24
o o o o
ngh o n gh
Phase B 1
o n gh on g h
Tud Clock
0
Tu d
4
T u d
3 3
2 2

.c o m Counter
. c1o m . c o m .
2 4 Current
2 4 24 24
hoa hoa hoa a
Value 0
gh o
ng o g Example of Modes 9, 10, or 11 (Quadrature
nOperation
Figure 6-24
d d o ng 1x Mode)
o n
Tu Tu 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 115
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 .co m
4. c om .
oa2 o 2
Counter enable bit set to enabled.
o a2
Current value loaded to 0, preset loaded to 9, initial counting direction set to up.
a o a 24
ngh gh gh g h
Direction Changed
on PV=CV interrupt generated
on interrupt generated
on
T ud T ud PV=CV T u d
interrupt generated
Phase A 1
Clock 0

. co m .c o m . c o m
4.
Phase B
24 24 a24
1
Clock
2
ng hoa g
0
hoa gho ng ho a
Tu don 11
Tu do
12 n
11
Tu d o
10 10
9 9
8 8

4 .c om 4 .c om 7
46.c
7
o m .
6a2 2 6
2 24
ng ho g hoa 5
gh o a
g h o a
don o n on
4

Tu 3
Tu d T u d
2
Counter Current 1
Value
0

4 .c omFigure 6-25 4 .co m


Operation Example of Modes 9, 10, or 11 (Quadrature 4x Mode)
4 .co 4.
m
o a2 oa 2
ho a 2
hoa 2
ngh d n g h
o Operation do n g
do ng
Reset and
T u Start
T u T u
The operation of the reset and start inputs shown in Figure 6-26 applies to all modes that use reset and
start inputs. In the diagrams for the reset and start inputs, both reset and start are shown with the active
state programmed to a high level.

.co m .co m .co m .


a 2 4 a 2 4 a 2 4
Reset interrupt Reset interrupt
a 24
o Example with Reset
o Example with Reset
o o
ngh gh gh h
generated generated
and without Start
o n
and Start
o n Counter Counter Counter Counter
on g
Tud d d
disabled enabled disabled enabled

Start
Tu
(Active High)
1
0
T u
Reset interrupt Reset 1

.c o m Reset 1
generated

. c o m (Active High)
0
. c o m .
a24 2 4 24 24
(Active High)

hoa hoa a
0

o o
ngh g g gh
+2,147,483,647 +2,147,483,647

d on d on Current Current
o n
Tud
Counter Counter

T u
Current Value

–2,147,483,648
0

T u
Current Value
0

–2,147,483,648
value
frozen
value
frozen

Counter value is somewhere in this range. Counter value is somewhere in this range.

.co mFigure 6-26 .co m . com


a2 4 Operation Examples Using Reset with and without Start

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
116
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2 o 2 o a2
Four counters have three control bits that are used to configure the active state of the reset and start
a
inputs and to select 1x or 4x counting modes (quadrature counters only). These bits are located in the
o a 24
ngh n gh n gh
control byte for the respective counter and are only used when the HDEF instruction is executed. These
o o on g h
T ud
bits are defined in Table 6-26.
T ud T u d
Tip
You must set these three control bits to the desired state before the HDEF instruction is executed.
Otherwise, the counter takes on the default configuration for the counter mode selected.

. co m .c o m . c o m
24
Once the HDEF instruction has been executed, you cannot change the counter setup unless you first
24 a24 2 4.
hoa hoa a
place the S7-200 in STOP mode.

ng n g n gho ng ho
o udoonly when HDEF is executed) o
Tud HSC1 HSC2 HSC4 DescriptionT(used d
Table 6-26
Active Level for Reset, Start, and 1x/4x Control Bits
HSC0 Tu
Active level control bit for Reset1:
SM37.0 SM47.0 SM57.0 SM147.0
0 = Reset is active high 1 = Reset is active low

4 .c om ––– SM47.1 SM57.1


4 .–––om
c 0 = Start is active high
1
Active level control bit for Start :

4 . c olowm
1 = Start is active
4.
oa 2 a 2 a 2 6a 2
n g h n g ho SM147.2 0 = 4X counting rate ngh1o= 1X counting rate
SM37.2 SM47.2 SM57.2
Counting rate selection for quadrature counters:

n g ho
1 Thed o setting of the reset input and the start inputuaredoactive high, and the quadrature counting rate isu4xd(orofour
u default
Ttimes the input clock frequency). T T

4 .c om 4
m
Example: High-Speed Counter Definition Instruction
.co 4 .co m
4.
2 M
2 Network 1
2
//On the first scan:
2
hoa oa o a hoa
A //1. Select the start and reset inputs

ng I
o ngh o n gh // to be active high and select 4x mode.
o ng
N
Tu d TLDu d Tud
//2. Configure HSC1 for quadrature mode
// with reset and start inputs
SM0.1
MOVB 16#F8, SMB47
HDEF 1, 11

.com .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 117
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 omSetting the Control Byte 4.com 4 . c om 4.


o a 2 a 2 a 2 a 2
ngh
After you define the
n g hocounter has a control byte that allows nthegfollowing
counter and the counter mode, you can program
ho actions:
the dynamic parameters of the
n g ho
o
counter. Each high-speed
o o
Tud or disabling the counter
- Enabling Tud Tud
- Controlling the direction (modes 0, 1, and 2 only), or the initial counting direction for all other modes
- Loading the current value

. co m- .c o m . c o m
a 24
Loading the preset value
a 24 a 2 4 by the execution of a2 4.
o Examination of the controlo
ho ho
ngh h 6-27 describes each of these control bits.
byte and associated current and preset values is invoked
n g
the HSC instruction. Table
n g n g
do Bits for HSC0, HSC1, HSC2, HSC3, HSC4,
TuControl
Table 6-27
o
Tuandd HSC5 Tud
o
HSC0 HSC1 HSC2 HSC3 HSC4 HSC5 Description
Counting direction control bit:

.c o m .c om
SM37.3 SM47.3 SM57.3 SM137.3 SM147.3 SM157.3
0 = Count down
.co m
1 = Count up
.
6a2 4 4
a2 SM147.4
SM37.4 SM47.4 SM57.4 SM137.4 SM157.4 2 4
Write the counting direction to the HSC:
a a 24
ho h o 0 = No update
gh o 1 = Update direction
h o
ng d o
SM37.5 SM47.5
g SM137.5 SM147.5
nSM57.5 SM157.5
d o n
Write the new preset value to the HSC:
d on g
T u T uWrite the new current value to the HSC:
0 = No update 1 = Update preset
T u
SM37.6 SM47.6 SM57.6 SM137.6 SM147.6 SM157.6
0 = No update 1 = Update current value
Enable the HSC:

om SM37.7 SM47.7 SM57.7

.com
SM137.7 SM147.7 SM157.7
0 = Disable the HSC
om1 = Enable the HSC

o a 24.c a 2 4
oand Preset Values o a 2 4 . c
a 2 4.
ngh
Setting Current Values
n g hhas n g hvalue. ng ho
T u
preset valuesdareosigned integer values. To load a newTcurrent
Each high-speed counter a 32-bit current value and a
u door preset value into the high-speed Tudo
32-bit preset Both the current and the

counter, you must set up the control byte and the special memory bytes that hold the current and/or preset
values, and also execute the HSC instruction to cause the new values to be transferred to the high-speed
counter. Table 6-28 lists the special memory bytes used to hold the new current and preset values.

.co mIn addition to the control bytes and the.cnew


om . c om 4.
preset and current holding bytes, the current value of each

a 2 4 2
high-speed counter can only be read
a 4 using the data type HC (High-Speed Counter
a 2 4 Current) followed by
a 2
o hothe HSC instruction. ho ho
ngh
the number (0, 1, 2, 3, 4, or 5) of the counter. The current value is directly accessible for read operations,
n g
but can only be written with
n g n g
do and Preset Values of HSC0, HSC1, HSC2,
TuCurrent
Table 6-28
doHSC4, and HSC5
TuHSC3, Tud
o
Value to be Loaded HSC0 HSC1 HSC2 HSC3 HSC4 HSC5
New current SMD38 SMD48 SMD58 SMD138 SMD148 SMD158

.c o m New preset . c
SMD42o m SMD52 SMD62 SMD142
. c o m
SMD152 SMD162
.
2 4 2 4 2 4 24
ng hoa g hoa g hoa gh oa
d on 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
118
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
o a2 o a 2
Addressing the High-Speed Counters (HC)
o a2 o a 24
ngh gh gh h
To access the count value for the high-speed counter, specify the address of the high-speed counter,
on on
using the memory type (HC) and the counter number (such as HC0). The current value of the high-speed
on g
ud ud
counter is a read-only value that can be addressed only as a double word (32 bits), as shown in
T
Figure 6-27. T T u d
HC 2 MSB LSB

.com .com o m
31 0

24
High-speed counter number

24
Most significant
. c
4 Byte 1 Least significant
4.
2 2 2
Area identifier (high-speed counter)

h o a o a Byte 3 Byte a
o Byte 0
ho a
ng Figure 6-27on
gh o n gh ong
Tud Tud d
Accessing the High-Speed Counter Current Values
Tu
Assigning Interrupts

om m m
All counter modes support an interrupt on current value equal to the preset value. Counter modes that use

2 4 .c 2 4 .co 2 4 .co
an external reset input support an interrupt on activation of the external reset. All counter modes except
6 2 4.
hoa a a a
modes 0, 1, and 2 support an interrupt on a change in counting direction. Each of these interrupt

gh o gh o
conditions can be enabled or disabled separately. For a complete discussion on the use of interrupts, see
gho
ng o n
the section on Communications and Interrupt instructions.
d d o n o n
Tu
Notice Tu Tud
A fatal error can occur if you attempt either to load a new current value or to disable and then re-enable
the high-speed counter from within the external reset interrupt routine.

4 .c om 4 . c om 4 . c om 4.
o a2 Status Byte
hothea 2 a 2
hobits that indicate the current counting hoa 2
ngh
A status byte for each high-speed counter provides status memory
o n
direction and g
whether
o tog
current value is greater or equaln the preset value. Table 6-29 defines these ng
o
Tudbits for each high-speed counter. Tud
status
Tud
Tip
Status bits are valid only while the high-speed counter interrupt routine is being executed. The purpose

.com .co m
consequence to the operation being performed.
.co m
of monitoring the state of the high-speed counter is to enable interrupts for the events that are of
.
a 2 4 a 2 4 a 2 4 a 24
o hBitsofor HSC0, HSC1, HSC2, HSC3, HSC4, and ho o
ngh n
Table 6-29
HSC0 do
g
Status
n gHSC5
do Description d on g h
T u HSC1 HSC2 HSC3 HSC4
T u
HSC5
SM36.0 SM46.0 SM56.0 SM136.0 SM146.0 SM156.0 Not used
T u
SM36.1 SM46.1 SM56.1 SM136.1 SM146.1 SM156.1 Not used

.c o m SM36.2 SM46.2 SM56.2

. c o m
SM136.2 SM146.2 SM156.2 Not used

. c o m .
2 4 SM36.3 SM46.3 SM56.3
24
SM136.3 SM146.3 SM156.3 Not used
24 24
ng hoa SM36.4 SM46.4
g hoa
SM56.4 SM136.4 SM146.4 SM156.4 Not used
hoa
n0 =gCounting down gh oa
SM36.5
d on SM46.5 SM56.5
o
SM136.5 SM146.5 SM156.5 Current counting direction status bit:
d o n
T u Tu 1 = Counting up Tud
SM36.6 SM46.6 SM56.6 SM136.6 SM146.6 SM156.6 Current value equals preset value status bit:
0 = Not equal

4 .c om .com
1 = Equal
. com 4.
2 SM36.7 SM46.7
24SM136.7
SM56.7
a2 4
SM146.7 SM156.7 Current value greater than preset value status bit:
2
ng hoa gh oa 0 = Lesso
1 =g
h than or equal ng ho a
don do n o
Greater than

Tu Tu Tu d

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 119
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
oSample .c m
ofor . c om
a 2 4 Initialization 2 4
Sequences
a the High-Speed Counters
a 2 4 a 2 4.
o ghocounter o ho
ngh HSC1 is used as the model
sequences. Theo n in the following descriptions of theh
d the first scan memory bit is true. IfTthisuisdnot
initialization n g initialization and operation
o the case, remember that the HDEF udo
descriptions assume that the S7-200 has just been placed in RUN mode, n g
T u
instruction can be executed only one time for each high-speed counter after entering RUN mode. T
and for that reason,

Executing HDEF for a high-speed counter a second time generates a run-time error and does not change
the counter setup from the way it was set up on the first execution of HDEF for that counter.

. co m Tip .c o m . c o m
a 2 4 a 2 4show how to change direction, current value,
a 2 4and preset value a2 4.
o o all or any combination of them in the g
Although the following sequences
hosequence by setting the value ngho
ngh o n g hand
individually, you can change
o n same
o
Tud Tud Tud
of SMB47 appropriately then executing the HSC instruction.

Initialization Modes 0, 1, or 2
The following steps describe how to initialize HSC1 for Single Phase Up/Down Counter with Internal

.co m Direction (Modes 0, 1, or 2).


.co m .co m .
6 2 4 1.
2 4 2 4
Use the first scan memory bit to call a subroutine in which the initialization operation is performed.
24
g hoa gh o a
gh o a
Since you use a subroutine call, subsequent scans do not make the call to the subroutine, which
g h o a
n d o n d o n
reduces scan time execution and provides a more structured program.
d on
2.
T u
In the
T u
initialization subroutine, load SMB47 according
T u
to the desired control operation. For example:
SMB47 = 16#F8 Produces the following results:
Enables the counter
Writes a new current value

4 .c om 4 .co m
Writes a new preset value
4 .co m
4.
a2 2 2 2
Sets the direction to count up
o oa ho a
Sets the start and reset inputs to be active high
hoa
ngh 3. Execute then g hinstruction with the HSC input set to 1 and
do0 for no external reset or start, 1 for external
HDEF n g
o and no start, or 2 for both external reset
dreset the MODE input set to one of the
do ng
T u
following:
and start. T u T u
4. Load SMD48 (double-word-sized value) with the desired current value (load with 0 to clear it).

4 . c om 6. 5.

4
m
Load SMD52 (double-word-sized value) with the desired preset value.
.co 4 .co m .
2 2 2
In order to capture the current value equal to preset event, program an interrupt by attaching the
24
ng hoa n g ho a
n g ho
Interrupt Instructions for complete details on interrupt processing.
a
CV = PV interrupt event (event 13) to an interrupt routine. See the section that discusses the
ng h o a
d o d o d o
7.
Tu event (event 15) to an interrupt routine.Tu
In order
interrupt
to capture an external reset event, program an interrupt by attaching the external
Tu
reset

8. Execute the global interrupt enable instruction (ENI) to enable interrupts.

.c o m 9.
. c m
Execute the HSC instruction to cause the S7-200 to program HSC1.
o . c o m .
a24 10. Exit the subroutine.
a 24 24 24
ngh
o
n gh o g hoa gh oa
o on o n
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
120
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2 o a 2
Initialization Modes 3, 4, or 5
o a2 o a 24
ngh gh gh h
The following steps describe how to initialize HSC1 for Single Phase Up/Down Counter with External
on
Direction (Modes 3, 4, or 5):
on o ng
ud
T1. Use ud Tu d
T in which the initialization operation is performed.
the first scan memory bit to call a subroutine
Since you use a subroutine call, subsequent scans do not make the call to the subroutine, which
reduces scan time execution and provides a more structured program.

. co m 2.
.c m the following results: . c o m
In the initialization subroutine, load SMB47 according to the desired control operation. For example:
o
24 24 Enables the counter
SMB47 = 16#F8 Produces
24 2 4.
ng hoa n gh o a Writes a new current value gh o a
ng ho a
u d o d
Writes a new preset value
u oof nthe HSC to count up d o
T Sets the initial T
direction
Sets the start and reset inputs to be active high
Tu
3. Execute the HDEF instruction with the HSC input set to 1 and the MODE input set to one of the
following: 3 for no external reset or start, 4 for external reset and no start, or 5 for both external reset
.co m . c om . c om 4.
and start.

a 2 4 a 2 4 a 2 4 6a 2
o ho(double-word-sized value) with the desired
4. Load SMD48 (double-word-sized
o value.
value) with the desired current value (load with 0 to clear it).
ho
ngh 5. Load n g
o to capture the current-value-equal-to-preset n g hpreset n g
udo event, program an interrupt by attaching udtheo
SMD52
dorder
T6. uInCV T T
= PV interrupt event (event 13) to an interrupt routine. See the section that discusses the
Interrupt Instructions for complete details on interrupt processing.
7. In order to capture direction changes, program an interrupt by attaching the direction changed

4 .c om . c om
interrupt event (event 14) to an interrupt routine.
4 4 . c om 4.
o a 2 a 2 a 2 a 2
ho(event 15) to an interrupt routine. ngho ho
8. In order to capture an external reset event, program an interrupt by attaching the external reset

ngh n g
interrupt event
do the global interrupt enable instruction o o ng
T9. uExecute Tud(ENI) to enable interrupts.
10. Execute the HSC instruction to cause the S7-200 to program HSC1.
Tud
11. Exit the subroutine.

.co m .c om . c om
a 2 4 Initialization Modes 6, 7, or 8
a 2 4
The following steps describe
a 2
how to initialize HSC1 for Two Phase Up/Down 4 Counter with Up/Down
a 2 4.
o 7,o ho ho
ngh
Clocks (Modes 6,h
n g or 8):
n g n g
dothe first scan memory bit to call a subroutine
T1. uUse doin whichscans
Tusubsequent
performed. Since you use a subroutine call,
the initialization operations are udo
T
do not make the call to the
subroutine, which reduces scan time execution and provides a more structured program.
2. In the initialization subroutine, load SMB47 according to the desired control operation. For example:

.c o m . c
SMB47 = 16#F8 o m the following results:
Produces
. c o m .
o a24 o a 24 Enables the counter
o a 24 oa 24
ngh gh Writes a new preset valuengh gh
Writes a new current value

o n doofinputs o n
Tud Tureset Tud
Sets the initial direction the HSC to count up
Sets the start and to be active high
3. Execute the HDEF instruction with the HSC input set to 1 and the MODE set to one of the following:
6 for no external reset or start, 7 for external reset and no start, or 8 for both external reset and start.

.co m 4.
c om com
Load SMD48 (double-word-sized value) with the desired current value (load with 0 to clear it).
. .
a2 4 a 2 4
5. Load SMD52 (double-word-sized a
value) with the desired preset 2 4
value. a2 4.
o o hoprogram an interrupt by attaching the ngho
ng h n
6. In order
CVo
to h
g capture the current-value-equal-to-presetn g
event,
oroutine. See the section on interrupts. udo
Tud Tud
= PV interrupt event (event 13) to an interrupt
T

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 121
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 7. 4 .co m
4. c om .
oa2 o 2
interrupt event (event 14) to an interrupt routine.
o a2
In order to capture direction changes, program an interrupt by attaching the direction changed
a o a 24
ngh 8.
on gh on gh
In order to capture an external reset event, program an interrupt by attaching the external reset
on g h
T ud
interrupt event (event 15) to an interrupt routine.
T ud T u d
9. Execute the global interrupt enable instruction (ENI) to enable interrupts.
10. Execute the HSC instruction to cause the S7-200 to program HSC1.

. co m 11. Exit the subroutine.


.c o m . c o m
24 24 a24 2 4.
ng hoa hoa
Initialization Modes 9, 10, or 11
g gho ng ho a
or 11):
Tu don Tu do n
The following steps describe how to initialize HSC1 for A/B Phase Quadrature Counter (for modes 9, 10,

Tu d o
1. Use the first scan memory bit to call a subroutine in which the initialization operations are
performed. Since you use a subroutine call, subsequent scans do not make the call to the
subroutine, which reduces scan time execution and provides a more structured program.

.co m 2. .c om . c om
In the initialization subroutine, load SMB47 according to the desired control operation. .
6 2 4 2 4 a2 4 24
g hoa h o
Example (1x counting amode): h o h o a
n d o ng
SMB47 = 16#FC Produces the following results:
d o ng d on g
Tu u u
Enables the counter
T
Writes a new current value
Writes a new preset value
T
Sets the initial direction of the HSC to count up
Sets the start and reset inputs to be active high

4 .c om Example (4x counting mode):


4 .co m
4 .co m
4.
o a2 SMB47 = 16#F8
oa 2
Produces the following results:
o a 2
hoa 2
ngh gh gh
Enables the counter
o n Writes a new current value
o n o ng
Tu d Writes a new preset value
Tu d
Sets the initial direction of the HSC to count up Tud
Sets the start and reset inputs to be active high
3. Execute the HDEF instruction with the HSC input set to 1 and the MODE input set to one of the

.co m . c om .c om
following: 9 for no external reset or start, 10 for external reset and no start, or 11 for both external

a 2 4 reset and start.


a 2 4 a 2 4 a 2 4.
o ho o ho
ngh hvalue.
4. Load SMD48 (double-word-sized value) with the desired current value (load with 0 to clear it).
n g n g n g
udo o
Tudevent, program an interrupt by attaching T udo
5. Load SMD52 (double-word-sized value) with the desired preset
6. InTorder to capture the current-value-equal-to-preset the
CV = PV interrupt event (event 13) to an interrupt routine. See the section on enabling interrupts
(ENI) for complete details on interrupt processing.

.c o m 7.
. c m . c o m
In order to capture direction changes, program an interrupt by attaching the direction changed
o .
a24 24 24 24
interrupt event (event 14) to an interrupt routine.

ngh
o 8.
hoa hoa
In order to capture an external reset event, program an interrupt by attaching the external reset
g g gh oa
on
interrupt event (event 15) to an interrupt routine.
d d on o n
9.
T u T u
Execute the global interrupt enable instruction (ENI) to enable interrupts.
Tud
10. Execute the HSC instruction to cause the S7-200 to program HSC1.
11. Exit the subroutine.

4 .c om 4 .co m
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
122
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2 o a 2
Change Direction in Modes 0, 1, or 2
o a2 o a 24
ngh gh gh h
The following steps describe how to configure HSC1 for Change Direction for Single Phase Counter with
on
Internal Direction (Modes 0, 1, or 2):
on on g
T1. ud T
Load SMB47 to write the desired direction: ud T u d
SMB47 = 16#90 Enables the counter
Sets the direction of the HSC to count down

. co m SMB47 = 16#98
.c o m
Enables the counter
. c o m
a24 a 2 4 Sets the direction of the HSC to count
a
up
2 4 a2 4.
o o instruction to cause the S7-200 to program hoHSC1. ho
ngh g hHSC g g
2. Execute the
n n n
T udoa New Current Value (Any Mode)
Loading
T udo T udo
Changing the current value forces the counter to be disabled while the change is made. While the counter
is disabled, it does not count or generate interrupts.

4 .c om 4
m
4
m
The following steps describe how to change the counter current value of HSC1 (any mode):
.co .co 4.
2 1.
2
Load SMB47 to write the desired current value:
2 6 2
ng hoa gh
SMB47 = 16#C0
n
o a Enables the counter
n gh o a
gho
a
u d o d o
Writes the new current value
u u d on
T2. Load SMD48 (double-word-sized value) with
T the desired current value (load with 0 to clear
T it).
3. Execute the HSC instruction to cause the S7-200 to program HSC1.

4 .c om 4 .co
Loading a New Preset Value (Any Mode) m
4 .co m
4.
a2 2 2 2
The following steps describe how to change the preset value of HSC1 (any mode):
o oa o a hoa
ngh 1.
o n gh
Load SMB47 to write the desired preset value:
d = 16#A0 o n gh o ng
TuSMB47 ud
Enables the counter
Writes the new T
preset value Tud
2. Load SMD52 (double-word-sized value) with the desired preset value.

om om om
3. Execute the HSC instruction to cause the S7-200 to program HSC1.

2 4 . c 4 .c 4 .c 24.
hoa
Disabling a High-Speed
h o a2 Counter (Any Mode) h o a2 h o a
ng d
1. uLoad
g
The following steps
onSMB47 d o ng
describe how to disable the HSC1 high-speed counter (any mode):
d on g
T SMB47 = 16#00 to disable the counter:
Tu
Disables the counter
T u
2. Execute the HSC instruction to disable the counter.

.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 123
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
Example: High-Speed Counter Instruction 4.
c om 4. c om .
o a2 M o a2 Network 1 //On the first scan, callhSBR_0.
o a2 o a 24
ng h ng h ng g h
A
d o LD SM0.1
d o d on
I
N Tu CALL SBR_0
Tu T u
S Network 1 //On the first scan, configure HSC1:

. co
B m .c o m //1. Enable the counter.
. c o m
24
R
2 4 a24
// – Write a new current value.
2 4.
hoa hoa ho ho a
0 // – Write a new preset value.

ng don
g
do n g
// – Set the initial direction to count up.
// – Select the start and reset inputs to be active high.
d ong
Tu Tu
// – Select 4x mode.
//2. Configure HSC1 for quadrature mode Tu
// with reset and start inputs.
//3. Clear the current value of HSC1.
//4. Set the HSC1 preset value to 50.

.co m .co m .co


//5. When HSC1 current value = preset value,m .
6 2 4 2 4 2 4
// attach event 13 to interrupt routine INT_0.
24
g hoa gh o a o
//6. Global interrupt enable.
gh
//7. Program HSC1.
a
g h o a
n d o n d o n d on
Tu Tu u
LD SM0.1
MOVB
HDEF
16#F8, SMB47
1, 11
T
MOVD +0, SMD48
MOVD +50, SMD52

om m m
ATCH INT_0, 13

4 .c 4 .co ENI
4 .co 4.
o a2 oa 2 HSC 1
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
I
Tud Network 1
Tu d
//Program HSC1:
T u d
N //1. Clear the current value of HSC1.
T //2. Select to write only a new current

.c o m
0
. c o mSM0.0 // and leave HSC1 enabled.
. c o m .
a24 24 MOVD +0, SMD48 24 24
LD

ngh
o g hoa MOVB 16#C0, SMB47
g hoa gh oa
Tu don HSC 1

T u d on
Tud
o n

.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
124
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .c om 4. c om .
o a2 Pulse Output
a2
Instruction
o o a2 o a 24
ng h h
g instruction (PLS) is used to control theoPulse
nand h
ng Train g h
d o
The Pulse Output
d d on
Tu on the high-speed outputs (Q0.0 and T
Output (PTO)
available
Position
Pulse Width Modulation (PWM) ufunctions
Q0.1).You can use T u
Control the Position Control wizard to configure the pulse outputs.
PTO provides a square wave (50% duty cycle) output with user

.com o m o m
control of the cycle time and the number of pulses.

24 . c
24thevariable 24. c 2 4.
h o a o a
PWM provides a continuous, duty cycle output with user
o a ho a
ng o n gh
control of the cycle time and pulse width.
o n gh ong
Tud pulse train or a pulse width modulated d aOne
Tuwaveform. Tu d
The S7-200 has two PTO/PWM generators that create either
high-speed
generator is assigned to digital output point Q0.0, and the other
generator is assigned to digital output point Q0.1. A designated
special memory (SM) location stores the following data for each

.co m .co m
generator: a control byte (8-bit value), a pulse count value (an
.co m
a 2 4 a 2 4
unsigned 32-bit value), and a cycle time and pulse width value (an
a 2 4 6a 2 4.
o o
unsigned 16-bit value).
o gho
ngh d n g h
o generators and the process-imageuregister
The PTO/PWM
d n g h
o generator
share the use of Q0.0 and Q0.1. When a PTO
d on
T u
or PWM
T
function is active on Q0.0 or Q0.1, the PTO/PWM
T u
has control of the output, and normal
use of the output point is inhibited. The output waveform is not affected by the state of the process-image
register, the forced value of the point, or the execution of immediate output instructions. When the
PTO/PWM generator is inactive, control of the output reverts to the process-image register. The

4 .c om m
to start and end at a high or low level.
4 4
m
process-image register determines the initial and final state of the output waveform, causing the waveform
.co .co 4.
o a2 oa 2
ho a 2
hoa 2
ngh Table 6-30 Valid h
n g Operands for Pulse Output Instruction
n g ng
T udo
Inputs/Outputs Data Types Operands
T udo Tud
o
Q0.X WORD Constant: 0 (= Q0.0) or 1 (= Q0.1)

Tip
.com .co m .co m
Before enabling PTO or PWM operation, set the value of the process-image register for Q0.0 and Q0.1
.
o a24 to 0.
ho a 2 4
ho a 2 4
o a 24
ngh d o g
d o n g
Default values for all control bits, cycle time, pulse width, and pulse count values are 0.
n d o ng h
Tu from off to on, and from on to off.Tu Tu
The PTO/PWM outputs must have a minimum load of at least 10% of rated load to provide crisp
transitions

Refer to the Tips and Tricks on the documentation CD for programs that use the PLS instruction for

.c o m
Tips and Tricks
. c m
PTO/PWM operation. See Tip 7, Tip 22, Tip 23, Tip 30, and Tip 50.
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 125
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
oPulse .c om . c om
a 2 4 Train Operation 2
(PTO)
a 4 a 2 4 a 2 4.
o o (50% duty cycle) output for a specifiedgnumber
ho of pulses and a specified ho
ngh PTO provides a square h
cycle time. (Seeo n g 6-28.)
wave
n
PTO can produce either a singleotrain
dprofile). You specify the number of pulses of pulses or multiple trains of pulses ong
Tuanddthe cycle time (in either microsecond orTud
Figure
Tuincrements):
(using a pulse
millisecond
- Number of pulses: 1 to 4,294,967,295 Cycle Time

. co m- Cycle time:
.c m
50 µs to 65,535 µs or
o . c o m
24 24
2 ms to 65,535 ms. 50%
a24
50% 50% 50%
2 4.
hoa hoa ho ho a
Off On Off On
Specifying an odd number of microseconds or milliseconds
ng don
g
for the cycle time (such as 75 ms), causes some distortion in
do n g
d ong
Tu
the duty cycle.

See Table 6-31 for pulse count and cycle time limitations.
Tu Figure 6-28 Pulse Train Output (PTO)
Tu
Table 6-31 Pulse Count and Cycle Time in the PTO function

4 .c om Pulse Count/Cycle TIme 4 .c om


Reaction
4 . c om 4.
o6a 2 a 2 a 2 a 2
ngh
Cycle time < 2 time units

n g ho Cycle time defaults to 2 time units.


Pulse count defaults to 1 pulse.ng
ho n g ho
do do do
Pulse count = 0

T u T u
The PTO function allows the “chaining” or “pipelining” of pulse trains. When the active pulse train is T u
complete, the output of a new pulse train begins immediately. This allows continuity between subsequent
output pulse trains.

4 .c omSingle-Segment Pipelining of4PTO . c m


oPulses 4 . c om 4.
o a 2 In single-segment pipelining,a 2 a 2 a 2
ngh n g ho has been started, you must modifynimmediately
After the initial PTO segment
you
g ho the SM locations as required ngho
are responsible for updating the SM locations for the next pulse train.

are heldT inu


do and execute the PLS instruction
for the second waveform
T
a pipeline until the first pulse train is completed.
dOnlyo one
uagain. The attributes of the second pulse train
entry at a time can be stored inT udo
the
pipeline. When the first pulse train completes, the output of the second waveform begins, and the pipeline
is made available for a new pulse train specification. You can then repeat this process to set up the
characteristics of the next pulse train.

.co mSmooth transitions between pulse trains


. c m unless there is a change in the time.base
ooccur c oormthe active
a 2 4 a 2
pulse train completes before a new4 pulse train setup is captured by the
a 2 4
execution of the PLS instruction.
a 2 4.
o ho of PTO Pulses ho ho
ngh n g n g n g
T udo pipelining, the S7-200 automatically
Multiple-Segment
In multiple-segment
Pipelining
T dothe characteristics of each pulse trainTudo
ureads
segment from a profile table located in V memory. The SM locations used in this mode are the control
byte, the status byte, and the starting V memory offset of the profile table (SMW168 or SMW178). The
time base can be either microseconds or milliseconds, but the selection applies to all cycle time values in

.c o m . c o m . c o m
the profile table, and cannot be changed while the profile is running. Execution on the PLS instruction
.
a24 24 24 24
starts multiple segment operation.
o o ain length, and is composed of a 16-bit cycle
o a oa
ngh
Each segment entry is 8hbytes
delta value, and a n
o 32-bit gh of the profile table. You can ongh
g pulse count value. Table 6-32 shows othenformat time value, a 16-bit cycle time

d the cycle time automatically by programming


increase orudecrease d a specified amount for each pulse.TAud
Tutime,
positiveTvalue in the cycle time delta field increases cycle a negative value in the cycle time delta
field decreases cycle time, and 0 results in an unchanging cycle time.

While the PTO profile is operating, the number of the currently active segment is available in SMB166 (or

4 .c omSMB176). 4 .co m
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
126
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2
Table 6-32
2
Profile Table Format for Multiple-Segment PTO Operation
o a a2 a 24
ngh
Byte Offset
gh Segment Description of Table Entries
g ho g h o
0 on o n on
T ud1 #1
Number of segments: 1 to
Tudunits of the time base)
2551
Initial cycle time (2 to 65,535 T u d
3 Cycle time delta per pulse (signed value) (–32,768 to 32,767 units of the time base)
5 Pulse count (1 to 4,294,967,295)

4 .com 9 #2
.c o m .
Initial cycle time (2 to 65,535 units of the time base)
4 time delta per pulse (signed value) (–32,768 to4
c o m
4.
h o a2 11
a 2 Cycle
ho Pulse count (1 to 4,294,967,295) ngho a 2 32,767 units of the time base)
ho a2
n g 13
n g n g
T udo #3 (Continues)
(Continues)
T udo T udo
1 Entering a value of 0 for the number of segments generates a non-fatal error. No PTO output is generated.

.co m Pulse Width Modulation.(PWM) c om . c om


a 2 4 a 2 4 a 2 4 6a 2 4.
o o You can specify the cycle time andgho ho
ngh h6-29.)
PWM provides a fixed cycle time output with a variable duty Cycle Time

n g
cycle. (See Figure
owidth in either microsecond or millisecondudo n n g
Tud
the pulse
increments: T Pulse Width
T u
Pulse Width do
Time Time
- Cycle time: 50 µ
µs to 65,535 µ
µs or
2 ms to 65,535 ms Figure 6-29 Pulse Width Modulation (PWM)

4 .c om - Pulse width time:


4 .com
0 µs to 65,535 µs or
4 . c om 4.
o a 2 a 2 0 ms to 65,535 ms
o setting the pulse width equal to the cycle a 2
otime (which makes the duty cycle gho a 2
ngh g h6-33, g hwidth
As shown in Table

d n
oturns the output off.
100 percent) turns the output on continuously. Setting
d o
the n
pulse on
to 0 (which makes the duty cycle
d
T u
0 percent)
T u T u
Table 6-33 Pulse Width Time and Cycle Time and Reactions in the PWM Function

Pulse Width Time/ Cycle Time Reaction

4 .com .c
Pulse width time >= Cycle time value
4 om .
The duty cycle is 100%: the output is turned on
4 c om
continuously.
4.
h o a2 Pulse width time = 0
o
hunitsa 2 a 2
htimeounits.
The duty cycle is 0%: the output is turned off.
ho a 2
n g Cycle time <n
o g
2 time The cycle time defaults n
o g
to two
o n g
Tud Tud Tud
There are two different ways to change the characteristics of a PWM waveform:

- Synchronous Update: If no time base changes are required, you can use a synchronous update.

.c o m . c o m . c o m
With a synchronous update, the change in the waveform characteristics occurs on a cycle
.
a24 24 24 24
boundary, providing a smooth transition.

ngh
o -
hoa hoa
Asynchronous Update: Typically with PWM operation, the pulse width is varied while the cycle time
g g gh oa
d on on
remains constant so time base changes are not required. However, if a change in the time base of
d o n
T u u
the PTO/PWM generator is required, an asynchronous update is used. An asynchronous update
T
causes the PTO/PWM generator to be disabled momentarily, asynchronous to the PWM waveform. Tud
This can cause undesirable jitter in the controlled device. For that reason, synchronous PWM
updates are recommended. Choose a time base that you expect to work for all of your anticipated
cycle time values.

.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 127
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 Tip 4 .co m
4. c om .
o a2 a 2 a2 a 24
ngh g ho g ho
The PWM Update Method bit (SM67.4 or SM77.4) in the control byte specifies the update type used
n n ng h o
o
when the PLS instruction is executed to invoke changes.
d d o d o
Tubase is changed, an asynchronous updateToccurs
If the time
Method bit.
u regardless of the state of the PWM Update
Tu

. co m
Using SM Locations to Configurem
.c o and Control the PTO/PWM Operation
. c o m the
a 2 4 The PLS instruction reads the
a
data
2 4SMB67 controls PTO 0 or PWM 0, and SMB77
stored in the specified SM memory locations
a 2 4controls PTO 1 or
and programs
a2 4.
o ghoto determine
PTO/PWM generator accordingly.
hooperation. You can use Table ngho
ngh n
PWM 1. Table 6-34 describes
6-35 as a quick o n g
the registers used to control the PTO/PWM
o o
desiredT ud reference
operation. T u d
the value to place in the PTO/PWM
Tud
control register to invoke the

You can change the characteristics of a PTO or PWM waveform by modifying the locations in the SM area
(including the control byte) and then executing the PLS instruction. You can disable the generation of a

.co m .c om
SM77.7) and then executing the PLS instruction.
. c om
PTO or PWM waveform at any time by writing 0 to the PTO/PWM enable bit of the control byte (SM67.7 or
.
6 2 4 2 4 2 4 2 4
g hoa The PTO Idle bit in the status
g
a
hInoaddition,
byte (SM66.7 or SM76.7) is provided to indicate
g
a
houpon the
the completion of the
g ho a
n n
programmed pulse train.
n
an interrupt routine can be invoked
o descriptions of the Interrupt instructionsuand completion of a pulse
dothe Communications instructions.) If T you do
n
are usingT udmultiple
train. (Refer to
the
the
segment operation, the interruptT routine is invoked upon completion of the profileu
table.

The following conditions set SM66.4 (or SM76.4) and SM66.5 (or SM76.5):

4 .c om - .co m .co m
Specifying a cycle time delta value that results in an illegal cycle time after a number of pulses
4 4 4.
o a2 oa 2
ho a 2
generates a mathematical overflow condition that terminates the PTO function and sets the Delta
hoa 2
ngh h
Calculation Error bit (SM66.4 or SM76.4) to 1. The output reverts to image register control.
Manually o n g o n g
sets the User Abort bit (SM66.5 or SM76.5) o ng
-
toT1.u
d aborting (disabling) a PTO profile in progress
Tud Tud
- Attempting to load the pipeline while it is full sets the PTO overflow bit (SM66.6 or SM76.6) to 1. You
must clear this bit manually after an overflow is detected if you want to detect subsequent overflows.
The transition to RUN mode initializes this bit to 0.
.co m .co m .co m .
a 2 4 Tip
a 2 4 a 2 4 a 24
o o o o
ngh gh gh h
When you load a new pulse count (SMD72 or SMD82), pulse width (SMW70 or SMW80), or cycle time
o n o n
(SMW68 or SMW78), also set the appropriate update bits in the control register before you execute the
on g
Tud Tu d
PLS instruction. For a multiple segment pulse train operation, you must also load the starting offset
(SMW168 or SMW178) of the profile table and the profile table values before you execute the PLS T u d
instruction.

.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
128
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2
Table 6-34
2
SM Locations of the PTO / PWM Control Registers
a
Q0.1 ho Status Bits
a2 a 24
ngh
Q0.0
n g n g ho g h o
SM66.4 o SM76.4 PTO profile aborted (delta calculationo on
Tud SM76.5 PTO profile aborted due to user d error): 00 == nono error d
1 = aborted
SM66.5 Tucommand: abort T
1 = aborted
u
SM66.6 SM76.6 PTO pipeline overflow/underflow: 0 = no overflow 1 = overflow/underflow
SM66.7 SM76.7 PTO idle: 0 = in progress 1 = PTO idle

. co m .c o m . c o m
4.
Q0.0 Q0.1 Control Bits

o a24 SM67.0 SM77.0


a 2 4 update the cycle time:
PTO/PWM
a 2
0 = no 4
update 1 = update cycle time
a2
ngh SM67.1
n g ho PWM update the pulse width time: ngho0 = no update 1 = update pulse widthngho
SM77.1

u doSM77.2 PTO update the pulse countTvalue:


SM67.2
T u do 0 = no update 1 = update pulsed
T u o
count
SM67.3 SM77.3 PTO/PWM time base: 0 = 1 µs/tick 1 = 1 ms/tick
SM67.4 SM77.4 PWM update method: 0 = asynchronous 1 = synchronous

om
SM67.5 SM77.5 PTO single/multiple segment operation:
om
0 = single
om1 = PWM
1 = multiple

2 4 .c SM67.6 SM77.6
4 .c
PTO/PWM mode select:
2
0 = PTO
2 4 . c 6 2 4.
ng hoa SM67.7 SM77.7

nQ0.1g hoaPTO/PWM enable: g hoa 0 = disable 1 = enable


gho
a
Q0.0
d o Other PTO/PWM Registers
PTO/PWM cycle time value ud
on o n
Tu SMW78
SMW68
SMW70 SMW80 PWM pulse width value
T range: 2 to 65,535
range: 0 to 65,535
Tud
SMD72 SMD82 PTO pulse count value range: 1 to 4,294,967,295

4 .c om SMB166 SMB176

4 . c om
Number of the segment in progress

4 .co m
Multiple-segment PTO operation only

4.
2 SMW168 SMW178
2
Starting location of the profile table
2
Multiple-segment PTO operation only
2
hoa oa ho a hoa
(byte offset from V0 )

ng ng h n g ng
udo PTO/PWM Control Byte Reference Tudo
Table 6-35
T Tud
o
Control Result of Executing the PLS Instruction
Register PTO PWM
(Hex Select Pulse Pulse Cycle
Enable Segment Update Time Base

.co m Value) Mode


.co
Operationm Method
.co
Count
mWidth Time
.
a 2 4 16#81 Yes
a 2 4
PTOSingle
a 2
1 µs/cycle4 Load
a 24
o Yesho PTO o o
ngh g PTO g h1 µs/cycle g h
16#84 Single Load
n
16#85 o Yes
d n
do 1 µs/cycle d on
u Yes PTO
T16#89
Single
Single Tu 1 ms/cycle
Load
u Load
T Load
16#8C Yes PTO Single 1 ms/cycle Load
16#8D Yes PTO Single 1 ms/cycle Load Load

.c o m 16#A0 Yes PTO


. c o m
Multiple 1 µs/cycle
.com .
o a24 16#A8 Yes
aPTO24Multiple
oPWM o a 24
1 ms/cycle
oa 24
ngh 16#D1
o n gh
Yes Synchronous
o
h1 µs/cycle
ng 1 µs/cycle o
Load
n gh
ud Yes
T16#D2 PWM
Tu d
Synchronous Load
Tud
16#D3 Yes PWM Synchronous 1 µs/cycle Load Load
16#D9 Yes PWM Synchronous 1 ms/cycle Load

.co m 16#DA Yes PWM

.co m Synchronous 1 ms/cycle

. comLoad
Load

a2 4 16#DB Yes
a 2 4 PWM Synchronous
4
1 ms/cycle
a2
Load
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 129
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
oCalculating .c om . c om .
a2 4 Profile Table 4
a2capability of the PTO/PWM
Values
a2 4 a 24
h o h o h o h o
ng g in many applications, particularly in ong
The multiple-segment pipelining
g
Frequency

ben
generators can o on
d
Tu control.
stepper motor
useful
Tud
10 kHz

T u d
For example, you can use PTO with a pulse profile to control 2 kHz

a stepper motor through a simple ramp up, run, and ramp


Time
down sequence or more complicated sequences by defining

24 .com 24 .com
a pulse profile that consists of up to 255 segments, with 1
. 2 om 3
c 4.
a24 2
each segment corresponding to a ramp up, run, or ramp

h o a down operation.
h o a ho 4,000 pulses
ho a
ng don
g
do n g
Figure 6-30 illustrates sample profile table values required to 1 Segment #1 2 Segment #2 3 Segment #3
d ong
Tu
generate an output waveform that accelerates a stepper
Tu
motor (segment 1), operates the motor at a constant speed
200 pulses 3400 pulses 400 pulses
Tu
(segment 2), and then decelerates the motor (segment 3). Figure 6-30 Frequency/Time Diagram

For this example: The starting and final pulse frequency is 2 kHz, the maximum pulse frequency is 10 kHz,

4 .c omand 4000 pulses are required to achieveo


4 . c mdesired number of motor revolutions. Since
the
4 . c mvalues for the
othe 4 .
o6a 2 profile table are expressed in
a 2
terms of period (cycle time) instead of frequency,
frequency values into cycleotime values. Therefore, the starting (initial) and a 2
o final
you must convert the given
a 2
ngh 500 µs, and the cycleg
n h corresponding to the maximum frequency
time
n g h100
is
(ending) cycle time is
µs. During the acceleration
n g ho
portion of thed o profile, the maximum pulse frequencyudshould o be reached in approximately 200 o
udeceleration Tcompleted in approximately 400 pulses. Tud
output
pulses. TThe portion of the profile should be

You can use the following formula to determine the delta cycle time value for a given segment that the
PTO/PWM generator uses to adjust the cycle time of each pulse:

4 .c omDelta cycle time for a segment = | 4End_CT


. c om– Init_CT | / Quantity
seg seg
4 .
seg c om 4.
h o a2 where: End_CT =o
h a2 cycle time for this segment
Ending
seg
h o a2 hoa 2
ng Init_CTg = Initial cycle time for this segment
d o n = Quantity of pulses in this segmentdong
seg
o ng
Tu Tu Tud
Quantity seg

Using this formula to calculate the delta cycle Table 6-36 Profile Table Values
time values for the sample application:
Address Value Description

om om m
Segment 1 (acceleration): VB500 3 Total number of segments

2 4 . c Delta cycle time = –2


2 4 .c VW501 500
4 .co
Initial cycle time
2 24.
ng hoa hoa
Segment 2 (constant speed):
ng
VW503
h
–2 Initial
g
a cycle time
odelta Segment 1
g h o a
Delta cycle time =
d o 0
VD505
d o200n Number of pulses d on
T3u(deceleration):
Segment
Delta cycle time = 1
VW509u
T 100 Initial cycle time T u
VW511 0 Delta cycle time Segment 2
Table 6-36 lists the values for generating the VD513 3400 Number of pulses

.c o m .com
example waveform (assumes that the profile
VW517 100
c o m
Initial cycle time
.
a24
table is located in V memory, starting at V500).
a2 4
You can include instructions in your program to VW519
a 2
1 Delta cycle 4
time Segment 3
a 2 4.
o o ho of pulses ho
ngh h
load these values into V memory, or you can
o n g
define the values of the profile in the data block.
VD521
n g
400 Number
o 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 oa2 a2 a 24
ngh
130
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2 o 2 o a2
In order to determine if the transitions between waveform segments are acceptable, you need to
a
determine the cycle time of the last pulse in a segment. Unless the delta cycle time is 0, you must
o a 24
ngh n gh n gh on
calculate the cycle time of the last pulse of a segment, because this value is not specified in the profile.
o o g h
T ud T ud
Use the following formula to calculate the cycle time of the last pulse:

Cycle time of the last pulse for a segment = Init_CTseg + ( Deltaseg * ( Quantityseg – 1 ))
T u d
where: Init_CTseg = Initial cycle time for this segment

. co m c o m
Deltaseg = Delta cycle time for this segment
. . c o m
24 Quantity a2
4 2 4 2 4.
g h oa g hoexample above is useful as an introduction,
= Quantity of pulses in this segment
seg

g
a
hrealo applications can require more ngho a
n n
do waveform profiles. Remember thatTtheudelta
While the simplified n
docycle time can be specified only as anTinteger
do
T u
complicated u
number of microseconds or milliseconds, and the cycle time modification is performed on each pulse.

The effect of these two items is that calculation of the delta cycle time value for a given segment could
require an iterative approach. Some flexibility in the value of the ending cycle time or the number of pulses

.co m c om
for a given segment might be required.
. . c om
a 2 4 2 4
The duration of a givenaprofile segment can be useful in the process aof 2
4 6a 2 4.
o ho formula to calculate the length ofntime hforocompleting a given profile segment: ngho
determining correct profile table

ngh o n g
values. Use the following
g
do/2 ) * ( Quantity – 1 ) ) ) o
Tudof segment = Quantity * ( Init_CT + T
Duration seg ((u
Delta seg seg
Tud
where: Quantityseg = Quantity of pulses in this segment

Init_CTseg = Initial cycle time for this segment

4 .c om 4 .co m
Deltaseg = Delta cycle time for this segment
4 .co m
4.
2 2 2 2
ng hoa ngh oa
n gh o a
ng hoa
do d o o
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 131
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
oSample .c om . c om
a 2 4 Operation of a
a 2
PWM 4 Output
a 2 4 a 2 4.
o ho ho ho
ngh Tip
o n g n g
doScansequences recommends using the Firstdo
n g
T
Scan bit
uddescription
The following
T
(SM0.1) to initialize the pulse output. Using the
uFirst
of the PWM initialization and operation
Tu
bit to call an initialization subroutine
reduces the scan time because subsequent scans do not call this subroutine. (The First Scan bit is set
only on the first scan following a transition to RUN mode.) However, your application could have other
constraints that require you to initialize (or re-initialize) the pulse output. In that case, you can use

. co m o m
another condition to call the initialization routine.
.c . c o m
24 24 a24 2 4.
ng hoa n g o
Initializing the PWMhOutput
a
n g ho n g ho a
T
subroutine dothe main program. Use the first scan memory
Typically, you use
ufrom a subroutine to initialize the PWM for
T udobit (SM0.1) to initialize the output usedTbyudo
the pulse output. You call the initialization

the PWM to 0, and call a subroutine to perform the initialization operations. When you use the subroutine
call, subsequent scans do not make the call to the subroutine, which reduces the scan time execution and
provides a more structured program.

.co mAfter creating the call to the initialization


.c m from the main program, use the.following
osubroutine c om steps to
6 2 4 2 4 2 4 2 4.
oa a a a
create the control logic for configuring pulse output Q0.0 within the initialization subroutine:

n g h n g
1. Configure the controlhobyte by loading one of the following valuesn g htooSMB67: 16#D3 (to select n g ho
u do increments) or 16#DB (to select millisecond
microsecond
T T u doincrements). T u do
Both of these values enable the PTO/PWM function, select PWM operation, set the update pulse
width and cycle time values, and select the time base (microseconds or milliseconds).
2. Load a word-sized value for the cycle time in SMW68.

4 .c om 3. . c om
Load a word-sized value for the pulse width in SMW70.
4 4 . c om 4.
o a 2 o a 2 o a 2 a 2
ngh
4.
n g hcontrol
Execute the PLS instruction (so that the S7-200 programs the
n g hchanges
PTO/PWM generator).
ng ho
o o o
Tud values in SMB67: 16#D2 (microseconds) Tuord16#DA (milliseconds). Tud
5. To preload a new byte value for subsequent pulse width (optional), load one of the
following
6. Exit the subroutine.

Changing the Pulse Width for the PWM Output


. c o mIf you preloaded SMB67 with 16#D2 orc16#DA
. om (see step 5. above), you can use4a subroutine
.c om that
a 2 4 changes the pulse width for
a
the2 4
pulse output (Q0.0). After creating the call
a
to 2
this subroutine, use the
a 2 4.
o hocontrol logic for changing the pulse n width: o
ho
ngh h
following steps to create the
n g
o value for the new pulse width inuSMW70. g n g
1. Load ad
T u word-sized
T do T u do
2. Execute the PLS instruction (so that the S7-200 programs the PTO/PWM generator).
3. Exit the subroutine.

.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 oa2 a2 a 24
ngh
132
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
S7-200 Instruction Set Chapter 6

4 .c omExample: Pulse Width Modulation (PWM)


4 .c om 4 . c om 4.
o a 2 a 2 a 2 a 2
ngh M
n g ho Network 1
theg
//On the first
//set n
o
hscan, n g ho
A
I
T u do LD
T u do
SM0.1
image register bit low and call SBR_0.

T u do
N R Q0.1, 1
CALL SBR_0
Network 2 //Set M0.0 elsewhere in the program

.com .comLD o m
//to change pulse width to 50% duty cycle.

24 24 . c 4.
a24
M0.0

o a o a a2
ho ho
EU

ng h g h CALL SBR_1
g ng
Tu don do n
Tu //Start of subroutine 0: Tu d o
S Network 1
B //1. Set up the control byte.
R // – Select PWM operation.

.co m 0
.co m //
.co
– Select ms increments and m
a 2 4 a 2 4 //
//
a 2 4
synchronous updates.
– Enable the loading of the pulse width 6a 2 4.
o o o gho
ngh gh gh
// and cycle time values.

d o n d o n
// – Enable the PWM function.
o n
Tu Tu //2.
//3.
Set the cycle time to 10,000 ms.
Set pulse width to 1,000 ms. Tud
//4. Invoke PWM operation: PLS1=>Q0.1.
//5. Preload the control byte for subsequent
// pulse width changes

4 .c om 4 .co mLD SM0.0


4 .co m
4.
a2 2 2 2
MOVB 16#DB, SMB77
o oa MOVW +10000, SMW78
o a hoa
ngh do ngh MOVW
n gh
+1000, SMW80

d o o ng
Tud
PLS 1
Tu MOVB
Tu 16#DA, SMB77

.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
S
Tud Network 1
d
Tu //Start of subroutine 1: T u d
B //Set the pulse width to 5000 ms.
R //Assert pulse width change.

.c o m 1
. c o mMOVW LD SM0.0
. c o m .
a24 24 24 24
+5000, SMW80

hoa hoa a
PLS 1
o o
ngh d on g
d on g o n gh
T u T u Tud

om m om
Timing Diagram

2 4 .c Q0.1
2 4 .co 4 . c 4.
hoa a 10% duty cycle 10% duty cycle
a2
50% duty cycle 50% duty cycle
a2
ng gho gh o
ng ho
Tu don Cycle time = 10,000 ms

Tu d o n
Subroutine 1 executed here

Tu d o

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 133
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
oSample .c om . c om
a 2 4 Operation of a PTO
a 2 4 Output
a 2 4 a 2 4.
o ho ho ho
ngh Tip
o n g n g n g
T uddescription
The following
Scan memory T
bit (SM0.1) to initialize the pulse output.
udo sequences recommends using theTFirstudo
of the PTO initialization and operation
Using the First Scan bit to call an initialization
subroutine reduces the scan time because subsequent scans do not call this subroutine. (The First
Scan bit is set only on the first scan following a transition to RUN mode.) However, your application
could have other constraints that require you to initialize (or re-initialize) the pulse output. In that case,

. co m o m
you can use another condition to call the initialization routine.
.c . c o m
24 24 a24 2 4.
ng hoa Initializing the PTO h
n g
a
o for a Single-Segment Operation
Output
n g ho n g ho a
do from the main program. Use theTfirst
Typically, you use a subroutine
Tusubroutine
initialization
to configure and initialize
udscan
the o memory bit (SM0.1) to initialize the udo
PTO for the pulse output. You call the
T
output used by the PTO to 0, and call a subroutine to perform the initialization operations. When you use
the subroutine call, subsequent scans do not make the call to the subroutine, which reduces the scan time
execution and provides a more structured program.

.co mAfter creating the call to the initialization


.c m from the main program, use the.following
osubroutine c om steps to
6 2 4 2 4 2 4 2 4.
oa a a a
create the control logic for configuring pulse output Q0.0 within the initialization subroutine:

n g h n g
1. Configure the controlhobyte by loading one of the following valuesn g hinoSMB67: 16#85 (to select n g ho
u do increments) or 16#8D (to select millisecond
microsecond
T T u doincrements). T u do
Both of these values enable the PTO/PWM function, select PTO operation, set the update pulse
count and cycle time values, and select the time base (microseconds or milliseconds).
2. In SMW68, load a word-sized value for the cycle time.

4 .c om 3. . c om
In SMD72, load a double-word-sized value for the pulse count.
4 4 . c om 4.
o a 2 a 2 a 2 a 2
ngh
4.
n g hoby attaching the pulse train completenevent
(Optional) To perform
program an interrupt
a related function as soon as the pulse
g
traino event 19) to an interrupt
h(interrupt
output is complete, you can
ng ho
oUse the ATCH instruction and executeuthedglobal
o interrupt enable instruction ENI. udo
Tud
subroutine.
5. T
Execute the PLS instruction (so that the S7-200 programs the PTO/PWM generator). T
6. Exit the subroutine.

.co mChanging the PTO Cycle Time.(Single-Segment


c om Operation)
. c om
a 2 4 a 2
For a single-segment PTO operation,4 you can use an interrupt routine or a
a 2 4
subroutine to change the cycle
a 2 4.
o ho time in an interrupt routine or subroutine howhen using a single-segment ho
ngh
time. To change the PTO cycle
o n g n g n g
udtooselect PTO operation, to select the time udo
PTO operation, follow these steps:

1. SetT uthedcontrol T
byte (to enable the PTO/PWM function, T
base, and to set the update cycle time value) by loading one of the following values in SMB67:
16#81 (for microseconds) or 16#89 (for milliseconds).

.c o m 2.
. c m
In SMW68, load a word-sized value for the new cycle time.
o . c o m .
a24 24 24 24
3. Execute the PLS instruction (so that the S7-200 programs the PTO/PWM generator). The S7-200

ngh
o hoa hoa
completes any PTO that is in process before starting to generate the PTO waveform with the
g g gh oa
on on n
updated cycle time.
d d o
4.
T u
Exit the interrupt routine or the subroutine.
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 oa2 a2 a 24
ngh
134
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2 o a 2
Changing the PTO Pulse Count (Single-Segment Operation)
o a2 o a 24
ngh gh gh h
For a single-segment PTO operation, you can use an interrupt routine or a subroutine to change the pulse
on on
count. To change the PTO pulse count in an interrupt routine or a subroutine when using a single-segment
on g
ud
PTO operation, follow these steps:
T1. T ud T u d
Set the control byte (to enable the PTO/PWM function, to select PTO operation, to select the time
base, and to set the update pulse count value) by loading either of the following values in SMB67:
16#84 (for microseconds) or 16#8C (for milliseconds).

. co m .c o m . c o m
a24
2. In SMD72, load a double-word-sized value for the new pulse count.
24
3. Execute the PLSainstruction (so that the S7-200 programs the a 2 4 generator). The S7-200 a2 4.
o hanyoPTO that is in process before startingntoggenerate
ho the waveform with the updated ngho
PTO/PWM
ngh n
completes
do
g o o
Tud Tud
pulse count.
T4. uExit the interrupt routine or the subroutine.

Changing the PTO Cycle Time and the Pulse Count (Single-Segment Operation)

4 .c om 4 .co m
4 .co m
For a single-segment PTO operation, you can use an interrupt routine or a subroutine to change the cycle
time and pulse count. To change the PTO cycle time and pulse count in an interrupt routine or a
4.
2 2 2 6 2
hoa a a a
subroutine when using a single-segment PTO operation, follow these steps:
gh o gh o gho
ng 1.
o n o n o
Set the control byte (to enable the PTO/PWM function, to select PTO operation, to select the time
d d n
Tu Tu Tud
base, and to set the update cycle time and pulse count values) by loading either of the following
values in SMB67: 16#85 (for microseconds) or 16#8D (for milliseconds).
2. In SMW68, load a word-sized value for the new cycle time.

om m m
3. In SMC72, load a double-word-sized value for the new pulse count.

2 4 .c 4.
24 .co 2 4 .co
Execute the PLS instruction (so that the S7-200 programs the PTO/PWM generator). The S7-200
2 4.
hoa oa ho a hoa
completes any PTO that is in process before starting to generate the waveform with the updated

ng g h
pulse count and cycle time.
n n g ng
dothe interrupt routine or the subroutine.Tudo
T5. uExit Tud
o
Initializing the PTO Output for a Multiple-Segment Operation
Typically, you use a subroutine to configure and initialize the PTO for the pulse output for multiple-segment

.co m .co m .co m


operation. You call the initialization subroutine from the main program. Use the first scan memory bit
.
a 2 4 a 2 4 a 2 4
(SM0.1) to initialize the output used by the PTO to 0, and call a subroutine to perform the initialization
operations. When you use the First Scan bit to call the initialization subroutine, the subsequent scans do
a 24
o ho ho o
ngh g g ng h
not make the call to the subroutine, which reduces scan time execution.

d o n d o n to o
the main program, use the following steps d
Tu the control logic for configuring pulse output
After creating
create TuQ0.0 within the initialization subroutine: Tu
the call to the initialization subroutine from

1. Configure the control byte by loading one of the following values in SMB67: 16#A0 (to select
microsecond increments) or 16#A8 (to select millisecond increments).

.c o m . c o m . c o m
Both of these values enable the PTO/PWM function, select PTO operation, select multiple-segment
.
o a24 a 24 24
a
operation, and select the time base (microseconds or milliseconds).
o o oa 24
ngh n ghload a word-sized value for the starting
2. In SMW168,
o
d V memory to set up the segment values o nVg h offset of the profile table.
memory
o n gh
T3. uUse uindthe profile table. Ensure that the NumberTofud
Tcorrect.
Segment field (the first byte of the table) is
4. (Optional) To perform a related function as soon as the PTO profile is complete, you can program an
interrupt by attaching the pulse train complete event (interrupt event 19) to an interrupt subroutine.

.co m om om
Use the ATCH instruction and execute the global interrupt enable instruction ENI.
. c . c
a2 4 a 2 4
5. Execute the PLS instruction
a 2 4
(so that the S7-200 programs the PTO/PWM generator).
a2 4.
o ho ho ho
ng h 6. Exit the g
o n subroutine.
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 135
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 Single-Segment Pulse Train Operation


4 . c om 4 . c om 4.
o a 2 Example:
a 2 (PTO)
a 2 a 2
ngh M
n g ho Network 1 //On the first scan,
n g hbitolow and call subroutine 0. n g ho
A
I
T u do LD SM0.1
T do
//set the image register
u T u do
N R Q0.0, 1
CALL SBR_0

. co m .c o m . c o m
24 24 4
2PTO 2 4.
ng hoa S
g hoa Network 1
o a
//Start of subroutine 0: Configure
hbyte:
goperation. ng ho a
on n
B //1. Set up the control
// – Selecto o
R
0
T u d // – u d single segment operation.
T Select
PTO
Tu d
// – Select ms increments.
// – Enable the loading of the pulse count
// and cycle time value.

.co m .co m // – Enable the PTO function.


//2. Set cycle time to 500ms.
.co m .
6 2 4 2 4 2
//3. Set pulse count to 4 pulses.4 24
g hoa gh o a
gh o a
//4. Define interrupt routine 0 to be the interrupt
g h o a
n d o n d o n
// for processing PTO complete interrupts.
//5. Global interrupt enable.
d on
Tu Tu
//6. Invoke PTO operation, PLS0 => Q0.0.
//7. Preload the control byte for subsequent cycle time
T u
//changes.
LD SM0.0

4 .c om 4 .co
MOVB
MOVW
m 16#8D, SMB67
+500, SMW68
4 .co m
4.
o a2 oa 2 MOVD +4, SMD72
o a 2
hoa 2
ngh gh gh
ATCH INT_0, 19

o n ENI
o n o ng
Tu d PLS
MOVB
0
Tu
16#89, SMB67
d 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
136
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
S7-200 Instruction Set Chapter 6

4 .c omExample: Single-Segment Pulse Train4Operation


.c om(PTO), continued 4 . c om 4.
o a 2 a 2 a 2 a 2
ngh I
n g ho Network 1
g h
//If current cycle
n
o is 500 ms:
time
n g ho
N
T
T u do LDW= T u
SMW68,
o
d+500
//Set the cycle time to 1000 ms and generate 4 pulses.

T u do
0 MOVW +1000, SMW68
PLS 0
CRETI

. co m .c o m . c o m
24 24
Network 2
a24
//If current cycle time is 1000 ms:
2 4.
hoa hoa a
//Set the cycle time to 500 ms and generate 4 pulses.

ng g LDW= SMW68, +1000


gho ng ho
Tu don MOVW
PLS do
+500, SMW68
0
Tu
n
Tu d o

.co m .co m .co m


a 2 4 a 2 4 a 2 4 6a 2 4.
o o o gho
ngh d o n gh
d o n gh o n
Tu Tu Tud

4 .c om 4 .co m
4 .co m
4.
o a2 oa 2 o a 2
hoa 2
ngh Timing Diagramdo ng h
d o n gh o ng
Tu Tu Tud
1 cycle 1 cycle
500 ms 1000 ms

Q0.0

.co m .co m .co m .


a 2 4 a 2 4
4 cycles or 4 pulses 4 cycles or 4 pulses
a 2 4 a 24
o o o o
ngh gh gh h
Interrupt 0 occurs Interrupt 0 occurs

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 137
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 Multiple-Segment Pulse Train Operation


4 .c om 4 . c om 4.
o a 2 Example:
a 2 (PTO)
a 2 a 2
ngh M
n g ho Network 1 //On the first scan,
n g hbitolow and call subroutine 0 n g ho
A
I
T u do LD SM0.1
T do
//set the image register
u T u do
N R Q0.0, 1
CALL SBR_0

. co m .c o m . c o m
24 S 24Network 1 //Preload the PTO profile table: 24 2 4.
ng hoa B
g hoa ofg
hoasegments to 3.
//Set number of profile table
ng ho a
R
u d on //Configure eachn
udosegment 1:
the 3 segments.
d o
Tu
0 //
T //1. T
//
Configure
– Set the initial cycle time = 500 ms.
// – Set the delta cycle time to –2 ms.
// – Set the number of pulses to 200.

.co m .co m //2.


//
Configure segment 2:

.co
– Set the initial cycle time to 100 ms. m .
6 2 4 2 4 //
2 4
– Set the delta cycle time to 0 ms.
24
g hoa gh o a //
//3. o a
– Set the number of pulses to 3400.
gh
Configure segment 3:
g h o a
n d o n //
d o n
– Set the initial cycle time to 100 ms.
d on
Tu //
// Tu
– Set the delta cycle time to 1 ms.
– Set the number of pulses to 400. T u
LD SM0.0
MOVB 3, VB500

4 .c om 4 .co
MOVW
MOVW
m
+500, VW501 //Segment 1
–2, VW503
4 .co m
4.
o a2 oa 2 MOVD +200, VD505
o a 2
hoa 2
ngh gh gh g
MOVW +100, VW509 //Segment 2

do n MOVW +0, VW511


d o n o n
Tu Tu Tud
MOVD +3400, VD513
MOVW +100, VW517 //Segment 3
MOVW +1, VW519
MOVD +400, VD521

.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
138
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
S7-200 Instruction Set Chapter 6

4 .c omExample: Multiple-Segment Pulse Train4Operation


.c om(PTO) , continued 4 . c om .
o a2 o a2 o 2
abyte: o a 24
ng h S
ng h Network 2 //1. Set up the h
ngmultiple
control
g h
B
u d o u d o
// – Select PTO operation
u d on
R
0 T T //// –– Select
// – Select segment operation
ms increments
Enable the PTO function
T
c //2. Set the start address of the profile table to V500.
o //3. Define interrupt routine 0 to be the interrupt

. co m n

.c o m //
. c o m
for processing PTO complete interrupts.

4.
t //4. Global interrupt enable
24 i
24 a24 2
hoa hoa a
//5. Invoke PTO operation, PLS0 => Q0.0.

ng
n
g LD SM0.0
gho ng ho
don n
u
do o
MOVB 16#A8, SMB67
e
d Tu
MOVW
ATCH Tu
+500, SMW168
INT_0, 19 Tu d
ENI
PLS 0

.co m .co m .co m


a 2 4 a 2 4 a 2 4 6a 2 4.
o o o gho
ngh d o n gh
d o n gh o n
Tu Tu Tud

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
I
Tu Network 1
Tu//When the PTO output profile is complete, Tud
N //Turn on output Q0.5
T LD SM0.0

.co m 0
.co m
= Q0.5
.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 139
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 Math Instructions
o a2 o a2 o a 24
ng h h
ng and Divide Instructions ng h g h
Add, Subtract,oMultiply,
u d d o d on
Add T Subtract Tu T u
IN1 + IN2 = OUT IN1 – IN2 = OUT LAD and FBD
IN1 + OUT = OUT OUT – IN1 = OUT STL

. co mThe Add Integer (+I) or Subtract Integer


.c (–I)m
o instructions add or
. c o m
a 24 subtract two 16-bit integers to
a 4 Integer (–D) instructions add a24
2Double
produce a 16-bit result. The Add
a2 4.
o o
h to produce a 32-bit result. The Addngho ho
ngh
Double Integer (+D) or Subtract
or subtract two 32-bitg
n integers
o Real (–R) instructions add or subtract
dSubtract otwo ong
Tunumbers Tud Tu d
Real (+R) and
32-bit real to produce a 32-bit real number result.

Multiply Divide

.c o mIN1 * IN2 = OUT IN1 / IN2 = OUTm


OUT / IN1.c o LAD and FBD
. c om .
6a2 4 IN1 * OUT = OUT
4 = OUT STL
a2Integer (/I) instructions multiply or hoa2 4 a 24
ho oro
The Multiply Integer (*I)h h o
ng g to produce a 16-bit result. (For division, g g
Divide
o n
divide two 16-bit integers
remainderu d d o n no
d on
u Double
T is kept.) The Multiply Double Integer (*D) orTDivide
Integer (/D) instructions multiply or divide two 32-bit integers to T u
produce a 32-bit result. (For division, no remainder is kept.) The
Multiply Real (*R) or Divide Real (/R) instructions multiply or divide
two 32-bit real numbers to produce a 32-bit real number result.

4 .c om 4 . c om 4 . c om 4.
h o a2 SM Bits and ENO
h o a2 h o a2 hoa 2
ng o n g errors and illegal values. If SM1.1 isoset,ng
SM1.1 indicates overflow
d d o ng
Tu are not altered.
then the status
input operands
of SM1.0 and SM1.2 is not valid and the u
If SM1.1 and SM1.3 are Tnot
original
set, then Tud
the math operation has completed with a valid result and SM1.0 and
SM1.2 contain valid status. If SM1.3 is set during a divide operation,

.co m .c om
then the other math status bits are left unchanged.
. c om
a 2 4 2 4
Error conditions that set ENO = 0
a
Special Memory bits affected
a 2 4 a 2 4.
o ho ho ho
ngh
H SM1.1 (overflow) H SM1.0 (zero)
H SM1.3 (divide by n g n g n g
udoaddress) udo udo
zero) H SM1.1 (overflow, illegal value generated during the operation, or illegal
H 0006T T T
input parameter found)
(indirect
H SM1.2 (negative)
H SM1.3 (divide by zero)

.c o mTable 6-37 Valid Operands for Add, Subtract,


. c o m . c o m
a2 4 a 2 4 Multiply, and Divide Instructions
a 2 4 a 2 4.
o ho IW, QW, VW, MW, SMW, SW, T, C,nLW,gAC, hoAIW, *VD, *AC, *LD, Constant ho
ngh
Inputs/Outputs Data Types Operands

o n g n g
doAC, HC, *VD, *LD, *AC, Constant udo
IN1, IN2 INT

Tud DINT REAL


T
ID, QD, VD, MD, SMD, SD, uLD,
ID, QD, VD, MD, SMD, SD, LD, AC, *VD, *LD, *AC, Constant
T
OUT INT IW, QW, VW, MW, SMW, SW, LW, T, C, AC, *VD, *AC, *LD

.c o m DINT, REAL

. c om
ID, QD, VD, MD, SMD, SD, LD, AC, *VD, *LD, *AC

. c m
ostandard
a2 4 a 4
Real (or floating-point) numbers are represented
2
(single-precision). Refer to that standard for more information.
a 2 4
in the format described in the ANSI/IEEE 754–1985
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
140
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
S7-200 Instruction Set Chapter 6

4 .c omExample: Integer Math Instructions 4.com 4. c om .


o a2 o a2 o a2 o a 24
ng h ng h Network 1
ng h g h
d o LD I0.0
d o d on
Tu +I
*I
Tu
AC1, AC0
AC1, VW100
T u
/I VW10, VW200

. 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 6a 2 4.
o ho ho gho
ngh Add
n g
d60o = 100
Multiply
20 do
n g Divide
d on
TuAC0 u u
40 + 40 = 800 4000 / 40 =100
AC1 AC0 AC1
*
T
VW100 VW100 VW200 VW10 T VW200

.c omExample: Real Math Instructions . c m


oNetwork . c om
a2 4 a24 1
a2 4 a 2 4.
h o h o LD I0.0
h o ho
ng d o ng +R AC1, AC0
d o ng o ng
Tu u Tud
*R AC1, VD100
/R VD10,TVD200

.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 n= g10000.0 ng gh
Add Multiply Divide

d o = o80000.0
200.0 d d on
TuAC0 Tu VD100 u
4000.0 + 6000.0 400.0 * 4000.0 / 41.0 = 97.5609
AC1 AC0 AC1 VD100 VD200 VD10 T VD200

.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 141
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
oMultiply .c omand Divide Integer with Remainder
. c om
a 2 4 Integer to Double
a 2 4
Integer
a 2 4 a 2 4.
o ho Integer ho ho
ngh g
Multiply Integernto
do LAD and FBD
Double n g n g
T
IN1 * IN2 =uOUT T udo T udo
IN1 * OUT = OUT STL
The Multiply Integer to Double Integer instruction (MUL) multiplies

. co m c
instruction, the least-significant word.(16
m
two 16-bit integers and produces a 32-bit product. In the STL MUL
o . c o m
a 24 used as one of the factors.
a 24
bits) of the 32-bit OUT is
a 24 a2 4.
o o o ho
ngh Divide Integer
d o n ghRemainder
with o n gh ong
T=uOUT
IN1 / IN2 LAD and FBD Tud Tu d
OUT / IN1 = OUT STL
The Divide Integer with Remainder instruction (DIV) divides two

4 .c om16-bit integers and produces a 32-bit resultm


remainder (the most-significant word).c
4 oaconsisting of a 16-bit
4 . c om .
o6a2 least-significant word).
o a2
and 16-bit quotient (the
o a2 o a 24
ng h h
ng word (16 bits) of the 32-bit OUTdisoused h
ngas the dividend. g h
o
In STL, the least-significant
d d on
SM Bits Tu and ENO Tu T u
For both of the instructions on this page, Special Memory (SM) bits indicate errors and illegal values. If
SM1.3 (divide by zero) is set during a divide operation, then the other math status bits are left

4 .c om operation.
4
m
unchanged. Otherwise, all supported math status bits contain valid status upon completion of the math
.co 4 .co m
4.
o a2 oa= 02 o a 2
hoa 2
ngh h gh
Error conditions that set ENO Special Memory bits affected
H SM1.1 (overflow)n g n ng
udoby zero) o o
H SM1.0 (zero)
H SM1.3T(divide d
TuH SM1.1 (overflow) Tud
H 0006 (indirect address) H SM1.2 (negative)
H SM1.3 (divide by zero)

.co mTable 6-38 . c om .c om


a 2 4 a 2 4 a 2 4
Valid Operands for Multiply Integer to Double Integer and Divide Integer with Remainder
a 2 4.
o ho IW, QW, VW, MW, SMW, SW, T, C,nLW,gAC,hoAIW, *VD, *LD, *AC, Constant ho
ngh
Inputs/Outputs Data Types Operands
n g n g
IN1, IN2
OUT Tu
do DINT
INT
ID, QD, VD, MD, SMD,T
doAC, *VD, *LD, *AC
uLD,
SD, Tud
o

Example: Multiply Integer to Double Integer Instruction and Divide Integer with Remainder Instruction

.c o m . c o m 1
Network
. c o m .
o a24 hoa
24 LD I0.0

hoa
24 oa 24
ngh gh
MUL AC1, VD100

on g DIV VW10, VD200


on g o n
T u d T u d
Multiply Integer to 400 * 200 = 80000 Tud
Double Integer
AC1 VW102 VD100

rem. quot.

4 .c om 4 .comwith Remainder
Divide Integer 4000
4 .
/
co23m 97
41 =
4.
2 2 VW202
2
VW10
2
VW200 VW202

ng hoa n g ho a
n g o a
hVW202. VD200

n g ho a
o
Note: VD100 contains:
o
VW100 and VW102, and VD200 contains: VW200 and
o
Tud Tud Tud

4 . com 4. c om 4 . com .
o a2 oa2 a2 a 24
ngh
142
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
S7-200 Instruction Set Chapter 6

4 .c om Numeric Functions Instructions


4 . c om 4. c om .
o a2 o a2 o a2 o a 24
ng h h
ngCosine h h
Sine, Cosine,
Theu d o(SIN), and Tangent
(COS), and Tangent (TAN)u d ong u d on g
T the trigonometric function of the angleTvalue IN and place the
Sine
evaluate
instructions
T
result in OUT. The input angle value is in radians.
SIN (IN) = OUT COS (IN) = OUT TAN (IN) = OUT

24 .com . c o m
4 in degrees by 1.745329E–2
To convert an angle from degrees
instruction to multiply the2
to radians: Use the MUL_R (*R)
24. c o m
2 4.
h o a o a angle
(approximately byhπ/180). o a ho a
ng o n g o n gh ong
Tud
Natural Logarithm and Natural
Tud
Exponential
The Natural Logarithm instruction (LN) performs the natural logarithm
Tu d
of the value in IN and places the result in OUT.
The Natural Exponential instruction (EXP) performs the exponential

4 .c om .co m
operation of e raised to the power of the value in IN and places the
4 4 .co m
4.
2 result in OUT.
2 2 6 2
ng hoa LN (IN) = OUT
n g
a
hoEXP (IN)= OUT n g ho a
gho
a
u d
To obtainothe base 10 logarithm from the natural logarithm:
u d o Divide the natural logarithm by 2.302585
u d on
T
(approximately the natural logarithm of 10). T T
To raise any real number to the power of another real number, including fractional exponents: Combine the
Natural Exponential instruction with the Natural Logarithm instruction. For example, to raise X to the Y

4 .c om 4 .co m
power, enter the following instruction: EXP (Y * LN (X)).
4 .co m
4.
o a2 Square Root
oa 2 a 2
hinstruction (SQRT) takes the square rootnofgahrealonumber (IN) and produces a real nghoa 2
ngh n
o OUT.
dresult
g
The Square Root
do do
T u
number
SQRT (IN)= OUT
T u T u
To obtain other roots: 5 cubed = 5^3 = EXP(3*LN(5)) = 125
The cube root of 125 = 125^(1/3) = EXP((1/3)*LN(125))= 5

.co m .co m .co m


The square root of 5 cubed = 5^(3/2) = EXP(3/2*LN(5)) = 11.18034
.
a 2 4 a 2 4 a 2 4 a 24
o o o o
ngh gh gh h
SM Bits and ENO for the Numeric Functions Instructions
o n o n on g
Tud d d
For all of the instructions that are described on this page, SM1.1 is used to indicate overflow errors and
Tu T
illegal values. If SM1.1 is set, then the status of SM1.0 and SM1.2 is not valid and the original inputu
operands are not altered. If SM1.1 is not set, then the math operation has completed with a valid result and
SM1.0 and SM1.2 contain valid status.
Error conditions that set ENO = 0 Special Memory bits affected

.c o m H SM1.1 (overflow)
. c o m
H SM1.0 (zero)
. c o m .
2 4 2 4 24 24
hoa hoa hoa a
H 0006 (indirect address) H SM1.1 (overflow)

gh o
ng d o ng H SM1.2 (negative)
d on g o n
T u
Table 6-39 Valid Operands for Numeric Functions T u Tud
Inputs/Outputs Data Types Operands

om m om
IN REAL ID, QD, VD, MD, SMD, SD, LD, AC, *VD, *LD, *AC, Constant

.c REAL .co ID, QD, VD, MD, SMD, SD, LD, AC, *VD, *LD, . c
2 4 OUT
4
2 are represented in the format described in o 2 4 *AC
2 4.
ng hoa Real (or floating-point)o
n g
(single-precision). Refer
a
h to that standard for more information. ngh
numbers thea
ANSI/IEEE 754–1985 standard
n g ho a
o o o
Tud Tud Tud

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 143
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
oIncrement .c om . c om .
a2 4 and
a2
Decrement 4
Instructions
a2 4 a 24
h o h o h o h o
ng Increment
d ongLAD and FBD d ong d on g
OUT + T
u
IN + 1 = OUT
1 = OUT STL Tu T u
Decrement

. co mIN – 1 = OUT LAD and FBD


.c o m . c o m
2 4 OUT – 1 = OUT STL
24 a24 2 4.
ng hoa hoa
The Increment and Decrement instructions add or subtract 1 to or
g gho ng ho a
don n
from the input IN and place the result into the variable OUT.

Tu Tu
Increment Byte (INCB) and Decrement Byte (DECB) operations are do Tu d o
unsigned.
Increment Word (INCW) and Decrement Word (DECW) operations
are signed.
.co mIncrement Double Word (INCD) and .Decrement
c om Double Word . c om .
6 2 4 a2 4 a2 4 24
g hoa o
(DECD) operations are signed.
h h o h o a
n o ng
Error conditions that
d set ENO = 0:
d o ng d on g
T u
H SM1.1 (overflow)
T u T u
H 0006 (indirect address)

Special Memory bits affected:

4 .c omH SM1.0 (zero) 4 . c om 4 . c om 4.


h o a2 H SM1.1 (overflow)
h o a2 h o a2 hoa 2
ng d o ng
H SM1.2 (negative) for Word and Double Word operations

d o ng o ng
Tu Tu Tud
Table 6-40 Valid Operands for the Increment and Decrement Instructions

.co m Inputs/Outputs Data Types


.co
Operands m .co m .
a 2 4 IN BYTE
a 2 4 a 2 4
IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *LD, *AC, Constant
a 24
o o ho o
ngh o n gh INT
g
IW, QW, VW, MW, SMW, SW, T, C, LW, AC, AIW, *VD, *LD, *AC, Constant
n on g h
OUT Tud BYTE
DINT
udAC,o*VD,
ID, QD, VD, MD, SMD, SD, LD, AC,
TLB,
IB, QB, VB, MB, SMB, SB,
HC, *VD, *LD, *AC, Constant
*AC, *LD T u d
INT IW, QW, VW, MW, SMW, SW, T, C, LW, AC,*VD, *LD, *AC
DINT ID, QD, VD, MD, SMD, SD, LD, AC, *VD, *LD, *AC

.c o m . c o m . c o m .
o a24 Example: Increment and
o a 24 Network 1
Decrement Instructions
o a 24 oa 24
ngh o n gh o n gh o n gh
Tud AC0 ud
Tud
LD I4.0
INCW
DECD T
VD100

Increment Word 125 +1= 126

.co m .co m AC0


. com AC0
a2 4 a 2 4 a 2 4
128000 –1= 127999
a2 4.
o gho
Decrement Double Word
hoVD100 ho
ng h o n o n g VD100
on g
Tud Tud Tud

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
144
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
S7-200 Instruction Set Chapter 6

4 .c om 4 . c om 4. c om .
o a2 o a2
Proportional/Integral/Derivative (PID) Loop
a2
Instruction
o o a 24
ng h h
nginstruction (PID) executes a PID loop d ng on h g h
The PID o
d Loop o
calculation
d on
Tu
the Tu
referenced LOOP based on the input and configuration
information in Table (TBL).
T u
Error conditions that set ENO = 0:

. co m H SM1.1 (overflow)

.c o m . c o m
24 H 0006 (indirect address)
24 a24 2 4.
ng hoa g h
Special Memory bits
n
a
oaffected:
n g ho ng ho a
H SM1.1 o
T ud (overflow)
T udo Tu d o
The PID loop instruction (Proportional, Integral, Derivative Loop) is
provided to perform the PID calculation. The top of the logic stack
(TOS) must be ON (power flow) to enable the PID calculation. The

.co m .co m
instruction has two operands: a TABLE address which is the starting
.co m
a 2 4 from 0 to 7. a 2 4
address of the loop table and a LOOP number which is a constant
a 2 4 6a 2 4.
o o o gho
ngh o n gh o n gh
Eight PID instructions can be used in a program. If two or more PID instructions are used with the same
d d o n
Tu Tu
loop number (even if they have different table addresses), the PID calculations will interfere with one
another and the output will be unpredictable. Tud
The loop table stores nine parameters used for controlling and monitoring the loop operation and includes
the current and previous value of the process variable, the setpoint, output, gain, sample time, integral

4 .c om 4 . c om
time (reset), derivative time (rate), and the integral sum (bias).
4 . c om 4.
o a2 a 2
o routine or from within the main program
To perform the PID calculation a 2
oat a rate controlled by a timer. The gho
at the desired sample rate, the PID instruction must be executed either a 2
ngh d
sample time n g h
from within a timed interrupt
n g
o must be supplied as an input to the PIDudinstruction
h
o via the loop table. d on
T u T T u
Table 6-41 Valid Operands for the PID Loop Instruction
Inputs/Outputs Data Types Operands

.com TBL BYTE


.com
VB
.co m .
o a24 LOOP
ho
24
aBYTE Constant (0 to 7)
ho a 2 4
o a 24
ngh d o n g
d o n g
d o ng h
Tu Select the Tools > Instruction WizardTmenu
STEP 7-Micro/WIN
process.
offers the PID Wizard to guide u command and then select PID from theTInstruction
you in defining a PID algorithm for a u
closed-loop control

Instruction Wizard window.


Wizard

.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 145
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
oUnderstanding . c om . c om
a 2 4 the PID
a 2 4
Algorithm
a 2 4 a 2 4.
o gherroraoPID ho so(SP)as to(thedrive ho
ngh In steady state operation,
zero. A measureoofnthe n g
controller regulates the value of the output the error (e) to
do The principle of PID control is basedTudo n g
thedprocess variable (PV) (the actual operatingupoint).
is given by the difference between the setpoint desired operating
point) and u
T T
upon the following equation that expresses the output, M(t), as a function of a proportional term, an
integral term, and a differential term:

. co m Output = Proportional term

.c o m + Integral term +
m
Differential term

. c o
24 4 t
4 4.
hoa
M(t) = KC * e
oa2 + KC  e dt  M
gthehloop output as a function of time
initial
+
h
K * 2
o aCde/dt
ho a2
ng o n 0
ong ong
Tud isis the ud Tu d
where: M(t)
is
KC
e
loop gain T
the loop error (the difference between setpoint and process variable)
Minitial is the initial value of the loop output

.co mIn order to implement this control function


.c oinma digital computer, the continuous function
. c mbe quantized
omust
6 2 4 2 4 2 4 2 4.
g hoa g
equation that is the basis
a
hforo the digital computer solution is: ngho
into periodic samples of the error a
value with subsequent calculation of the output. The corresponding
g ho a
n do n do do n
M n
T u = K * e c n + K * S +M T uI
n
+ K * (e –e )
initial D
T u
n n–1
1
output = proportional term + integral term + differential term

om m m
where: Mn is the calculated value of the loop output at sample time n

4 .c KC is the loop gain


4 .co 4 .co 4.
o a2 en
oa 2
is the value of the loop error at sample time n
o a 2
hoa 2
ngh gh gh
en – 1 is the previous value of the loop error (at sample time n – 1)
KI
o n is the proportional constant of the integral term
o n o ng
Tu d
Minitial
KD
is the initial value of the loop output
Tu
is the proportional constant of the differential term
d Tud
From this equation, the integral term is shown to be a function of all the error terms from the first sample to
the current sample. The differential term is a function of the current sample and the previous sample, while

.co m . c om .c om
the proportional term is only a function of the current sample. In a digital computer, it is not practical to

a 2 4 store all samples of the error term, nor is it necessary.


a 4
2calculate the output value each time theoerror
a 4
2is sampled beginning with a 2 4.
o Since the digital computero
hnecessary to store the previous value ofnthegherror and the previous value of the ngho
ngh
must

integral term.d
n g
the first sample, it is only
Asoa result of the repetitive nature of the digital o solution, a simplification in the udo
equation u must
Tthat be solved at any sample time can T be u
dcomputer
made. The simplified equation is: T
Mn = Kc * en + KI * en + MX + KD * (en–en–1)
output = proportional term + integral term + differential term

.c o m where: Mn
o m
is the calculated value of the loop output at sample time n
. c . c o m .
a24 24 24 24
KC is the loop gain

o hoa hoa oa
en is the value of the loop error at sample time n

ngh en – 1

d on g
d on g
is the previous value of the loop error (at sample time n – 1)
o n gh
Tud
KI is the proportional constant of the integral term

T u
MX
KD T u
is the previous value of the integral term (at sample time n – 1)
is the proportional constant of the differential term

.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
146
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2 2 a2
The S7-200 uses a modified form of the above simplified equation when calculating the loop output value.
a a 24
ngh n g ho
This modified equation is:
n g ho g h o
o= MP udo on
Tud = proportional term d
M + MIn + MDn
n
output
n
+ T
integral term + differential term T u
where: Mn is the calculated value of the loop output at sample time n
MPn is the value of the proportional term of the loop output at sample time n
MIn is the value of the integral term of the loop output at sample time n

. co m MDn
c o m
is the value of the differential term of the loop output at sample time n
. . c o m
24 24 a24 2 4.
ng hoa Understandinghthe
n g
a
o Proportional Term of the PID Equation
n g ho n g ho a
o do the setpoint (SP) and the processTvariable udo
Tud and the error (e), which is the difference
The proportional term MP is the product of the gain (K ), which controls the sensitivity of the output
Tubetween
C
calculation,
(PV) at a given sample time. The equation for the proportional term as solved by the S7-200 is:

MPn = KC * (SPn – PVn)

.co m where: MPn


.co m
is the value of the proportional term of the loop output at sample time n
.co m
a 2 4 KC
a 2 4
is the loop gain
a 2 4 6a 2 4.
o SPn
o
is the value of the setpoint at sample time n
o gho
ngh gh gh
PVn is the value of the process variable at sample time n

d o n d o n o n
Tu
Understanding the Integral Term of theT u Equation
PID
The integral term MI is proportional to the sum of the error over time. The equation for the integral term as
Tud
solved by the S7-200 is:

4 .c om MIn = KC *

4 . c omTS / TI * (SPn – PVn)

4 . c
+
om MX

4.
2 where: MIn
2
is the value of the integral term of the loop output at sample time n
2 2
ng hoa KC
g h oa is the loop gain
g hoa g hoa
don on n
TS is the loop sample time
d o
Tud
TI is the integration period of the loop (also called the integral time or reset)
Tu SPn
PVn
T u
is the value of the setpoint at sample time n
is the value of the process variable at sample time n
MX is the value of the integral term at sample time n – 1 (also called the integral sum or the bias)

4 . c om m
The integral sum or bias (MX) is the running sum of all previous values of the integral term. After each
.co .co
calculation of MIn, the bias is updated with the value of MIn which might be adjusted or clamped (see the
4 4
m .
2 2 2 24
hoa a a a
section “Variables and Ranges” for details). The initial value of the bias is typically set to the output value

gh o gh o
(Minitial) just prior to the first loop output calculation. Several constants are also part of the integral term,
h o
ng o n o n
the gain (KC), the sample time (TS), which is the cycle time at which the PID loop recalculates the output
on g
Tud Tu d
value, and the integral time or reset (TI), which is a time used to control the influence of the integral term in
the output calculation. 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 147
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 omUnderstanding the Differential 4 .c om 4 . c om 4.


o a 2 a 2 Term of the PID Equation
a 2 a 2
ngh
The differential term
n
MD
g ho
is proportional to the change in the error.
n
The
g ho
S7-200 uses the following equation
n g ho
o
for the differential term:
o o
MD Tu=dK
n * T
C / T
D * T S
ud– PV
((SP ) – (SPn – PVn )) n–1 Tud n–1

To avoid step changes or bumps in the output due to derivative action on setpoint changes, this equation
is modified to assume that the setpoint is a constant (SPn = SPn – 1). This results in the calculation of the

. co m o m
change in the process variable instead of the change in the error as shown:
.c . c o m
24 24 / T * (SP – PV – SP + PVa2)
4 2 4.
hoa o a o ho a
MD n = K C * T D S n n n n–1

ng or just:
o n gh o n gh ong
MD n
T u=dK C * T D / T S
T
* (PV ud – PV )
n–1 n
Tu d
where: MD n is the value of the differential term of the loop output at sample time n
KC is the loop gain
TS is the loop sample time

.co m TD
.co m .co
is the differentiation period of the loop (also called the derivative time or rate) m .
6 2 4 SPn
4
is the value of the setpoint at sample time n
2 2 4 24
oa a a a
SPn–1 is the value of the setpoint at sample time n–1

g h PVn
gh o
is the value of the process variable at sample time n
gh o g h o
n PVn–1
d o n d o
is the value of the process variable at sample time n–1n d on
Tu Tu
The process variable rather than the error must be saved for use in the next calculation of the differential T u
term. At the time of the first sample, the value of PVn – 1 is initialized to be equal to PVn.

.c omSelecting the Type of Loop Control m


c o to employ only one or two methods
In many control systems, it might be .necessary . c omcontrol. For
a 2 4 a 2 4or proportional and integral control mighta
4 of loop
be2required. The selection of a 2 4.
o o is made by setting the value of the constant
example, only proportional control
ho parameters. ho
ngh the type of loop control h
n g desired
dwanto integral action (no “I” in the PID calculation), n g
dothen a value of infinity should be specified do ng
T u
If you do not
T u T u
for the integral time (reset). Even with no integral action, the value of the integral term might not be zero,
due to the initial value of the integral sum MX.

If you do not want derivative action (no “D” in the PID calculation), then a value of 0.0 should be specified

4 . c m
o for the derivative time (rate). 4.com 4 .c om 4.
o a 2 a 2 (no “P” in the PID calculation) and youawant 2 a 2
ghoterms,forsetting ggainhowillinresult gho
If you do not want proportional action I or ID control, then a

ngh value of 0.0 should be specified


the integral ando n the gain. Since the loop gain is a factor
a value of 0.0 for theo n
d gain in the calculation of the integralTandudifferential
d
the equations for calculating
in a value of 1.0 being on
Tud
differential loop
Tuloop
used for the terms.

.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
148
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
S7-200 Instruction Set Chapter 6

4 .c om Converting and Normalizing 4 .c om 4 . c om 4.


o a 2 a 2 the Loop Inputs
ovariables, the setpoint and the process g a 2 a 2
ngh g
A loop has two input
n hspeed n ho TheThe
variable. setpoint is generally a fixed
n g ho
is d
value such
that u
o as the setting on the cruise control
u dtheoeffect that the loop output has on theTcontrolled
in your automobile. process variable is
u
a
do
value
T T
related to loop output and therefore measures
system. In the example of the cruise control, the process variable would be a tachometer input that
measures the rotational speed of the tires.

Both the setpoint and the process variable are real world values whose magnitude, range, and
. co m .c o m . c o m
engineering units could be different. Before these real world values can be operated upon by the PID
24 24 a24
instruction, the values must be converted to normalized, floating-point representations.
2 4.
ng hoa The first step isgtoh
n
a
o the real world value from a 16-bit integer
convert
n g hovalue to a floating-point or real numberngho a
u d
value. Theo following instruction sequence is provided
u dtooshow how to convert from an integer value too
u d a
T
real number. T T
ITD AIW0, AC0 //Convert an input value to a double word
DTR AC0, AC0 //Convert the 32-bit integer to a real number

.co m .co m .co m


a 2 4 a 2 4 a 2 4
The next step is to convert the real number value representation of the real world value to a normalized 6a 2 4.
o o o gho
ngh gh gh
value between 0.0 and 1.0. The following equation is used to normalize either the setpoint or process

d o n
variable value:
d o n o n
Tu
RNorm = ((RRaw / Span) + Offset) Tu Tud
where: RNorm is the normalized, real number value representation of the real world value
RRaw is the un-normalized or raw, real number value representation of the real world value

om m m
Offset is 0.0 for unipolar values

2 4 .c 24 .co
is 0.5 for bipolar values
2 4 .co 2 4.
hoa oa a a
Span is the maximum possible value minus the minimum possible value:

ng n g h = 32,000 for unipolar values (typical)


n g ho ng ho
u d o u d o
= 64,000 for bipolar values (typical)
u d o
T T T
The following instruction sequence shows how to normalize the bipolar value in AC0 (whose span is
64,000) as a continuation of the previous instruction sequence:

64000.0, AC0 //Normalize the value in the accumulator

.com m m
/R
+R 0.5, AC0
.co//Offset the value to the range from 0.0 to 1.0
.co .
a24 2 4 2 4 24
MOVR AC0, VD100 //Store the normalized value in the loop TABLE
o o a o a o a
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 149
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
oConverting . c oa m . c om
a 2 4 the Loop 2
Output
a 4 to Scaled Integer Value
a 2 4 a 2 4.
o gho variable, hocruise ho
ngh The loop output is the control
The loop outputo is n
dan analog output, the loop output must beTconverted
a normalized, real number value between 0.0 n
andg
such as the throttle setting of the
1.0.
control on an automobile.
do to a 16-bit, scaled integer value. This
Before the loop output can be
do n g
T u
used to drive u T
process is the reverse of converting the PV and SP to a normalized value. The first step is to convert the
u
loop output to a scaled, real number value using the formula given below:

. co m where:RScal = (Mn – Offset)

.
*
c o mSpan

. c o m
24
R Scal

a24real number value of the loop output hoa24


is the scaled, real number value of the loop output
2 4.
hoa a
M is the normalized,
foro ho
n
is 0.0h
ng Offset

d o nisg0.5 for bipolar values


unipolar values

d o ng d ong
u is the maximum possible value minus theTminimum
TSpan u possible value Tu
= 32,000 for unipolar values (typical)
= 64,000 for bipolar values (typical)

4 .c om 4 . om
The following instruction sequence shows how to scale the loop output:
c 4 . c om 4.
o6a2 MOVR VD108, AC0
a 2
//Moves the loop output to the accumulator
a 2 a 2
ng h –R 0.5, AC0
64000.0, n g ho //Scales the value in the accumulator ng
ho
//Include this statement only if the value is bipolar
n g ho
*R

T u do AC0

T u do T u do
Next, the scaled, real number value representing the loop output must be converted to a 16-bit integer.
The following instruction sequence shows how to do this conversion:

.c om ROUND AC0, AC0


m
//Converts the real number to a 32-bit integer

.co .co m
4.
DTI AC0, LW0 //Converts the value to a 16-bit integer
2 4 MOVW LW0, AQW0
24//Writes the value to the analog output
2 4 2
ng hoa n g h oa
n g ho a
ng hoa
Forward- or d
u o
Reverse-Acting Loops
u do udo
T T T
The loop is forward-acting if the gain is positive and reverse-acting if the gain is negative. (For I or ID
control, where the gain value is 0.0, specifying positive values for integral and derivative time will result in
a forward-acting loop, and specifying negative values will result in a reverse-acting loop.)

.co mVariables and Ranges .c om .c om


a 2 4 a 2 4 a 2 4 a 2 4.
o hbutonot altered by the PID instruction. ngho
The process variable and setpoint are inputs to the PID calculation. Therefore the loop table fields for
ho
ngh n g
these variables are read
dois generated by the PID calculation, T o do n g
The outputu thedoutput value field in the loop table is updated
so u u
T value
at the completion of each PID calculation. The output value is clamped between 0.0 and 1.0. The output T
value field can be used as an input by the user to specify an initial output value when making the transition
from manual control to PID instruction (auto) control of the output. (See the discussion in the “Modes”

.c o m section below).
. c o m . c o m
a2 4 If integral control is being used,
a 2 4PID calculation. When the calculated output
then the bias value is updated by the PID
2 4value goestheoutupdated
calculation
a
and
a 2 4.
o value is used as an
ho0.0 or greater than 1.0), the bias is adjusted
input in the next o to the following of range
ho
ngh (output would be lessg
n than
n g haccording n g
formulas:
T udo T udo T udo
MX = 1.0 – (MP + MD ) n when the calculated output M > 1.0
n n
or

om where: om om
MX = – (MPn + MDn) when the calculated output Mn < 0.0

2 4 .c MX
4 . c
is the value of the adjusted
is the value of2
bias
4 . c 4.
hoa
MP n
is theh o aof the a2n
proportional term of the loop output at sample time
h o ho a2
ng nis gthe value of the loop output at sample time ndong ng
MD n value the differential term of the loop output at sample time n
M
dn
o d o
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
150
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2 o 2 o a2
By adjusting the bias as described, an improvement in system responsiveness is achieved once the
a
calculated output comes back into the proper range. The calculated bias is also clamped between 0.0 and
o a 24
ngh n gh n gh
1.0 and then is written to the bias field of the loop table at the completion of each PID calculation. The
o o on g h
T ud T ud
value stored in the loop table is used in the next PID calculation.
T u
The bias value in the loop table can be modified by the user prior to execution of the PID instruction in
d
order to address bias value problems in certain application situations. Care must be taken when manually
adjusting the bias, and any bias value written into the loop table must be a real number between 0.0 and

. co m 1.0.
.c o m . c o m
24 24 a24
A comparison value of the process variable is maintained in the loop table for use in the derivative action
2 4.
ng hoa hoa ho
part of the PID calculation. You should not modify this value.
g g ng ho a
Tu
Modes don Tu do n
Tu d o
There is no built-in mode control for S7-200 PID loops. The PID calculation is performed only when power
flows to the PID box. Therefore, “automatic” or “auto” mode exists when the PID calculation is performed
cyclically. “Manual” mode exists when the PID calculation is not performed.

.co m .co m .co m


a 2 4 The PID instruction has a power-flow history bit, similar to a counter instruction. The instruction uses this
a 2 4 a 2 4
history bit to detect a 0-to-1 power-flow transition. When the power-flow transition is detected, it will cause 6a 2 4.
o o o gho
ngh gh gh
the instruction to perform a series of actions to provide a bumpless change from manual control to auto
o n o n
control. In order for change to auto mode control to be bumpless, the value of the output as set by the
d d o n
Tu Tu Tud
manual control must be supplied as an input to the PID instruction (written to the loop table entry for Mn)
before switching to auto control. The PID instruction performs the following actions to values in the loop
table to ensure a bumpless change from manual to auto control when a 0-to-1 power-flow transition is
detected:

4 .c om -
.co m
Sets setpoint (SPn) = process variable (PVn)
4 4 .co m
4.
2 - 2 2 2
hoa oa a a
Sets old process variable (PVn–1) = process variable (PVn)

ng - Sets bias
ng h = output value (M )
(MX) n
n g ho ng ho
Theu
T do state of the PID history bits is “set” and
default
T u dostate is established at startup and on T
that everyu do
STOP-to-RUN mode transition of the controller. If power flows to the PID box the first time that it is
executed after entering RUN mode, then no power-flow transition is detected and the bumpless mode
change actions are not performed.

.co m .c om .c om
a 2 4 2 4
Alarm Checking and Special Operations
The PID instruction is aasimple
4
the2PID calculation. If other
but powerful instruction that performsa a 2 4.
o ho ho on loop variables, these must be ngho
ngh o n g
processing is required
o n g
such as alarm checking or special calculations
o
Tud Tud Tud
implemented using the basic instructions supported by the S7-200.

Error Conditions
When it is time to compile, the CPU will generate a compile error (range error) and the compilation will fail
if the loop table start address or PID loop number operands specified in the instruction are out of range.
.c o m . c o m . c o m .
a24 24 24 24
Certain loop table input values are not range checked by the PID instruction. You must take care to ensure

ngh
o hoa hoa
that the process variable and setpoint (as well as the bias and previous process variable if used as inputs)
g g gh oa
on on n
are real numbers between 0.0 and 1.0.
d d o
T u T u
If any error is encountered while performing the mathematical operations of the PID calculation, then
Tud
SM1.1 (overflow or illegal value) is set and execution of the PID instruction is terminated. (Update of the
output values in the loop table could be incomplete, so you should disregard these values and correct the
input value causing the mathematical error before the next execution of the loop’s PID instruction.)

.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 151
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 omLoop Table 4 .co m


4. c om .
o a2 o a 2 o a2 o a 24
ngh gh gh h
The loop table is 36 bytes long and has the format shown in Table 6-42.
on on on g
ud Table
Table 6-42 Loop
T ud
T Description T u d
Offset Field Format Type
0 Process variable Double word In Contains the process variable, which must be scaled
(PVn) – REAL between 0.0 and 1.0.

. co m .c o m . c o m
4.
4 Setpoint Double word In Contains the setpoint, which must be scaled between
24 (SPn)
24– REAL 0.0 and 1.0.
a24 2
ng hoa 8 Output
g hoa Double word In/Out
gho
Contains the calculated output, scaled between 0.0
ng ho a
12 u
TGaindon
(Mn) – REAL
Double word In
do n
and 1.0.

TuContains the gain, which is a proportional constant.


Tu d o
(K )
C – REAL Can be a positive or negative number.
16 Sample time Double word In Contains the sample time, in seconds. Must be a
(TS) – REAL positive number.

.co m 20 Integral time or reset


.co m
Double word In
.co m
Contains the integral time or reset, in minutes. Must be
.
6 2 4 (TI)
2 4
– REAL a positive number.
2 4 24
g hoa 24
gh o
Derivative time or rate
a Double word In
gh o a
Contains the derivative time or rate, in minutes. Must
g h o a
n (TD)
d o n – REAL
o n
be a positive number.
d d o n
28 u
TBias Double word u
In/OutT Contains the bias or integral sum value betweenT u
0.0
(MX) – REAL and 1.0.
32 Previous process Double word In/Out Contains the previous value of the process variable
variable (PVn–1) – REAL stored from the last execution of the PID instruction.

4 .c om 4 . c om 4 . c om 4.
o a 2 PID Program Example a 2 a
o is used to maintain a constant water pressure. 2 a 2
ngh In this example, a n g htank n g ho Water is continuously being ngho
u
taken from the d o tank at a varying rate. A variable speed
water
water
u d o is used to add water to the tank at audo
pump
T T
rate that will maintain adequate water pressure and also keep the tank from being emptied. T
The setpoint for this system is a water level setting that is equivalent to the tank being 75% full. The
process variable is supplied by a float gauge that provides an equivalent reading of how full the tank is

.co m .co m .co m


and that can vary from 0% (or empty) to 100% (or completely full). The output is a value of pump speed
.
a 2 4 a 2 4
that allows the pump to run from 0% to 100% of maximum speed.
a 2 4 a 24
o o o o
ngh gh gh g h
The setpoint is predetermined and is entered directly into the loop table. The process variable is supplied
o n o n
as a unipolar, analog value from the float gauge. The loop output is written to a unipolar, analog output
on
Tud Tu d
which is used to control the pump speed. The span of both the analog input and analog output is 32,000.
T u d
Only proportional and integral control are employed in this example. The loop gain and time constants
have been determined from engineering calculations and can be adjusted as required to achieve optimum
control. The calculated values of the time constants are: KC = 0.25, TS = 0.1 seconds, and TI = 30

.c o m minutes.
. c o m . c o m
a2 4 The pump speed is controlledamanually2 4 until the water tank is 75% full, thenathe24 a 2 4.
o gis usedo totank.switch ghofrom manual to auto control ongho
valve is opened to allow

ngh water to be drained fromhthe


mode. A digital o n At the same time, the pump is switched
ton
the control from manualo
Tud control: 0 = manual and 1 = automatic. d in manual control mode, the pump speedTud
input auto. This input (I0.0) is
manual/automatic
TuWhile
is written by the operator to VD108 as a real number value from 0.0 to 1.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
152
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2 o a 2
Example: PID Loop Instruction
a2
ofirst scan, o a 24
ngh gh //Onh h
M
on
Network 1
o n g the
o ng
ud d d
A //Call the initialization subroutine
LD u
T
I
N T SM0.1
CALL SBR_0
Tu
S Network 1 //Load PID parameters and

. co m B

.c o m . c o m
//attach the PID interrupt routine:

4.
R //1. Load the loop setpoint = 75% full.
24 24 a24
//2. Load the loop gain = 0.25.
2
hoa hoa a
0

ng g gho //3. Load the loop sample time = 0.1 seconds.


ng ho
don n //4. Load the integral time = 30 minutes.

Tu Tu do //5. Set no derivative action.


//6. Set the timed interval (100ms) Tu d o
// for timed interrupt INT_0.
//7. Set up a timed interrupt to invoke
// the PID execution.

.co m .co m //8. Enable interrupts


.co m
a 2 4 a 2 4 LD
MOVR
SM0.0
0.75, VD104
a 2 4 6a 2 4.
o o o gho
ngh gh gh
MOVR 0.25, VD112

d o n MOVR
d o n0.1, VD116
o n
Tu Tu
MOVR
MOVR
MOVB
30.0, VD120
0.0, VD124
100, SMB34
Tud
ATCH INT_0, 10
ENI

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 153
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 Example: PID Loop Instruction, continued


4 .c om 4 . c om 4.
o a 2 a 2 a 2 a 2
ngh
I
n g ho Network 1 //Scale theh
n g PVo to a normalized real number:
n g ho
N
T
T u do T u oConvert the double integer to a real number. udo
//1. Convert
d//2. the integer value to a double integer.

//3. Normalize the value. T


0
//4. Store the normalized PV in the loop table.
LD SM0.0
ITD AIW0, AC0

. co m .c o m DTR AC0, AC0


. c o m
24 24
/R 32000.0, AC0
a24 2 4.
hoa hoa a
MOVR AC0, VD100

ng g gho ng ho
Tu don Network 2
LD u 0
TVB100,
I0.0
do n
//Execute the loop when placed in auto mode.

Tu d o
PID

Network 3 //Scale the Output Mn to an integer.

.co m .co m .co m


//Mn is a unipolar value and cannot be negative.
//1. Move the loop output to the accumulator.
.
6 2 4 2 4 2 4
//2. Scale the value in the accumulator.
24
g hoa gh o a
gh o a
//3. Convert the real number to a double integer.
g h o a
n d o n d o n
//4. Convert the double integer to an integer.
//5. Write the value to the analog output.
d on
Tu LD
MOVR
u
TVD108,
SM0.0
AC0
T u
*R 32000.0, AC0
ROUND AC0, AC0

om m m
DTI AC0, AC0

4 .c 4 .co MOVW AC0, AQW0


4 .co 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
154
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .c om 4. c om .
o a2 Interrupt Instructions
o a2 o a2 o a 24
ng h h
ng and Disable Interrupt dong h g h
Enable d o
Interrupt d on
TuEnable Interrupt instruction (ENI) globally enables
The Tu processing of T u
all attached interrupt events. The Disable Interrupt instruction (DISI)
globally disables processing of all interrupt events.

. co m o m
When you make the transition to RUN mode, interrupts are initially
.c . c o m
24 24
disabled. In RUN mode, you can enable interrupt processing by
a24 2 4.
hoa hoa ho ho a
executing the Enable Interrupt instruction. Executing the Disable

ng don
g
active interrupt events will continue to be queued. n g
Interrupt instruction inhibits the processing of interrupts; however,
do d ong
Tu
Error conditions that set ENO = 0: Tu Tu
H 0004 (attempted execution of ENI, DISI, or HDEF instructions in an
interrupt routine)

.co m .co m .co m


a 2 4 2 4
Conditional Return from Interrupt
a a 2 4 6a 2 4.
o o o gho
ngh gh gh
The Conditional Return from Interrupt instruction (CRETI) can be
o n o n
used to return from an interrupt, based upon the condition of the
d d o n
Tu
preceding logic.
Tu Tud
Attach Interrupt

om m m
The Attach Interrupt instruction (ATCH) associates an interrupt event

2 4 .c event.
24 .co
EVNT with an interrupt routine number INT and enables the interrupt
2 4 .co 2 4.
ng hoa ngh oa
Error conditions that set ENO = 0:
n gh o a
ng hoa
do d o o
Tud
H 0002 (conflicting assignment of inputs to an HSC)
Tu Tu
Detach Interrupt
The Detach Interrupt instruction (DTCH) disassociates an interrupt event EVNT from all interrupt routines

.com .co
and disables the interrupt event. m .co m .
o a24 a 2 4
ho for the Attach Interrupt and Detach Interrupt o a 2 4
o a 24
ngh g g hInstructions g h
Table 6-43 Valid Operands
n
o Data Types Operands udo n on
Tud d
Inputs/Outputs
INT BYTE T
Constant (0 to 127) T u
EVNT BYTE Constant CPU 221 and CPU 222: 0 to 12, 19 to 23, and 27 to 33
CPU 224: 0 to 23 and 27 to 33

.c o m . c o m CPU 226 and CPU 226XM:


. c o m 0 to 33

a2 4 a 2 4 Interrupt and Detach Interrupt a 2 4Instructions a 2 4.


o Operation of the o can be invoked, an association must
Attach
hbeoestablished between the interrupt ngho
ngh n g hroutine
dothe program segment that you want toTexecute n g
udowhen the event occurs. Use the Attach do
Before an interrupt

Tuand
event
instruction TuInterrupt
to associate an interrupt event (specified by the interrupt event number) and the program
segment (specified by an interrupt routine number). You can attach multiple interrupt events to one
interrupt routine, but one event cannot be concurrently attached to multiple interrupt routines.

.co m .co m om
When you attach an interrupt event to an interrupt routine, that interrupt is automatically enabled. If you
. c
a2 4 a 2 4 a2 4
disable all interrupts using the global disable interrupt instruction, each occurrence of the interrupt event is
a2 4.
o gho o
queued until interrupts are re-enabled, using the global enable interrupt instruction, or the interrupt queue
ho
ng h overflows.
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 155
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 omYou can disable individual interrupt4events


. c om by breaking the association between 4 the.c
om 4.
o a 2 a 2
o state. Table 6-44 lists the differentgtypes a 2 interrupt event and
a 2
ngh
the interrupt routine with the Detach
n g
interrupt to an inactive hignored
or
n hoof interrupt events.
Interrupt instruction. The Detach Interrupt instruction returns the
n g ho
do Events
TuInterrupt
Table 6-44 Tud
o
Tud
o
CPU 221 CPU 226
Event Description CPU 224
CPU 222 CPU 226XM

. co m 0 I0.0
. c o
Rising edge
m Y
om
Y 4.c Y
Y Y

24 1 I0.0
24
Falling edge
aY2 Y
Y
2 4.
ng hoa 2 I0.1
g h o a
Rising edge
h o Y
ho a
don ong Y ong
Tud d
3 I0.1 Falling edge Y Y
4 TuI0.2 Rising edge Y Y YTu
5 I0.2 Falling edge Y Y Y
6 I0.3 Rising edge Y Y Y

.co m 7 I0.3
c o m
Falling edge
. Y
. c Ym
o Y
.
6 2 4 4
2 character 4
aY2 Y 24
oa aReceive a
8 Port 0 Y

n g h 9 Port 0
n g ho Transmit complete n gh oY Y Y
g h o
u dointerrupt 0 SMB34 d o d on
Tu u
10 Timed Y Y Y
11 T Timed interrupt 1 SMB35 Y Y T
Y
12 HSC0 CV=PV (current value = preset value) Y Y Y
13 HSC1 CV=PV (current value = preset value) Y Y

4 .c om 14 HSC1 Direction c
4 . om
changed
4 . c oY m Y
4.
2 2 reset a2 Y 2
hoa oaExternal o hoa
15 HSC1 Y

ng 16 HSC2 h
ng Direction
CV=PV (current value = preset value)
ng h Y Y
ng
u d o u d o Y ud
o
17
18
T HSC2
HSC2
changed
External reset
T Y
Y
T
Y
19 PLS0 PTO pulse count complete interrupt Y Y Y

om om oY m
20 PLS1 PTO pulse count complete interrupt Y Y Y

2 4 . c 21 Timer T32 CT=PT .


2 4 c
interrupt Y
4
2 Y.c Y
24.
ng hoa 22 Timer T96
g hoaCT=PT interrupt g hoaY Y
g h o a
23
donPort 0
24 TuPort 1
Receive message complete
Receive message completeTu
don Y Y Y
YTu
don
25 Port 1 Receive character Y
26 Port 1 Transmit complete Y

.c o m 27 HSC0
. c o m
Direction changed Y
. c Ym
o Y
.
o a24 28 HSC0
24
External reset
oaCV=PV (current value = preset value) ghoaY
Y
24 Y Y
oa 24
ngh g h gh
29 HSC4 Y Y
30
u d on
HSC4 Direction changed
u d on Y Y Y
udo
n
31 T HSC4 External reset T Y Y YT
32 HSC3 CV=PV (current value = preset value) Y Y Y
33 HSC5 CV=PV (current value = preset value) Y Y Y

4 .c om .com .com 4.
2 24 24 2
ng hoa gh oa
gh o a
ng ho a
u d on u d on d o
T T Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
156
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
S7-200 Instruction Set Chapter 6

4 .c om Understanding How the4.S7-200 c om Processes Interrupt Routines 4 . c om 4.


o a 2 a 2
ois executed in response to an associatedginternala 2
o or external event. Once the last gho a 2
ngh d
instruction of g
the
hinterrupt
The interrupt routine
n
oby executing a Conditional Return fromuInterrupt
routine has been
d
executed, n
control is
hreturned
o instruction (CRETI). d
to the main program. You can n
oexit
u
T guidelines and restrictions for using interrupt
the routine
some T routines in your program. T u
Table 6-45 emphasizes

Table 6-45 Guidelines and Restrictions for Using Interrupt Routines

. co m Guidelines
. c o m . c o m
a 24 a 4 and
2task,
Interrupt processing provides quick
a 2
reaction to special internal or external events. You 4 should optimize interrupt a2 4.
o routines to perform a o
ho ho
ngh h specific then return control to the main routine.
n
By keeping the g
interrupt routines short and to the point, executionn
o of time. If this is not done, unexpected conditions is g
quick and other processes are not deferred for ng
o cause abnormal operation of equipment controlled o
Ttheudmain program.
long periods
by Tudthecanbetter,’’
For interrupts, the axiom, ‘‘the shorter, is definitely true. Tud
Restrictions
You cannot use the Disable Interrupt (DISI), Enable Interrupt (ENI), High-Speed Counter Definition (HDEF), and End

4 .c om 4 .co m
(END) instructions in an interrupt routine.
4 .co m
4.
2 2 2 6 2
ng hoa n gh o a
System Support for Interrupts
n gh o a
n gho
a
o o
Because contact, coil, and accumulator logic can be affected by interrupts, the system saves and reloads
d d o
Tu Tu
the logic stack, accumulator registers, and the special memory bits (SM) that indicate the status of
accumulator and instruction operations. This avoids disruption to the main user program caused by Tud
branching to and from an interrupt routine.

4 .c om 4 .co m
Sharing Data Between the Main Program and Interrupt Routines
4 .co m
You can share data between the main program and one or more interrupt routines. Because it is not 4.
2 2 2 2
ng hoa ngh oa
n gh o a
possible to predict when the S7-200 might generate an interrupt, it is desirable to limit the number of
variables that are used by both the interrupt routine and elsewhere in the program. Problems with the
ng hoa
do d o o
Tud
consistency of shared data can result due to the actions of interrupt routines when the execution of
Tu Tu
instructions in your main program is interrupted by interrupt events. 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.

om m m
There are a number of programming techniques you can use to ensure that data is correctly shared

2 4 . c 2 4 .co 2 4 .co
between your main program and interrupt routines. These techniques either restrict the way access is
made to shared memory locations or prevent interruption of instruction sequences using shared memory 24 .
ng hoa locations.
n g ho a
n g ho a
g h o a
d o
- For d o If the shared data is a single byte, word,doron
Tudouble u in STL, then correct shared access canTbeu
an STL program that is sharing a single variable:
word variable and your program isT written
ensured by storing the intermediate values from operations on shared data only in non-shared
memory locations or accumulators.

.c o m -
. c m . c m
For a LAD program that is sharing a single variable: If the shared data is a single byte, word, or
o o
double word variable and your program is written in LAD, then correct shared access can be
.
o a24 hoa
24
hoa
24
ensured by establishing the convention that access to shared memory locations be made using
oa 24
ngh gh
only Move instructions (MOVB, MOVW, MOVD, MOVR). While many LAD instructions are
on g on g
composed of interruptible sequences of STL instructions, these Move instructions are composed of
o n
T u d T u d
a single STL instruction whose execution cannot be affected by interrupt events.
Tud
- For an STL or LAD program that is sharing multiple variables: If the shared data is composed of a
number of related bytes, words, or double words, then the interrupt disable/enable instructions (DISI
and ENI) can be used to control interrupt routine execution. At the point in your main program where

.co m .co m om
operations on shared memory locations are to begin, disable the interrupts. Once all actions
. c
a2 4 a 2 4 a2 4
affecting the shared locations are complete, re-enable the interrupts. During the time that interrupts
are disabled, interrupt routines cannot be executed and therefore cannot access shared memory
a2 4.
o gho o ho
ng h gh ng
locations; however, this approach can result in delayed response to interrupt events.

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 157
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
S7-200 Programmable Controller System Manual

4 .c omCalling Subroutines from Interrupt 4 .c m


oRoutines 4. c om 4.
o a 2 a 2 a 2 a 2
ngh
You can call one
n g hoan interrupt routine and a subroutine that
nesting level of subroutines from an interrupt
ish
routine.
n g o
The accumulators and the logic
n g ho
udo udo udo
stack are shared between called.

T
Types of Interrupts Supported by the S7-200
T T
The S7-200 supports the following types of interrupt routines:

. co m- o m o m
Communications port interrupts: The S7-200 generates events that allow your program to control
.c . c
24 the communications port.
24 a24 2 4.
ng hoa -
hoa ho
I/O interrupts: The S7-200 generates events for different changes of state for various I/O. These
g g ng ho a
don do n o
events allow your program to respond to the high-speed counters, the pulse outputs, or to rising or

Tu
falling states of the inputs.
Tu Tu d
- Time-based interrupts: The S7-200 generates events that allow your program to react at specific
intervals.

.co mCommunications Port Interrupts . c om . c m


omode
6 2 4 The serial communications port of4
2 Freeport mode. In Freeport mode, youroprogram
the 4
2 defines theofbaud
S7-200 can be controlled by your program. This operating
2 4.
g hoa g
a
the communications port isocalled a
h are available to facilitate your ngho
hand protocol. The Receive and Transmitninterrupts
g
rate, a
n n
bits per character, parity,
o communications. Refer to the Transmitud oReceive instructions for more information. o
Tud Tud
program-controlled and
T
I/O Interrupts
I/O interrupts include rising/falling edge interrupts, high-speed counter interrupts, and pulse train output

4 .c om m m
interrupts. The S7-200 can generate an interrupt on rising and/or falling edges of an input (either I0.0, I0.1,
.co .co
I0.2, or I0.3). The rising edge and the falling edge events can be captured for each of these input points.
4 4 4.
o a2 oa 2
ho a 2
These rising/falling edge events can be used to signify a condition that must receive immediate attention
hoa 2
ngh h
when the event happens.
n g n g ng
docounter
Tuvalue,
The high-speed
the preset
do such
Tucorrespond
interrupts allow you to respond to conditions
a change in counting direction that might
as the current value reaching do
Tu
to a reversal in the direction in
which a shaft is turning, or an external reset of the counter. Each of these high-speed counter events
allows action to be taken in real time in response to high-speed events that cannot be controlled at
programmable logic controller scan speeds.

.co mThe pulse train output interrupts provide


.c m notification of completion of outputting
oimmediate .c om
a 2 4 number of pulses. A typical use2
a 4
of pulse train outputs is stepper motor control.2
a 4 the prescribed
a 2 4.
o ho o to the related I/O event. ho
ngh n g n g hroutine n g
udo udo udo
You can enable each of the above interrupts by attaching an interrupt

T
Time-Based Interrupts
T T
Time-based interrupts include timed interrupts and the timer T32/T96 interrupts. You can specify actions to
be taken on a cyclic basis using a timed interrupt. The cycle time is set in 1-ms increments from 1 ms to

.c o m o m o m
255 ms. You must write the cycle time in SMB34 for timed interrupt 0, and in SMB35 for timed interrupt 1.
. c . c
a2 4 a 2
The timed interrupt event transfers 4control to the appropriate interrupt routineaeach
2 4 time the timer expires. a 2 4.
o o to control the sampling of analogginputs hoor to execute a PID loop at ho
ngh
Typically, you use timedh
regular intervals. ng g
interrupts
n n
A timedT
udo
interrupt is enabled and timing begins when you
doan interrupt routine to a timed interrupt
Tuattach Tud
o
event. During the attachment, the system captures the cycle time value, so subsequent changes to
SMB34 and SMB35 do not affect the cycle time. To change the cycle time, you must modify the cycle time
value, and then re-attach the interrupt routine to the timed interrupt event. When the re-attachment occurs,

.co m .co m com


the timed interrupt function clears any accumulated time from the previous attachment and begins timing
.
a2 4 with the new value.
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
158
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2 o 2 o a2
After being enabled, the timed interrupt runs continuously, executing the attached interrupt routine on each
a
expiration of the specified time interval. If you exit RUN mode or detach the timed interrupt, the timed
o a 24
ngh n gh n gh on
interrupt is disabled. If the global disable interrupt instruction is executed, timed interrupts continue to
o o g h
T ud
full). T ud T u d
occur. Each occurrence of the timed interrupt is queued (until either interrupts are enabled or the queue is

The timer T32/T96 interrupts allow timely response to the completion of a specified time interval. These
interrupts are only supported for the 1-ms resolution on-delay (TON) and off-delay (TOF) timers T32 and

. co m .c m . c o m
T96. The T32 and T96 timers otherwise behave normally. Once the interrupt is enabled, the attached
o
24
interrupt routine is executed when the active timer’s current value becomes equal to the preset time value
24 a24 2 4.
hoa hoa a
during the normal 1-ms timer update performed in the S7-200. You enable these interrupts by attaching an

ng
interrupt routine to the T32/T96 interrupt events.
g gho ng ho
Tu don
Interrupt Priority and Queuing Tu do n
Tu d o
Interrupts are serviced by the S7-200 on a first-come-first-served basis within their respective priority
group. Only one user-interrupt routine is ever being executed at any point in time. Once the execution of
an interrupt routine begins, the routine is executed to completion. It cannot be pre-empted by another
.co m .co m .co m
4.
interrupt routine, even by a higher priority routine. Interrupts that occur while another interrupt is being

a 2 4 2 4
processed are queued for later processing.
a a 2 4 6a 2
o o o gho
ngh n gh n gh
Table 6-46 shows the three interrupt queues and the maximum number of interrupts they can store.
d o d o o n
Tu6-46
Table u
TQueue
Maximum Number of Entries per Interrupt Tud
Queue CPU 221, CPU 222, CPU 224 CPU 226 and CPU 226XM
Communications queue 4 8

4 .c om I/O Interrupt queue


4 .co m 16
4 .co m16
4.
o a2 Timed Interrupt queue
oa 2 8
o a 2 8
hoa 2
ngh n g hinterrupts can occur than the queue can n
dothe type of interrupt events that haveTbeen
Potentially, more g hTherefore, queue overflow memory bits ng
o are maintained by the system. Table u6-47do
hold.
dlost)
T u
(identifying u
shows the interrupt queue overflow bits. You should use these bits only in an interrupt routineT
because
they are reset when the queue is emptied, and control is returned to the main program.

Table 6-48 shows all interrupt events, with their priority and assigned event number.

.com .co m .co m .


a24 2 4 2 4 24
Table 6-47 Interrupt Queue Overflow Bits
o ho a o a o a
ngh g gh g h
Description (0 = No Overflow, 1 = Overflow) SM Bit
n
do queuequeue
Communications
d o n SM4.0
d on
TuInterrupt
I/O Tu SM4.1 T u
Timed Interrupt queue SM4.2

.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 159
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 omTable 6-48 4 .co m


4. c om .
oa2 2
Priority Order for Interrupt Events
o a a2 a 24
ngh
Event
gh
Description
g ho Group
Priority Priority in Group
g h o
Port 0 on n on
8
9
ud0
TPort
Receive character
Transmit complete T udo Highest Priority
Communications 0
0 T u d
23 Port 0 Receive message complete 0
24 Port 1 Receive message complete 1

.com 25 Port 1
.c o m
Receive character
. c o m 1
4.
o a24 26 Port 1
o a 24complete
Transmit
o a 24 1
ho a2
ngh 19 PLS0
o n gh PTO pulse count complete interrupt ongDiscrete
h 0
ong
20 ud
TPLS1 Tud
PTO pulse count complete interrupt
Medium Priority
1
Tu d
0 I0.0 Rising edge 2
2 I0.1 Rising edge 3

om om om
4 I0.2 Rising edge 4

6a2 4 .c 6 I0.3
4 .c
Rising edge
2 2 4 . c 5
24 .
ho 1 I0.0 a edge
hoFalling hoa 6
h o a
ng 3
don
I0.1 g Falling edge
don
g 7
d on g
5 u
TI0.2 Falling edge Tu 8 T u
7 I0.3 Falling edge 9
12 HSC0 CV=PV (current value = preset value) 10

4 .c om 27 HSC0
.co
Direction changed
4
m
4 .co m 11
4.
o a2 28 HSC0
oa 2
External reset
o a 2 12
hoa 2
ngh 13 HSC1
o ng h CV=PV (current value = preset value)
o n gh 13
o ng
14
15
ud
HSC1
THSC1
Direction changed
External reset Tu d 14
15 Tud
16 HSC2 CV=PV (current value = preset value) 16
17 HSC2 Direction changed 17

4 .com 18 HSC2
4 .c
External resetom 4 .c om 18
24.
oa2 32 HSC3
o a2 (current value = preset value)
CV=PV
o a2 19
o a
ngh 29 HSC4 ng
d o
h CV=PV (current value = preset value)
d o ng h 20
d on g h
30 u
THSC4 Direction changed
Tu 21
T u
31 HSC4 External reset 22
33 HSC5 CV=PV (current value = preset value) 23

.c o m 10 Timed interrupt 0 SMB34


. c o m Timed
. c o m 0
.
a24 24 24 24
Lowest Priority
11 Timed interrupt 1 SMB35 1
o a interrupt
hoCT=PT hoa oa
ngh g g gh
21 Timer T32 2
22
Tu don
Timer T96 CT=PT interrupt
Tu don 3
Tud
o n

.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
160
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
S7-200 Instruction Set Chapter 6

4 .c omExample: Interrupt Instructions 4.com 4 . c om 4.


o a 2 a 2 a 2 a 2
ngh
M
n g ho Network 1 //On the first scan:
n g ho
routine INT_0 to be a falling-edge interrupt for I0.0ng
ho
A
I
T u do T u
//2. Globally
o interrupts.
denable
//1. Define interrupt

T u do
N LD SM0.1
ATCH INT_0, 1
ENI

. co m .c o m
Network 2 //If an I/O error is detected,
. c o m
24 24 a24
//disable the falling-edge interrupt for I0.0.
2 4.
hoa hoa a
//This network is optional.

ng g LD SM5.0
gho ng ho
Tu don DTCH
Network 3
1

Tu do n
//When M5.0 is on,
Tu d o
//disable all interrupts.
LD M5.0
DISI

.co m .co m .co m


a 2 4 a 2 4 a 2 4 6a 2 4.
o o o gho
ngh d o n gh
d o n gh o n
I
N Tu Network 1
Tu
//I0.0 falling-edge interrupt routine:
//Conditional return based on an I/O error. Tud
T LD SM5.0
0 CRETI

4 .c om 4 . c om 4 . c om 4.
h o a2 o a2 the Value of an Analog Input
Example: Timed Interrupt for Reading
h h o a2 hoa 2
ng M
d o ng Network 1
ng subroutine 0.
//On the first scan, call
d o o ng
Tu u Tud
A
SBR_0 T
LD SM0.1
I CALL
N

S Network 1 //1. Set the interval for the timed interrupt 0 to 100 ms.

.co m B
.co m .co m
//2. Attach timed interrupt 0 (Event 10) to INT_0.
.
a 2 4 R
0
a 2 4 //3. Global interrupt enable.
a 2 4 a 24
o o LD SM0.0
o o
ngh o n gh MOVB 100, SMB34
o n gh on g h
Tud d d
ATCH INT_0, 10
ENI
Tu T u

.c o m . c o m . c o m .
o a24 hoa
24
hoa
24 oa 24
ngh I
d on g Network 1
on g
//Read the value of AIW4 every 100 ms
d o n gh
N
T T u LD
MOVW
SM0.0
AIW4, VW100T u Tud
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 161
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 Logical Operations
a2
Instructions
o o a2 o a 24
ng h ng h n gh g h
u d o
Invert Instructions
ud o u d on
Invert T
Byte, Word, and Double Word T T
The Invert Byte (INVB), Invert Word (INVW), and Invert Double Word
(INVD) instructions form the one’s complement of the input IN and

. co m .c m
load the result into the memory location OUT.
o . c o m
a 24 Error conditions that set ENO
H 0006 (indirect address) oa
= 0
24 a24 a2 4.
o ho ho
ngh o n gh
do n g ong
ud
SM bits affected:
H SM1.0T(zero) Tu Tu d

.co m .co m .co m .


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

4 .c om 4 .co m
4 .co m
4.
o a2 oa 2 o a 2
hoa 2
ngh Table 6-49
ngh
Valid Operands for the Invert Instructions
o
d Data Types d o n gh o ng
IN
T u
Inputs/Outputs
BYTE
Operands
Tu
IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *LD, *AC, Constant
Tud
WORD IW, QW, VW, MW, SMW, SW, T, C, LW, AC, AIW, *VD, *LD, *AC, Constant
DWORD ID, QD, VD, MD, SMD, SD, LD, AC, HC, *VD, *LD, *AC, Constant

.com OUT BYTE


. c om .c
IB, QB, VB, MB, SMB, SB, LB, AC,*VD, *LD, *ACom .
o a24 WORD
o
4
a2IW, 4
a*AC2 *AC
QW, VW, MW, SMW, SW, T, C, LW, AC, *VD, *LD,
o o a 24
ngh d o ng
DWORDh ID, QD, VD, MD, SMD, SD, LD, AC, *VD,h

d o ng *LD,

d on g h
Tu
Example: Invert Instruction
Tu T u
Network 1

.c o m . c o mINVW LD I4.0
AC0
. c o m .
o a24 hoa
24 Invert Word 24
hoa 1101 0111 1001 0101
AC0
oa 24
ngh d on g
d on g complement
o n gh
T u T u AC0 0010 1000 0110 1010
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
162
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
S7-200 Instruction Set Chapter 6

4 .c om AND, OR, and Exclusive 4 .c om 4. c om .


o a2 o a2 OR Instructions
o a2 o a 24
ng h h
g Word, and AND Double Word ong
AND Byte,nAND h g h
Theu d o dDouble Word d on
T ANDinstructions
(ANDD) Tofutwo
Byte (ANDB), AND Word (ANDW), and AND
AND the corresponding bits input values T u
IN1 and IN2 and load the result in a memory location OUT.

. co m OR Byte, OR Word and OR Double Word


.c o m . c o m
24 24
The OR Byte (ORB), OR Word instruction (ORW), and OR Double
a24 2 4.
hoa hoa a
Word (ORD) instructions OR the corresponding bits of two input

ng g gho
values IN1 and IN2 and load the result in a memory location OUT.
n n ng ho
T u do OR Byte, Exclusive OR Word,Tand
Exclusive u do Tu d o
Exclusive OR Double Word
The Exclusive OR Byte (XROB), Exclusive OR Word (XORW), and
Exclusive OR Double Word (XORD) instruction XOR the

.co m .co m
corresponding bits of two input values IN1 and IN2 and load the
.co m
a 2 4 a 2 4
result in a memory location OUT.
a 2 4 6a 2 4.
o o o gho
ngh SM Bitso n g
and ENO
h
o n g h
o n
Tualldof the instructions described on this page,Tthe
For
conditions affect SM bits and ENO.
udfollowing Tud
Error conditions that set ENO = 0

4 .c om H 0006 (indirect address)

4 .co m
4 .co m
4.
o a2 SM bits affected:
oa 2 o a 2
hoa 2
ngh do gh
H SM1.0 (zero)
n d o n gh o ng
Tu Tu Tud

.co m .c om .c om .
a 2 4 4
a2for the AND, OR, and Exclusive OR Instructionsa2 4 a 24
o o o o
ngh h h h
Table 6-50 Valid Operands

d o ng Data Types Operands


Inputs/Outputs
d o ng d on g
TuIN2
IN1, BYTE IB, QB, VB, MB,T u SB, LB, AC, *VD, *LD, *AC, Constant
SMB, T u
WORD IW, QW, VW, MW, SMW, SW, T, C, LW, AC, AIW, *VD, *LD, *AC, Constant
DWORD ID, QD, VD, MD, SMD, SD, LD, AC, HC, *VD, *LD, *AC, Constant

.c o m OUT
. c
IB, m
o
BYTEQB, VB, MB, SMB, SB, LB, AC, *VD, *AC, *LD
. c o m .
a24 24 ID, QD, VD, MD, SMD, SD, LD, AC, o*VD,a*AC,
24*LD 24
WORD
IW, QW, VW, MW, SMW, SW, T, C, LW, AC, *VD, *AC, *LD
o o a oa
ngh gh gh gh
DWORD

o n o n o n
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 163
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
oExample: . c om . c om .
a2 4 4
a2 Network 1
AND, OR, and Exclusive OR Instructions
a2 4 a 24
h o h o h o h o
ng d o ng LD I4.0
d ong d on g
Tu Tu
ANDW AC1, AC0
ORW AC1, VW100
T u
XORW AC1, AC0
AND Word OR Word

24 .com 24 .com
AC1 0001 1111 0110 1101
. c o m
AC1 0001 1111 0110 1101
4.
a24 2
AND OR

h o a h o a AC0 1101 0011 1110 0110


ho VW100 1101 0011 1010 0000
ho a
ng don
g equals
do n g equals
d ong
Tu Tu
AC0 0001 0011 0110 0100
Tu
VW100 1101 1111 1110 1101

Exclusive OR Word
AC1 0001 1111 0110 1101

.co m .co m XOR


.co m .
6 2 4 2 4 4
AC0 0001 0011 0110 0100
2 24
g hoa gh o a
gh o a
equals
g h o a
n d o n d o n
AC0 0000 1100 0000 1001
d on
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 .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
164
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .c om 4. c om .
o a2 Move Instructions
o a2 o a2 o a 24
ng h h
g Double Word, or Real ong
nWord, h g h
Move Byte,
d o
uMove Byte (MOVB), Move Word (MOVW),TMoveudDouble Word u d on
T
The
(MOVD), and Move Real (MOVR) instructions move a value from a
T
memory location IN to a new memory location OUT without
changing the original value.

. co m .c o m . c o m
24 24
Use the Move Double Word instruction to create a pointer. For more
a24 2 4.
hoa hoa a
information, refer to the section on pointers and indirect addressing

ng
in Chapter 4.
n g n g ho ng ho
For thed o Move instruction, the input and outputudataotypes can o
Tubut must be of the same size. T d Tu d
IEC
vary,
Error conditions that set ENO = 0
H 0006 (indirect address)

.co m .co m .co m


a 2 4 a 2 4 a 2 4 6a 2 4.
o o o gho
ngh d o n gh
d o n gh o n
Tu Tu Tud

4 .c om 4 .co m
4 .co m
4.
o a2 oa 2
ho a 2
hoa 2
ngh n g h
Table 6-51o Valid Operands for the Move Instructions
d do n g o ng
T u
Inputs/Outputs Data Types Operands T u Tud
IN BYTE IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *LD, *AC, Constant
WORD, INT IW, QW, VW, MW, SMW, SW, T, C, LW, AC, AIW, *VD, *AC, *LD, Constant

4.com . c omID,
DWORD, DINT
4 . c om&VB, &MB, &SB, &T,
QD, VD, MD, SMD, SD, LD, AC, HC, &IB, &QB,
4 4.
a2 2 2 2
&C, *VD, *LD, *AC, Constant

h o o
hBYTE
REALa ID, QD, VD, MD, SMD, SD, LD, a
hLB,oAC, *VD, *LD, *AC
AC, *VD, *LD, *AC, Constant
ho a
n g n g
o WORD, INT n g n g
Tud
OUT
IW, QW, TVW,u
do
IB, QB, VB, MB, SMB, SB,
MW, SMW, SW, T, C, LW, AC, AQW, *VD, *LD, *ACT udo
DWORD, DINT, REAL ID, QD, VD, MD, SMD, SD, LD, AC, *VD, *LD, *AC

.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 165
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 Move Byte Immediate
o a2 allow you to immediately hoa2
(Read and Write)
o a 24
ng h h
ngthe physical I/O and a memory location. ng g h
on
The Move Byte Immediate instructions
d o
move a byte between
d o d
TuByte Immediate Read (BIR) instruction readsTuphysical
The Move T u
input (IN) and writes the result to the memory address (OUT), but
the process-image register is not updated.

. co mThe Move Byte Immediate Write instruction


.c o m (BIW) reads the data
. c o m
a 24 from the memory address (IN)
a
and4 location.
2image
writes to physical output (OUT),
a 24 a2 4.
o o
and the corresponding process
o ho
ngh o n
Error conditions that ghENO = 0
set
o n gh ong
T udaddress)
H 0006 (indirect
T ud Tu d
H Unable to access expansion module

.co mTable 6-52 .c om


Valid Operands for the Move Byte Immediate Read Instruction
. c om .
6 2 4 Inputs/Outputs Data Types a2
4 a2 4 24
g hoa h o Operands
h o h o a
n IN
d o ng
BYTE IB, *VD, *LD, *AC
d o ng d on g
OUT
Tu BYTE Tu SB, LB, AC, *VD, *LD, *AC
IB, QB, VB, MB, SMB,
T u
Table 6-53 Valid Operands for the Move Byte Immediate Write Instruction

4 .c om Inputs/Outputs 4 . c om
Data Types
Operands
4 . c om 4.
2 a2 IB, QB, VB, MB, SMB, SB, LB, AC,h*VD,a*LD,2*AC, Constant 2
hoa o o hoa
IN BYTE

ng OUT
ng
BYTE h QB, *VD, *LD, *AC
ng ng
do d o o
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
166
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
S7-200 Instruction Set Chapter 6

4 .c om Block Move Instructions 4 .c om 4. c om .


o a2 o a2 or Double Word o a2 o a 24
ng h ng h ng h g h
on
Block Move Byte, Word,
d o d o d
TuDouble Word (BMD) instructions move a Tspecified
The Block
Move
u amount of
Move Byte (BMB), Block Move Word (BMW), and Block
T u
data to a new memory location by moving the number of bytes,
words, or double words N starting at the input address IN to a new
block starting at the output address OUT.

. co m .c o m . c o m
24
N has a range of 1 to 255.
24 a24 2 4.
ng hoa hoa
Error conditions that set ENO = 0
g gho ng ho a
Tu don
H 0006 (indirect address)
H 0091 (operand out of range) Tu do n
Tu d o

.co m .co m .co m


a 2 4 a 2 4 a 2 4 6a 2 4.
o o o gho
ngh d o n gh
d o n gh o n
Tu Tu Tud

4 .c om 4 .co m
4 .co m
4.
o a2 oa 2 o a 2
hoa 2
ngh n g h
Table 6-54o Valid Operands for the Block Move Instructions o n g h
o ng
Tud
Inputs/Outputs Data Types Operands T
ud Tud
IN BYTE IB, QB, VB, MB, SMB, SB, LB, *VD, *LD, *AC
WORD, INT IW, QW, VW, MW, SMW, SW, T, C, LW, AIW, *VD, *LD, *AC

4 . c om c o mQD, VD, MD, SMD, SD, LD, *VD, *LD, *AC.com


DWORD, DINT
. ID,
4.
2 BYTE 24 IB, QB, VB, MB, SMB, SB, LB, *VD, *LD,2 4 2
o a OUT
a a *AC
o INT IW, QW, VW, MW, SMW, SW,gT,hC,oLW, AQW, *VD, *LD, *AC ho a
ngh o n g hWORD, n
doSB, LB, AC, Constant, *VD, *LD, *AC Tudo n g
Tud
DWORD, DINT ID, QD, VD, MD, SMD, SD, LD, *VD, *LD, *AC
N BYTE TuSMB,
IB, QB, VB, MB,

Example: Block Move Instruction

.c o m . c o m Network 1 . c o m .
2 4 24 24
//Move array 1 (VB20 to VB23)
24
hoa hoa hoa a
//to array 2 (VB100 to VB103)

gh o
ng don
g LD

d o ng
I2.1
o n
Tud
BMB VB20, VB100, 4

Tu Tu VB20
30
VB21
31
VB22
32
VB23
33
Array 1

VB100 VB101 VB102 VB103

.co m .co m Array 2 30 31


. com 32 33

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 167
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 Program Control
a2
Instructions
o o a2 o a 24
ng h ng h ng h g h
Conditional End
d o d o d on
Tu End instruction (END) terminates theTcurrent
The Conditional u scan
based upon the condition of the preceding logic. You can use the
T u
Conditional End instruction in the main program, but you cannot use
it in either subroutines or interrupt routines.

. co m .c o m . c o m
24 Stop 24 a24 2 4.
ng hoa g h oaterminates the execution of your gho
The Stop instruction (STOP)
ng ho a
d ona transition of the S7-200 CPU fromuRUN
program by causing
u d oton d o
T
STOP mode.
T Tu
If the Stop instruction is executed in an interrupt routine, the interrupt
routine is terminated immediately, and all pending interrupts are
ignored. Remaining actions in the current scan cycle are completed,

4 .c om .c om
including execution of the main user program, and the transition
4 4 . c om 4.
o6a 2 o a 2
from RUN to STOP mode is made at the end of the current scan.
o a 2 o a 2
ngh Watchdog Reset
d o n g h
d o n g h
d o n g h
T u T u
The Watchdog Reset instruction (WDR) retriggers the system watchdog timer of the S7-200 CPU toT u
extend the time that the scan is allowed to take without getting a watchdog error.

You should use the Watchdog Reset instruction carefully. If you use looping instructions either to prevent

.c omscan completion or to delay excessively them


until the scan cycle is completed: .co . c o mare inhibited
completion of the scan, the following processes

a 2 4 a 2 4 a 2 4 a 2 4.
o o Freeport Mode) ho ho
ngh
- Communications h (except
n g n g ng
T do (except Immediate I/O)
- I/O updating
u T u do T u do
- Force updating

- SM bit updating (SM0, SM5 to SM29 are not updated)

4 . c om - - Run-time diagnostics

4 .co m
4 .com .
2 2 2
10-ms and 100-ms timers will not properly accumulate time for scans exceeding 25 seconds
24
ng hoa -
g ho a
STOP instruction, when used in an interrupt routine
n n g ho a
ng h o a
d o modules with discrete outputs also includedao
watchdog timer that turns off outputs if the do
Tu is not written by the S7-200. Use an immediate
Tu write to each expansion module with Tu
- Expansion
module
discrete outputs to keep the correct outputs on during extended scan times. Refer to the example
that follows this description.

.c o m Tip . c o m . c o m
a2 4 If you expect your scan time
a
to
2 4for more than 500 ms, you should use the
exceed 500 ms, or if you expect a burst of
2 4 Reset
interrupt
a
activity that could
a 2 4.
o prevent returning to the o
main scan
ho Watchdog
ho
ngh n g
instruction to retrigger
Each timeu
h
the watchdog timer.
douse the Watchdog Reset instruction, you n g
do also use an immediate write to one udo n g
output T
you
byte (QB) in each discrete expansion module T
ushould
to reset each expansion module watchdog. T
If you use the Watchdog Reset instruction to allow the execution of a program that requires a long scan
time, changing the mode switch to the STOP position causes the S7-200 to transition to STOP mode

.co m within 1.4 seconds.


.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
168
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
o a2 o a 2
Example: Stop, End, and Watchdog Reset Instructions
o a2 o a 24
ngh gh gh g h
Network 1 //When an I/O error is detected:
on on on
ud Tud d
//Force the transition to STOP mode.

T LD
STOP
SM5.0
T u
Network 2 //When M5.6 is on, allow the scan to be extended:

.com .com o m
//1. Retrigger the Watchdog Reset for the S7-200.

24 24 . c 4.
a24
//2. Retrigger the watchdog for the first output module.

o a o a a2
ho ho
LD M5.6

ng h g h WDR
g ng
Tu don BIW QB2, QB2
do n
Tu//When I0.0 is on, terminate the current scan. Tu d o
Network 3
LD I0.0
END

.co m .co m .co m


a 2 4 a 2 4 a 2 4 6a 2 4.
o o o gho
ngh d o n gh
d o n gh o n
Tu Tu Tud

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 169
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
oFor–Next . c om . c om .
a2 4 Loop Instructions 2 4
a(NEXT) a2 4 a 24
h o h o h o h o
ng Use the For (FOR)
that is repeatedo
d
g
and Next instructions to delineate
d
a
o ng
fornthe specified count. Each For instruction requires
loop
d on g
Tu You can nest For–Next loops (placeTauFor–Next
a Next instruction.
loop within a For–Next loop) to a depth of eight.
T u
The For instruction executes the instructions between the For and

. co m .c m
the Next instructions. You specify the index value or current loop
o . c o m
4.
count INDX, the starting value INIT, and the ending value FINAL.
24 24 a24 2
ng hoa hoa
The Next instruction marks the end of the FOR loop.
g gho ng ho a
don
Error conditions that set ENO = 0

Tu
H 0006 (indirect address)
Tu do n
Tu d o
If you enable the For–Next loop, it continues the looping process
until it finishes the iterations, unless you change the final value from

.co m .co m
within the loop itself. You can change the values while the For–Next
.com .
6 2 4 4
loop is in the looping process. When the loop is enabled again, it
2 2 4 24
g hoa gh
a
copies the initial value into the index value (current loop number).
o gh o a
g h o a
n d o n
The For–Next instruction resets itself the next time it is enabled.
d o n d on
Tu Tu
For example, given an INIT value of 1 and a FINAL value of 10, the instructions between the For
instruction and the Next instruction are executed 10 times with the INDX value being incremented:
T u
1, 2, 3, ...10.

.c omIfinstructions
the starting value is greater than the final m
. c o c o m and
value, the loop is not executed. After each execution
the Next instruction, the INDX value is.incremented
of the

a 2 4 a
result is compared to the final value.4
between the For instruction
2
and
If the INDX is greater than the final value,2
a 4
the loop is terminated.
the
a 2 4.
o ho ho ho
ngh o n
If the top of stack is
your programd
1g
o
when your program enters the For–Next loop, n gthen the top of stack will be 1 when
o ng
Tu exits the For–Next loop. Tud Tud
Table 6-55 Valid Operands for the For and Next Instructions

om INDX oQW,mVW, MW, SMW, SW, T, C, LW, AC, *VD,4*LD,.c*AC


om
Inputs/Outputs Data Types Operands

2 4 . c 4 .
INT c
IW,
2 VW, IW, QW, MW, SMW, SW, T, C, LW, oAC,aAIW,
2 *VD, *LD, *AC, Constant 2 4.
o a INToa
ho a
ngh h h
INIT, FINAL

o n g o n g 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
170
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
o a2 2
Example: For–Next Loop Instructions
o a a2 a 24
ngh n gh n g
Network 1 ho I2.0 comes on, the outside loop
//When
ng h o
ud o 1
d o
u I2.0
//(arrow 1) is executed 100 times
d o
T TLD
FOR VW100, +1, +100
Tu
Network 2 //The inside loop (arrow 2) is executed twice

.com .com o m
//for each execution of the outside loop

24 24 . c 4.
a24
//when I2.1 is on.

o a o a 2
a2
ho ho
LD I2.1

ng h g h FOR
g VW225, +1, +2
ng
Tu don u 3do
TNetwork
n
//End of Loop 2.
Tu d o
NEXT

Network 4 //End of Loop 1 .

4 .c om 4 .c om NEXT
4 .co m
4.
2 2 2 6 2
ng hoa g hoa gh o a
gho
a
Tu don Tu d o n
Tud
o n

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

.com .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 171
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
oJump . c om . c om .
a2 4 Instructions 2 4
a(JMP) a2 4 a 24
h o h o h o h o
ng The Jump to
d
specified label No ng the program.
Label instruction
within
performs a branch to the
d ong d on g
Tuinstruction (LBL) marks the location of the jump
The Label Tu T u
destination N.
You can use the Jump instruction in the main program, in

. co msubroutines, or in interrupt routines. The


. c o m and its corresponding
Jump
. c o m
a 24 Label instruction must always
a 24a subroutine, or an interrupt
be located within the same segment
a 24 a2 4.
o o
of code (either the main program,
o ho
ngh routine).
o n gh
d from the main program to a label in either o n gh ong
Tuorjump
You cannot
subroutine
uda from a
Tjump
an interrupt routine. Likewise, you cannot Tu d
subroutine or interrupt routine to a label outside that subroutine or
interrupt routine.

.co mYou can use a Jump instruction within.canoSCRm segment, but the . c om .
6 2 4 a2 4
corresponding Label instruction must be located within the same
a2 4 24
g hoa SCR segment.
h o h o h o a
n d o ng d o ng d on g
Tu Tu u
Table 6-56 Valid Operands for the Jump Instructions
Inputs/Outputs Data Types Operands
T
N WORD Constant (0 to 255)

4 .c om 4 . c om 4 . c om 4.
h o a2 a2Network 1 //If the retentive data has hnotobeen
Example: Jump to Label Instruction
h o a2lost, Jump to LBL4 hoa 2
ng d o ng d o ng o ng
Tu Tu Tud
LDN SM0.2
JMP 4
Network 2
LBL 4

.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
172
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
S7-200 Instruction Set Chapter 6

4 .c om Sequence Control Relay 4 . c om Instructions 4. c om .


o a2 o a2 (SCR)
o a2 o a 24
ng h h
g provide you with a simple yet powerfulostate
ntechnique h
ngcontrol g h
SCR instructions
d o that fits naturally into a LAD,d d on
Tu Tu u
programming FBD, or STL
program. T
Whenever your application consists of a sequence of operations that
must be performed repetitively, SCRs can be used to structure your

. co m o m
program so that it corresponds directly to your application. As a
.c . c o m
24 24
result, you can program and debug your application more quickly
a24 2 4.
hoa hoa a
and easily.

ng g gho ng ho
don do n o
The Load SCR instruction (LSCR) loads the SCR and logic stacks

Tu Tu
with the value of the S bit referenced by the instruction N.
Tu d
The SCR segment is energized or de-energized by the resulting
value of the SCR stack. The value of the SCR stack is copied to the
top of the logic stack so that boxes or output coils can be tied directly

.co m .co m
to the left power rail without an intervening contact.
.co m
a 2 4 Restrictions a 2 4 a 2 4 6a 2 4.
o o o gho
ngh n gh
When using SCRs, be aware of the following restrictions:
d o d o n gh o n
TuYou
- cannot use the same S bit in more thanu
T onedoroutine.
example, if you use S0.1 in the main program,
For
not use it in Tud
a subroutine.
- You cannot jump into or out of an SCR segment; however, you

4 .c om 4 . om
can use Jump and Label instructions to jump around SCR
c 4 . c om 4.
2 athe2END instruction in an SCR segment.hoa2
segments or to jump within an SCR segment.
2
ng hoa - You cannot use
h o
nValidgOperands for the Sequence Control RelaydInstructions
ng ng hoa
d o o o
Tu Tu Tud
Table 6-57
Inputs/Outputs Data Types Operands
S_bit BOOL S

.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 173
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 omFigure 6-31 shows the S stack and4the.clogic


omstack and the effect of executing the4Load
. c m
oSCR 4.
o a 2 a 2 a 2 instruction.
a 2
ngh - The Loado n ho (LSCR) marks the beginning ofnangSCR
The following is true of Sequence
ginstruction
Control Relay instructions:
hosegment, and the SCR End n g ho
T u d (SCRE) marks the end of an SCR segment.
instruction
SCR
T u doAll logic between the Load SCR and theTudo
SCR End instructions are dependent upon the value of the S stack for its execution. Logic between
the SCR End and the next Load SCR instruction is not dependent on the value of the S stack.
- The SCR Transition instruction (SCRT) Load the value of Sx.y onto the SCR and logic stacks.

. co m c o m
provides the means to transfer control from
. . c o m
4.
S stack ivS Sx.y
24 2 4
an active SCR segment to another SCR
iv0 a2
4 S bit
2
hoa hoa o ho a
segment. Sx.y

ng on g o n ghiv1 iv1
ong
T d
Execution of the SCR Transition instruction
u
when it has power flow will reset the S bit Tud
Logic stack iv2
iv3
iv2
iv3 Tu d
of the currently active segment and will set iv4 iv4
the S bit of the referenced segment. iv5 iv5
Resetting the S bit of the active segment

.co m .co m
does not affect the S stack at the time the
iv6
iv7
. c om
iv6
iv7
.
6 2 4 4
SCR Transition instruction executes.
2 Before
a2 4 After
24
g hoa o a
Consequently, the SCR segment remains
gh gh
iv8
o iv8

g h o a
n d o n
energized until it is exited.
d o n
Figure 6-31 Effect of LSCR on the Logic Stack
d on
-
u u u
T Conditional SCR End instruction (CSCRE)Tprovides a means to exit an active SCR segment
The T
without executing the instructions between the Conditional SCR End and the SCR End instructions.
The Conditional SCR End instruction does not affect any S bit nor does it affect the S stack.

.c omInscan. . c oam . c omthe State 1


the following example, the first scan bit SM0.1 sets S0.1, which will be the active State 1 on the first

a 2 4 After a 2-second delay, T37 causes


a
SCR (S0.1) segment and activates 2 4 transition to State 2. This transition deactivates
the State 2 SCR (S0.2) segment.
a 2 4 a 2 4.
o ho ho ho
ngh o n g o n g o ng
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
174
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2 o a 2
Example: Sequence Control Relay Instruction
o a2 o a 24
ngh gh gh g h
Network 1 //On the first scan enable State 1.
on SM0.1 on on
T ud LD
S
Tu1d
S0.1,
T u d
Network 2 //Beginning of State 1 control region.
LSCR S0.1

. co m .c o m . c o m
24 2 4 Network 3 a24
//Control the signals for Street 1:
2 4.
ng hoa g hoa ho
//1. Set: Turn on the red light.
g ng ho a
don n
//2. Reset: Turn off the yellow and green lights.

Tu LD Tu
SM0.0
do
//3. Start a 2–second timer.
Tu d o
S Q0.4, 1
R Q0.5, 2
TON T37, +20

.co m .c om . c otom
a 2 4 a 2 4 Network 4
a 2 4
//After a 2 second delay, transition State 2.
6a 2 4.
o ho ho ho
ngh
LD T37

o n g SCRT S0.2
n g n g
Tud Network 5 Tu
do
//End of SCR region for State 1. Tud
o
SCRE

om om om
Network 6 //Beginning of State 2 control region.

2 4 .c 4 . c LSCR S0.2
4 . c 4.
hoa h oa2 h o afor2Street 2: hoa 2
ng ng gon the green light. g
Network 7 //Control the signals
//1. Set:n n
do d o Turn
o
Tu Tu //2.
LD
Start a 25–second timer.
SM0.0
Tud
S Q0.2, 1
TON T38, +250

.co m .c om .c otomState 3.
a 2 4 a 2 4 Network 8 //After a 25 second delay, transition

a 2 4 a 2 4.
o ho
LD T38
ho ho
ngh g g g
SCRT S0.3
o n n
doof SCR region for State 2. n
Tud Network 9
T u//End T udo
SCRE

.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 175
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 omDivergence Control 4 .c om 4 . c om 4.
o a 2 a 2 a 2 a 2
ngh
In many applications,
n g a
ho into multiple streams, all outgoingnstreams
single stream of sequential states must be
ho must be activated
split
g into two or more different streams.
n g ho
o
When a control stream diverges
o o
Tud This is shown in Figure 6-32.
simultaneously.
Tud Tud
State L

. co m .c o m . c o m
24 24 a24 2 4.
hoa hoa a
Transition Condition

ng g gho ng ho
Tu don State M Tu do n
State N Tu d o

.c o mFigure 6-32 Divergence of a Control Stream


.c om . c om
6a 2 4 a 2 4 a 2 4 a 2 4.
o htheostreams o by using multiple SCRT ho
ngh g g hfollowing g
The divergence of control can be implemented in an SCR program
n n n
udo udo udo
instructions enabled by same transition condition, as shown in the example.
T
Example: Divergence of Control Streams
T T
Network 1 //Beginning of State L control region.

om om m
LSCR S3.4

4 .c 4 . c 4 .co 4.
o a2 oa2 Network 2 ho a 2
hoa 2
ngh do ngh LD M2.3
n g
o to State M
d//Transition o ng
Tud
A I2.1

Tu SCRT
SCRT
S3.5
S6.5 Tu //Transition to State N

Network 3 //End of the State region for State L.

.co m .co
SCRE 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
Convergence Control

.c o m . c m o
streams merge into a single stream, theycare
. m
A situation similar to divergence control arises when two or more streams of sequential states must be
o
a2 4 merged into a single stream. When multiple
converge. When streams
a 2
converge, 4 all incoming streams must be complete
a 2 4
before the
said to
next state is
a 2 4.
o ho ho ho
ngh
executed. Figure 6-33 depicts the convergence of two control streams.
n g n g
oof control streams can be implementeduindanoSCR program by making the transition udo n g
from state uL todstate
The convergence
T T state M to state M’. When both SCR bits T
L’ and by making the transition from
representing L’ and M’ are true, state N can the enabled as shown in the following example.

.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
176
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
S7-200 Instruction Set Chapter 6

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

. co m .c o m State N
. c o m
24 24 a24 2 4.
ng hoa n g hoa n gho ng ho a
Figure 6-33o Convergence of a Control Stream o o
Tud Tud Tu d
Example: Convergence of Control Streams

4 .c om 4 .c om LSCR Network 1

4 .co m
//Beginning of State L control region

4.
2 2 S3.4
2 6 2
ng hoa g hoa gh o a
gho
a
don n n
Network 2 //Transition to State L’
d o o
Tu LD
uV100.5
SCRT T S3.5 Tud
Network 3 //End of SCR region for State L

om m om
SCRE

4 .c 4 .co 4 . c 4.
o a2 oa 2 Network 4 //Beginning of State2
o a M control region hoa 2
ngh o ngh LSCR S6.4
o ng h
o ng
Tud LD
d
T5u //Transition to State M’
Network
C50
Tud
SCRT S6.5

4 . c om .c o m Network 6 .co
//End of SCR region for State M m .
2 24 SCRE
2 4 24
ng hoa ng hoa n gh o a
g h o a
d o Network 7
d o //When both State L’ and State M’ are activated:
d on
Tu Tu u
//1. Enable State N (S5.0)
//2. Reset State L’ (S3.5)
//3. Reset State M’ (S6.5)
T
LD S3.5
A S6.5

.c o m . c o m S S5.0, 1
. c o m .
a24 24 24 24
R S3.5, 1

o hoa hoa oa
R S6.5, 1

ngh d on g
d on g o n gh
T u T u Tud

.com .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 177
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 omIn other situations, a control stream4might


.c obemdirected into one of several possible4control
. c om 4.
o a 2 a 2 condition comes true first. Such a situationais2
streams,
a 2
ngh n g
which shows an equivalenthoSCR program.
depending upon which transition
n g ho depicted in Figure 6-34,
n g ho
o udo udo
Tud T
State L
T

. co m .c o m . c o m
24 24
Transition Condition
a24
Transition Condition
2 4.
ng hoa g oaM
hState ghStateoN ng ho a
Tu don Tu do n
Tu d o
Figure 6-34 Divergence of a Control Stream, Depending on the Transition Condition

.co m .c om . c om .
6 2 4 a2 4 a2 4 24
g hoa o
Example: Conditional Transitions
h h o h o a
n d o ng Network 1
d o ngL control region
//Beginning of State
d on g
Tu LSCR S3.4
Tu T u
Network 2 //Transition to State M
LD M2.3

4 .c om 4 . c om SCRT S3.5

4 .co m
4.
o a2 oa2 Network 3 //Transition to State N
o a 2
hoa 2
ngh do ngh LD I3.3
d o n gh o ng
Tud
SCRT S6.5
Tu Network 4
Tu
//End of SCR region for State L
SCRE

.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
178
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .c om 4. c om .
o a2 Shift and Rotate
a2
Instructions
o o a2 o a 24
ng h h
g Shift Left Instructions ong
nand h g h
Shift Right
d o d by the shift
uShift instructions shift the input value IN rightToruleft u d on
T
The
count N and load the result in the output OUT.
T
The Shift instructions fill with zeros as each bit is shifted out. If the

.com m m
shift count (N) is greater than or equal to the maximum allowed (8 for
.c o
byte operations, 16 for word operations, and 32 for double word . c o 4.
a 24 24 a24 2
hoa a
operations), the value is shifted the maximum number of times for
h o ho ho
ng g g ng
the operation. If the shift count is greater than 0, the overflow

Tu don Tu do n
memory bit (SM1.1) takes on the value of the last bit shifted out. The
zero memory bit (SM1.0) is set if the result of the shift operation is
Tu d o
zero.
Byte operations are unsigned. For word and double word
operations, the sign bit is shifted when you use signed data types.

.co m .co m .co m


a 2 4 Error conditions that set ENO = 0

a
H 0006 (indirect address) 2 4 SM bits affected:
H SM1.0 (zero)
a 2 4 6a 2 4.
o o o gho
ngh d o n gh n gh
H SM1.1 (overflow)
d o o n
TuRight and Rotate Left Instructions
Rotate Tu Tud
The Rotate instructions rotate the input value (IN) right or left by the
shift count (N) and load the result in the memory location (OUT). The
rotate is circular.

4 .c om 4 .co m
If the shift count is greater than or equal to the maximum for the 4 .co m
4.
o a2 oa 2
operation (8 for a byte operation, 16 for a word operation, or 32 for a
o a 2
hoa 2
ngh do gh
d o n gh
double-word operation), the S7-200 performs a modulo operation on
n o ng
Tud
the shift count to obtain a valid shift count before the rotation is
Tu Tu
executed. This result is a shift count of 0 to 7 for byte operations, 0
to 15 for word operations, and 0 to 31 for double-word operations.
If the shift count is 0, a rotate operation is not performed. If the rotate

.co m .c om
operation is performed, the value of the last bit rotated is copied to
.c om 4.
the overflow bit (SM1.1).

a 2 4 an2
If the shift count is not a
4 a 2 4 a 2
o ho the last bit rotated out is copied tonthe o memory bit (SM1.1). The zero gho
integer multiple of 8 (for byte operations), 16 (for word operations), or 32 (for
ngh n g
double-word operations),
d
memory bit o (SM1.0) is set when the value to be rotated d
g
ois zero.
hoverflow
d on
u
T operations are unsigned. For word and double
Byte
u
T word operations, the sign bit is shifted when u
T you use
signed data types.
Error conditions that set ENO = 0 SM bits affected:

.c o m H 0006 (indirect address)


. c o m H SM1.0 (zero)
. c o m .
2 4 2 4 24 24
hoa hoa hoa a
H SM1.1 (overflow)

gh o
ng o
Table 6-58
d nValidgOperands for the Shift and Rotate Instructions
d o ng o n
Tu
Inputs/Outputs Data Types Operands Tu Tud
IN BYTE IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *LD, *AC, Constant
WORD IW, QW, VW, MW, SMW, SW, T, C, LW, AC, AIW, *VD, *LD, *AC, Constant

4 .c om DWORD

4 . om
IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *LD, *AC .c
4 om
ID, QD, VD, MD, SMD, SD, LD, AC, HC, *VD, *LD, *AC, Constant
c 4 .
2 OUT
2 BYTE
2 2
ng hoa n g o a
hWORD IW, QW, VW, MW, SMW, SW, T, C, LW,o
n g
a
h*VD,AC,*LD,*VD,*AC*LD, *AC n g ho a
N ud
o BYTEDWORD
doLB, AC, *VD, *LD, *AC, Constant
ID, QD, VD, MD, SMD, SD, LD, AC,
o
T TuSB,
IB, QB, VB, MB, SMB,
Tud

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 179
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 Example: Shift and Rotate Instructions


4 . c om 4. c om .
o a2 o a2 o a2 o a 24
ng h ng h Network 1
ng h g h
d o LD I4.0
d o d on
Tu RRW
SLW
u2 3
TVW200,
AC0,
T u

. co m .c o m . c o m
24 24 a24 2 4.
ng hoa g hoa gho ng ho a
Tu don do
Tu Shift
n
Tu d o
Rotate
Before rotate Overflow Before shift Overflow
AC0 0100 0000 0000 0001 x VW200 1110 0010 1010 1101 x

4 .c om 4 .c om 4 .com .
o6a2 After first rotate
a
o0000 2 Overflow
o a 2
After first shift Overflow
o a 24
ng h AC0 1010 0000 h
g 0000 1
ng
VW200 h1100 0101 0101 1010 1
g h
don
Tu After second rotate Overflow T u d o
After second shift T u
Overflow
d on
AC0 0101 0000 0000 0000 0 VW200 1000 1010 1011 0100 1

Zero Memory Bit (SM1.0) = 0

4 .c om Overflow Memory Bit (SM1.1) = 0

4 . c om 4 . c om
After third shift Overflow

4.
2 2 VW200
2
0001 0101 0110 1000 1
2
ng hoa g h oa g h
Zero Memory Bit
a
o(SM1.0) = 0
g hoa
Tu don T udo
n Memory Bit (SM1.1)
Overflow = 1

Tud
o n

.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
180
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
S7-200 Instruction Set Chapter 6

4 .c om Shift Register Bit Instruction 4 .c om 4. c om .


o a2 o a2 o a2 o a 24
ng h h
ngprovides g h
nRegister. g h
The Shift Register
d o Bit instruction shifts a value into the Shift
d o d on
Tu product flow or data. Use this instruction Tuto shift the entire u
This instruction an easy method for sequencing and
controlling T
register one bit, once per scan.
The Shift Register Bit instruction shifts the value of DATA into the

.com o m o m
Shift Register. S_BIT specifies the least significant bit of the Shift

24 24 .c . c 4.
a24
Register. N specifies the length of the Shift Register and the
a 2
hoa a
direction of the shift (Shift Plus = N, Shift Minus = –N).
h o ho ho
ng don
g
do n g
Each bit shifted out by the SHRB instruction is placed in the overflow
d ong
Tu
memory bit (SM1.1).
Tu
This instruction is defined by both the least significant bit (S_BIT)
Tu
and the number of bits specified by the length (N).

om m m
Error conditions that set ENO = 0

2 4 .c H 0006 (indirect address)


2 4 .co 2 4 .co 6 2 4.
ng hoa o a
H 0091 (operand out of range)
g h gh o a
gho
a
d onin count field)
H 0092 (error
d o n o n
u
Tbits affected:
SM Tu Tud
H SM1.1 (overflow)

4 .c om Table 6-59
4 . c om
Valid Operands for the Shift Register Bit Instruction
4 .co m
4.
o a2 oa2
Inputs/Outputs Data Types Operands
ho a 2
hoa 2
ngh nghBOOL
DATA, S_Bit

do
I, Q, V, M, SM, S, T, C, L
n g
oLB, AC, *VD, *LD, *AC, Constant o ng
Tu Tud Tud
N BYTE IB, QB, VB, MB, SMB, SB,

Use the following equation to compute the address of the most significant bit of the Shift Register (MSB.b):

MSB.b = [(Byte of S_BIT) + ([N] – 1 + (bit of S_BIT)) / 8].[remainder of the division by 8]

.com .co m .co m .


a24 4 4 24
For example: if S_BIT is V33.4 and N is 14, the following
o a 2 a 2
Shift Minus, S_BIT

a
h=oV33 + ([14] – 1 +4)/8 ho o
calculation shows that the MSB.b is V35.1. Length = –14 MSB LSB

ngh n g
o = V33 + 17/8
MSB.b
do n g V33 7 4
on
0
g h
Tud T
= V33 + 2 with a remainder of 1
u V34 7 T u d
0
= V35.1
On a Shift Minus, indicated by a negative value of length V35 7 1 0

.c o m . c o m
(N), the input data shifts into the most significant bit of the
. c o m .
a24 4 4 24
Shift Register, and shifts out of the least significant bit
2 a2
hoa a
MSB of Shift Register
o (S_BIT). The data shifted out is then placed in the overflow
hShiftoPlus, o
ngh d ngindicated by a positive value of lengthd(N),
memory bit (SM1.1).
oPlus, o ng Length = 14 S_BIT

o n gh
Tud
MSB LSB
On u
the
a Shift
Tubit of the
T input data (DATA) shifts into the least significant V33 7 4 0

Shift Register, specified by the S_BIT, and out of the most V34 7 0
significant bit of the Shift Register. The data shifted out is
then placed in the overflow memory bit (SM1.1).

4 .c om 4 . c om
The maximum length of the shift register is 64 bits, positive 4 . comV35 7 1 0

4.
2 2 2 2
hoa gho
a hoa ho a
or negative. Figure 6-35 shows bit shifting for negative and MSB of Shift Register

ng positive values of N.
d on d on g Figure 6-35
d ong
T u T u Tu
Shift Register Entry and Exit

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 181
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
oExample: c om c om
4 Shift Register Bit Instruction 4. 4. .
o a2 o a2 o a2 o a 24
ng h ng h Network 1
gh g h
o I0.2on on
Tu d LD
EU
T ud T u d
SHRB I0.3, V100.0, +4

. co m .c o m . c o m
24 Timing Diagram 24 a24 2 4.
hoa hoa a
7 (MSB) 0 (LSB) S_BIT

ng g Before first shift


gho
V100 0 1 0 1 I0.3
ng ho
Tu
I0.2 don Tu do n
Overflow (SM1.1) x
Tu d o
Positive S_BIT

transition (P) After first shift V100 1 0 1 1 I0.3

4 .c om I0.3

4 .co m Overflow (SM1.1)


4
0
. c om .
24
S_BIT

o6a2 First shift


oa 2 Second shift After second shift V100
a2 0 1 1 0 I0.3
a
ng h n gh n g ho g h o
d o do Overflow (SM1.1) d on
Tu Tu u
1
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
182
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
S7-200 Instruction Set Chapter 6

4 .c om Swap Bytes Instruction4.com 4. c om .


o a2 o a2 o a2 o a 24
ng h h
ng instruction exchanges the most significant h
g with
nbyte g h
The Swap Bytes
d o d o d on
Tu Tu u
the least significant byte of the word IN.
Error conditions that set ENO = 0
T
H 0006 (indirect address)

. 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 .c om . c om
a 2 4 Table 6-60 Valid Operands2 4
a for the Swap Bytes Instruction a2 4 6a 2 4.
o o o gho
ngh d o
h
Inputs/Outputsg Data Types
n Operands
d o n g h
o n
IN u
T WORD
Tu SW, T, C, LW,AC, *VD, *LD, *AC
IW, QW, VW, MW, SMW,
Tud

om m Network 1 m
Example: Swap Instructions

2 4 .c 24 .co 2 4 .co 2 4.
ng hoa ngh oa LD
SWAP
I2.1
VW50
n gh o a
ng hoa
do d o o
Tu Tu Tud
Swap D6 C3
VW50 VW50 C3 D6

.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 183
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 String Instructions
o a2 o a2 o a 24
ng h String Lengthong
h ng h g h
d d o d on
TuLength instruction (SLEN) returns the lengthTofuthe string
The String
specified by IN.
T u
Copy String
. co mThe Copy String instruction (SCPY) copies
.c o m . c o m
a 24 a 24 the string specified by IN
a 24 a2 4.
o o
to the string specified by OUT.
o ho
ngh o n gh o n gh ong
Tud
Concatenate String
Tud
The Concatenate String instruction (SCAT) appends the string
Tu d
specified by IN to the end of the string specified by OUT.

.co m
SM Bits and ENO
.c om . c om .
6 2 4 a2 and4 a2 4 24
oa a
For the String Length, Copy String, Concatenate String

g h instructions, the following h oconditions affect ENO. h o h o


n d o ng d o ng d on g
H 0006T
u
Error conditions that set ENO = 0
(indirect address) Tu T u
H 0091 (range error)

.c omTable 6-61 Valid Operands for the String.cLength


o mInstruction . c om
a2 4 Inputs/Outputs Data Types 4
a2 VB, LB, *VD, *LD, *AC
Operands
a2 4 a 2 4.
h o h o h o ho
ng IN

d o ng
BYTE (String)
IB, QB, VB, MB, SMB, SB,d o ng o ng
Tu Tu Tud
OUT BYTE LB, AC, *VD, *LD, *AC

Table 6-62 Valid Operands for the Copy String and Concatenate String Instructions
Inputs/Outputs Data Types Operands

.com IN, OUT BYTE (String) om


VB,cLB,
. *VD, *LD, *AC
.co m .
o a24 o a2 4
o a 2 4
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 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
184
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2 o a 2
Example: Concatenate String, Copy String, and String Length Instructions
a2
o the string at VB20 o a 24
ngh gh //1. h h
//g to the string at VB0 g
Network 1 Append
on n on
T ud T udo //2. Copy the string at VB0
// to a new string at VB100 T u d
//3. Get the length of the string
// that starts at VB100

. co m .c o m LD I0.0

. c o m
4.
SCAT VB20, VB0
24 24 STRCPY VB0, VB100
a24 2
ng hoa g hoa STRLEN
ho
VB100, AC0
g ng ho a
Tu don Tu do n
Tu d o

.co m .c om . c om
a 2 4 a 2 4 a 2 4 6a 2 4.
o ho
Before executing the program
o ho
ngh VB0
n g VB6 VB20 gh
n VB25
n g
T ud6 o ’H’ ’E’ ’L’ ’L’ ’O’ ’ ’ Tudo5 ’W’ ’O’ ’R’ ’L’ ’D’ Tudo
After executing the program
VB0 VB11
11 ’H’ ’E’ ’L’ ’L’ ’O’ ’ ’ ’W’ ’O’ ’R’ ’L’ ’D’

4 .c om VB100
4 . c om VB111
4 .co m
4.
o a2 11 ’H’
oa2
’E’ ’L’
’L’ ’O’ ’ ’ ’W’ ’O’ ’R’ ’L’
o a 2
’D’
hoa 2
ngh n
AC0
o gh o n gh o ng
Tud Tu d Tud
11

.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 185
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 Copy Substring from
o a2instruction (SSCPY) copies the hoa2
String
o a 24
ng h g h
ncharacters g g h
IN,n on
The Copy Substring from String

at u
startingT d
specified numbero of N from the string specified by o
the index INDX, to a new string specified byT u d u d
OUT. T
Error conditions that set ENO = 0
H 0006 (indirect address)

. co mH 0091 (range error) .c o m . c o m


a 24 H 009B (index=0)
a 24 a24 a2 4.
o o ho ho
ngh o n gh
do n g ong
Tud Tu Tu d

.co m .c om . c om .
6 2 4 the2
4 a2 4 24
g hoa Table 6-63 Valid Operands fora
h o Copy Substring from String Instructions
h o h o a
n o ngTypes
Inputs/Outputs Data
d
Operands
d o ng d on g
IN, OUTTu BYTE (String) Tu
VB, LB, *VD, *LD, *AC T u
INDX, N BYTE IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *LD, *AC, Constant

4 .c om Example: Copy Substring Instruction4.com 4 . c om 4.


o a 2 a 2 //Starting at the seventha 2 a 2
ngh n g ho Network 1

n g
//copy 5 charactershtooa new string at VB20
character in the string at VB0,

ng ho
o o o
Tud T7,u5,dVB20 Tud
LD I0.0
SSCPY VB0,

. c o m BeforeVB0executing the program .c om .c om .


a2 4 4
a’L’2 ’O’ ’ ’ ’W’ ’O’ ’R’ ’L’ ’D’hoa2
VB11
4 a 24
h o 11 ’H’ ’E’
h
’L’
o h o
ng d o ng d o ng d on g
Tu
After executing
VB20
the program
VB25 Tu T u
5 ’W’ ’O’ ’R’ ’L’ ’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 oa2 a2 a 24
ngh
186
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .c om 4. c om .
o a2 Find String Within a
o 2
String
o a2 o a 24
ng h h
ngof the string IN2 within the string IN1.dThe g h
nsearch g h
on
The Find String Within String instruction (SFND) searches for the
d o
first occurrence o d
Tu at the starting position specified by OUT.TIfua sequence of
begins
characters is found that matches exactly the string IN2, the position
T u
of the first character in the sequence for the string is written to OUT.
If the string IN2 was not found in the string IN1, the instruction OUT

. co m is set to 0.
.c o m . c o m
24 Error conditions that set ENO4
2 =0 a24 2 4.
ng hoa n gh o a
H 0006 (indirect address)
n gho ng ho a
ud o
H 0091 (range error)
do d o
HT009B (index=0) Tu Tu
Find First Character Within String

om m m
The Find First Character Within String instruction (CFND) searches

2 4 .c 2 4 .co
the string IN1 for the first occurrence of any character from the
2 4 .co 6 2 4.
hoa a a a
character set described in the string IN2. The search begins at

gh o gh
starting position OUT. If a matching character is found, the positiono gho
ng o n o n
of the character is written to OUT. If no matching character is found,
d d o n
Tu
OUT is set to 0.
Error conditions that set ENO = 0
Tu Tud
H 0006 (indirect address)
H 0091 (range error)

4 .c om H 009B (index=0)
4 .co m
4 .co m
4.
2 2 2 2
ng hoa n g oa
hOperands for Find String Within String and FindnFirst
g
a
o Within String Instructions
hCharacter ng hoa
o Data Types
Table 6-64 Valid
o o
Tud
Inputs/Outputs
IN1, IN2 BYTE (String)
Operands
Tud
VB, LB, *VD, *LD, *AC
Tud
OUT BYTE IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *LD, *AC

.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 187
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 Example: Find String Within String4Instruction


. c om 4 . c om 4.
o a 2 a 2 a 2 a 2
ngh g
The following example uses
n haostring stored at VB0 as a command for turningn g ah o on or off. A string ’On’ is stored at
pump
n g ho
o udinothe command string (VB12). udo
Tud If the result is not 0, then theNetwork
VB20, and a string ’Off’ is stored at VB30. The result of the Find String Within String instruction is stored in AC0 (the
OUT parameter).
T
string ’On’ was found
1 //1. Set AC0 to 1.
T
// (AC0 is used as the OUT parameter.)
//2. Search the string at VB0 for the string

. co m .c o m //
. c o m
at VB20 (’On’), starting at the first

24 24 LD
// position (AC0=1).

a24 2 4.
hoa hoa ho ho a
I0.0

ng g g ng
MOVB 1, AC0

Tu don SFND VB0, VB20, AC0

Tu do n
Tu d o

.co m VB0
.c om’ ’ .
VB12 m
c’n’o .
6 2 4 12 ’T’
a2
’u’4 ’n’ ’r’ ’P’ ’u’ ’m’ ’p’ ’ ’
2 4’O’
24
g hoa g hoVB22 gh o a
g h o a
n nVB20
do ’O’ ’n’
VB30 VB33
d o n d on
Tu Tu u
2 3 ’O’ ’f’ ’f’

If the string in VB20 AC0 If the string in VB20 AC0


T
is found: 11 is not found: 0

4 .c om 4 . c om 4 . c om 4.
o a 2 a 2
o String Instruction o a 2 a 2
ngh n g hstring
Example: Find Character Within
n g hstring ng ho
charactersu
T dtheo + and –) that can identify a temperature T
In the following example,
(and
a stored at VB0 contains the
in au doThe sample program finds the starting position
temperature.
string.
The at VB20 stores all the numeric
T udo
for a number in that string and then converts the numeric characters into a real number. VD200 stores the real-number
value of the temperature.
Network 1 //1. Set AC0 to 1.

.co m .co m //
.co
(AC0 is used as the OUT parameter
m .
a 2 4 a 2 4 //
//2.
a 2
Find the numeric character4
and points to the first position of the string.)

a 24
o o o o
ngh gh gh h
// in the string at VB0.

o n //3.
o n
Convert the string to a real number.
on g
Tud LD
MOVB
I0.0
1, AC0Tu d T u d
CFND VB0, VB20, AC0
STR VB0, AC0, VD200

.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
VB0
T u
VB11
Tud
11 ’T’ ’e’ ’m’ ’p’ ’ ’ ’ ’ ’9’ ’8’ ’.’ ’6’ ’F’

om om’5’ om
VB20 VB32

2 4 .c 12 ’1’ ’2’
2 4 . c
’3’ ’4’ ’6’ ’7’ ’8’ ’9’ ’0’
4 . c
’+’ ’–’
4.
hoa h oaof the temperature o a2 ho a2
ng g
on in VB0: AC0
Starting position
o n gh
Real-number value of the
ong
T u dstored
Tu d temperature:
VD200 Tu d
7 98.6

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
188
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .c om 4. c om .
o a2 Table Instructions
o a2 o a2 o a 24
ng h ng h ng h g h
Add To d o
Table d o d on
Tu Tu
The Add To Table instruction adds word values (DATA) to a table
T u
(TBL). The first value of the table is the maximum table length (TL).
The second value is the entry count (EC), which specifies the

. co m .c m
number of entries in the table. New data are added to the table after
o . c o m
24
the last entry. Each time new data are added to the table, the entry
24 a24 2 4.
hoa hoa a
count is incremented.

ng g gho ng ho
don n
A table can have up to 100 data entries.

Tu
Error conditions that set ENO = 0
Tu do Tu d o
H SM1.4 (table overflow)
H 0006 (indirect address)

4 .c om H 0091 (operand out of range)

4 .co m
4 .co m
4.
2 2 2 6 2
hoa a a a
SM bits affected:

gh o
H SM1.4 is set to 1 if you try to overfill the table
gh o gho
ng d o n d o n o n
Tu6-65
Table Valid Operands for the Table InstructionsT
u Tud
Inputs/Outputs Data Types Operands

om m om
DATA INT IW, QW, VW, MW, SMW, SW, T, C, LW, AC, AIW, *VD, *LD, *AC, Constant

.c . IW,o
c . c
2 4 TBL WORD
a2 4 4
QW, VW, MW, SMW, SW, T, C, LW, *VD, *LD, *AC
a2 2 4.
ng hoa ng h o
ng h o
ng hoa
d o d o o
Tu Tu Tud
Example: Add to Table Instruction
Network 1 //Load maximum table length
LD SM0.1
MOVW +6, VW200

.co m .co m .co m .


a 2 4 a 2 4 Network 2
a 2 4 a 24
o o LD I0.0
o o
ngh o n gh ATT
n gh
VW100, VW200
o on g h
Tud Tu d T u d

.c o m . c o m . c o m .
o a24 a 24 of ATT
Before execution
o After execution of2
o a 4
ATT
oa 24
ngh don
g h
VW100 1234

d o n gh o n gh
Tu VW200
VW202
0006
0002 EC (entry count) Tu
TL (max. no. of entries) VW200
VW202
0006
0003
TL (max. no. of entries)
EC (entry count) Tud
VW204 5431 d0 (data 0) VW204 5431 d0 (data 0)
VW206 8942 d1 (data 1) VW206 8942 d1 (data 1)
VW208 xxxx VW208 1234 d2 (data 2)

4 .c om VW210 xxxx

.com
VW210 xxxx

. com 4.
24 4
VW212 xxxx VW212 xxxx

2 a2 2
hoa a a
VW214 xxxx VW214 xxxx

gh o gh o ho
ng don d o n d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 189
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
oFirst-In-First-Out .c om . c om .
a2 4 and 4
a2entries.
Last-In-First-Out
a2 4 a 24
h o h o h o h o
ng A table can have
d o ng
up to 100 data
d o ng d on g
Tu
First-In-First-Out Tu
The First-In-First-Out instruction (FIFO) moves the oldest (or first)
T u
entry in a table to the output memory address by removing the first
entry in the table (TBL) and moving the value to the location

. co m o m
specified by DATA. All other entries of the table are shifted up one
.c . c o m
24 24
location. The entry count in the table is decremented for each
a24 2 4.
hoa hoa ho ho a
instruction execution.

ng don
Last-In-First-Out
g
do n g
d ong
Tu Tu
The Last-In-First-Out instruction (LIFO) moves the newest (or last)
entry in the table to the output memory address by removing the last
Tu
entry in the table (TBL) and moving the value to the location
specified by DATA. The entry count in the table is decremented for

.co m each instruction execution.


.c om . c om
6 2 4 Error conditions that set ENO = 02 4 2 4 2 4.
g hoa H SM1.5 (empty table) ho
g
a SM bits affected:

g
a
o an entry from an empty table
hremove
H SM1.5 is set to 1 if you try to
g ho a
n n
doaddress) do n do n
T u
H 0006 (indirect
H 0091 (operand out of range) T u T u
Table 6-66 Valid Operands for the First-In-First-Out and Last-In-First-Out Instructions

4 .c om Inputs/Outputs Data Types


4 .co
Operands m
4 .co m
4.
o a2 TBL WORD
oa 2 IW, QW, VW, MW, SMW, SW, T, C, LW, *VD, *LD, *AC
o a 2
hoa 2
ngh DATA

do ngh
INT
n gh
IW, QW, VW, MW, SMW, SW, T, C, LW, AC, AQW, *VD, *LD, *AC

d o o ng
Tu
Example: First-In-First-Out Instruction
Tu Tud
Network 1

om omFIFO m
LD I4.1

2 4 . c 2 4 .c VW200, VW400
2 4 .co 24.
ng hoa ng hoa n gh o a
g h o a
d o d o After execution of FIFO ud
on
Tu of FIFO
Before execution
Tu VW400 5431
T
VW200 0006 TL (max. no. of entries) VW200 0006 TL (max. no. of entries)
VW202 0003 EC (entry count) VW202 0002 EC (entry count)
VW204 5431 d0 (data 0) VW204 8942 d0 (data 0)

.c o m VW206 8942
c o m
d1 (data 1)
.
VW206 1234
c o m
d1 (data 1)
. .
2 4 VW208 1234
2 4
d2 (data 2) VW208 xxxx
24 24
hoa hoa hoa oa
VW210 xxxx VW210 xxxx

ng on
VW212
VW214 g xxxx
xxxx
VW212

on
VW214 g xxxx
xxxx
o n gh
T u d 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
190
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2 2
Example: Last-In-First-Out Instruction
o a a2 a 24
ngh n gh Network 1
n g ho g h o
ud o LIFO ud
LD o
I0.1
u d on
T T VW200, VW300 T

. co m Before execution of LIFO


.c o m VW300 1234
. c o m After execution of LIFO

24 24 a24 2 4.
hoa hoa a
VW200 0006 TL (max. no. of entries) VW200 0006 TL (max. no. of entries)

ng g VW202 0003 EC (entry count)


gho
VW202 0002 EC (entry count)

ng ho
don do n o
VW204 5431 d0 (data 0) VW204 5431 d0 (data 0)

Tu
VW206
VW208
8942
1234
d1 (data 1)
d2 (data 2) Tu
VW206
VW208
8942
xxxx
d1 (data 1)
Tu d
VW210 xxxx VW210 xxxx
VW212 xxxx VW212 xxxx
VW214 xxxx VW214 xxxx

.co m .co m .co m


a 2 4 a 2 4 a 2 4 6a 2 4.
o o o gho
ngh d o n gh
d o n gh o n
Tu Tu Tud

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 191
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
oMemory .co m . c om .
a2 4 Fill
a 2 4 a2 4 a 24
o o o o
ngh n gh
The Memory Fill instruction (FILL) writes N consecutive words,
o on gh on g h
IN. T ud
beginning at address OUT, with the word value contained in address
T ud T u d
N has a range of 1 to 255.
Error conditions that set ENO = 0

. co mH 0006 (indirect address) .c o m . c o m


a 24 H 0091 (operand out of range)
a 24 a24 a2 4.
o o ho ho
ngh o n gh
do n g ong
Tud Tu Tu d

.co m .co m .co m .


6 2 4 2 4 2 4 24
g hoa Table 6-67
ho a
Valid Operands for the Memory Fill Instruction
g gh o a
g h o a
n n
Inputs/Outputs oData Types o n on
Tud INT d d
Operands
IN Tu
IW, QW, VW, MW, SMW, SW, T, C, LW, AC, AIW, *VD, *LD, *AC, Constant T u
N BYTE IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *LD, *AC, Constant
OUT INT IW, QW, VW, MW, SMW, SW, T, C, LW, AQW, *VD, *LD, *AC

4 .c om 4 .co m
4 .co m
4.
2 2 2 2
ng hoa ngh oa
Example: Memory Fill Instruction
n gh o a
ng hoa
do d o o
Tu Network 1
LD
TI2.1u Tud
FILL +0, VW200, 10

.co m .co m .co m .


a 2 4 a 2 4 a 2 4 a 24
o hIN0o o o
ngh g0 h h
VW200 VW202 VW218

o n g FILL 0 0 ...
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
192
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
S7-200 Instruction Set Chapter 6

4 .c om Table Find 4 .c om 4. c om .
o a2 o a2(FND) searches a table for data that hoa2 o a 24
ng h h
ngcriteria. The Table Find instruction searches
ngthe g h
on
The Table Find instruction
matches o o
d certain
d
TuTBL, starting with the table entry INDX, forTtheudata value or
table T u d
pattern PTN that matches the search criteria defined by CMD. The
command parameter CMD is given a numeric value of 1 to 4 that
corresponds to =, <>, <, and >, respectively.

. co m .c o m . c o m
4.
If a match is found, the INDX points to the matching entry in the
24 24
table. To find the next matching entry, the INDX must be incremented
a24 2
ng hoa hoa
before invoking the Table Find instruction again. If a match is not
g gho ng ho a
don n
found, the INDX has a value equal to the entry count.

Tu Tu do
A table can have up to 100 data entries. The data entries (area to be Tu d o
searched) are numbered from 0 to a maximum value of 99.
Error conditions that set ENO = 0

.co m H 0006 (indirect address)


.co m .co m
a 2 4 H 0091 (operand out of range)
a 2 4 a 2 4 6a 2 4.
o o o gho
ngh d o n gh
d o n gh o n
Tu
Table 6-68
Tu
Valid Operands for the Table Find Instruction
Inputs/Outputs Data Types Operands
Tud
TBL WORD IW, QW, VW, MW, SMW, T, C, LW, *VD, *LD, *AC

4 .c om PTN INT
. c o mVW, MW, SMW, SW, T, C, LW, AC, AIW, *VD,
IW, QW,

4 IW, QW, VW, MW, SMW, SW, T, C, LW, AC,a*VD, . c o


4*LD, *AC
m*AC, Constant
*LD,

4.
o a 2 INDX WORD
o a 2 2
o 3: Less Than (<), 4: Greater Than (>) ghoa 2
ngh hBYTE (Constant) 1: Equal (=), 2: Not Equalh
CMD
o ng o n g (<>),
on
T
Tipu d T u d T u d
When you use the Table Find instruction with tables generated with the Add to Table, Last-In-First-Out,
and First-In-First-Out instructions, the entry count and the data entries correspond directly. The
maximum-number-of-entries word required for the Add to Table, Last-In-First-Out, or First-In-First-Out

.co m .co m
instructions is not required by the Table Find instruction. See Figure 6-36.
.co m .
a 2 4 a 2 4 a 2 4
Consequently, you should set the TBL operand of a Find instruction to one-word address (two bytes)
a 24
o o o o
ngh gh gh h
higher than the TBL operand of a corresponding the Add to Table, Last-In-First-Out, or First-In-First-Out
o n
instruction.
o n on g
Tud Tu d T u d
Table format for ATT, LIFO, and FIFO Table format for TBL_FIND

VW200 0006 TL (max. no. of entries) VW202 0006 EC (entry count)

.c o m VW202 0006
.com
EC (entry count) VW204
.com
xxxx d0 (data 0)
.
a24 24 24 24
VW204 xxxx d0 (data 0) VW206 xxxx d1 (data 1)

o VW206
o a xxxx d1 (data 1)
o a VW208 xxxx d2 (data 2)
oa
ngh h h gh
VW208 xxxx d2 (data 2) VW210 xxxx d3 (data 3)

on g
VW210 xxxx d3 (data 3)
on g VW212 xxxx d4 (data 4)
o n
T u d VW212
VW214
xxxx
xxxx
d4 (data 4)
d5 (data 5) T u d VW214 xxxx
Tud
d5 (data 5)

Figure 6-36 Different Table Formats between the Table Find Instruction and the ATT, LIFO, and FIFO Instructions

.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 193
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 Example: Table Find Instruction 4.com 4. c om .


o a2 o a2 a2 a 24
ng h ng h Network 1
n g ho g h o
d o LD I2.1 o
d 16#3130, AC1 d on
Tu FND=
T uVW202, T u

. co m .c o m . c o m
24 24 a24 2 4.
ng hoa g h
When I2.1 is on, search the oafor
table
gho ng ho a
onHEX. n
AC1 0 AC1 must be set to 0 to search from the top of

T u d
a value equal to 3130
Tu do
Execute table search
table.
Tu d o
VW202 0006 EC (entry count) AC1 contains the data entry number
AC1 2
VW204 3133 d0 (data 0) corresponding to the first match found in the
VW206 4142 d1 (data 1)

om m m
table (d2).

4 .c VW208 3130 d2 (data 2)

4 .c oAC1 4 .co .
24
Increment the INDX by one, before searching

o6a2 VW210 3030

a2
d3 (data 3)

o
3
a 2
the remaining entries of the table.
a
ho o
VW212 3130 d4 (data 4)

ng h VW214 4541
n gh d5 (data 5)
n g g h
d o doAC1 contains the data entry number
Execute table search
d on
Tu
If the table was created using ATT,
AC1
T4 u T
corresponding to the second match found in
u
LIFO, and FIFO instructions, VW200 the table (d4).
contains the maximum number of Increment the INDX by one, before searching
AC1 5

om om om
allowed entries and is not required by the remaining entries of the table.

4 .c the Find instructions.


4 . c 4 . c 4.
o a2 hoa 2 Execute table search
a 2
ho a value equal to the entry count. nghoa 2
ngh g g
AC1 6 AC1 contains

o n o n
The entire table has been searched without
o
Tud Tud finding another match.
AC1 0
Tud
Before the table can be searched again, the
INDX value must be reset to 0.

.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
194
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2 Example: Creating a Table
o a 2 o a2 o a 24
ngh gh gh g h
The following program creates a table with 20 entries. The first memory location of the table contains the length of the
on on on
ud ud d
table (in this case 20 entries). The second memory location shows the current number of table entries. The other

T T T u
locations contain the entries. A table can have up to 100 entries. It does not include the parameters defining the
maximum length of the table or the actual number of entries (here VW0 and VW2). The actual number of entries in the
table (here VW2) is automatically incremented or decremented by the CPU with every command.
Before you work with a table, assign the maximum number of table entries. Otherwise, you cannot make entries in the

. co m .c m
table. Also, be sure that all read and write commands are activated with edges.
o . c o m
24
To search the table, the index (VW106) must set to 0 before doing the find. If a match is found, the index will have the
24 a24 2 4.
hoa hoa a
table entry number, but if no match is found, the index will match the current entry count for the table (VW2).

ng g g
Network 1 ho table with 20 entries starting with memoryng
//Create ho
Tu don o n
Tud //1.
//location 4.
o
Tudlength
On the first scan, define the maximum
//of the table.
LD SM0.1
MOVW +20, VW0

.co m .co m .co m


a 2 4 a 2 4 Network 2
a 2 4
//Reset table with input I0.0
//On the rising edge of I0.0, 6a 2 4.
o o o gho
ngh gh gh //fill memory locations from VW2 with ”+0” .

d o n d o n o n
Tud
LD I0.0

Tu Tu
EU
FILL +0, VW2, 21
Network 3 //Write value to table with input I0.1
//On the rising edge of I0.1,

om m m
//copy value of memory location VW100 to table.

4 .c 4 .co LD I0.1
4 .co 4.
o a2 oa 2 EU
ho a 2
hoa 2
ngh gh ATT VW100, VW0
n Network 4 ng ng
o o do
Tud Tud //Move
//Read first table value with input I0.2

T u
the last table value to location VW102.
//This reduces the number of entries.
//On the rising edge of I0.2,
//Move last table value to VW102

om om m
LD I0.2

2 4 . c 2 4 .c EU
LIFO VW0, VW102
2 4 .co 24.
ng hoa ng hoa Network 5
n g//Read a
holast table value with input I0.3
//Move the first table value to location VW102. ng
h o a
d o o udo
Tu Tud //This reduces the number of entries.
//On the rising edge of I0.0,
//Move first table value to VW104
T
LD I0.3
EU

.c o m . c o m FIFO VW0, VW104


. c o m .
o a24 hoa
24 Network 6
24
//Search table for the first location that has a

hoa oa 24
ngh gh
//value of 10.

on g on g //1. On the rising edge of I0.4,


o n
T u d T u d // reset index pointer.
Tud
//2. Find a table entry that equals 10.
LD I0.4
EU
MOVW +0, VW106

4 .c om .com
FND= VW2, +10, VW106
. com 4.
2 24 a2 4 2
ng hoa gh oa
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 195
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 Timer Instructions
o a2 o a2 o a 24
ng h ng h n gh g h
SIMATIC Timer
d oInstructions
ud o d on
TuTimer
On-Delay T T u
Retentive On-Delay Timer
The On-Delay Timer (TON) and Retentive On-Delay Timer (TONR)

. co m .c m
instructions count time when the enabling input is on. The timer
o . c o m
a 24
number (Txx) determines the resolution
a 24
of the timer.
a 24 a2 4.
o o o ho
ngh h is used to delay turning an output offnforgh
Off-Delay Timer
o n g(TOF) ng
udo
udof time after the input turns off. The timerTnumber d o
The Off-Delay Timer
T
a fixed period
(Txx) determines the resolution of the timer.
Tu

.co m . c om . c om .
6 2 4 the2
4 a2 4 24
g hoa Table 6-69 Valid Operands fora
h o SIMATIC Timer Instructions
h o h o a
n d o ngTypes Operands
Inputs/Outputs Data
d o ng d on g
Txx Tu WORD Constant (T0 to T255) Tu T u
IN BOOL I, Q, V, M, SM, S, T, C, L, Power Flow
PT INT IW, QW, VW, MW, SMW, SW, T, C, LW, AC, AIW, *VD, *LD, *AC, Constant

4 .c om Tip 4 . c om 4 . c om 4.
o a2 a 2
ho timer number (Txx) for an off-delay ntimer a 2
o and an on-delay timer hoa 2
ngh h(TOF)
You cannot share the same
o n
(TON). For example,g o
you cannot have both a TON T32 and a TOF g
T32.
o ng
Tud Tud
As shown in Table 6-70, the three types of timers perform different types of timing tasks: Tud
- You can use a TON for timing a single interval.

4 . c om - -
.co m
You can use a TONR for accumulating a number of timed intervals.
4 4 .co m .
2 2 2
You can use a TOF for extending time past an off (or false) condition, such as for cooling a motor
24
ng hoa ho
after it is turned off.
n g
a
n gh o a
g h o a
o o on
Tud of the Timer Instructions
Table 6-70 Operations

Type Current >= Preset


Tu d
State of the Enabling Input (IN)
T
Power Cycle/First Scan
u d
TON Timer bit on ON: Current value counts time Timer bit off
Current continues counting

.c o m to 32,767
. c m
OFF: Timer bit off, current value = 0
o . c o m
Current value = 0

a24 TONR Timer bit on


a 24 ON: Current value counts time
a 2 4Timer bit off a 2 4.
o Current continueso
ho last Current ho
ngh h counting
n g n g
OFF: Timer bit and current value maintain value can be
n g
dobit off o udo
to 32,767 1

udvalue
state maintained
TOF TuTimer
Current = Preset, stops
ON: Timer bit on, T
current =0 Timer bit off T
OFF: Timer counts after on-to-off transition Current value = 0
counting

.c o m The
memory retention for the S7-200 CPU. com
1

. . c om
retentive timer current value can be selected for retention through a power cycle. See Chapter 4 for information about

a2 4 a 2 4 a 2 4 a2 4.
o hoon the documentation CD for a sample ho that uses the on-delay timer ngho
ng h 31ng g
Refer to the Tips and Tricks program
(TON). See Tipo o n o
Tud
Tips and Tricks
Tud Tud

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
196
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2 o 2
equal to or greater than the preset time, the timer bit is on.
o a2
The TON and TONR instructions count time when the enabling input is on. When the current value is
a o a 24
ngh on gh on gh on g h
ud ud d
- The current value of a TON timer is cleared when the enabling input is off, whereas the current
T T
value of the TONR timer is maintained when the input is off.
T u
- You can use the TONR timer to accumulate time when the input turns on and off. Use the Reset
instruction (R) to clear the current value of the TONR.

. co m -
o m o m
Both the TON and the TONR timers continue counting after the preset is reached, and they stop
.c . c
a24 is a
24
counting at the maximum value of 32,767.
a 2 4of time after the input turns off. a2 4.
o The TOF instructiono
ho and the current value is set to 0. ngho
ngh hinput turns on, the timer bit turns on immediately,
used to delay turning an output off for a fixed period
n g
When the enabling
theo
n g
When d
T-uWhen the preset is reached, the timer bitTturns udo time reaches the preset time. Tudo
input turns off, the timer counts until the elapsed
off and the current value stops incrementing;
however, if the input turns on again before the TOF reaches the preset value, the timer bit remains
on.

.co m -
. c om . c om 4.
The enabling input must make an on-to-off transition for the TOF to begin counting time intervals.

a 2 4 is 2
- If the TOF timer a
4
inside an SCR region and the SCR region isa 2 4 6a 2
o hobit is turned off, and the current valuendoeshnotoincrement.
inactive, then the current value is set
ho
ngh to 0, theg
o n timer g n g
Tipud
T T udo T udo
You can reset a TONR only by using the Reset (R) instruction. You can also use the Reset instruction to
reset any TON or TOF. The Reset instruction performs the following operations:
H Timer Bit = off

4 .c om H Timer Current = 0
4 . c om 4 . c om 4.
o a 2 a 2 a 2 a 2
timer to restart. ho ho ho
After a reset, TOF timers require the enabling input to make the transition from on to off in order for the

ngh o n g o n g o ng
Tud
Determining the Resolution of the Timer Tud Tud
Timers count time intervals. The resolution (or time base) of the timer determines the amount of time in
each interval. For example, a TON with a resolution of 10 ms counts the number of 10-ms intervals that

.co m .co m .co m


elapse after the TON is enabled: a count of 50 on a 10-ms timer represents 500 ms. The SIMATIC timers
.
a 2 4 a 2 4 a 2 4
are available in three resolutions: 1 ms, 10 ms, and 100 ms. As shown in Table 6-71, the timer number
a 24
o ho
determines the resolution of the timer.
ho o
ngh Tip
d o n g
d o n g
d o ng h
Tuguarantee a minimum time interval, increaseTtheu preset value (PV) by 1. For example: To T
To
minimum timed interval of at least 2100 ms for a 100-ms timer, set the PV to 22.
u a
ensure

.c o m Table 6-71
o m
Timer Numbers and Resolutions
. c . c o m
a24 Timer Type
2 4
Resolution
a Maximum Value
a 2 4 Number
Timer
a 2 4.
o ho 1 ms ho T0, T64 ho
ngh (retentive) ng g g
TONR 32.767 s (0.546 min.)
o 327.67 s do
n o n
Tud Tus (54.6 min.) T5 to T31, T69 to T95 Tud
10 ms (5.46 min.) T1 to T4, T65 to T68
100 ms 3276.7
TON, TOF 1 ms 32.767 s (0.546 min.) T32, T96
(non-retentive)
10 ms 327.67 s (5.46 min.) T33 to T36, T97 to T100

4 .c om 100 ms
4 . c om 3276.7 s (54.6 min.)
4 . com
T37 to T63, T101 to T255
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 197
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
oUnderstanding . c m
oAffects . c om
a 2 4 How 2 4
Resolution
a the Timer Action
a 2 4 a 2 4.
o hoofthan o updated asynchronous to the ho
ngh scan cycle. For o n ggreater
For a timer with a resolution
1 ms, the timer bit and the o n ghvalue
1 ms, the timer bit and the current value are
o n g
T thedscan. Tud Tud
scans current are updated multiple times
throughoutu

For a timer with a resolution of 10 ms, the timer bit and the current value are updated at the beginning of
each scan cycle. The timer bit and current value remain constant throughout the scan, and the time
intervals that accumulate during the scan are added to the current value at the start of each scan.
. co mFor a timer with a resolution of 100 ms,.cthe
o m . c o m
a 2 4 a 2 4 timer bit and current value are 4 timertheonlyinstruction
updated
2
your program executes the instruction for aa100-ms
when is
a2 4.
o hotimer to maintain the correct timing. ngho
executed; therefore, ensure that once per
ho
ngh n g
scan cycle in order for the
n g
udo On-Delay Timer
TSIMATIC
Example: Tud
o
Tud
o
Network 1 //100 ms timer T37 times out after (10 x 100 ms = 1s)
//I0.0 ON=T37 enabled, I0.0 OFF=disable and reset T37

4 .c om .c
LD m
o I0.0
.co m .
24 4 24
TON T37, +10
6a2 2
ng ho g hoa gh o a
g h o a
don n on
Network 2 //T37 bit is controlled by timer T37

d o d
Tu Tu u
LD T37
= Q0.0 T

4 .c om Timing Diagram 4 . c om 4 .co m


4.
h o a2 h oa2 o a 2
hoa 2
ng o ng o n gh o ng
Tu d Tu d 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
198
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2 Tip
o a 2 o a2 o a 24
ngh gh gh g h
To guarantee that the output of a self-resetting timer is turned on for one scan each time the timer
on on on
reaches the preset value, use a normally closed contact instead of the timer bit as the enabling input to
T ud
the timer.
T ud T u d
Example: SIMATIC Self-Resetting On-Delay Timer

. co m .c o m
Network 1
. c o m
//10 ms timer T33 times out after (100 x 10 ms = 1s)

a24 a 2 4 LDN M0.0 //M0.0 pulse is too fast to monitor

a 2 4 with Status view

a2 4.
o ho ho ho
ngh g g g
TON T33, +100
o n n
do becomes true at a rate that is visibleTudo n
Tud Network 2
Tu//Comparison
//with Status view. Turn on Q0.0 after (40 x 10 ms)
//for a 40% OFF/60% ON waveform
LDW>= T33, +40

.co m .c om = Q0.0
. c om
a 2 4 a2 4 //T33 (bit) pulse too fast2
a 4 6a 2 4.
o o Network 3
othrough M0.0 after the (100 x 10 ms) period gho
to monitor with Status view

ngh gh g h
//Reset the timer

d o n LD T33
d o n d on
Tu =
T u
M0.0
T u

4 .c om Timing Diagram

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

.co m .c om . c om
a 2 4 a 2 4 a 2 4 a 2 4.
o ho
Example: SIMATIC Off-Delay Timer
o ho
ngh o n g Network 1 //10-ms n g h
doON–to–OFF=T33 enabled
timer T33 times out after (100 x 10 ms = 1s)
o n g
Tud Tu//I0.0
//I0.0 OFF–to–ON=disable and reset T33 Tud
LD I0.0
TOF T33, +100

.c o m . c o m . c o m contact T33
4.
Network 2 //Timer T33 controls Q0.0 through timer

o a24 ho a 2 4 LD T33
ho a 2 4
hoa 2
ngh g g g
= Q0.0
o n o n o n
Tud Tud Tud
Timing Diagram

.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 199
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 Example: SIMATIC Retentive On-Delay


4 . c om 4 . c om 4.
o a 2 a 2 Timer
a 2 a 2
ngh n g ho Network 1
n g
//10 ms TONR timer T1 o out at PT=(100 x 10 ms=1s)
htimes n g ho
o do o
Tud TONR T1, +100 Tu Tud
LD I0.0

Network 2 //T1 bit is controlled by timer T1.


//Turns Q0.0 on after the timer accumulates a total

. co m .c o m //of 1 second
. c o m
24 24 LD T1
a24 2 4.
ng hoa g hoa = Q0.0
g ho ng ho a
Tu don Network 3 d o n
TauT address.
//TONR timers
//with
must be reset by a Reset instruction
Tu d o
//Resets timer T1 (current and bit) when I0.1 is on.
LD I0.1
R T1, 1

.co m .co m .co m .


6 2 4 2 4 2 4 24
g hoa Timing Diagram
gh o a
gh o a
g h o a
n d o n d o n d on
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 .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
200
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
S7-200 Instruction Set Chapter 6

4 .c om IEC Timer Instructions4.com 4. c om .


o a2 o a2 o a2 o a 24
ng h h
ngTimer (TON) instruction counts time when ng h g h
on
On-Delay Timer
d o d o d
Tu input is on.
The On-Delay
enabling Tu the
T u
Off-Delay Timer

. co m .c m
The Off-Delay Timer (TOF) delays turning an output off for a fixed
o . c o m
4.
period of time after the input turns off.
24 24 a24 2
ng hoa Pulse Timer
g hoa gho ng ho a
don do
The Pulse Timer (TP) generates pulses for a specific duration.
Tu Tu
n
Tu d o
Table 6-72 Valid Operands for the IEC Timer Instructions

Inputs/Outputs Data Types Operands

4 .c om Txx

4 . om
TON, TOF, TP Constant (T32 to T63, T96 to T255)
c 4 . c om 4.
oa 2 IN
a 2
BOOL I, Q, V, M, SM, S, T, C, L, Power Flow
a 2 6a 2
n g h PT
n g hINTo IW, QW, VW, MW, SMW, SW, LW, AC,o
n g h AIW, *VD, *LD, *AC, Constant n g ho
Q
u d o BOOL I, Q, V, M, SM, S, L
u d o u d o
T
ET INT T
IW, QW, VW, MW, SMW, SW, LW, AC, AQW, *VD, *LD, *AC T
Tip

om om om
You cannot share the same timer numbers for TOF, TON, and TP. For example, you cannot have both a

4 .c TON T32 and a TOF T32.


4 . c 4 . c 4.
o a2 a 2
ho counts time intervals up to the preset a 2
o when the enabling input (IN) gho a 2
ngh hvalue
- The TON instruction
ng true. When the elapsed time (ET) is equaln
o on. The output bit resets when the enabling
becomes to g
oinput turns off. When the preset is reached, on
the Preset Time (PT), the timer output bit (Q)
T u d
turns
T u d T u dtiming
stops and the timer is disabled.
- The TOF instruction delays setting an output to off for a fixed period of time after the input turns off.
It times up to the preset value when the enabling input (IN) turns off. When the elapsed time (ET) is

.co m .co m .co m


equal to the preset time (PT), the timer output bit (Q) turns off. When the preset is reached, the timer
.
a 2 4 a 2 4 a 2 4
output bit turns off and the elapsed time is maintained until the enabling input makes the transition
a 24
o ho ho
to on. If the enabling input sets the transition to off for a period of time shorter than the preset time,
o
ngh d o g
the output bit remains on.
n d o n g
d o ng h
Tuoutput bit (Q) turns on. The output bit remains
- The
Tuon for the pulse specified within the presetTtime
TP instruction generates pulses for a specific
u (PT).
duration. As the enabling input (IN) turns on, the

When the elapsed time (ET) reaches preset (PT), the output bit turns off. The elapsed time is
maintained until the enabling input turns off. When the output bit turns on, it remains on until the
pulse time has elapsed.

.c o m . c o m . c o m .
a24 24 24 24
Each count of the current value is a multiple of the time base. For example, a count of 50 on a 10-ms timer

hoa hoa a
represents 500 ms. The IEC timers (TON, TOF, and TP) are available in three resolutions. The resolution
o o
ngh ng g gh
is determined by the timer number, as shown in Table 6-73.

d o d on o n
Tu Resolution of the IEC Timers
Table 6-73
Resolution Maximum Value
T u
Timer Number
Tud
1 ms 32.767 s (0.546 minutes) T32, T96

4 .c om 10 ms

4 . c o m
327.67 s (5.46 minutes)

4 . com
T33 to T36, T97 to T100

4.
2 100 ms
2 3276.7 s (54.6 minutes)
a2
T37 to T63, T101 to T255
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 201
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 Example: IEC On-Delay Timer Instruction


4 . c om 4. c om .
o a2 o a2 Timing Diagram o a2 o a 24
ng h ng h ng h g h
d o d o d on
Tu Tu Input
T u
VW100 (current)

. co m .c o m PT = 3

. c o m PT = 3

24 24
Output (Q)
24 2 4.
ng hoa ng hoa gh oa
ng ho a
d o on o
TIEC
Example: u Off-Delay Timer Instruction Tud Tu d
Timing Diagram
Input

4 .c om 4 .c om 4 .co m .
6a2 2 VW100 (current)
2 24
ng ho g hoa gh
PT = 3 o a PT = 3
g h o a
Tu don Output (Q)

Tu d o n
T u d on

.c om Example: IEC Pulse Timer Instruction .com . c om


a2 4 a2 4 Timing Diagram
a2 4 a 2 4.
h o h o h o ho
ng ng ng g
Input

d o d o o n
Tu Tu
VW100 (current)
Tud
PT = 3
Output

.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
202
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
S7-200 Instruction Set Chapter 6

4 .c om 4 . c om 4. c om .
o a2 Subroutine Instructions
o a2 o a2 o a 24
ng h h
ng You instruction (CALL) transfers control ton g h g h
d o
The Call Subroutine
d o the
d on
Tu parameters. After the subroutine completes
subroutine
without
SBR_N. can use a Call
Tuits execution,
Subroutine instruction with or
T u
control returns to the instruction that follows the Call Subroutine.
The Conditional Return from Subroutine instruction (CRET)

.com o m o m
terminates the subroutine based upon the preceding logic.

24 .c
24the Edit > Insert > Subroutine menu oa24. c 2 4.
h o a h o a
To add a subroutine, select
ho a
ng
command.
o n gthat o n gh ong
ud
Error conditions set ENO = 0
HT0008 (maximum subroutine nesting exceeded) Tud Tu d
H 0006 (indirect address)

4 .c om m
From the main program, you can nest subroutines (place a
.co
subroutine call within a subroutine) to a depth of eight. From an
4 4 .co m
4.
2 2 2 6 2
hoa a a a
interrupt routine, you cannot nest subroutines.
gh o gh o gho
ng o n o n
A subroutine call cannot be placed in any subroutine called from an interrupt routine. Recursion (a
d d o n
Tu Tu
subroutine that calls itself) is not prohibited, but you should use caution when using recursion with
subroutines. Tud
Table 6-74 Valid Operands for the Subroutine Instructions

4 .c om Inputs/Outputs
4 . c om
Data Types
Operands
4 . c om 4.
o a2 SBR_N WORD2
oa a2 and CPU 226:
Constant for CPU 221, CPU 222, CPU 224,
o
0 to 63
hoa 2
ngh h h
for CPU 226XM: 0 to 127

d o ng d o ng o ng
Tu
Tip
Tu Tud
STEP 7–Micro/WIN automatically adds an unconditional return from each subroutine.

.co m .co m .co m


When a subroutine is called, the entire logic stack is saved, the top of stack is set to one, all other stack
.
a 2 4 a 2 4 a 2 4
locations are set to zero, and control is transferred to the called subroutine. When this subroutine is
a 24
o ho ho
completed, the stack is restored with the values saved at the point of call, and control is returned to the
o
ngh n g
calling routine.
d o d o n g
d o ng h
Tu
Accumulators are common to subroutines and theu
T calling routine. No save or restore operationTisu
performed on accumulators due to subroutine use.

Calling a Subroutine With Parameters


.c o m . c o m . c o m
Subroutines can contain passed parameters. The parameters are defined in the local variable table of the .
2 4 24 24 24
hoa hoa hoa a
subroutine. The parameters must have a symbol name (maximum of 23 characters), a variable type, and
a data type. Sixteen parameters can be passed to or from a subroutine.
gh o
ng d on g
d on g o n
u u Tud
The variable type field in the local variable table defines whether the variable is passed into the subroutine
T T
(IN), passed into and out of the subroutine (IN_OUT), or passed out of the subroutine (OUT). Table 6-75
describes the parameter types for a subroutine. To add a parameter entry, place the cursor on the variable
type field of the type (IN, IN_OUT, or OUT) that you want to add. Click the right mouse button to get a
menu of options. Select the Insert option and then the Row Below option. Another parameter entry of the

.co m .co m
selected type appears below the current entry.
. 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 203
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
S7-200 Programmable Controller System Manual

4 .c omTable 6-75 4 .co m


4. c om .
o a2 2
Parameter Types for a Subroutine
a a2 a 24
ngh
Parameter
n g ho
Description
n g ho ng h o
IN
d o d o
Parameters are passed into the subroutine. If the parameter is a direct address (such as VB10), the
d o
Tu value Tusubroutine. If the parameter is an indirect addressTu
at the specified location is passed into the
(such as *AC1), the value at the location pointed to is passed into the subroutine. If the parameter is a
data constant (16#1234) or an address (&VB100), the constant or address value is passed into the
subroutine.

. co m IN_OUT o m o m
The value at the specified parameter location is passed into the subroutine, and the result value from
.c . c
24 24 a24 4.
the subroutine is returned to the same location. Constants (such as 16#1234) and addresses (such as
2
hoa a a
&VB100) are not allowed for input/output parameters.
o from the subroutine is returned to the specified
hvalue o location. Constants (such
hparameter ho
ng OUT
n g
The result
n g n g
TEMP T
udo
as 16#1234) and addresses (such as &VB100)
udo can be used for temporary storage within
are not
Tparameters
Any local memory that is not used for passed
allowed as output parameters.
Tuthed
o
subroutine.

As shown in Figure 6-37, the data type field in the local variable table defines the size and format of the
.c o m . c m
obelow: . c om 4.
parameter. The parameter types are listed
6a 2 4 - BOOL: This data type a 2 4 a 2 4 a 2
o ho is used for single bit
ho ho
ngh n g
inputs and outputs. IN3 in the following
doa Boolean input.
example is
do n g
do n g
T u
- BYTE, WORD, DWORD: These data types T u T u
identify an unsigned input or output
parameter of 1, 2, or 4 bytes, respectively.

.c om- .co m
INT, DINT: These data types identify signed
.co m
24 4
input or output parameters of 2 or 4 bytes,
2 2 4 2 4.
hoa oa o a hoa
respectively. Figure 6-37 Local Variable Table

ng n g h n g hfloating-point ng
-
o
REAL: This data type identifies a single precision (4 o
byte) IEEE value. o
- TudFlow: Boolean power flow is allowed onlyTforubitd(Boolean) inputs. This declaration tellsTud
Power
STEP 7-Micro/WIN that this input parameter is the result of power flow based on a combination of
bit logic instructions. Boolean power flow inputs must appear first in the local variable table before
any other type input. Only input parameters are allowed to be used this way. The enable input (EN)

.co m .co m
and the IN1 inputs in the following example use Boolean logic.
.co m .
a 2 4 a 2 4 a 2 4 a 24
o o o o
ngh gh gh h
Example: Subroutine Call

o n o n on g
Tud d d
There are two STL examples provided. The first set of STL instructions can be displayed only in the STL editor since
Tu
the BOOL parameters used as power flow inputs are not saved to L memory.
The second set of STL instructions can be displayed also in the LAD and FBD editors because L memory is used to
T u
save the state of the BOOL inputs parameters that are shown as power flow inputs in LAD and FBD.
STL only:

.c o m . c o mNetwork 1 . c o m .
2 4 2 4 24 24
hoa hoa hoa a
LD I0.0

gh o
ng g g
CALL SBR_0, I0.1, VB10, I1.0, &VB100, *AC1, VD200

d on d on o n
T u T u
To display correctly in LAD and FBD:
Network 1
Tud
LD I0.0
= L60.0

.co m .co m LD I0.1


. com
a2 4 a 2 4 =
LD
L63.7
L60.0
a2 4 a2 4.
o gho o ho
ng h gh ng
CALL SBR_0, L63.7, VB10, I1.0, &VB100, *AC1, VD200

Tu don Tu d o n
Tu d o

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
204
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
S7-200 Instruction Set Chapter 6

4 .c om 4 .co m
4. c om .
oa2 o 2 o a2
Address parameters such as IN4 (&VB100) are passed into a subroutine as a DWORD (unsigned double
a
word) value. The type of a constant parameter must be specified for the parameter in the calling routine
o a 24
ngh n gh n gh
with a constant descriptor in front of the constant value. For example, to pass an unsigned double word
o o on g h
T ud T ud
constant with a value of 12,345 as a parameter, the constant parameter must be specified as DW#12345.
If the constant describer is omitted from the parameter, the constant can be assumed to be a different T u d
type.

There are no automatic data type conversions performed on the input or output parameters. For example,

. co m .c m . c o m
if the local variable table specifies that a parameter has the data type REAL, and in the calling routine a
o
a24
double word (DWORD) is specified for that parameter, the value in the subroutine will be a double word.
a24 a 2 4 of the subroutine. The a2 4.
o hof othe local variable table shows the localnmemory
hoaddress for each passed parameter.ngho
ngh
When values are passed to a subroutine, they are placed into the local memory
n g
left-most column g
udovaluesvalues
Input parameter
T
parameter are copied from the subroutine’sT ulocalomemory
are copied to the subroutine’sdlocal memory when the subroutine is called. d
T
to the specified output parameter
o
uOutput
addresses when the subroutine execution is complete.

The data element size and type are represented in the coding of the parameters. Assignment of

4 .c om 4 . om
parameter values to local memory in the subroutine is as follows:
c 4 . c om 4.
oa 2 a
- Parameter values are 2 a 2
assigned to local memory in the order specified
oparameters starting at L.0.
by the call subroutine 6a 2
n g h instruction h
n g with
n g ho n g ho
doto eighttoconsecutive
- One
Tucontinuing Lx.7.
bit parameter values d
Tu
oassigned to a single byte starting with Lx.0
are
Tud
o
and

- Byte, word, and double word values are assigned to local memory on byte boundaries (LBx, LWx,
or LDx).

4 .c om 4 . om 4 . om
In the Call Subroutine instruction with parameters, parameters must be arranged in order with input
c c
parameters first, followed by input/output parameters, and then followed by output parameters. 4.
o a2 o ain2STL, the format of the CALL instructionhois:a2 hoa 2
ngh g h n2, g g
If you are programming

d o nsubroutine d o o n
Tu CALL number, parameter 1,
Tu
parameter ... , parameter
Tud
Example: Subroutine and Return from Subroutine Instructions

4 . c om M

4 .c om Network 1

4 .co m
//On the first scan, call subroutine 0 for initialization.
.
24
A LD SM0.1
2 2 2
hoa hoa a a
I
ho o
CALL SBR_0

ng
N
ng n g g h
d o do//You can use a conditional return to leave d on
TB u
S
Tu
Network 1
//the subroutine before the last network. T u
R LD M14.3
0 CRET

.c o m . c o m Network 2
. c o m
//This network will be skipped if M14.3 is on.
.
o a24 hoa
24 LD SM0.0
hoa
24 oa 24
ngh g g gh
MOVB 10, VB0

d on 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 205
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 .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 .


6 2 4 2 4 2 4 24
g hoa gh o a
gh o a
g h o a
n d o n d o n d on
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
206
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 Communicating a 2 over a Network a 2 a 2
ngh n g ho n g ho n g ho
do
TuS7-200
o o
Tudand networking needs by supporting notTuonlydthe
The is designed to solve your communications
simplest of networks but also supporting more complex networks. The S7-200 also provides tools that
allow you to communicate with other devices, such as printers and weigh scales which use their own
communications protocols.

. co m .c o m . c o m
24 24
STEP 7–Micro/WIN makes setting up and configuring your network simple and straightforward.
a24 2 4.
ng hoa ng hoa n gho ng ho a
d o do d o
Tu
In This Chapter
Tu Tu
Understanding the Basics of S7-200 Network Communications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
Selecting the Communications Protocol for Your Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211

.co m .co m .co m


Installing and Removing Communications Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
.
a 2 4 a 2 4 a 2 4
Building Your Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
a 24
o o o o
ngh h h h
Creating User-Defined Protocols with Freeport Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
o n g o n g ng
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . o224
d
Using Modems and STEP 7–Micro/WIN with Your Network
d d
Tu Topics . . . . . . . . . . . . . . . . . . . . . . . . . T. . .u. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .T. . .u. . 228
Advanced

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 207
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 the Basics
a 2 of S7-200 Network 2
Communications
a a 2
ngh n g ho n g ho n g ho
Using Master
u o Slave Devices on a Network
dand u do u do
T T T
The S7-200 supports a master-slave network and can function as either a master or a slave in a network,
while STEP 7–Micro/WIN is always a master.

. co m Tip
. c o mno other master can be present on the.cnetwork.
o m
a 2 4 If you use Windows NT and a PC/PPI
a 2 4 cable,
a 2 4 a2 4.
o ho ho ho
ngh Masters n g
dis oa master on a network can initiate a request n g
dtooanother device on the network. A master don g
T u
A device that
T u
can also respond to requests from other masters on the network. Typical master devices include
T u
STEP 7–Micro/WIN, human-machine interface devices such as a TD 200, and S7-300 or S7-400 PLCs.
The S7-200 functions as a master when it is requesting information from another S7-200 (peer-to-peer

.co m communications).
.co m .co m .
a 2 4 Tip
a 2 4 a 2 4 a 24
o o o o
ngh d o gh
A TP070 will not work on a network with another master device.
n d o n gh
d on g h
7 Slaves
Tu Tu T u
A device that is configured as a slave can only respond to requests from a master device; a slave never
initiates a request. For most networks, the S7-200 functions as a slave. As a slave device, the S7-200

4 .c om 4 . om 4 . om
responds to requests from a network master device, such as an operator panel or STEP 7–Micro/WIN.
c c 4.
o a2 Setting the Baud Rate a 2
hoand Network Address nrate, o a 2
hoa 2
ngh The speed that o n g g hwhich ng
Tud (kbaud) or megabaud (Mbaud). The T udrateomeasures how much data can be Tudo
data is transmitted across the network is the baud is typically measured in
units of kilobaud baud
transmitted within a given amount of time. For example, a baud rate of 19.2 kbaud describes a
transmission rate of 19,200 bits per second.

Every device that communicates over a given


omnetwork om om
Table 7-1 Baud Rates Supported by the S7-200

4 . c .c
must be configured to transmit data
the same baud rate. Therefore, the4fastest
at
Network
4 . c
Baud Rate
24.
h o a2 h o a2 by the baud
o a29.6 kbaud to 187.5 kbaud o a
gh h
rate for the network is determined Standard Network

ng d o ng to the network.
slowest device connected
d o
Using an EM 277 n 9.6 kbaud to 12 Mbaud
d on g
u the baud rates supported by the
Tlists
Table 7-1 Tu
Freeport Mode 1200 baud to 115.2 kbaud u
T
S7-200.

The network address is a unique number that Table 7-2 Default Addresses for S7-200 Devices

.c o m . c o m
you assign to each device on the network. The
unique network address ensures that the data S7-200 Device
. c o m
Default Address
.
o a24 hoa
24
is transferred to or retrieved from the correct STEP 7–Micro/WIN
oa 24 0
oa 24
ngh h gh
device. The S7-200 supports network
g g
HMI (TD 200, TP, or OP) 1

don on o n
addresses from 0 to 126. For an S7-200 with

Tu
two ports, each port can have a network
address. Table 7-2 lists the default (factory)
u d
S7-200 CPU
T
2
Tud
settings for the S7-200 devices.

.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
208
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
Communicating over a Network Chapter 7

4 .c om 4 .co m
4. c om .
oa2 o a 2
Setting the Baud Rate and Network Address for STEP 7–Micro/WIN
o a2 o a 24
ngh gh gh h
You must configure the baud rate and network address for STEP 7–Micro/WIN. The baud rate must be the
on on
same as the other devices on the network, and the network address must be unique.
on g
ud
Typically, ud T u d
T you do not change the network addressT (0) for STEP 7–Micro/WIN. If your network includes
another programming package, such as STEP 7, then you might need to change the network address for
STEP 7–Micro/WIN.

. co m .c m
As shown in Figure 7-1, configuring the baud rate and
o . c o m
24 24
network address for STEP 7–Micro/WIN is simple. After you
a24
1.
2 4.
hoa hoa a
click the Communications icon in the Navigation bar, you

ng g
perform the following steps:
n n gho ng ho
do the icon in the Communications
T1. uDouble-click T u do
Setup
Tu d o
window.
2. Click the Properties button on the Set PG/PC Interface
dialog box. 2.

4 .c om 3.
c om
Select the network address for STEP 7–Micro/WIN.
4 . 4 . c om .
2 a2for STEP 7–Micro/WIN. a2 3.
24
hoa a
4. Select the baud rate
h o h o h o
ng d o ng d o ng d o ng
Tu Tu Tu 4. 7
Figure 7-1 Configuring STEP 7–Micro/WIN

4 .c om 4 .com 4 . c om 4.
o a 2 a 2
Setting the Baud Rate and Network Address for the S7-200
a 2 a 2
ngh ho the baud rate and network addressnfor
You must also configure
n g g htheoS7-200. The system block of the
select the parameters for the S7-200, you ng
ho
o
S7-200 stores
o
the baud rate and network address. After you
o
T d the system block to the S7-200.Tud
mustudownload

The default baud rate for each S7-200 port is 9.6 kbaud, and
Tud
the default network address is 2.

4 . c om 4 .co m
As shown in Figure 7-2, use STEP 7–Micro/WIN to set the
4 .co m .
24
baud rate and network address for the S7-200. After you
2 2 2
hoa a a a
select the System Block icon in the Navigation bar or select
ho ho o
1.

ng g
the View > Component > System Block menu command,
n n g g h
do
you perform the following steps:
do d on 2.

T1. uSelect T
the network address for the S7-200.
u T u
2. Select the baud rate for the S7-200.
3. Download the system block to the S7-200.

.c o m . c o m . c o m .
2 4 24 24 24
ng hoa g hoa ghoa
Figure 7-2 Configuring the S7-200 CPU
gh oa
d on 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 209
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 omSetting the Remote Address4.com 4 . c om 4.


o a 2 a 2 a 2 a 2
ngh
Before you can
n g ho and the remote address of thenS7-200
download the updated settings to the S7-200, you
hoto match the current setting of ngho
must
g set both the communications

udo See Figure 7-3. udo udo


(COM) port of STEP 7–Micro/WIN
the remote S7-200.
T
After you download the updated settings, you must
T T
reconfigure the COM port (if different from the setting used
to download the settings for the remote S7-200). To display 1.

. co m o m
the Communications dialog box, either click the
.c . c o m
24 24
Communications icon in the Navigation bar or select the
a24 2 4.
hoa hoa ho ho a
View > Component >Communications menu command.

ng 1.
don
g
Select the remote address.
do n g
d ong
2. Tu Tu
Ensure that the parameters (baud rate) for the COM
port, the remote S7-200 port, and the PC/PPI cable
Tu
match. Otherwise, the communications fail.
Figure 7-3 Configuring the S7-200 CPU

.co mSearching for the S7-200 CPUs.conoam . c om .


a 2 4 a 2 4 Network
a 2 4 a 2 4
o o rate o network. You can also search ho
ngh hbaud hS7-200s.
You can search for and identify the S7-200 CPUs that are attached to your
n g
the network at a specific or at all baud rates when lookingg
n for
n g
7 T
If you are u do
using a PC/PPI cable, STEP 7–Micro/WIN can T udo T udo
only search at 9.6 kbaud and 19.2 kbaud. For a CP card,
STEP 7–Micro/WIN searches 9.6 kbaud, 19.2 kbaud and 1.
187.5 kbaud. The search starts at the baud rate that is

4 .c om currently selected.
4 . c om 4 . c om 4.
o a2 1. Open the Communications
o 2dialog
aicon box and
o a2 hoa 2
ngh g h g h g
double-click the Refresh to start the search.
To searcho allnbaud rates, select the Search All Baud on o n
2.
d
Tucheck box.
Rates Tu d Tu2.d
Figure 7-4 Searching for CPUs on a Network

.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
210
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
Communicating over a Network Chapter 7

4 .c om 4 .c om 4. c om 4.
o a 2 Selecting the
a 2
Communications Protocol for Your
o one or more of the following communications a 2Network
a 2
ngh The S7-200n g hsupport n g ho capabilities that allow you to ngho
doyour network for the performance andTfunctionality
udo that your application requires: Tudo
CPUs

T-uPoint-to-Point
configure

Interface (PPI)
- Multi-Point Interface (MPI)

. co m - PROFIBUS
.c o m . c o m
a 24 a
Based on the Open System 2 4Interconnection (OSI) seven-layer modelaof2communications
4 architecture,
a2 4.
o hoimplemented o to the PROFIBUS standard as gho
ngh
on a token ring network whichh
n g
these protocols are
owith one start bit, eight data bits, even parity,
defined in the European Standard EN 50170. These protocols n g conforms
are asynchronous, character-based
on
o one stop bit. Communications framesudepend
u d
protocols
T special start and stop characters, source and u d and d
T destination station addresses, frame length,Tand a
upon
checksum for data integrity. The protocols can run on a network simultaneously without interfering with
each other, as long as the baud rate is the same for each protocol.

.co m PPI Protocol . c om . c om .


a 2 4 a 2 4 a 2 4 a 2 4
o hodevices, ho STEP ho
ngh
PPI is a master-slave protocol: the master devices send
requests to thegslave g g
7–Micro/WIN:
n and the slave devices
n n
udoSeebutFigure udoor udo
Master
respond. 7-5. Slave devices do not initiate
T
messages, wait until a master sends them aT request T 7
polls them for a response. S7-200
Masters communicate to slaves by means of a shared

4 .c om 4
m
connection which is managed by the PPI protocol. PPI does
.co
not limit the number of masters that can communicate with
4 .co m HMI: Master
4.
o a2 oa 2
any one slave; however, you cannot install more than 32
a 2
ho 7-5 PPI Network hoa 2
ngh g h g g
masters on the network. Figure
n n
doPPI Advanced allows network devicesTtouestablish
do a logical connection between theTdevices.do n
u
Selecting
T u
With PPI Advanced, there are a limited number of connections supplied by each device. See Table 7-3 for
the number of connections supported by the S7-200.

S7-200 CPUs can act as master devices while they are in RUN mode, if you enable PPI master mode in

.com .co m .co m


the user program. (See the description of SMB30 in Appendix D.) After enabling PPI master mode, you
.
a24 4 4 24
can use the Network Read or the Network Write instructions to read from or write to other S7-200s. While
o o a 2 o a 2
the S7-200 is acting as a PPI master, it still responds as a slave to requests from other masters.
o a
ngh o n gh o n gh on g h
Tud d d
You can use PPI protocol to communicate with all S7-200 CPUs. To communicate with an EM 277, you
must enable PPI Advanced.
Tu T u
Table 7-3 Number of Connections for the S7-200 CPU and EM 277 Modules

.c o m Module

. c o m
Baud Rate

. c o m
Connections

a2 4 S7-200 CPU
a 2 49.6 kbaud, 19.2 kbaud, or 187.5 kbaud a24 4
Port 0 9.6 kbaud, 19.2 kbaud, or 187.5 kbaud 4
a 2 4.
ho ho Port 1
ho ho
ng o n
EM 277 Moduleg 9.6 kbaud to 12 Mbaud
o n g 6 per module
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 211
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
oMPI .co m . c om .
a2 4 Protocol
a 2 4 a2 4 a 24
o o o o
ngh gh STEPh h
MPI allows both master-master and master-slave
on n g 7–Micro/WIN:
S7-200: Slave
on g
udo
Master
ud d
communications. See Figure 7-6. To communicate with an
T
S7-200 CPU, STEP 7–Micro/WIN establishes a
master–slave connection. MPI protocol does not T T u
communicate with an S7-200 CPU operating as a master.
S7-300: Master
Network devices communicate by means of separate

. co m c o m
connections (managed by the MPI protocol) between any
. . c o m
24 24
two devices. Communication between devices is limited to
a24 2 4.
ng hoa hoa
the number of connections supported by the S7-200 CPU or
g gho ng ho a
don n
EM 277 modules. See Table 7-3 for the number of
connections supported by the S7-200.
Tu Tu do
Figure 7-6MPI Network
Tu d o
For MPI protocol, the S7-300 and S7-400 PLCs use the XGET and XPUT instructions to read and write
data to the S7-200 CPU. For information about these instructions, refer to your S7-300 or S7-400
programming manual.

.c m
oPROFIBUS .c om . c om
a 2 4 Protocol
a 2 4 a 2 4 a 2 4.
o hisodesigned for high-speed ho ho
ngh
The PROFIBUS protocol S7-200 (EM 277): Slave
n g n g n g
doPROFIBUS devices available from aTvariety do S7-300: Master do
communications with distributed I/O devices (remote I/O).
There are u u u
7 T many
of manufacturers. These devices range from simple input or T
output modules to motor controllers and PLCs.
PROFIBUS networks typically have one master and several ET 200: Slave

.c om c
configured to know what types of I/O.slaveso
slave I/O devices. See Figure 7-7. The master m device is
. c o m
a 2 4 and at what addresses. The a 2 4 are connected
a 2 4 a 2 4.
o odevices on the network match the gho
master initializes the network
o
ngh g h
and verifies that the slave
n n
o master continuously writes output datautodoFigure 7-7 PROFIBUS Network o ng h
T anddreads input data from them. Tud
configuration. The
the slavesu
T
When a DP master configures a slave device successfully, it then owns that slave device. If there is a
second master device on the network, it has very limited access to the slaves owned by the first master.

.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
212
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
Communicating over a Network Chapter 7

4 .c om Sample Network Configurations


4 .c om Using Only S7-200 Devices 4. c om .
o a2 o a2 o a2 o a 24
ng h h
g PPI Networks ng h g h
For u
onsingle-master
Single-Master
d u d o u d on
T and the S7-200 CPU are connected by T
a simple
station
network, the programming
either a T
PC/PPI cable or by a communications processor (CP) card
installed in the programming station.

. co m .c o m
In the sample network at the top of Figure 7-8, the
. c o m S7-200

24 24
programming station (STEP 7–Micro/WIN) is the network
a24
STEP 7–Micro/WIN
2 4.
ng hoa hoa ho
master. In the sample network at the bottom of Figure 7-8, a
g g ng ho a
don n
human-machine interface (HMI) device (such as a TD 200,
TP, or OP) is the network master.
Tu Tu do HMI (such as a TD 200)
Tu d o
S7-200
In both sample networks, the S7-200 CPU is a slave that
responds to requests from the master. Figure 7-8 Single-Master PPI Network

om
For a single-master PPI configuration, you configure STEP 7–Micro/WIN to use PPI protocol: select either
.c .co m
single-master, multi-master, or PPI Advanced.
.co m .
2 4 2 4 2 4 24
ng hoa g ho a
Multi-Master PPI Networks
n n g ho a
ng h o a
d o
Figure 7-9 shows a sample network of multiple masterso
d with one slave. The programming station
d o
Tu 7–Micro/WIN) uses either a CP card or aTPC/PPI
(STEP
device share the network.
u cable, and STEP 7–Micro/WIN and theTHMI u 7
Both STEP 7–Micro/WIN and the HMI device are masters

4 .c om CPU is a slave.
4 . c om
and must have separate network addresses. The S7-200
4 . c om S7-200

4.
2 2 2 2
ng hoa g h o a masters accessing a single
For a network with multiple
g h o a
g hoa
on STEP
slave, you configure
d on
7–Micro/WIN to use PPI protocol
d o n
withu
T the
optimal.
multi-master
T u
driver enabled. PPI Advanced is STEP 7–Micro/WIN
Tud
HMI

Figure 7-9 Multiple Masters with One Slave

om m m
Figure 7-10 shows a PPI network with multiple masters

2 4 . c 2 4 .co
communicating with multiple slaves. In this example, both
STEP 7–Micro/WIN and the HMI can request data from any 2 4 .co 24.
ng hoa ho a
S7-200 CPU slave. STEP 7–Micro/WIN and the HMI device
n g n g ho a S7-200

g h o a
share the network.
udo(masters and slaves) have differentTnetwork
udo u d on
Tdevices
All
addresses.
STEP 7–Micro/WIN T
S7-200
For a PPI network with multiple masters and multiple slaves, HMI

.c o m . c o m
you configure STEP 7–Micro/WIN to use PPI protocol with
the multi-master driver enabled. PPI Advanced is optimal.
. c o m
Figure 7-10 Multiple Masters and Slaves
.
o a24 oa 24 oa 24 oa 24
ngh g h
Complex PPI Networks
d onshows a sample network that uses multipleon
d
g h
o n gh
Tud
Figure 7-11
T u
masters with peer-to-peer communications. Tu
STEP 7–Micro/WIN and the HMI device read and write over S7-200
the network to the S7-200 CPUs, and the S7-200 CPUs use

.co m . c om
the Network Read and Network Write instructions to read
. com 4.
and write to each other (peer-to-peer communications). STEP 7–Micro/WIN

a2 4 a 2 4 a 2 4 a2
o hoto use PPI protocol with the multi-master
For this type of complex PPI network, you configure
ho ho
ng h
HMI
g g g
S7-200

driver d n
STEP 7–Micro/WIN
o PPI Advanced is optimal. o n on
Tud Figure 7-11 Peer-to-Peer Communications
Tud
enabled.
Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 213
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 omFigure 7-12 shows another example 4 .c om 4. c om .


o a2 o a2 each
network that uses multiple masters
of a complex PPI
with peer-to-peer
o a2
HMI HMI

o a 24
ng h g h ng h g h
S7-200 CPU.don on
communications. In this example, HMI monitors one
d o d
Tu
The S7-200 CPUs use the NETR and NETW instructions to
Tu T u
read and write to each other (peer-to-peer communications). STEP 7–Micro/WIN

For this network, you configure STEP 7–Micro/WIN to use

. co mPPI protocol with the multi-master drivero


. c m PPI
enabled.
. c o m
a 2 4 Advanced is optimal.
a 2 4 a 2 4 and Peer-to-Peer S7-200

a2 4. S7-200

o ho ho ho
ngh
Figure 7-12 HMI Devices

o n g o n g on g
Tud Configurations Using S7-200,
Sample Network Tud S7-300, and S7-400 Devices Tud
Networks with Baud Rates Up to 187.5 kbaud

.c o m .c
uses the XPUT and XGET instructions to m
In the sample network shown in Figure 7-13, the S7-300
ocommunicate with
. c om
S7-300
HMI

.
a2 4 a2
an S7-200 CPU. The S7-300 cannot4 communicate with an
a2 4 a 24
ho h o
S7-200 CPU in master mode.
h o h o
ng For baud rates o
d ng19.2 kbaud, STEP 7–Micro/WIN mustdong
above
d on g
7 Tu by a communications processor (CP) card.
be connected Tu STEP 7–Micro/WIN T u
To communicate with the S7-200 CPUs, you configure S7-200 S7-200
STEP 7–Micro/WIN to use PPI protocol with the multi-master

om om om
driver enabled. PPI Advanced is optimal. Figure 7-13 Baud Rates Up to 187.5 Kbaud

2 4 .c 2 4 . c 2 4 . c 2 4.
o a Networks with Baud Rates a Above 187.5 kbaud (Up to 12 Mbaud)
hokbaud, the S7-200 CPU must use annEM a
h277omodule for connecting to the nghoa
ngh For baud rates aboveg
n 187.5
do 7-14. STEP 7–Micro/WIN must beTconnected
g
network. See Figure
card. Tu udo by a communications processor (CP) Tud
o
In this configuration, the S7-300 can communicate with the S7-300 HMI

S7-200s, using the XPUT and XGET instructions, and the

.co m .co m
HMI can monitor either the S7-200s or the S7-300.
.co m .
a 2 4 2 4
The EM 277 is always a slave device.
a a 2 4 a 24
o o o o
ngh gh
STEP 7–Micro/WIN can program or monitor either S7-200
o n o n gh on g h
Tud d d
CPU through the EM 277. To communicate with an EM 277,
Tu u
STEP 7–Micro/WIN
you configure STEP 7–Micro/WIN to use PPI protocol with
the PPI Advanced driver enabled.
T
S7-200 EM 277 S7-200 EM 277

.c o m . c o m . c o m
Figure 7-14 Baud Rates Above 187.5 Kbaud
.
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
214
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
Communicating over a Network Chapter 7

4 .c om Sample PROFIBUS-DP4Network .c om Configurations 4. c om 4.


o a 2 a 2
o DP as PROFIBUS Master and a 2
o 277 as PROFIBUS Slave gho a 2
ngh Networks n
d o g
with
hS7-315–2
d o n g hEM
d on
u
Figure
an
7-15 shows a sample PROFIBUS network u
TS7-315–2 DP as the PROFIBUS master. AnTEM 277
that uses
T u
S7-315-2 DP

module is a PROFIBUS slave.


The S7-315–2 DP can read data from or write data to the PROFIBUS-DP

. co m c o m
EM 277, from 1 byte up to 128 bytes. The S7-315–2 DP
. . c o m
24 2 4
reads or writes V memory locations in the S7-200.
2 4 2 4.
ng hoa g
This network supports
n
a
ho baud rates from 9600 baud to ngho a
n g ho a
o
12 Mbaud. o o
Tud Tud Figure 7-15 Network with S7-315–2TDPud
ET 200 ET 200 S7-200 EM 277

Networks with STEP 7–Micro/WIN and HMI

4 .c om 4 .c om
Figure 7-16 shows a sample network with an S7-315–2 DP
.co
S7-315–2 DP

4
m .
2 2
as the PROFIBUS master and EM 277 as a PROFIBUS
2 HMI
24
ng hoa hoa
slave. In this configuration, the HMI monitors the S7-200
g gh o a
g h o a
don n on
through the EM 277. STEP 7–Micro/WIN programs the
S7-200 through the EM 277.
d o d
Tu Tu
This network supports baud rates from 9600 baud to
PROFIBUS-DP
T u 7
12 Mbaud. STEP 7–Micro/WIN requires a CP card for baud
rates above 19.2 kbaud.

4 .c om 4 .co m
You configure STEP 7–Micro/WIN to use PROFIBUS ET 200
4 .co m S7-200 EM 277
4.
a2 2 2 2
protocol for the CP card. If there are only DP devices
o oa
present on the network, select the DP or Standard profile. If
o a hoa
ngh ngh
there are non-DP devices on the network, then select the
do d o n gh o ng
Tud
Universal (DP/FMS) profile for all PROFIBUS master
Tu
devices. Tu STEP 7–Micro/WIN

Figure 7-16 PROFIBUS Network

.com .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 215
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 Installing and Removing
a 2Communications Interfaces
a 2 a 2
ngh n g ho dialog box, you use the Installing/Uninstalling
n g ho Interfaces dialog box to install ngho
udo interfaces for your computer do
udo
From the Set PG/PC Interface
or remove communications
T T u T
1. In the Set PG/PC Interface dialog box, click Select to access the Installing/Uninstalling Interfaces
dialog box.

. co m .c m . c o m
The Selection box lists the interfaces that are available, and the Installed box displays the interfaces
o 4.
that have already been installed on your computer.

oa 24 a 24
o When you close the Installing/Uninstallling a 2 4installed on your a2
n g h 2. To add a communications
computer and g
n hInstall.
click
n g ho Interfaces dialog box, the Set ngho
interface: Select the communications hardware

u d o
PG/PC Interface dialog box displays the interface in
u d
theoInterface Parameter Assignment Used box. o
ud
3. Tremove a communications interface: Select T
To the interface to be removed and click Uninstall.T
When you close the Installing/Uninstallling Interfaces dialog box, the Set PG/PC Interface dialog
box removes the interface from the Interface Parameter Assignment Used box.

.co m .co m .co m .


a 2 4 a 2 4 1. 2.
a 2 43.
a 24
o o o o
ngh d o n gh
d o n gh
d on gh
7 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

4 . c om Figure 7-17
.co m
Set PG/PC Interface and Installing/Uninstalling Interfaces Dialog Boxes

4 4 .co m .
2 2 2 24
ng hoa Tip
n g ho a
n g ho a
ng h o a
d o d o d o
Tuhardware modules under the Windows NT operating
Tu system is slightly different from installing
Tu
Special Hardware Installation Information for Windows NT Users
Installing
hardware modules under Windows 95. Although the hardware modules are the same for either
operating system, installation under Windows NT requires more knowledge of the hardware that you

.c o m . c m . c
does not. Windows NT provides you with default values only. These values may or may not match them
want to install. Windows 95 tries automatically to set up system resources for you, but Windows NT
o o .
o a24 hoa
24
hoa
24
hardware configuration. These parameters can be modified easily to match the required system
oa 24
ngh gh
settings.

on g on g
When you have installed a piece of hardware, select it from the Installed list box and click the
o n
T u d T u d
Resources button. The Resources dialog box appears. The Resources dialog box allows you to modify
Tud
the system settings for the actual piece of hardware that you installed. If this button is unavailable (gray),
you do not need to do anything more.
At this point you may need to refer to your hardware manual to determine the setting for each of the

.co m .co m . com


parameters listed in the dialog box, depending on your hardware settings. You might need to try several

a2 4 different interrupts in order to establish communications correctly.


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
216
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
Communicating over a Network Chapter 7

4 .c om Adjusting the Port Settings 4 .c oofmYour Computer for PPI Multi-Master 4 . c om 4.


o a 2 a 2 a 2 a 2
ngh g hoPC/PPI
If you are using the
n cable with an operating system thath
n g o the PPI Multi-Master
supports
n g ho
o o o
Tudon your computer: Tud Tud
configuration (Windows NT does not support the PPI Multi-Master), you might need to adjust the port
settings

1. Right-click the My Computer icon on the desktop and select the Properties menu command.
2. Select the Device Manager tab. For Windows 2000, select first the Hardware tab and then Device

.com o m o m
Manager button.
4 . c
4(COM & LPT). 4 . c 4.
h o a2 a 2
3. Double-click the Ports
h o a 2
ho(for example, COM1). ho a2
n g n
4. Select the g communications
n g
port that you are currently using
n g
dothe Port Settings tab, click the Advanced
T5.6. uSet
On
T do
ubutton. T udo
the Receive Buffer and the Transmit Buffer controls to the lowest value (1).
7. Click OK to apply the change, close all the windows, and reboot the computer to make the new

.co m settings active.


.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 7

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 217
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 Building Your Network
a 2 a 2 a 2
ngh n g ho n g ho n g ho
T do
General Guidelines
u T u do T u do
Always install appropriate surge suppression devices for any wiring that could be subject to lightning
surges.

Avoid placing low-voltage signal wires and communications cables in the same wire tray with AC wires

. co mand high-energy, rapidly switched DC.cwires.


o mAlways route wires in pairs, with the neutral
. c o mcommon wire
or

a 2 4 paired with the hot or


2 4
signal-carrying
a
wire.
a 2 4 a2 4.
o gho o an RS-485 repeater or an ho
ngh The communications port
EM 277 moduleo ton
of the S7-200 CPU is not isolated. Considerh
n g using
n g
ud udo udo
provide isolation for your network.
T
Caution
T T
Interconnecting equipment with different reference potentials can cause unwanted currents to flow
through the interconnecting cable.

.co m These unwanted currents can cause.ccommunications


om c om
errors or can damage equipment.
.
a 2 4 Be sure all equipment that you2
a 4 a 2
are about to connect with a communications cable4 either shares a
a 2 4.
o hoor is isolated to prevent unwanted current ho See the information about ho
ngh g in g g
common circuit reference flows.
o n
grounding and circuit reference points for using isolated circuitsn
o Chapter 3.
o n
7 Tud Tud Tud
Determining the Distances, Transmission Rate, and Cable for Your Network
As shown in Table 7-4, the maximum length of a network segment is determined by two factors: isolation

4 .c omIsolation is required when you connect


4 . om at different ground potentials. Different
(using an RS-485 repeater) and baud rate.
c 4 . c m
oground 4.
o a 2 a 2 devices
a 2 potentials
a 2
ngh n g hophysically
can exist when grounds are
n g ho over short distances, load
separated by a long distance. Even
ng ho
do do do
currents of heavy machinery can cause a difference in ground potential.

T
Table 7-4
u Maximum Length for a Network Cable
T u T u
Baud Rate Non-Isolated CPU Port1 CPU Port with Repeater or EM 277

om 500 kbaud m omm


9.6 kbaud to 187.5 kbaud 50 m 1,000 m
. c c o c
2 4 24. Not supported 4 .400
a2 200 m 24.
ng hoa 1 Mbaud to 1.5 Mbaud
n g hoa Not supported
n g ho ng h o a
d o
3 Mbaud to 12 Mbaud
u
Not supported
u d o 100 m
u d o
1 The T
maximum distance allowed without using an isolator T
or repeater is 50 m. You measure this distance from T
the first
node to the last node in the segment.

.c o mUsing Repeaters on the Network m


. c o . c o m
a2 4 An RS-485 repeater provides
a
bias
2 4and termination for the network segment.
a
You
2 4 a repeater for
can use
a 2 4.
o the following purposes:
ho of a network: Adding a repeater to your ho allows you to extend the ho
ngh - To increase n g
o 50 m. If you connect two repeatersuwith
danother
the length n g
dono other nodes in between (as shownTinudo
network n g
T u
network
T
Figure 7-18), you can extend the network to the maximum cable length for the baud rate. You can
use up to 9 repeaters in series on a network, but the total length of the network must not exceed
9600 m.

.co m- .co m com


To add devices to a network: Each segment can have a maximum of 32 devices connected up to
.
a2 4 a 2 4 a2 4
50 m at 9600 baud. Using a repeater allows you to add another segment (32 devices) to the
a2 4.
o network.
gho o ho
ng h -
don o n gh
To electrically isolate different network segments: Isolating the network improves the quality of the
d d ong
T u T u
transmission by separating the network segments which might be at different ground potentials.
Tu
A repeater on your network counts as one of the nodes on a segment, even though it is not assigned a
network address.

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
218
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
Communicating over a Network Chapter 7

4 .c om 4 .co m
4. c om .
oa2 oa
Segment 2 Segment
o a2 Segment
o a 24
ngh on g h
on gh on g h
Tud RS-485
Repeater T ud RS-485
Repeater T u d

. co m 50 m
.c o m Up to 1000 m
. c o m 50 m

24 24with Repeaters 24 2 4.
hoa a oa a
Figure 7-18 Sample Network

gh o h ho
ng o n on g ong
Tud the Network Cable
Selecting Tud Tu d
S7-200 networks use the RS-485 standard on twisted pair cables. Table 7-5 lists the specifications for the
network cable. You can connect up to 32 devices on a network segment.

.co m Table 7-5


c om
General Specifications for Network Cable
. .co m .
a 2 4 Specifications 4
a2 Description a 2 4 a 24
o o o o
ngh Cable type
o n gh Shielded, twisted pair
o n gh on g h
Tud
Loop resistance
Effective capacitance
115 Ω/km
30 pF/m
Tu d T u d 7
Nominal impedance Approximately 135 Ω to 160 Ω (frequency =3 MHz to 20 MHz)

4 .c om Attenuation

4 . c om 0.9 dB/100 m (frequency=200 kHz)


2 2
4 .co m
4.
2 Cross-sectional core area

oa2 8 mm ±0.5 mm
0.3 mm to 0.5 mm
2 2
ng hoa gh
Cable diameter
n n gh o a
ng hoa
do d o o
Tu
Connector Pin Assignments Tu Tud
The communications ports on the S7-200 CPU are RS-485 compatible on a nine-pin subminiature D
connector in accordance with the PROFIBUS standard as defined in the European Standard EN 50170.
Table 7-6 shows the connector that provides the physical connection for the communications port and
.co m .co m
describes the communications port pin assignments.
.co m .
a 2 4 a 2 4 a 2 4 a 24
o hoPin Number hoPort 0/Port 1 o
ngh h
Table 7-6
Pin Assignments for the S7-200 Communications Port

o n g n g on g
Tud
Connector
1
PROFIBUS
Shield Tu
do
Signal
Chassis ground T u d
2 24 V Return Logic common
Pin 1 3 RS-485 Signal B RS-485 Signal B

.c o m Pin 6
4
.comRequest-to-Send c o
RTS (TTL)
. m .
o a24 o a 245 5 V Return
o a 24
Logic common
oa 24
ngh d o ng h
Pin 9
6 +5 V
d on gh +5 V, 100 Ω series resistor
o n gh
T u
Pin 5 7
8
+24 V
T u
RS-485 Signal A
+24 V
RS-485 Signal A
Tud
9 Not applicable 10-bit protocol select (input)

om om om
Connector shell Shield Chassis ground

2 4 .c 2 4 . c 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 n gh n gho 219
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
oBiasing .c om Cable . c om
a 2 4 and Terminating
a 2
the4 Network
a 2 4 a 2 4.
o ho of connector o connect multiple devices to ho
ngh n g
Siemens provides two types network connectors that you can use to
do port, which allows you to connect o n g heasily
do n g
adprogramming station or an HMI device to the
a network: a standard network (see Table 7-6 for the pin assignments), and a connector that
includes a u u u
T programming
T T
network without disturbing any existing network connections. The programming port connector passes all
signals (including the power pins) from the S7-200 through to the programming port, which is especially
useful for connecting devices that draw power from the S7-200 (such as a TD 200).

. co mBoth connectors have two sets of terminal


. c o m to allow you to attach the incoming
screws
. c o
andm outgoing

a 2 4 network cables. Both connectors


a 2 4
also have switches to bias and terminate
2
the
a 4
network selectively.
a2 4.
o ho ho ho
ngh
Figure 7-19 shows typical biasing and termination for the cable connectors.
n g n g n g
T
Cable umustdobe terminated T
Switch position = On
Terminated and biased
udo Switch position = Off
No termination or bias T udo
Switch position = On
Terminated and biased
and biased at both ends.
On Off On

m m m
aÔ Ô aÔ
2 4 .co 2 4 .co
ABAB ABAB

2 . co
A B AB

4 24 .
ngh
o a
d o n gh o Ô Ôdongho Ô d on g h o a
7 Tu u u
T (1/2 in.) must contact the metal guides of all locations.
Bare shielding: approximately 12 mm T
Switch position = On: Switch position = Off:
B
Terminated and biased No termination or bias TxD/RxD +
om om oA m
Pin # Pin #

2 4 .c 6 .c
4 4
TxD/RxD -
. c 4.
a23 2 2
6

hoa hoa a
Cable shield
o
B 390 Ω
h B
ho
ng TxD/RxD +

do ng Network
don
g TxD/RxD + 3
o ng
Tu8 d
A 220 Ω
TxD/RxDu
Tu
connector A
T - 8
390 Ω
TxD/RxD -

5 5
Cable shield 1 Cable shield 1

.co mFigure 7-19 .co m .co m .


a 2 4 a 2 4
Bias and Termination of the Network Cable
a 2 4 a 24
o ho ho o
ngh Choosing u d n g
oCP Card or PC/PPI Cable foruYour d n g
o Network d o ng h
T the
T Tu
As shown in Table 7-7, STEP 7–Micro/WIN supports several CP cards that allow the programming station
(your computer or SIMATIC programming device) to act as a network master.

.c o m . c m at several baud rates. The PC/PPI cablec


. o m
The CP cards contain dedicated hardware to assist the programming station in managing a multi-master
o 4.
network and can support different protocols also allows you to

a2 4 enable multiple masters.


a 2 4 a 2 4 a 2
o o RS-485 port for connection to the network. ho The CP 5511 PCMCIA card ngho
ngh n g
Each CP card provides ha single n g
udothattheprovides
has an adapter
Tconnect
card and other end to a programming portT u oneoendonofyourthenetwork.
the 9-pin D port. You connect d
connector
cable to the RS-485 port of thedo
Tu
If you are using a CP card with PPI communications: STEP 7–Micro/WIN does not support two different
applications running on the same CP card at the same time. You must close the other application before

.co m . c om
connecting STEP 7–Micro/WIN to the network through the CP card.
. c om
a2 4 Caution a 2 4 a 2 4 a2 4.
o ho ho port of your computer. ho
ng h Using a non-isolatedg
n RS-485-to-RS-232 g
converter can damage the
o cable (order number 6ES7 901–3BF21–0XA0) n RS-232
n g
T
between udRS-485
The Siemens
the
PC/PPI
port on the S7-200 CPU and theT udoport thatprovides
RS-232
electrical isolation
connects to your computer.T If u
do
you do not use the Siemens PC/PPI cable, you must provide isolation for the RS-232 port of your
computer.

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
220
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
Communicating over a Network Chapter 7

4 .c om 4 .co m
4. c om .
oa2
Table 7-7
o a 2
CP Cards and Protocols Supported by STEP 7–Micro/WIN
a2
oBaud Rate o a 24
ngh gh gh h
Configuration Protocol

on on on g
ud ud d
PC/PPI cable1 9.6 kbaud or PPI
T T
Connected to the COM port on the programming station 19.2 kbaud
T u
CP 5511 9.6 kbaud to PPI, MPI, and PROFIBUS
Type II, PCMCIA card (for a notebook computer) 12 Mbaud

. co m CP 5611 (version 3 or greater)

.c o m 9.6 kbaud to

. c o m PPI, MPI, and PROFIBUS

4.
PCI card 12 Mbaud
24 2 4 a2 4 2
hoa hoa a
MPI 9.6 kbaud to PPI, MPI, and PROFIBUS
h o ho
ng ng ong ng
Either an integrated port on a SIMATIC programming device or a CP card 12 Mbaud

d o
for your computer (ISA card)
d d o
1
TTheuPC/PPI cable provides electrical isolation between
Tuthe RS-485 port (on the S7-200 CPU) and the RS-232
Tu port that
connects to your computer. Using a non-isolated RS-485-to-RS-232 converter could damage the RS-232 port of your
computer.

.co m Using HMI Devices on Your .c m


oNetwork . c om
a 2 4 a 2 4
many types of HMI devices from Siemensa 2 4 a 2 4.
o hoHMI devices (such as the TD 200 or nTP070)
The S7-200 CPU supports
hodo not allow you to select the
and also from other manufacturers.
ho
ngh While some ofg
n these
o protocol used by the device, otherudevices g
o (such as the OP7 and TP170) allowuyoudtoo n g
Tud T d
communications
select the communications protocol for that device. T 7
If your HMI device allows you to select the communications protocol, consider the following guidelines:
- For an HMI device connected to the communications port of the S7-200 CPU, with no other devices

4 .c om . c om . c om
on the network, select either the PPI or the MPI protocol for the HMI device.
4 4 4.
o a 2 - For an HMI device
o a 2 a 2 a 2
ho ho
connected to an EM 277 PROFIBUS module, select either the MPI or the

ngh PROFIBUShprotocol.
o n g o n g
do n g
Tud– Ifforthethenetwork Tud S7-300 or S7-400 PLCs, select the MPI
with the HMI device includes
HMI device. Tuprotocol
– If the network with the HMI device is a PROFIBUS network, select the PROFIBUS protocol for
the HMI device and select a profile consistent with the other masters on the PROFIBUS

.co m network.
.co m .co m .
a 2 4 -
a 2 4 a 2 4
For an HMI device connected to the communications port of the S7-200 CPU which has been
a 24
o o o o
ngh gh gh h
configured as a master, select the PPI protocol for the HMI device. PPI Advanced is optimal. The

o n n
MPI and PROFIBUS protocols do not support the S7-200 CPU as a master.
o 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 221
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 Creating User-Defined
a 2
Protocols with Freeport Mode
a 2 a 2
ngh n g hoprogram to control the communicationsngporthofothe S7-200 CPU. You can use ngho
udtooimplement o to communicate with many types uof do
Freeport mode allows your
user-defined communications d
Freeport mode
Tdevices.
intelligent Freeport mode supports both ASCII
u protocols
Tand binary protocols. T
To enable Freeport mode, you use special memory bytes SMB30 (for Port 0) and SMB130 (for Port 1).
Your program uses the following to control the operation of the communications port:

. co m- .c o m . c o m
24
Transmit instruction (XMT) and the transmit interrupt: The Transmit instruction allows the S7-200 to
24 a24 2 4.
hoa hoa a
transmit up to 255 characters from the COM port. The transmit interrupt notifies your program in the

ng g
S7-200 when the transmission has been completed.
n n g ho ng ho
- d o d o d o
Tu has been received on the COM port. T uprogram can then act on that character, based
Tu
Receive character interrupt: The receive character interrupt notifies the user program that a
character Your
on the protocol being implemented.
- Receive instruction (RCV): The Receive instruction receives the entire message from the COM port

.co m .co m
and then generates an interrupt for your program when the message has been completely received.
.co
You use the SM memory of the S7-200 to configure the Receive instruction for starting and stopping m .
a 2 4 a 2 4
the receiving of messages, based on defined conditions. The Receive instruction allows your
a 2 4 a 24
o o o o
ngh gh gh h
program to start or stop a message based on specific characters or time intervals. Most protocols
o n
can be implemented with the Receive instruction.
o n o n g
7 u d
Tmode is active only when the S7-200 is in RUN
Freeport u d
T mode. Setting the S7-200 to STOP mode halts u
T all d
Freeport communications, and the communications port then reverts to the PPI protocol with the settings
which were configured in the system block of the S7-200.

.c omTable 7-8 Using Freeport Mode .com .co m


a 24 Network Configuration
a 24 Description
a 2 4 a 2 4.
o o hanoS7-200 with an electronic scale ho
ngh gh ang g
Using Freeport over Example: Using
o n
an RS-232 connection that hasn
o cable connects the RS-232 port on the udo
RS-232 port. n
Tud TuH dPC/PPI
Scale
PC/PPI
Cable
T
scale to the RS-485 port on the S7-200 CPU.
S7-200 H S7-200 CPU uses Freeport to communicate with
the scale.

4 . c om 4 .c om H

4 .co m
Baud rate can be from 1200 baud to 115.2 kbaud.
.
2 2 H
2
User program defines the protocol.
24
ng hoa Using USS protocol
ng hoa MicroMaster ho a
Example: Using an S7-200 with SIMODRIVE
n g ng h o a
d o o
MicroMaster drives.
d d o
Tu MicroMaster TuH S7-200 CPU is a master, and the drives areTu
H STEP 7–Micro/WIN provides a USS library.

S7-200 slaves.

MicroMaster Refer to the Tips and Tricks on the

.c o m . c o m . c o m
documentation CD for a sample USS
.
2 4 2 4 Tips and Tricks
24
program. See Tip 28.
24
ng hoa Creating a user
ng hoa Modbus Network
network.ng
h o a
Example: Connecting S7-200 CPUs to a Modbus
n gh oa
o
program that emulates
d o o
T u
a slave device on
another network TuH dUser program in the S7-200 emulates a Modbusud
slave.
T
Modbus
Device H STEP 7–Micro/WIN provides a Modbus library.
S7-200 S7-200
Refer to the Tips and Tricks on the

4 .c om 4 . c om 4 . com
documentation CD for a sample Modbus
4.
2 2 a2
program. See Tip 41.
2
hoa a a
Tips and Tricks

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
222
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
Communicating over a Network Chapter 7

4 .c om Using the PC/PPI Cable4.and c om 4 . c om 4.


o a 2 a 2 Freeport Mode with 2
RS-232
a Devices
a 2
ngh g hareo compatible
You can use the PC/PPI
n g
cable and the Freeport communications
n
o to connect the S7-200 CPUs togho
hfunctions
u d o
many devices that with the RS-232
u d o
standard.
u d on
T PC/PPI cable is in Transmit mode when dataTis transmitted from the RS-232 port to the RS-485
The T port.
The cable is in Receive mode when it is idle or is transmitting data from the RS-485 port to the RS-232
port. The cable changes from Receive to Transmit mode immediately when it detects characters on the
RS-232 transmit line.
. co m .c o m . c o m
24 24 a24
The PC/PPI cable supports baud rates between 1200 baud and 115.2 kbaud. Use the DIP switches on the
2 4.
ng hoa hoa ho
housing of the PC/PPI cable to configure the cable for the correct baud rate. Table 7-9 shows the baud
g g ng ho a
don n
rates and switch positions.

Tu
The cable switches back to Receive mode
Tu do
Table 7-9 Turnaround Time and Settings
Tu d o
when the RS-232 transmit line is in the idle
Baud Rate Turnaround Time Settings (1 = Up)
state for a period of time defined as the
turnaround time of the cable. The baud rate 38400 to 115200 0.5 ms 000

om om om
selection of the cable determines the 19200 1.0 ms 001

2 4 .c 2 4 .c
turnaround time, as shown in Table 7-9.
9600
2 4 . c
2.0 ms 010
24 .
ng hoa If you are using the o
h a cable in a system
PC/PPI
where Freeportgcommunications
n S7-200 must comprehend the do2400
4800
n g h oa 4.0 ms 011
g h o a
u
programd othe
in
are used, the
u
7.0 ms
u d
100on
T
turnaround time for the following situations: T 1200 14.0 ms T101 7
- The S7-200 responds to messages transmitted by the RS-232 device.
After the S7-200 receives a request message from the RS-232 device, the S7-200 must delay the

4 .c om .co m .co m
transmission of a response message for a period of time greater than or equal to the turnaround
4 4 4.
2 2
time of the cable.
2 2
ng hoa n g
- The RS-232 oa
hdevice responds to messages transmittedn g hothe S7-200.
from
a
n g hoa
dothe S7-200 receives a response message
TuAfter
transmission of the next request message
o the RS-232 device, the S7-200 mustudelay
Tforuadperiod
from o
T d the
of time greater than or equal to the
turnaround time of the cable.
In both situations, the delay allows the PC/PPI cable sufficient time to switch from Transmit mode to

.co m .co m .co


Receive mode so that data can be transmitted from the RS-485 port to the RS-232 port. 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 223
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 Modems and STEP
a 2 7–Micro/WIN with Your 2
Network
a a 2
ngh n g ho3.2 uses the standard Windows Phone g o Options for selecting and gho
hModem
STEP 7–Micro/WIN
u d o modems. The Phone and Modem uOptions
version
configuring telephone d n
o are under the Windows Control Panel.udon
and

TWindows setup options for modems allows T


Using the you to: T
- Use most internal and external modems
supported by Windows.

. co m- .c o m . c o m
24
Use the standard configurations for most
24 a24 2 4.
hoa oa dialing rules for a
modems supported by Windows.

ng - g h gho ng ho
of n n
Use the standard Windows
selection o
T
code
d pulse or tone dialing, and Tudo
locations, country and area
usupport, Tu d o
calling card support.
- Use higher baud rates when
communicating to the EM 241 Modem
.co m module.
. c om .co m .
a 2 4 4
a2to display the a 2 4 a 24
o o
Use the Windows control panel
o o
ngh d o
allows you to configure
h
ng the local modem. You
Modem Properties dialog box. This dialog box
d o n gh
d on g h
select yourumodem from the list of modems
7 T
supported by Windows. If your modem type is
Tu T u
not listed in the Windows modem dialog box,
select a type that is the closest match for your

4 .c om modem, or contact your modem vendor to


.co
acquire the modem configuration files for
4
m
4 .co m
4.
o a2 Windows.
oa 2 a 2
hothe Local Modem hoa 2
ngh h Figure 7-20 Configuring
n g
o also lets you use radio and cellular modems. n g
o These modem types do not appear in o ng
TudModem Properties dialog box, but are available
Tudwhen configuring a connection for Tud
STEP 7–Micro/WIN
the Windows
STEP 7–Micro/WIN.

Configuring a Modem Connection


. c o mA connection associates an identifying.cname
omwith the physical properties of the connection.
. c omFor a
a 2 4 a 2 4include the type of modem, 10 or 11 bita 2 4 a 2 4.
o hoselections
telephone modem these properties
handoother
protocol selections, and
ho
ngh n g
timeouts. For cellular modems
g
the connection allows setting of a PIN and
n parameters. Radio
n g
udo udo udo
modem properties include for baud rate, parity, flow control other parameters.
T
Adding a Connection
T T
Use the Connection wizard to add a new connection, remove, or edit a connection as shown in
Figure 7-21.

.c m 1.
Connection
o Wizard
. c o m . c o m .
a24 24 24 24
Double-click the icon in the Communications Setup window.
o o a o a oa
ngh ghOn the Local Connection tab, checkothenModem
gh Connection box. gh
2. Double-click the PC/PPI cable to open the PG/PC interface. Select the PPI cable and click the
o n
Properties button.
d Communications dialog box again, andTdouble-click o n
3. Tuthe
Open ud the modem Connect icon. Tud
4. Click the Settings button to display the Modem Connections Settings dialog box.
5. Click the Add button to start the Add Modem Connection wizard.

4 .c om 6. .co m
Configure the connection as prompted by the wizard.
4 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
224
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
Communicating over a Network Chapter 7

4 .c om 4 .co m
4. c om .
oa2 o a 21.
o a2
5. 6.
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 Figure 7-21


.co m
Adding a Modem Connection
.co m .
a 2 4 a 2 4 a 2 4 a 24
o ho ho o
ngh n g
do to the S7-200 with a Modem
Connecting do n g
d on g h
T u T
After you have added a modem connection, you
u T u 7
can connect to an S7-200 CPU.
1.
1. Open the Communications dialog box and

4 .c om . c om
double-click on the Connect icon to display
4 4 . c om 4.
o a2 o a2
the Modem Connection dialog box.
o a2 hoa 2
ngh h
ngto dial the modem. ng h g
2. In the Modem Connection dialog box, click

d o d o o n
Tud 2.
Connect
Tu Tu

.co m .co m .c om .
a 2 4 a 2 4 4
a2 to the S7-200 a 24
o ho o o
ngh h h
Figure 7-22 Connecting
n g ng on g
T u do a Remote Modem
Configuring
Tu d o
T u d
The remote modem is the modem that is
connected to the S7-200. If the remote modem is
an EM 241 Modem module, no configuration is

.c o m . c m
required. If you are connecting to a stand-alone
o
modem or cell modem, you must configure the
. c o m .
o a24 Modem connection.
hoa
24
hoa
24 oa 24
ngh g g gh
Expansion

on
The Modem Expansion wizard configures the
on n
Wizard

d d o
u u Tud
remote modem which is connected to the S7-200
T
CPU. Special modem configurations are required
in order to properly communicate with the
T
RS-485 half duplex port of the S7-200 CPU.
Simply select the type of modem, and enter the

.co m .co m
information as prompted by the wizard. For more
. com
a2 4 a 2 4
information, refer to the online help.
a2 4
Figure 7-23 Modem Expansion Wizard
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 225
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 m
oCable . c om
a 2 4 a Modem with the
a 2 4
PC/PPI
a 2 4 a 2 4.
o ho1,to2,connect horate. ho
ngh dPPI
See Figure 7-24. n g
You can use a PC/PPI cable
o protocol. Switch 5 selects either the Data
Switches and 3 on the PC/PPI cable o
set n
the g
the RS-232 communications port
baud
of a modem to an S7-200 CPU.
dCommunications Switch 4 selects either a
do n g
T u
10-bit or 11-bit
T u T
Equipment (DCE) or Data
Terminal Equipment (DTE) mode. Switch 6 (if present) selects the operation of the RTS signal on the
u
RS-232 port of the PC/PPI cable.

. co m .c o m . c o m
24 24
Isolated

a24 2 4.
hoa hoa a
PC/PPI Cable

1=h10o ho
PPI
ng g g ng

PC
don n
Dipswitch # 123 4 BIT
115.2–38.4K 000
d o 0= 11 BIT
d o
Tu 1
0 1 2 3 4 5 6
19.2K
9.6K
Tu
001
010
5 1= DTE
0= DCE
Tu
2.4K 100 6 1= RTS for XMT
1.2K 101 0= RTS Always

.co m .co m .co m .


a 2 4 Figure 7-24
2 4
Settings for the PC/PPI Cable
a a 2 4 a 24
o ho ho o
ngh d o n g
use the RS-232 control signals (such as d o n g
CTS, and DTR) to allow a computer to do
ng h
theu u cable, you must configure the modem toTu
Modems normally RTS,
7 control T modem. When you use a modem with a PC/PPIT
operate without these signals. To determine the commands required for configuring the modem, consult
the documentation for your specific modem.

.c omSwitch 4 of the PC/PPI cable selects eitherm


. c o o m4 for411-bit
a 10-bit or 11-bit mode for PPI protocol. Use switch
with a modem. Otherwise, set.c
only

a 2 4 a
mode to ensure proper operation2 4 other devices.
when the S7-200 is connected to STEP
with
7–Micro/WIN
a 2 4 switch
a 2 4.
o o o to either DCE or DTE mode. If gho
ngh ng h g
cable allows you to set the RS-232 port ofnthe
oPC/PPI cable with STEP 7–Micro/WINuordif the
Switch 5 of the PC/PPI
d
hcable
o PC/PPI cable is connected to a udon
u
you are using the
T set the PC/PPI cable to DCE mode. If you are
computer, T using the PC/PPI cable with a modem (which T is a
DCE device), set the PC/PPI cable to DTE mode. This eliminates the need to install a null modem adapter
between the PC/PPI cable and the modem. Depending on the connector on the modem, you might still
need to use a 9-pin-to-25-pin adapter.

.co mSwitch 6 of the PC/PPI cable selects.the


c m of the
ooperation .c om .
a 2 4 4
ato2be active a2 4 RS-485 RS-232

a 24
o o
RTS signal on the RS-232 connector. Selecting “RTS for
o o
ngh XMT” causes the RTS
d o
is transmitting on the
h
ngRS-485 port, and the RTS signal to bedong
signal when the S7-200 h S7-200 Modem

d on g h
inactiveT u the S7-200 is receiving data. SelectingT“RTS
when u T u
Always” causes the RTS signal to always be active on the
RS-232 port of the PC/PPI cable, regardless of whether the
9-pin-to-25-pin adapter
S7-200 is transmitting or receiving. Switch 6 affects only the

.c o m . c m
RTS signal when the PC/PPI cable is set for DTE mode.
o 9-pin
. c o m
25-pin

a2 4 Figure 7-25 shows the pin


2 4
assignment
a for a common RD
a 32
2 4 3 TD2
a 2 4.
o ho oRTS 7
TD RD
ho
ngh hGND
modem adapter.

o n g o n g 4 RTS
o n g
Tud Tud Tud
5 7 GND

Figure 7-25 Pin Assignments for Adapters

.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
226
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
Communicating over a Network Chapter 7

4 .c om 4 .co m
4. c om .
oa2 o 2 o a2
Table 7-10 shows the pin numbers and functions for the RS-485 and RS-232 ports of the PC/PPI cable in
a
DTE mode. Table 7-11 shows the pin numbers and functions for the RS-485 and RS-232 ports of the
o a 24
ngh n gh n gh
PC/PPI cable in DCE mode. The PC/PPI cable supplies RTS only when it is in DTE mode.
o o on g h
T ud
Table 7-10 T ud
Pin-outs for RS-485 and RS-232 DTE Connector T u d
RS-485 Connector Pin-out RS-232 DTE Connector Pin-out1
Pin Signal Description Pin Signal Description

4 .com 1
. c o
Ground (RS-485 logic ground)m
24logic ground)
1
. c o m
Not used: Data Carrier Detect (DCD)
4(RD) (input to PC/PPI cable) 4.
h o a2 2
a
24 V Return (RS-485
o
2 Receive 2
o a Data
o a2
n g 3
ngBh(RxD/TxD+)
Signal
4 do o
3 gh
n Transmit Data (TD) (output from PC/PPI cable) gh
used: Data Terminal Ready (DTR) do
n
T5 u RTS (TTL level)
Ground (RS-485 logic ground)
Tud 45 Not
Ground (RS-232 logic ground)
Tu
6 NC (No connect) 6 Not used: Data Set Ready (DSR)

om m m
7 24 V Supply 7 Request To Send (RTS) (switch selectable)

4 .c 8 Signal A (RxD/TxD–) .c
4 o 8 Not used: Clear.c
4 To o
Send (CTS)
4 .
oa 2 a 2 a 2 a 2
n g h 9
n g ho
Protocol select 9
from female to male, and a conversion from 9-pinnto g
hNotoused: Ring Indicator (RI) n g ho
udo udo udo
1 A conversion 25-pin, might be required for modems

T T
Table 7-11 Pin-outs for RS-485 and RS-232 DCE Connector
T 7
RS-485 Connector Pin-out RS-232 DCE Connector Pin-out

om om om
Pin Signal Description Pin Signal Description

2 4 .c 1
4 . c
Ground (RS-485 logic ground) 1
4 . c
Not used: Data Carrier Detect (DCD)
4.
o a o a2 logic ground) a 2
o Data (RD) (output from PC/PPI cable) ho a 2
ngh h hReceive
2 24 V Return (RS-485 2

do ngB (RxD/TxD+) o3ng Transmit Data (TD) (input to PC/PPI cable) ng


o
Tud 4 Not used: Data Terminal Ready (DTR)Tud
3 Signal

Tu
4 RTS (TTL level)
5 Ground (RS-485 logic ground) 5 Ground (RS-232 logic ground)
6 NC (No connect) 6 Not used: Data Set Ready (DSR)

.co m 7 24 V Supply
.co m 7
.co m
Not used: Request To Send (RTS)
.
a 2 4 8
a 2 4
Signal A (RxD/TxD–) 8
a 2 4
Not used: Clear To Send (CTS)
a 24
o o hNotoused: Ring Indicator (RI) o
ngh 9
o n gh Protocol select
do n g9
on g h
Tud Tu 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 227
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 Advanced Topics
a 2 a 2 a 2
ngh n g ho n g ho n g ho
Optimizing the
T u doNetwork Performance Tudo T u do
The following factors affect network performance (with baud rate and number of masters having the
greatest effect):

- Baud rate: Operating the network at the highest baud rate supported by all devices has the greatest

. co m effect on the network.


.c o m . c o m
a 24 - Number of masters on the
a 2 4 Minimizing the number of mastersaon24a network also increases
network:
a2 4.
o of o ho the overhead requirements ngho
ngh
the performance h
n g g
the network. Each master on the network increases
n
udoof master and slave addresses: The addresses
udoof the master devices should be setTsoudo
of the network; having fewer masters lessens the overhead.
- T
Selection T
that all of the masters are at sequential addresses with no gaps between addresses. Whenever
there is an address gap between masters, the masters continually check the addresses in the gap
to see if there is another master wanting to come online. This checking requires time and increases

.co m .co m .co m


the overhead of the network. If there is no address gap between masters, no checking is done and
.
a 2 4 a 2 4 a 2 4
so the overhead is minimized. You can set the slave addresses to any value without affecting
a 24
o ho ho
network performance, as long as the slaves are not between masters. Slaves between masters
o
ngh Gapu d
g
o factor (GUF): Used only when an S7-200d o n g
increase the network overhead in the same way as having address gaps between masters.
n d o ng h
7 -
T the S7-200 how often to check the addressTgapu for other masters. You use STEP 7–Micro/WIN
tells
update CPU is operating as a PPI master, the
Tu
GUF

to set the GUF in the CPU configuration for a CPU port. This configures the S7-200 to check
address gaps only on a periodic basis. For GUF=1, the S7-200 checks the address gap every time
it holds the token; for GUF=2, the S7-200 checks the address gap once every two times it holds the

4 .c om .co m .co m
token. If there are address gaps between masters, a higher GUF reduces the network overhead. If
4 4 4.
a2 2 2 2
there are no address gaps between masters, the GUF has no effect on performance. Setting a large
o oa ho a
number for the GUF causes long delays in bringing masters online, because the addresses are
hoa
ngh n g h
checked less frequently. The default GUF setting is 10.
o address (HSA): Used only when anuS7-200
dstation n g
do CPU is operating as a PPI master,Ttheudo ng
- u
Highest
T T
HSA defines the highest address at which a master should look for another master. You use
STEP 7–Micro/WIN to set the HSA in the CPU configuration for a CPU port. Setting an HSA limits
the address gap which must be checked by the last master (highest address) in the network.

.co m .co m .co m


Limiting the size of the address gap minimizes the time required to find and bring online another
master. The highest station address has no effect on slave addresses: masters can still
.
a 2 4 a 2 4 a 2 4
communicate with slaves which have addresses greater than the HSA. As a general rule, set the
a 24
o ho ho o
ngh h
highest station address on all masters to the same value. This address should be greater than or
n g n g on g
do do
equal to the highest master address. The default value for the HSA is 31.

T u T u T u d
Calculating the Token Rotation Time for a Network
In a token-passing network, the only station that can initiate communications is the station that holds the
token. The token rotation time (the time required for the token to be circulated to each of the masters in the

.c o m . c m
logical ring) measures the performance of your network.
o . c o m
a2 4 Figure 7-26 provides a sample
a 2 4 the TD 200 (station 3) communicates
network as an example for calculating the
2
token
a 4 the CPUfor222a
rotation time
a 2 4.
o ho 5) communicates with the CPU 222ng(station ho 4), and so on. The two ho
ngh
multiple-master network. In this example, with
n
(station 2), the TD 200g (station
o use the Network Read and Network Write o to gather data from the other do
n g
S7-200s: ud224
CPU 224 modules
T CPU T u2,dinstructions
(station 6) sends messages to stations 4, and 8, and the CPU 224 (station 8) T u
sends
messages to stations 2, 4, and 6. In this network, there are six master stations (the four TD 200 units and
the two CPU 224 modules) and two slave stations (the two CPU 222 modules).

.co mRefer to the Tips and Tricks on the documentation


. c om CD for a discussion about token. c omSee Tip 42.
rotation.

a2 4 a 2 4 a 2 4 a2 4.
o Tips and Tricks

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
228
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
Communicating over a Network Chapter 7

4 .c om 4 .co m
4. c om .
oa2
CPU 222
Station 2
o a 2
CPU 222
Station 4
CPU 224
Station 6
CPU 224
Station 8
TD 200
Station 9
o a2
TD 200
Station 7
TD 200
Station 5
TD 200
Station 3
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
Figure 7-26
24
Example of a Token-Passing Network

a24 2 4.
ng hoa g hoa gho ng ho a
Tu don Tu do n
In order for a master to send a message, it must hold the token. For example: When station 3 has the
token, it initiates a request message to station 2 and then it passes the token to station 5. Station 5 then
Tu d o
initiates a request message to station 4 and then passes the token to station 6. Station 6 then initiates a
message to station 2, 4, or 8, and passes the token to station 7. This process of initiating a message and
passing the token continues around the logical ring from station 3 to station 5, station 6, station 7,
station 8, station 9, and finally back to station 3. The token must rotate completely around the logical ring
.co m .co m .co m
in order for a master to be able to send a request for information. For a logical ring of six stations, sending
.
a 2 4 a 2 4 a 2 4
one request message per token hold to read or write one double-word value (four bytes of data), the token
a 24
o o o o
ngh gh gh h
rotation time is approximately 900 ms at 9600 baud. Increasing the number of bytes of data accessed per
n n
message or increasing the number of stations increases the token rotation time.
o o o n g
u d
T token rotation time is determined by how long
The u d u
T each station holds the token. You can determine
T thed 7
token rotation time for your multiple-master network by adding the times that each master holds the token.
If the PPI master mode has been enabled (under the PPI protocol on your network), you can send
messages to other S7-200s by using the Network Read and Network Write instructions with the S7-200. If

4 .c om 4 .co m
you send messages using these instructions, you can use the following formula to calculate the
4 .co
approximate token rotation time, based on the following assumptions: each station sends one request per
m
4.
o a2 oa 2 o a 2
token hold, the request is either a read or write request for consecutive data locations, there is no conflict
hoa 2
ngh gh gh g
for use of the one communications buffer in the S7-200, and there is no S7-200 that has a scan time
o n
longer than about 10 ms.
d d o n o n
Tu Tu
Token hold time (Thold) = (128 overhead + n data char) x 11 bits/char x 1/baud rate
Tud
Token rotation time (Trot) = Thold of master 1 + Thold of master 2 + . . . + Thold of master m

4 . c om where
.co m
n is the number of data characters (bytes)
4 4 .co m .
24
m is the number of masters
2 2 2
ng hoa gh o a
gh o a
The following equations calculate the rotation times (one “bit time” equals the duration of one signaling
n n g h o a
o
period) for the example shown in Figure 7-26:
ud d o d on
TT
(token hold time) = Tu
(128 + 4 char) x 11 bits/char x 1/9600 bit times/s T u
= 151.25 ms per master
T (token rotation time) = 151.25 ms per master  6 masters
= 907.5 ms

.c o m . c o m . c o m .
o a24 Tip
hoa
24
hoa
24 oa 24
ngh gh
SIMATIC NET COM PROFIBUS software provides an analyzer to determine network performance.
on g on g o n
T u d 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 229
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
oComparing .c om . c om
a 2 4 Token Rotation
a 2 4 Times
a 2 4 a 2 4.
o o of the token rotation time versus thegnumber
o of stations, amount of data, ho
ngh n g htimes
Table 7-12 shows comparisons
dothe S7-200 CPU or other master devices. o n hNetwork
o n g
Tud Tud
and the baud rate. The are figured for a case where you use the Read and Network Write
Tuwith
instructions

Table 7-12 Token Rotation Time (in Seconds)


Number of Masters

. co m Baud Rate Bytes

. c o3m
.8 om
c 4.
Transferred 2 4 5 6 7 9 10
24 4 0.44
20.30 4
2 1.18 1.33 2
hoa hoa a
o1.16 ho a
1 0.59 0.74 0.89 1.03 1.48

ng
9.6 kbaud

o n g16 0.33 0.50 0.66


n
0.83
o gh
0.99 1.32 1.49 1.65
ong
Tu
19.2 kbaud
d 1 0.15 0.22
T d 0.44
0.30 u0.37 0.52 0.59 0.67
Tu d
0.74
16 0.17 0.25 0.33 0.41 0.50 0.58 0.66 0.74 0.83
1 0.009 0.013 0.017 0.022 0.026 0.030 0.035 0.039 0.043
187.5 kbaud

4 .c om 16 0.011

4 .c om 0.016 0.021 0.026 0.031 0.037

4 . c om
0.042 0.047 0.052
.
2 2 2 24
ng hoa g hoa g hoa g h o a
d on
Understanding the Connections That Link the Network Devices
u u d on u d on
7 T T
Network devices communicate through individual connections, which are private links between the master T
and slave devices. As shown in Figure 7-27, the communications protocols differ in how the connections
are handled:

4 .c om - 4 . om 4 . om
The PPI protocol utilizes one shared connection among all of the network devices.
c c 4.
o a2 - The PPI Advanced, MPI,2
a a 2
and PROFIBUS protocols utilize separate connections
ho with each other. ho
between any two
hoa 2
ngh g g g
devices communicating
n n n
udoAdvanced,
When using PPI
Testablished
has been udo
MPI, or PROFIBUS, a second master
between a master and a slave. T
S7-200
cannot interfere with a connection that do
CPUs and EM 277s always reserve one Tu
connection for STEP 7–Micro/WIN and one connection for HMI devices. Other master devices cannot use
these reserved connections. This ensures that you can always connect at least one programming station
and at least one HMI device to the S7-200 CPU or EM 277 when the master is using a protocol that

.co m .co
supports connections, such as PPI Advanced. m .co m .
a 2 4 a 2 4 a 2 4 a 24
o ho o o
ngh n g n gh on g h
PPI
AllT udoshare a common
devices
PPI Connection
Tu d oPPI Connection PPI Connection
T u d
connection

.c o m . c o m . c o m .
o a24 PPI Advanced
hoa
24
hoa
24 oa 24
ngh gh
Connection 2
MPI

d o ng d on g o n
Tud
PROFIBUS Connection 1 Connection 1 Connection 1

Tudevice communicates
Each
through a separate connection
T u

.co m .co m . com


a2 4 Figure 7-27
2 4
Managing the Communications Connections
a 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 oa2 a2 a 24
ngh
230
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
Communicating over a Network Chapter 7

4 .c om 4 .co m
4. c om .
o a2 o 2 o a2
As shown in Table 7-13, the S7-200 CPU or EM 277 provide a specific number of connections. Each port
a
(Port 0 and Port 1) of an S7-200 CPU supports up to four separate connections. (This allows a maximum
o a 24
ngh n gh n gh
of eight connections for the S7-200 CPU.) This is in addition to the shared PPI connection. An EM 277
o o on g h
T ud
supports six connections.
T ud T u d
Table 7-13 Capabilities of the S7-200 CPU and EM 277 Modules
Module Baud Rate Connections Protocols Supported

24 .com S7-200 CPU Port 0

24 .com
9.6 kbaud, 19.2 kbaud, 4
. c o m
PPI, PPI Advanced, MPI, and PROFIBUS1
4.
a24 2
or 187.5 kbaud

h o a h o a
Port 1
9.6 kbaud, 19.2 kbaud, 4
ho PPI, PPI Advanced, MPI, and PROFIBUS1
ho a
ng don
g or 187.5 kbaud
do n g
d ong
1
TForuPort 0 and Port 1 of the S7-200 CPU, you can T
EM 277 Module 9.6 kbaud to 12 Mbaud u 6 per module PPI Advanced, MPI, and PROFIBUS
use MPI and PROFIBUS only when communicating with an S7-200
Tu
device which is a slave.

.co m .co m .co m .


a 2 4 a 2 4 a 2 4 a 24
o o
Working with Complex Networks o o
ngh d o n g
For the S7-200,
h
d o
complex networks typically have multiple n g h
S7-200 masters that use the Network Readon
d
g h
Tu and Network Write (NETW) instructionsTtoucommunicate with other devices on a PPI network.
(NETR)
Tu
Complex networks typically present special problems that can block a master from communicating with a
7
slave.

If the network is running at a lower baud rate (such as 9.6 kbaud or 19.2 kbaud), then each master

4 .c om .co m .co m
completes the transaction (read or write) before passing the token. At 187.5 kbaud, however, the master
4 4 4.
2 2 2
issues a request to a slave and then passes the token, which leaves an outstanding request at the slave.
2
ng hoa n g
Figure 7-28 shows
oa
ha network with potential communicationsng conflicts.
a
ho In this network, Station 1, Station 2,nghoa
T ud4.oThe3 areNetwork
and Station
Station Read and Network Write T udo useWrite
masters, using the Network Read or Network
instructions
instructions to communicate witho
T udshare
PPI protocol so all of the S7-200s
the single PPI connection in Station 4.

In this example, Station 1 issues a request to Station 4. For Station 1 Master Station 2 Master Station 3 Master

.co m .co m
baud rates above 19.2 kbaud, Station 1 then passes the
token to Station 2. If Station 2 attempts to issue a request to
.co m .
a 2 4 a 2 4
Station 4, the request from Station 2 is rejected because the
a 2 4 a 24
o o o o
ngh gh gh h
request from Station 1 is still present. All requests to
o n
Station 4 will be rejected until Station 4 completes the
o n on
Station 4 Slave g
Tud
response to Station 1. Only after the response has been
Tu
completed can another master issue a request to Station 4.
d
Figure 7-28 Communications Conflict
T u d
To avoid this conflict for the communications port on Station 1 Slave Station 2 Slave Station 3 Slave

.c o m . c m
Station 4, consider making Station 4 the only master on the
o
network, as shown in Figure 7-29. Station 4 then issues the
. c o m .
o a24 oa 24
read/write requests to the other S7-200s.
oa 24 oa 24
ngh Not only does g
conflict ino
d n h
this configuration ensure that there is no
d on g h
o n gh
Tud
communications, but it also reduces the overhead
T u
caused by having multiple masters and allows T
theunetwork
Station 4 Master

to operate more efficiently.


Figure 7-29 Avoiding Conflict

.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 231
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 omFor some applications, however, reducing


4 .c m
othe 4. c om .
o a2 o a2masters,
Table 7-14
a2
HSA and Target Token Rotation Time
a 24
n g h number of masters on the network
g h is not an
n rotation time andyou
HSA
n g ho
9.6 kbaud 19.2 kbaud 187.5 kbaud
g h o
on
option. When there are several
must managed o o 0.613 s
Tud 1.040 s d
the token HSA=15 0.307 s 31 ms
ensure Tthatuthe network does not exceed the HSA=31 0.520 s T
53 ms
u
target token rotation time. (The token rotation
time is the amount of time that elapses from HSA=63 1.890 s 0.950 s 97 ms
when a master passes the token until that HSA=126 3.570 s 1.790 s 183 ms

. co m master receives the token again.)


.c o m . c o m
a 2 4 If the time required for the token to4
a 2 2 4when
return to the master is greater than a target token
a rotation time, then
a2 4.
o htheotarget token rotation time. ho ho
ngh
the master is not allowed to issue a request. The master can issue a request only the actual token
rotation time is lessn g
than n g n g
T
The highest
do address (HSA) and the baud rate T
ustation udofor the S7-200 determine the target token
settings T udo
rotation time. Table 7-14 lists target rotation times.

For the slower baud rates, such as 9.6 kbaud and 19.2 kbaud, the master waits for the response to its

.co m .co m .co m


request before passing the token. Because processing the request/response cycle can take a relatively
long time in terms of the scan time, there is a high probability that every master on the network can have a .
a 2 4 a 2 4 a 2 4
request ready to transmit every time it holds the token. The actual token rotation time would then increase,
a 24
o o o o
ngh gh gh h
and some masters might not be able to process any requests. In some situations, a master might only
o n
rarely be allowed to process requests.
o n on g
7 u d u
T Consider a network of 10 masters that transmit
For example:
d u
T 1 byte at 9.6 kbaud that is configured with
T an d
HSA of 15. For this example, each of the masters always has a message ready to send. As shown in
Table 7-14, the target rotation time for this network is 0.613 s. However, based on the performance data
listed in Table 7-12, the actual token rotation time required for this network is 1.48 s. Because the actual

4 .c om 4 .co m
transmit a message until some later rotation of the token. 4 .co m
token rotation time is greater than the target token rotation time, some of the masters will not be allowed to
4.
o a2 oa 2 a 2
o rotation time is greater than hoa 2
ngh the target tokeno
d
ghtime:for improving a situation where theoactual
You have two basic options
n
rotation
d n ghtoken
do ng
T u T u
- You can reduce actual token rotation time by reducing the number of masters on your network. T u
Depending on your application, this might not be a feasible solution.
- You can increase the target token rotation time by increasing the HSA for all of the master devices

.co m on the network.


.co m .co m .
a 2 4 a 2 4 a 2 4
Increasing the HSA can cause a different problem for your network by affecting the amount of time that it
a 24
o o o o
ngh gh gh h
takes for a S7-200 to switch to master mode and enter the network. If you use a timer to ensure that the
o n o n
Network Read or Network Write instruction completes its execution within a specified time, the delay in
on g
Tud Tu d
initializing master mode and adding the S7-200 as a master on the network can cause the instruction to
time out. You can minimize the delay in adding masters by reducing the Gap Update Factor (GUF) for all T u d
masters on the network.

Because of the manner in which requests are posted to and left at the slave for 187.5 kbaud, you should

.c o mallow o m rotation time. For 187.5 kbaud, the.actual


extra time when selecting the target token
c
time should be approximately half of .the c o mtoken rotation

a2 4 a 2 4 target token rotation time.


a 2 4 a 2 4.
o o time, use the performance data in Table ho ho
ngh
To determine the token h
n g
required for completing
rotation
n g 7-12 to determine the time
o as the TD 200), use the performanceudatadofor transferring 16 bytes. Calculate the token
the Network Read and Network Write operations. To calculate the time required for
o n g
rotationT
ud(such
time by adding the time for each device on theT
HMI devices
Tud
network. Adding all of the times together describes
a worst-case scenario where all devices want to process a request during the same token rotation. This
defines the maximum token rotation time required for the network.

.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
232
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
Communicating over a Network Chapter 7

4 .c om 4 .co m
4. c om .
oa2 2 a2
For example: Consider a network running at 9.6 kbaud with four TD 200s and four S7-200s, with each
a a 24
ngh n g ho n g ho
S7-200 writing 10 bytes of data to another S7-200 every second. Use Table 7-12 to calculate the specific
g h o
on
transfer times for the network:
dodevices transferring 16 bytes of data T
4 TDu200
T
o
= ud 0.66 s
T u d
4 S7-200s transferring 10 bytes of data = 0.63 s
Total token rotation time = 1.29 s

. co m .c m . c o m
To allow enough time for this network to process all requests during one token rotation, set the HSA to 63.
o 4.
(See Table 7-14.) Selecting a target token rotation (1.89 s) that is greater than the maximum token rotation
24 24 a24
time (1.29 s) ensures that every device can transfer data on every rotation of the token.
2
ng hoa n g
To help improve the
a
horeliability of a multi-master network, youngshould
hoalso consider the following actions: ngho a
do the update rate for the HMI devices
T-uChange T utod
o
T u
allow more time between updates. For example,do
change the update rate for a TD 200 from “As fast as possible” to “Once per second.”
- Reduce the number of requests (and the network overhead for processing the requests) by
combining the operations of Network Read or Network Write operations. For example, instead of

.co m .co m .co m


using two Network Read operations that read 4 bytes each, use one Network Read operation that
.
a 2 4 a 2 4 a 2 4
reads 8 bytes. The time to process the two requests of 4 bytes is much greater than the time to
a 24
o o
process one request for 8 bytes.
o o
ngh -
o n gh o n gh
Change the update rate of the S7-200 masters so that they do not attempt to update faster than the
d d d on g h
Tu token rotation time.
Tu T u 7

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 233
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 .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
7 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
234
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 Hardware a 2
Troubleshooting Guide
a 2 and a 2
ngh n g ho n g ho n g ho
o
Software udo o
Tud Debugging TTools Tud
STEP 7–Micro/WIN provides software tools to help you debug and test your program. These features

.com m m
include viewing the status of the program as it is executed by the S7-200, selecting to run the S7-200 for a
.c o . c o 4.
24 24 a24
specified number of scans, and forcing values.
a 2
ng h o hoa ho
Use Table 8-1 as a guide for determining the cause and possible solution when troubleshooting problems
g g ng ho a
don do n o
with the S7-200 hardware.

Tu Tu Tu d
In This Chapter

4 .c om 4 . om 4 . c om
Features for Debugging Your Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
c
236
.
2 Displaying the Program Status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2 2 238
24
ng hoa o
Using a Status Chart
n gValues
toaMonitor and Modify the Data in the S7-200o . .a
h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .n. .g. .h. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
.......................... 239
n gh o a
o
Forcing Specific
o o
TudYour Program for a Specified Number Tof Scans
Running ud . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .T. . .u. .d 240
Hardware Troubleshooting Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241

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 235
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 Features for Debugging
a 2
Your Program
a 2 a 2
ngh n g ho several features to help you debugnyourghprogram:
o bookmarks, cross
n g ho
o
STEP 7–Micro/WIN provides
o o
Tud and run-time edits.
reference tables,
Tud Tud
Using Bookmarks for Easy Program Access
You can set bookmarks in your program to make it easy to move back and forth between designated

. co m(bookmarked) lines of a long program..cYou


o m c o m line of your
can move to the next or the previous bookmarked
.
a 2 4 program.
a 2 4 a 2 4 a2 4.
o ho Table to Check YournProgram ho References ho
ngh Using the Cross n g
do table allows you to display the cross
Reference g
do and element usage informationTforudo n g
T
The cross ureference T ureferences
your program.
Cross
Reference The cross reference table identifies all operands

.co m .co m
used in the program, and identifies the program
block, network or line location, and instruction .co m .
a 2 4 a 2 4
context of the operand each time it is used.
a 2 4 a 24
o o o o
ngh n gh
You can toggle between symbolic and absolute
d o d o n gh
d on g h
Tu Tu u
view to change the representation of all
operands. T
Figure 8-1 Cross Reference Table

8 m Tip
4 .c o the.c
Double-clicking on an element in 4
om
cross reference table takes you to that part4of.c
om 4.
o a 2 a 2 a 2 your program or
a 2
ngh
block.
n g ho n g ho ng ho
o o o
TudProgram in RUN Mode Tud
Editing Your Tud
CPU 224 Rel. 1.10 (and higher) and CPU 226 Rel. 1.00 (and higher) models support RUN mode edits.
The RUN mode edit capability is intended to allow you to make small changes to a user program with
minimal disturbance to the process being controlled by the program. However, implementing this capability

.co m .co m
also allows massive program changes that could be disruptive or even dangerous.
.co m .
a 2 4 a 2 4 a 2 4 a 24
o o o o
ngh gh gh h
Warning

o n o n
When you download changes to an S7-200 in RUN mode, the changes immediately affect process
on g
Tud Tu d
operation. Changing the program in RUN mode can result in unexpected system operation, which could
cause death or serious injury to personnel, and/or damage to equipment. T u d
Only authorized personnel who understand the effects of RUN mode edits on system operation should
perform a RUN mode edit.

.c o mTo perform a program edit in RUN mode, . c o m . c o medits and must


a2 4 be in RUN mode.
a 2 4 a 2 4
the online S7-200 CPU must support RUN mode
a 2 4.
o h>oProgram Edit in RUN menu command.ngho ho
ngh do n g n g
udoyou are prompted to save it. The RUNTudo
1. Select the Debug
2. IfTtheuproject is different than the program in theTS7-200,
mode edit can be performed only on the program in the S7-200.
3. STEP 7–Micro/WIN alerts you about editing your program in RUN mode and prompts you to either
continue or to cancel the operation. If you click Continue, STEP 7–Micro/WIN uploads the program
.co m .co m . com 4.
from the S7-200. You can now edit your program in RUN mode. No restrictions on edits are

a2 4 enforced.
a 2 4 a2 4 a2
o gho o ho
ng h Tip
don d o n gh
d ong
Tu Tu Tu
Positive (EU) and Negative (ED) transition instructions are shown with an operand. To view information
about edge instructions, select the Cross Reference icon in the View. The Edge Usage tab lists numbers
for the edge instructions in your program. Be careful not to assign duplicate edge numbers as you edit
your program.

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
236
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
Hardware Troubleshooting Guide and Software Debugging Tools Chapter 8

4 .c om 4 .co m
4. c om .
oa2 o a 2
Downloading the Program in RUN Mode
o a2 o a 24
ngh gh gh h
RUN-mode editing allows you to download only your program block while the S7-200 is in RUN mode.
on on
Before downloading the program block in RUN mode, consider the effect of a RUN-mode modification on
on g
ud ud
the operation of the S7-200 for the following situations:
T- T T u d
If you deleted the control logic for an output, the S7-200 maintains the last state of the output until
the next power cycle or transition to STOP mode.

. co m -

.c m . c o m
If you deleted a high-speed counter or pulse output functions which were running, the high-speed
o
a24
counter or pulse output continues to run until the next power cycle or transition to STOP mode.
- If you deleted ana 24 the2
Attach Interrupt instruction but did not delete a
4 a2 4.
o o the interrupt routine until a powergcycle hoor a transition to STOP mode. ngho
interrupt routine, the S7-200
ngh n g
continues
d
Likewise, if
hexecute
to
you deleted a Detach Interrupt n
o cycle or transition to STOP mode. udo interrupts are not shut down untiluthedonext
instruction, the
T upower T T
- If you added an Attach Interrupt instruction that is conditional on the first scan bit, the event is not
activated until the next power cycle or STOP-to-RUN mode transition.

4 .c om -
.co m .co m
If you deleted an Enable Interrupt instruction, the interrupts continue to operate until the next power
4 4 .
2 cycle or transition from RUN to STOP mode.
2 2 24
ng hoa -
n gh o a
n gh o a
If you modified the table address of a receive box and the receive box is active at the time that the
g h o a
o o
S7-200 switches from the old program to the modified program, the S7-200 continues to write the
d d d on
Tu Tu u
data received to the old table address. Network Read and Network Write instructions function in the
same manner. T
- Any logic that is conditional on the state of the first scan bit will not be executed until the next power
cycle or transition from STOP to RUN mode. The first scan bit is set only by the transition to RUN
8
4 .c om 4 . om
mode and is not affected by a RUN-mode edit.
c 4 . c om 4.
oa 2 Tip
oa2 a 2 a 2
ng h ngh n g ho
Before you can download your program in RUN mode, the S7-200 must support RUN mode edits, the
ng ho
do o o
Tud d
program must compile with no errors, and the communications between STEP 7–Micro/WIN and the
Tu
S7-200 must be error-free.
You can download only the program block.
Tu
To download your program in RUN mode, click on the Download button or select the File > Download

.com .co m .co m


menu command. If the program compiles successfully, STEP 7–Micro/WIN downloads the program block
.
a24 4 4 24
to the S7-200.
o a 2 a 2 a
ngh n g ho
Exiting RUN-Mode Edit n g ho ng h o
d o d o d o
Tu If you have changes that have not been
To exit RUN-mode
checkmark.
editing, select the Debug >
Tusaved, STEP 7–Micro/WIN prompts you T
Program Edit in RUN menu command and u
deselect the
either to
continue editing, to download changes and exit RUN-mode editing, or to exit without downloading.

.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 237
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
S7-200 Programmable Controller System Manual

4 .c om 4 .c om 4 . c om 4.
o a 2 Displaying the Program
a 2
Status
a 2 a 2
ngh n g hoyou to monitor the status of the user program
n g hoas it is being executed. When n g ho
udoprogram status, the program editor displays udtheostatus of instruction operand values.Tudo
STEP 7–Micro/WIN allows
you monitor the
T T
To display the status, click the Program Status button or select the Debug > Program Status menu
command.

. co m
Displaying the Status of the .Program c o m in LAD and FBD . c o m
a 2 4 STEP 7–Micro/WIN providesa 2 4 a 2 4 a2 4.
o hoSTEP 7–Micro/WIN acquires the valuesnforghtheostatus display across multiple ngho
two options for displaying the status of LAD and FBD programs:

ngh - End of scann g


do and then updates the status screenTdisplay.
scanucycles
status:
doThe status display does not reflect theTudo
T u
actual status of each element at the time of execution. The end-of-scan status does not show status
for L memory or for the accumulators.
For end of scan status, the status values are updated in all of the CPU operating modes.

4 .c om - .co m .co m
Execution status: STEP 7–Micro/WIN displays the values of the networks as the elements are
4 4 .
2 2 2 24
hoa a a a
executed in the S7-200. For displaying the execution status, select the Debug > Use Execution

ng n g ho
Status menu command.
n g ho ng h o
d o
For execution status, the status values are updated onlyowhen the CPU is in RUN mode.
d d o
Tip
Tu Tu Tu
STEP 7–Micro/WIN provides a simple method for changing the state of a variable. Simply select the
8 variable and right-click to display a menu of options.

4 .c om 4 . c om 4 . c om 4.
h o a2 Configuring How the Status
h o aa 2variety
is Displayed in the LAD and FBD a
h o 2
Program
hoa 2
ng STEP 7–Micro/WIN
d o ng in the program.
provides of options
d o ng o ng
Tud
for displaying the status
Tu the display option for the status
To configure Tu
screen, select the Tools > Options menu
command and then select the Program Editor

.co m tab, as shown in Figure 8-2.


.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 Figure 8-2 Options for the 2
o a 4 Display
Status
oa 24
ngh d on g o n gh o n gh
T u 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
238
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
Hardware Troubleshooting Guide and Software Debugging Tools Chapter 8

4 .c om Displaying the Status of 4 .c om 4 . c om 4.


o a 2 a 2 the Program in STL
a 2 a 2
ngh g hoexecution
You can monitor the
n g
status of your STL program on an
n
o
hinstruction-by-instruction basis. For an
n g ho
T u do
STL program, STEP 7–Micro/WIN displays the
T u do
status of the instructions that are displayed on
T
the
u do
screen.

STEP 7–Micro/WIN gathers status information from the S7-200, beginning from the first STL statement at
the top of the editor window. As you scroll down the editor window, new information is gathered from the
S7-200.

. co m o m
STEP 7–Micro/WIN continuously updates values
.c . c o m
24 24
on the screen. To halt the screen updates, select
a24 2 4.
ng hoa hoa
the Triggered Pause button. The current data
g gho ng ho a
don n
remains on the screen until you deselect the
Triggered Pause button.
Tu Tu do Tu d o
Configuring Which Parameters Are
Displayed in the STL Program
STEP 7–Micro/WIN allows you to display the

4 .c om .co m
status of a variety of parameters for the STL
4 4 .co m .
2 2
instructions. Select the Tools > Options menu
2 24
ng hoa o a
command and then select the STL Status tab.
n gh n gh o a
g h o a
on
See Figure 8-3.
d o d o d
Tu TuFigure 8-3 T
Options for Displaying STL Status
u

m m m 8
o
4.c Using a Status Chart to c o
4.Monitor o
4.cin the S7-200
and Modify the Data 4.
o a 2 a 2
o you to read, write, force, a 2 a 2
ngh
The Status Charth
n g allows
n g ho ng ho
T u doyour program. Select the View > Tudo
and monitor
executing
variables while the S7-200 is
T udo
Component > Status Chart menu command to
create a status chart. Figure 8-4 shows a sample
status chart.

.co m c om
You can create multiple status charts.
. .c om .
a 2 4 4
2 toolbar
achart:
STEP 7–Micro/WIN provides icons for a2 4 a 24
o o o o
ngh manipulating the h
d o ng Single Read, Write All, Force, dong
Sort Descending,
status Sort Ascending, h
d on g h
Tu Unforce All, and Read All Forced. Tu
Unforce,
T u
To select a format for a cell, select the cell and
click the right mouse button to display the context
menu. Figure 8-4 Status Chart

.c o m . c o m . c o m .
2 4 2 4 24 24
ng hoa g hoa g hoa gh oa
d on 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 239
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 Forcing Specific Values
a 2 a 2 a 2
ngh The S7-200 allowsn g hto oforce any or all of the I/O points (I and nQ gbits).hoIn addition, you can also force up ngho
u owords,(Vorordouble oV memory or M memory values can be udo
you
to 16 memorydvalues
Tbytes,
forced in words. Analog values
udforced
M) or analog I/O values (AI or AQ).
Tare as words only, on even-numberedT byte
boundaries, such as AIW6 or AQW14. All forced values are stored in the permanent EEPROM memory of
the S7-200.

. co mBecause the forced data might be changedm


.c o during the scan cycle (either by the program, m
. c o by the I/O

a 2 4 a 2 4
update cycle, or by the communications-
a 2 4
processing cycle), the S7-200 reapplies the forced values at
a2 4.
o various times in the
hoThe S7-200 applies the forced valuesnto gthehinputs
scan cycle.
o ho
ngh - Reading then g n g
udothe control logic in the program: The Tudo udo
inputs: as they are read.
T
- Executing
S7-200 applies the forced values to all immediate I/O Writes to the outputs
T
accesses. Forced values are applied for up to
16 memory values after the program has been

.co m executed.
.c o m . c o m .
a 2 4 - 4
a2values requests:
Processing any communications The
a2 4
Perform the CPU Diagnostics

a 24
o o o o
ngh h h h
S7-200 applies the forced to all read/write Process any Communications

d o ngaccesses.
communications
d o ng
Requests

d on g
- Tu to the outputs: The S7-200 applies the forced
Writing
values to the outputs as they are written.
Tu Execute the Program
T u
Scan Cycle
You can use the Status Chart to force values. To force a
8 new value, enter the value in the New Value column of the

4 .c om .co m
Status Chart, then press the Force button on the toolbar. To
4 4 .co m
4.
2 2
force an existing value, highlight the value in the Current
2
Reads the inputs
2
ng hoa gh oa
Value column, then press the Force button.
n n gh
Figure 8-5
a
o S7-200 Scan Cycle
ng hoa
do d o o
Tip Tu Tu
The Force function overrides a Read Immediate or Write Immediate instruction. The Force function also
Tud
overrides the output table that was configured for transition to STOP mode. If the S7-200 goes to STOP
mode, the output reflects the forced value and not the value that was configured in the output table.

.co m .co m .co m .


a 2 4 a 2 4 a 2 4 a 24
o ho ho o
ngh ong for a Specified Number
Running Your Program
d ongof Scans d d on g h
To helpT
u
you debug your program, STEP 7–Micro/WINT
u T u
allows you to run the program for a specific number
of scans.

You can have the S7-200 execute only the first scan. This allows you to monitor the data in the S7-200

.c o m c o
after the first scan. Select the Debug > First
. mScan menu command to run the first scan.
. c o m
a2 4 a 2 4your program for a limited number of scans
a 2 4 a 2 4.
o htoomonitor the program as it changes variables.
You can have the S7-200 execute
o the Debug > Multiple
(from 1 scan to 65,535
ho
ngh scans). This allows you
o n g o n g hSelect
o n g
Tud Tud Tud
Scans menu command to specify the number of scans to be executed.

.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
240
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
Hardware Troubleshooting Guide and Software Debugging Tools Chapter 8

4 .c om 4 .c om 4. c om .
o a2 Hardware
o a2
Troubleshooting Guide
o a2 o a 24
ng h h
ng Guide for the S7-200 Hardware dong h g h
Table 8-1
d o
Troubleshooting
d on
SymptomTu Possible Causes Tu Possible Solution T u
Outputs stop working H The device being controlled has H When connecting to an inductive load (such as a
caused an electrical surge that motor or relay), a proper suppression circuit

. co m .c m
damaged the output
o . c o m
should be used. Refer to Chapter 3.

24
H User program error
24 loose or incorrect
H Correct user program
4 correct
2and 2 4.
hoa a a a
H Wiring H Check wiring
o
h H Excessive load o
h load against point ratings ho
ng o ng n H
gCheck ng
T u d
SF (System Fault) light on the
H Output point is forced
T udoH Check the S7-200 for forced I/O
The following list describes the most Tu
Read the fatal error code number and refer to
d o
S7-200 turns on common error codes and causes: Appendix C for information about the type of error:
H User programming error H For a programming error, check the usage of the

.co m – 0003
.c om Watchdog error
. c om
FOR, NEXT, JMP, LBL, and Compare instructions.

a 2 4 4
a–20012 Illegal floating-point
– 0011Indirect addressing H
a 2 4
For electrical noise:
a 2 4.
o o oimportant that the control panel is
– Refer to the wiring guidelines in Chapter 3. It is
o
ngh d o n gh value
n g h
very
o connected to a good ground and that high o n g h
Tu H
– 0014 Range error
Electrical noise Tud voltage wiring. T lowd
voltage wiring is not run in parallel withu

(0001 through 0009) – Connect the M terminal on the 24 VDC Sensor


H Component damage Power Supply to ground.
m m (0001 through 0010)
m 8
o
4.c None of the LEDs turn on HHaBlown c
4.fuse o o
4.cto the system to check the
Connect a line analyzer
4.
o a 2 2 a 2 a 2
hoH Incorrect voltage ono ho
Reversed 24 V power wires magnitude and duration of the over-voltage spikes.

ngh
Basedh
o n g n g this information, add the proper type arrestor
o to the wiring guidelines in Chapter 3 forudo n g
Tud Tud Refer
device to your system.

T
information about installing the field wiring.
Intermittent operation H Improper grounding Refer to the wiring guidelines in Chapter 3.
associated with high energy H Routing of wiring within the control It is very important that the control panel is connected

.com .com om
devices cabinet
c
to a good ground and that high voltage wiring is not run
. 4.
a24 a24 2 4 2
H in parallel with low voltage wiring.
o ho
Too short of a delay time for the
a
htooground. ho a
ngh
input filters Connect the M terminal on the 24 VDC Sensor Power
n g n g
Supply
n g
T udo T udoIncrease the input filter delay in the systemTdata o
udblock.
Communications network is The communications cable can provide H Refer to the wiring guidelines in Chapter 3 and to
damaged when connecting to a path for unwanted currents if all the network guidelines in Chapter 7.
an external device non-isolated devices, such as PLCs, H Purchase the isolated PC/PPI cable.

.c o m
Either the port on the
. c m
computers, or other devices that are
o o m
H Purchase the isolated RS-485-to-RS-485
when you connect.c
repeater
4.
connected to the network do not share

a2 4 computer, the port on the


S7-200, or the PC/PPI cable is
a 2 4 the same circuit common reference.
commona 2 4 reference.
machines that do not have a
a 2
o hoThe o E for information about order gho
electrical

ngh g g hAppendix
damaged unwanted currents can cause

d o n communications errors or damage to


d o n
Refer to
numbers for S7-200 equipment.
d on
T u
Other communications
the circuits.
T u
Refer to Chapter 7 for information about network communications.
T u
problems (STEP 7–Micro/WIN)
Error handling Refer to Appendix C for information about error codes.

4 .c om 4 .co m
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 241
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 .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
8
4 .c om 4 .co m
4 .co m
4.
2 2 2 2
ng hoa ngh oa
n gh o a
ng hoa
do d o o
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
242
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 .
o a2 Creating a o a2
Program for the o a2 o a 24
ng h g h
nModule ng h g h
Position
d o d o d on
Tu Tu T u

. co m .c o m . c o m
24
The EM 253 Position module is an S7-200 special function module that generates the pulse trains used
24 a24 2 4.
hoa hoa a
for open-loop control of the speed and position for either stepper motors or servo motors. It communicates

ng g gho
with the S7-200 over the expansion I/O bus and appears in the I/O configuration as an intelligent module
ng ho
don do n o
with eight digital outputs.

Tu upon configuration information that is stored


Based
d
Tuin the V memory of the S7-200, the PositionTumodule
generates the pulse trains required to control motion.

To simplify the use of position control in your application, STEP 7–Micro/WIN provides a Position Control

4 .c om 4
m
wizard that allows you to completely configure the Position module in minutes. STEP 7–Micro/WIN also
.co 4 .co m .
24
provides a control panel that allows you to control, monitor and test your motion operations.
2 2 2
ng hoa n g ho a
n gh o a
g h o a
udo
In This Chapter u d o u d on
T
Features of the Position Module
T
.........................................................
T 244
Configuring the Position Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246

4 .c om 4 . c om 4 . c om
Position Instructions Created by the Position Control Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Sample Programs for the Position Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
257
269
4.
o a2 ho a 2 a 2
ho. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 hoa 2
ngh
Monitoring the Position Module with the EM 253 Control Panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
Error Codesn forgthe Position Module and the Position Instructions n g n g
o o o
Tud Topics . . . . . . . . . . . . . . . . . . . . . . . . . T. . .u. .d. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .T. . .u. .d 278
Advanced

.com .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 243
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 Features of the Position
a 2
Module
a 2 a 2
ngh n g ho the functionality and performancenthatgyou
honeed for single-axis, open-loop ngho
udo udo udo
The Position module provides
position control:
T T T
- Provides high-speed control, with a range from 12 pulses per second up to 200,000 pulses per
second

. co m -

.c m
Supports both jerk (S curve) or linear acceleration and
o . c o m
24
deceleration
24 a24 2 4.
ng hoa -
hoa
Provides a configurable measuring system that allows
g gho ng ho a
don n
you to enter data either as engineering units (such as
inches or centimeters) or as a number of pulses
Tu Tu do Tu d o
- Provides configurable backlash compensation
- Supports absolute, relative, and manual methods of
position control

.co m- Provides continuous operation


.c om . c om .
a 2 4 4
a2profiles, with up to 4 speed a2 4 a 24
o -
o
Provides up to 25 motion
o o
ngh n g h
changes per profile
d o d o n g h
d on g h
-
Tua choice
Provides
with Tu
four different reference-point seek modes,
of the starting seek direction and the T u
final approach direction for each sequence
- Provides removable field wiring connectors for easy

.c om installation and removal .com Figure 9-1 EM 253 Positionm


. c o Module

a 2 4 You use STEP 7–Micro/WIN a to 2 4 all of the configuration and profile information
create a 2 4 used by the Position a 2 4.
o isodownloaded to the S7-200 with your program horeplace ho
ngh 9 g hposition g g
module. This information blocks. Because all the
o n o n o n
Tud or reconfigure the module. Tud Tud
information required for control is stored in the S7-200, you can a Position module without
having to reprogram

The S7-200 reserves 8 bits of the process image output register (Q memory) for the interface to the
Position module. Your application program in the S7-200 uses these bits to control the operation of the
Position module. These 8 output bits are not connected to any of the physical field outputs of the Position

.co m module.
.c om .c om
a 2 4 a 2 4digital inputs and four digital outputs thata 2 4 a 2 4.
o o 9-1. These inputs and outputs are local
The Position module provides five
htoothe Position module. Appendix A ngho
provide the interface to your
ngh n g
motion application. SeehTable
o specifications for the Position module n g
oalso includes wiring diagrams for udo
TuthedPosition module to some of the more commonTud motor driver/amplifier units.
provides the detailed and
connecting T
Table 9-1 Inputs and Outputs of the Position Module

.c o m STP Signal Description

. c o m . c o m .
2 4 24 24
The STP input causes the module to stop the motion in progress. You can select the desired operation
24
hoa a a a
of STP within the Position Control wizard.
The RPSh o o
gh point or home position for absolute ongh o
ng RPS
o n goperations. n
(Reference Point Switch) input establishes the reference
o
TudThe ZP (Zero Pulse) input helps establish theTreference
ud point or home position. Typically, the motor
Tud
move
ZP
driver/amplifier pulses ZP once per motor revolution.
LMT+ LMT+ and LMT– inputs establish the maximum limits for motion travel. The Position Control wizard
LMT– allows you to configure the operation of LMT+ and LMT– inputs.

.co m P0 .co m . com


a2 4 P1
a 2 4 a2 4
P0 and P1 are open drain transistor pulse outputs that control the movement and direction of
movement of the motor. P0+, P0– and P1+, P1– are differential pulse outputs that provide the identical
a2 4.
o gho o ho
ng h gh
P0+, P0– functions of P0 and P1, respectively, while providing superior signal quality. The open drain outputs
P1+, P1–
don o n
and the differential outputs are all active simultaneously. Based upon the interface requirements of
d d ong
DIS
Tu Tu
motor driver/amplifier, you choose which set of pulse outputs to use.
DIS is an open drain transistor output used to disable or enable the motor driver/amplifier.
Tu
CLR CLR is an open drain transistor output used to clear the servo pulse count register.

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
244
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
Creating a Program for the Position Module Chapter 9

4 .c om Programming the Position 4 .c m


oModule 4 . c om 4.
o a 2 a 2 a 2 a 2
ngh g
STEP 7–Micro/WIN
n hosteps: g hoprogramming the Position module. ngho
provides easy-to-use tools for configuring and
n
do
Simply follow these
T1. uConfigure T u do T u do
the Position module. STEP 7–Micro/WIN provides a Position Control wizard for creating
the configuration/profile table and the position instructions. See page 246 for information about
configuring the Position module.

. co m 2.
o m o m
Test the operation of the Position Module. STEP 7–Micro/WIN provides an EM 253 control panel for
.c . c
24 24 a24
testing the wiring of the inputs and outputs, the configuration of the Position module, and the
2 4.
hoa hoa ho ho a
operation of the motion profiles. See page 274 for information about the EM 253 control panel.

ng 3.
don
g
do n g
Create the program to be executed by the S7-200. The Position Control wizard automatically
d ong
Tu Tu Tu
creates the position instructions that you insert into your program. See page 257 for information
about the position instructions. Insert the following instructions into your program:
– To enable the Position module, insert a POSx_CTRL instruction. Use SM0.0 (Always On) to
ensure that this instruction is executed every scan.

.co m –
.co m .co m
To move the motor to a specific location, use a POSx_GOTO or a POSx_RUN instruction.
.
a 2 4 a 2 4 a 2 4
The POSx_GOTO instruction move to a location specified by the inputs from your program.
a 24
o o o o
ngh gh gh h
The POSx_RUN instruction executes the motion profiles you configured with the Position

o n Control wizard.
o n on g
Tu d –
T u d
To use absolute coordinates for your motion,
T u
you must establish the zero position for d
your
application. Use the a POSx_RSEEK or a POSx_LDPOS instruction to establish the zero
position.
– The other instructions that are created by the Position Control wizard provide functionality for

4 .c om 4 . c om 4 . c om
typical applications and are optional for your specific application.
4.
o a 2 a 2
4. Compile your program
S7-200. ho
a 2
and download the system block, data block, and program block to the
a 2
ngh n g n g ho ng ho9
Tipudo o o
T Tud Tud
Refer to Appendix A for information about connecting the Position module to several common stepper
motor controllers.

4 . c om Tip
4 .co m
4 .co m .
2 2 2
To match the default settings in the Position Control wizard, set the DIP switches on the stepper motor
24
ng hoa n gh o a
controller to 10,000 pulses per revolution.
n gh o a
g h o a
o o on
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 245
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 Configuring the Position
a 2Module
a 2 a 2
ngh You must create an g ho n ginh
o
n g ho
udo The Position Control wizard makesTtheud o o
configuration/profile table for the Position module order for the module to control your
motion application.
leadingT
Position
you step-by-step through the configuration process.
configuration process quick and easy by
Refer to the Advanced Topics on page 278Tuford
Control detailed information about the configuration/profile table.
The Position Control wizard also allows you to

. co mcreate the configuration/profile table offline.m


can create the configuration without . c o You
. c o m
a 24 a 24a Position
being
a24 a2 4.
o connected to an S7-200 CPU
o with
ho ho
ngh module installed.
To run theu o n gh
d Control wizard, your project do n g
d ong
T Position
must have been compiled and set to symbolic Tu Tu
addressing mode.
To start the Position Control wizard, either click

4 .c omthe 4 .
double-click the Position Control Wizard
mor
oicon,
Tools icon in the navigation bar and then
c 4 . c om 4.
o a 2 a 2 a 2 a 2
ho o Wizard ho
select the Tools> Position Control Wizard

ngh menu command.


n g n g hControl
Figure 9-2 Position
o wizard allows you to configure eitheruthedooperation of the Position module or the udo
dControl n g
T u
The Position
T T
PTO/PWM operation of the Pulse Output instruction. After you select the option for the Position module
and click Next, the wizard guides you through the steps required for configuring the Position module.

.c m
oEntering the Location of the Position
. c om Module . c om
a 2 4 You must define the parameters2
a 4
for your module and the set of motion profiles2
a 4
for your application by
a 2 4.
o o location. The Position Control wizardgsimplifies
ho this task by automatically ho
ngh 9 hand
entering the module type
o n g n ng
reading the position of
doinstall the intelligent module next to Ttheudo
the intelligent module. You only have to click

TudCPU with firmware prior to version 1.2,Tyouumust


For an S7-200
the Read Modules button.

CPU in order for the Position Control wizard to configure the module.

. c m
Selecting
o the Type of Measurement
.c otombe used throughout the configuration. .c m
ocan
a 2 4 You must select the measurement4
a 2 system
a 2 4 You select to use
a 2 4.
o ho you must enter the following data: the
either engineering units or pulses.
ho of pulses required to produce ngho
If you select pulses, you do not have to specify any other information. If
ngh n
you select engineeringg units,
othemillimeter, n gnumber

(such asT udfoot,


one revolution of
inch, or centimeter), and the T udoof motion
motor (refer to the data sheet for your motor
amount
or drive), the base unit of measurement o
(or “units”) provided by one Tu
d
revolution of the motor.

STEP 7–Micro/WIN provides an EM253 Control Panel that allows you to modify the number of units per

.c o m . c m
revolution after the Position module has been configured.
o . c o m
a2 4 If you change the measurement
a 2 4 Control wizard. You must then enter ayour24
system later, you must delete the entire configuration including any
a 2 4.
o ho ho ho
ngh
instructions generated by the Position selections consistent with
the new measurement
o n g system.
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
246
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
Creating a Program for the Position Module Chapter 9

4 .c om Editing the Default Input 4 .c omOutput Configurations 4.com 4.


o a 2 a 2 and
owizard provides an Advanced Options selection a 2 a 2
ngh g houtput
The Position Control
n n g ho that allows you to view and edit thengho
T-uThedo
default input and configurations for the
do
Position
T u
module:
T u do
Input Active Levels tab changes the activation level settings. When the level is set to High, a
logic 1 is read when current is flowing in the input. When the level is set to Low, a logic 1 is read
when there is no current flow in the input. A logic 1 level is always interpreted as meaning the
condition is active. The LEDs are illuminated when current flows in the input, regardless of
. co m . c o m
activation level. (Default = active high)
. c o m
a 24 a 2
- The Input Filter Times
4tab allows you to specify a delay time (range
a 2 4of 0.20 ms to 12.80 ms) for a2 4.
o o RPS, LMT+, and LMT– inputs. This delay o to filter noise on the input wiring gho
ngh filtering theh
n
thatocould
d
gcause
STP,
inadvertent changes to the stateo
d ofn
ghhelps
the inputs. (Default = 6.4 ms)
d on
u
T- The Pulse and Directional Outputs tab allowsu u
T you to specify the method of controlling direction.
T First
you must specify the polarity of the outputs.

Selecting Positive Polarity

4 .c om .co m .co m
For an application that uses positive polarity, select one of the following methods (shown in Figure 9-3) to
4 4 .
2 2 2 24
hoa a a a
accommodate your drive and the orientation of your application:

gh o gh o h o
ng -
n n
The Position module emits pulses from the P0 output for positive rotation and pulses from the P1
d o d o d on g
T-uThe Position module emits pulses from theTP0
u output. The module turns on the P1 output for u
output for negative rotation.
T
positive rotation and turn off the P1 output for negative rotation. (This is the default setting.)

4 .c om Positive Rotation
4 . c omRotation
Negative
.
Positive Rotation
4 c om
Negative Rotation
4.
o a2 oa2 o a 2 oa 2
ngh gh gh ngh 9
P0 P0

do n d o n o
TP1u Tu P1 Tud
Figure 9-3 Rotation Options for Positive Polarity

.com .co m .co m .


o a24 ho a 2 4
ho a 2 4
o a 24
ngh For and o g
Selecting Negative Polarity
n
application d o
that uses negative polarity, select one n g
of the following methods (shown in Figured o
9-4) nto g h
Tu
accommodate your drive and the orientation of T uapplication:
your Tu
- The Position module emits pulses from the P0 output for negative rotation and pulses from the P1
output for positive rotation.

.c o m -
. c o m . c o m
The Position module emits pulses from the P0 output. The module turns off the P1 output for
.
a24 24 24 24
positive rotation and turn on the P1 output for negative rotation.

ngh
o
ngRotation hoa hoa
g Rotation
nPositive n gh oa
d o d o o
Tu Tu Tud
Positive Negative Rotation Negative Rotation

P0 P0

.co m P1
. c om P1
. com
a2 4 a2 4 a2 4 a2 4.
o o o ho
ng h Figure 9-4

d o ng h
Rotation Options for Negative Polarity

d o ng h
d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 247
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
oConfiguring .c om . c om
a 2 4 the Response
a 2 4
of the Module to the Physical
a 2 4
Inputs
a 2 4.
o oPosition module responds to each of thegLMT+ ho(default), ho
ngh g h(ignore
You must specify how the
n n switch, the LMT– switch, and
n g
udo udo udo
the STP input: no action the input condition), decelerate to a stop or immediate stop.
T
Warning
T T
Control devices can fail in unsafe conditions, and can result in unpredictable operation of controlled
equipment. Such unpredictable operations could result in death or serious personal injury, and/or

. co m equipment failure.
.c o m . c o m
a 2 4 The limit and stop functions
a
in
2
the4 by electromechanical controls. Consider
Position Module are electronic logic
2 4using an emergency
implementations
a
that do not
a2 4.
o ho overrides, or redundant safeguards
provide the level of protection provided
hthatoare independent of the ho
ngh n g
stop function, electromechanical
oand the S7-200 CPU. o n g on g
Tud Tud Tud
Position module

Entering the Maximum and Start/Stop Speeds


You must specify the maximum speed (MAX_SPEED) and Start/Stop Speed (SS_SPEED) for your

4 .c omapplication: 4 . c om 4 . c om 4.
oa 2 a 2 a 2
o The torque required to drive the loadgishdetermined
o by friction, inertia, and a 2
n g h - MAX_SPEED: Enter the
n g
capability of your hmotor. value for the optimum operating speed of your
n
application within the torque
n g ho
o owizard calculates and displays the o
Tud speed that can be controlled by the PositionTudmodule for a specified MAX_SPEED. Tud
the acceleration/deceleration times. The Position Control
minimum
- SS_SPEED: Enter a value within the Speed
capability of your motor to drive your load
at low speeds. If the SS_SPEED value is MAX_SPEED

4 .c om . c om
too low, the motor and load could vibrate or
4 4 .co m
4.
o9a 2 oa2
move in short jumps at the beginning and
o a 2 a 2
ng h ngh
end of travel. If the SS_SPEED value is too
high, the motor could lose pulses on start
SS_SPEED
n gh ng ho
do d o Distance do
Tu Tu Tu
up, and the load could overdrive the motor
when attempting to stop.
Figure 9-5 Maximum Speed and Start/Stop Speed

Motor data sheets have different ways of specifying the start/stop (or pull-in/pull-out ) speed for a motor

.co m .co m
and given load. Typically, a useful SS_SPEED value is 5% to 15% of the MAX_SPEED value. The
.co
SS_SPEED value must be greater than the minimum speed displayed from your specification of
m .
a 2 4 MAX_SPEED.
a 2 4 a 2 4 a 24
o o o o
ngh n gh n gh
To help you select the correct speeds for your application, refer to the data sheet for your motor.
o o on g h
Tud Tu d u d
Figure 9-6 shows a typical motor torque/speed curve.
T
Torque required Motor torque versus
to drive the load speed characteristic

.c o m . c o m . c o m .
o a24 hoa
24
hoa
24 oa 24
ngh d on
Motor g
d on g o n gh
u u Tud
Torque
T T Start/Stop speed versus torque
This curve moves towards lower
speed as the load inertia increases.

.co m . c om . c om
a2 4 a 2 4 Motor Speed
a 2 4 a2 4.
o hforothis load o the motor can drive the load o
ng h g g h g h
Start/Stop speed Maximum speed that
n n n
udo udo udo
(SS_SPEED) MAX_SPEED should not exceed this value.
T
Figure 9-6 Typical Torque–Speed Curve for a Motor
T T

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
248
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
Creating a Program for the Position Module Chapter 9

4 .c om Entering the Jog Parameters 4 .c om 4 . c om 4.


o a 2 a 2 a 2 a 2
ngh g
The Jog command
n hisotheused g holocation. Using the Position Control ngho
to manually move the tool to a desired
n
do
wizard, you specify
T-uJOG_SPEED:
following Jog parameters
T do
values:
u T u do
The JOG_SPEED (Jog speed for the motor) is the maximum speed that can be
obtained while the JOG command remains active.
- JOG_INCREMENT: Distance that the tool is moved by a momentary JOG command.

24 .com .c o m . c o m
Figure 9-7 shows the operation of the Jog command. When the Position module receives a Jog
24 4.
h o a hoa a24
command, it starts a timer. If the Jog command is terminated before 0.5 seconds has elapsed, the Position
ho
module moves the tool the amount specified in the JOG_INCREMENT at the speed defined by
ho a2
ng don
g
do n g
SS_SPEED. If the Jog command is still active when the 0.5 seconds have elapsed, the Position module
d ong
Tu Tu
accelerates to the JOG_SPEED. Motion continues until the Jog command is terminated. The Position
module then performs a decelerated stop. You can enable the Jog command either from the EM 253 Tu
control panel or with a position instruction.

4 .c om Speed
4 .co m
4 .co m .
2 2 2 24
hoa a a a
MAX_SPEED

ng n g ho n gh o
JOG command terminated
g h o
o
dJOG_SPEED d o d on
Tu Tu T u
SS_SPEED

4 .c om 4 . c om 4 .co m Distance
4.
o a2 a2
oJOG_INCREMENT o a 2 oa 2
ngh gh JOG command active for gh ngh 9
JOG command active for

do n d o n o
Tud
more than 0.5 seconds

Tu less than 0.5 seconds


Tu
Figure 9-7 Representation of a JOG Operation

.co m Entering the Acceleration.cand omDeceleration Times 4.com


a 2 4 a 2 4 a 2 a 2 4.
o ho for the Position module, you setnthe o ho
ngh hacceleration
As part of the configuration and deceleration times. The
n g g time is 1 second. Typically, motors canng
doless than 1 second. You specify the following
udotimes in milliseconds: udo
default setting for both the acceleration time and the deceleration
workuwith
T- ACCEL_TIME: T
Time required for the motor Speed
T
to accelerate from SS_SPEED to MAX_SPEED
MAX_SPEED.

.c o m Default = 1000 ms
. c o m . c o m
a24 - DECEL_TIME: Time
a 2 4 for the motor SS_SPEED a24
required
a 2 4.
o hofrom MAX_SPEED to ho ho
ngh
to decelerate
n g n g Distance ng
do = 1000 ms o udo
SS_SPEED.

TuDefault Tud ACCEL_TIME


T
DECEL_TIME

Figure 9-8 Acceleration and Deceleration Times

.co m Tip
.co m . com
a2 4 a 2 4 a2 4
Motor acceleration and deceleration times are determined by trial and error. You should start by entering
a2 4.
o gho o ho
ng h gh
a larger value with the Position Control wizard. As you test your application, you can then use the EM

don d o n
253 Control Panel to adjust the values as required. Optimize these settings for the application by
d ong
Tu Tu Tu
gradually reducing the times until the motor starts to stall.

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 249
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
oEntering .c om . c om
a 2 4 the Jerk Time
a 2 4 a 2 4 a 2 4.
o o smoother position control by reducing gthehjerk o (rate of change) in acceleration gho
ngh d o g hthe
Jerk compensation provides
n d o n on
profiling.” Jerk compensation can only be ud
and deceleration parts of motion profile. See Figure 9-9. Reducing jerk improves position tracking

appliedT
u
performance. u
Tis applied equally to the beginning and endingT
Jerk compensation is also known as “S curve
to simple one-step profiles. This compensation
portions of both the acceleration and deceleration curve. Jerk compensation is not applied to the initial and
final step between zero speed and SS_SPEED.

. co mYou specify the jerk compensation by.centering


o ma Speed
. c o m
a 24 time value (JERK_TIME). This
a 24from zero to MAX_SPEED oa24
is the time
a2 4.
o o ho
ngh gh defined gh
required for acceleration to change

o n
the maximum acceleration by
o n ong
MAX_SPEED,
T udfor DECEL_TIME. A longer jerk Tud
or equivalently
SS_SPEED, and ACCEL_TIME,
Tu d
time yields smoother operation with a smaller SS_SPEED
increase in total cycle time than would be Distance
obtained by simply increasing the ACCEL_TIME

.co m .co m
and DECEL_TIME. A value of zero indicates that
JERK_TIME
.co m .
a 2 4 a 2 4
no compensation should be applied.
a 2 4 a 24
o o o o
ngh gh gh g h
(Default = 0 ms) Figure 9-9 Jerk Compensation

d o n d o n d on
Tip
Tu Tu
A good first value for JERK_TIME is 40% of ACCEL_TIME.
T u

.c m
Configuring
o a Reference Point and
. c o mthe Seek Parameters .com
a 2 4 2 4a known
If your application specifies movements
a 2 4 a iszero
from an absolute position, you must establish
a
position that
a 2 4.
o o ho an external reference point ngho
ngh 9
fixes the position measurements to point on the physical system. One method to provide a
reference point (RP) gonh your physical system. The Position moduleg
n
o that is used when seeking the RP. udo n provides
switch (RPS)d
T u input T T udo
You can configure the Reference Point Seek (RP seek) parameters that control how your motion
application seek the RP. The RP can be centered in the RPS Active zone, the RP can be located on the
edge of the RPS Active zone, or the RP can be located a specified number of zero pulse (ZP) input

.co m .co m .co m


transitions from the edge of the RPS Active zone. To configure the RP, you enter the following information:
.
a 2 4 -
2 4
You specify the RP seek speeds for the motor:
a a 2 4 a 24
o ho ho o
ngh –
d o g
d o n g
RP_FAST is the initial speed the module uses when performing an RP seek command.
n
Typically, the RP_FAST value is approximately 2/3 of the MAX_SPEED value.
d o ng h
T–uRP_SLOW is the speed of the final approach
Tuto the RP. A slower speed is used on approach
Tu
to the RP, so as not to miss it. Typically, the RP_SLOW value is the SS_SPEED value.
- You specify the initial seek direction (RP_SEEK_DIR) and the final approach direction

.c o m o m o
(RP_APPR_DIR) for the RP Seek. These directions are specified as negative or positive.
. c . c m
a24 – RP_SEEK_DIR is the
a 2to4initial 2 4 thisroleis thein defining
direction for the RP seek operation. Typically,
a direction
a 2 4.
o from the worko o ho
ngh h ahRP seek operation, encountering a
zone the vicinity of the RP. Limit switches play an important
n g
the region that is searched for the RP. When performing n g n g
doswitch= Negative)
Tu(Default
limit
Tud
can result in a reversal of the direction,owhich allows the search to continue. udo
T
– RP_APPR_DIR is the direction of the final approach to the RP. To reduce backlash and
provide more accuracy, RP_APPR_DIR moves in the same direction as the normal work

.co m cycle. (Default = Positive)


.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
250
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
Creating a Program for the Position Module Chapter 9

4 .c om 4 .co m
4. c om .
oa2 o 2 o a2
The Position Control wizard provides advanced reference point options that allow you to specify a RP
a
offset (RP_OFFSET), which is the distance from the RP to the zero position. See Figure 9-10. The RP is
o a 24
ngh n gh n gh
identified by a method of locating an exact position with respect to the RPS. To configure the RP offset,
o o on g h
T- ud
you enter the following values:

RP_OFFSET: Distance from the RP to the


T ud T u d
Work
zero position of the physical measuring Zone
system. Default = 0

. co m -
c o m
Backlash compensation: Distance that the
. . c o m
24 24
motor must move to eliminate the slack RP
24 Zero Position
2 4.
ng hoa hoa
(backlash) in the system on a direction
g g ho aRP_OFFSET
ng ho a
don n
change. Backlash compensation is always
d o d o
Tu
a positive value. Default = 0
TuFigure 9-10 Relationship Between RP and
Tu
Zero Position

Configuring the RP Seek Sequence

om
You can configure the sequence that the Position module uses to search for the reference point.
.c .co m .co m
Figure 9-11 shows a simplified diagram of the default RP seek sequence. You can select the following
.
2 4 2 4
options for the RP search sequence:
2 4 24
ng hoa -
n g ho a
n g ho
RP Seek mode 0: Does not perform a RP seek sequence
a
n g h o a
d o d o d o
T-uRP Seek mode 1: The RP is where the RPSu
side. (Default)
u zone
T input goes active on the approach from theTwork
- RP Seek mode 2: The RP is centered RP Seek Mode 1
RP Seek Direction
within the active region of the RPS input. LMT– RPS

4 .c om -
.co m
RP Seek mode 3: The RP is located
4
Active
.co
Active
4
m RP Approach Direction

4.
o a2 oa 2
outside the active region of the RPS input.
o a 2 Work Zone
oa 2
ngh gh gh ngh 9
RP_Z_CNT specifies how many ZP (Zero
o n
Pulse) input counts should be received
d d o n o
T-uRP Seek mode 4: The RP is generally Tu
after the RPS becomes inactive.
Tud
within the active region of the RPS input.
RP_Z_CNT specifies how many ZP (Zero

.com .co m
Pulse) input counts should be received
.co m .
a 2 4 a 2 4
after the RPS becomes active.
a 2 4
Figure 9-11 Default RP Search Sequence (Simplified)
a 24
o o o o
ngh Tip
o n gh o n gh on g h
Tud Tu d
The RPS Active region (which is the distance that the RPS input remains active) must be greater than
the distance required to decelerate from the RP_FAST speed to the RP_SLOW speed. If the distance is T u d
too short, the Position module generates an error.

For more information about the different RP seek sequences for the Position module, see Figures 9-14

.c o m . c o m
through 9-17 on pages 254 through 255.
. c o m .
2 4 24 24 24
ng hoa g hoa ghoa gh oa
d on 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 251
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
oConfiguring . c m
ofor . c om
a 2 4 the Motion
a 2 4
Profiles the Position Module
a 2 4 a 2 4.
o g opoint todescription o of movement that effect a ho
ngh A profile is a pre-definedhmotion
movement fromo an
consisting of one or moreh
an ending point. You do noto n gto speeds
dsubroutine (POSx_GOTO) for you to useTtoudo
dPosition Control wizard provides an instruction
starting have define a profile in order to use the n g
T
module. The u
control moves. T u
- Number of profiles: You can select up to a maximum of 25 profiles.

. co m- o m o m
Address for the command byte: You must enter the output (Q) memory address of the command
.c . c
24 24 a24
byte for the Position module. See Figure 4-10 on page 31 for a description of the I/O numbering.
2 4.
ng hoa -
hoa ho
Address for the configuration/profile table: You must enter the starting memory address for the
g g ng ho a
don do n o
configuration/profile table that stores the configuration data for the Position module and the data for

Tu Tu Tu
all of the profiles. The configuration data for the Position module requires 92 bytes of V memory,
and each profile requires 34 bytes of V memory. For example, the amount of memory required for
d
the configuration/profile table for a Position module with one profile is 126 bytes of V memory.
The Position Control wizard can suggest an unused V memory block address of the correct size.

.c m
oDefining the Motion Profile4.co
m . c om
a 2 4 a 2 a 2 4 a 2 4.
o hoprovides a Motion Profile Definition where o define ho
ngh hdefine
The Position Control wizard you each motion profile for
n g
each profile, you select the operating moden
othe profile. The Position Control wizardualso
your application. For g
oallows you to define a symbolic name forudo
and the specifics of each n g
T u d
individual step for
T d
each profile by simply entering the symbol name as you define the profile. After you have finished T
configuring the profile, you can save to configuration and print a copy of the parameters.

.c omSelecting the Mode of Operation form


. c o the Profile
. c om
a 2 4 a 2 4
You configure the profile according the the
a 2 4
mode of operation, either an absolute position, a relative
a 2 4.
o ho
position, a single-speed continuous
ho
rotation, or a two-speed continuous rotation. Figure 9-12 shows the
ho
ngh 9 do n g
different modes of operation.
do n g
do ng
T u
Absolute Position Single-Speed
T u Single-Speed Continuous Rotation
T u
Continuous Rotation with Triggered Stop

Target Speed RPS signals

.com .com .com


Reached Stop

24 24Controlled by your program until 24 24.


h o a h o a h o a h o a
ng 0 Starting gEnding
o n another command (such as Abort)ng
o on g
Tud Tud d
Position Position
Zero
Position
is issued
T u
Relative Position Two-Speed Continuous Rotation
Target Speed with Target Speed with

.c o m . c o m RPS Inactive RPS Active

. c o m .
o a24 hoa
24
hoa
24 oa 24
ngh d o ngPosition d on g o n gh
Tud
Starting Ending
Tu
Position Measured from the
starting point T u
Figure 9-12 Mode Selections for the Position Module

4 .c om 4 .co m
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
252
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
Creating a Program for the Position Module Chapter 9

4 .c om 4 .co m
4. c om .
oa2 o a 2
Creating the Steps for the Profile
o a2 o a 24
ngh gh gh h
A step is a fixed distance that a tool moves, including the distance covered during acceleration and
on on
deceleration times. Each profile can have up to 4 individual steps.
on g
T ud T
You specify the target speed and ending position ud T u d
for each step. If you have more than one step,
simply click the New Step button and enter the
information for each step of the profile.

. co m o m
Figure 9-13 shows four possible profiles;
.c . c o mTwo-Step Profile
24 24
however, there are other possible combinations. One-Step Profile

a24 2 4.
ng hoa n g oaPlot Step button, you can
By simply clickinghthe
n gho ng ho a
o the Position Control wizard. This udo
view a graphical representation of the step, as
o
Tudyou byto easily
calculated
allows and interactively review andT Tu d
edit each step. Three-Step Profile Four-Step Profile

4 .c om 4 .c om 4 . om
Figure 9-13 Sample Motion Profiles
c 4.
oa 2 a 2 a 2 a 2
n g h n g ho
Finishing the Configuration for the Position
n g hyouosimply click Finish, and the Positionngho
Module
o
After you have
o
configured the operation of the Position module,
o
Tudwizard performs the following tasks: Tud
Control
Tud
- Inserts the module configuration and profile table into the data block for your S7-200 program
- Creates a global symbol table for the motion parameters

4 .c om -
.co m .co m
Adds the motion instruction subroutines into the project program block for you to use in your
4 4 4.
o a2 application
oa 2 a 2 a
hanyo configuration or profile information. ngho9
2
ngh g h Control wizard again in order to modify
You can run the Position
o n n g
Tipud
T T udo T udo
Because the Position Control wizard makes changes to the program block, the data block and the
system block, be sure to download all three blocks to the S7-200 CPU. Otherwise, the Position module
might not have all the program components that it needs for proper operation.

.com .c om .c om
a 2 4 Understanding theaRP 2 4Seek Modes Supported by the a 2 4
Position Module a 2 4.
o hoprovide diagrams of the different options o RP seek mode. ho
ngh n g
The following figures
do 9-14 shows two of the options for TRPuseek n g heach
for
domode 1. This mode locates the RP where n g
T-uFigure T udtheo
RPS input goes active on the approach from the work zone side.
- Figure 9-15 shows two of the options for RP seek mode 2. This mode locates the RP in the center
within the active region of the RPS input.
.c o m . c o m . c o m .
a24 24 24 24
- Figure 9-16 shows two of the options for RP seek mode 3. This mode locates the RP a specified
o hoa hoa oa
number of zero pulses (ZP) outside the active region of the RPS input.

ngh -
d on g on g
Figure 9-17 shows two of the options for RP seek mode 4. This mode locates the RP a specified
d o n gh
T u u
number of zero pulses (ZP) within the active region of the RPS input.
T Tud
For each mode, there are four combinations of RP Seek direction and RP Approach direction. (Only two of
the combinations are shown.) These combinations determine the pattern for the RP seek operation. For
each of the combinations, there are also four different starting points:

.co m .co m . com


a2 4 The work zones for each diagram have been located so that moving from the reference point to the work
a 2 4 a2 4
zone requires movement in the same direction as the RP Approach Direction. By selecting the location of
a2 4.
o gho o ho
ng h gh
the work zone in this way, all the backlash of the mechanical gearing system is removed for the first move

don
to the work zone after a reference point seek.
d o n d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 253
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 Default configuration :
o a2 Active a2 a 24
ho o
LMT– RPS Active

ng h h
ngPositive
RP Seek Direction: Negative
n g g h
d o
RP Approach Direction:
udo
RP
d on
Tu u
Work Zone
T T
Positive motion

. co m Negative motion

.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
RP Seek Direction: Positive RPS Active LMT+
RP Approach Direction: Positive Active
RP

4 .c om 4 .c om Work Zone

4 .co m .
2 2 2 24
ng hoa Positive motion

g hoa gh o a
g h o a
don
Negative motion

Tu Tu d o n
T u d on

4 .c om 4 . c om 4 .co m
4.
h o
9 a2 Figure 9-14 RP Seek Mode 1 a2
ho o a 2
hoa 2
ng o n g o n gh o ng
Tud Tu d Tud
Default configuration : RPS Active
RP Seek Direction: Negative LMT–
Active RP

. c o m RP Approach Direction: Positive


.c om .co
Work Zone m .
a2 4 a2 4 a 2 4 a 24
h o h o gh o h o
ng ng g
Positive motion

d o d o n d on
Tu
Negative motion
Tu T u

.c o m . c o m . c o m .
o a24 hoa
24
hoa
24 oa 24
ngh gh
RP Seek Direction: Positive
g RPS Active
g
don on o n
RP Approach Direction: Positive LMT+

Tu
RP
T u d Tud
Active
Work Zone

Positive motion

.co m .co m . com


a2 4 Negative motion

a 2 4 a2 4 a2 4.
o gho o ho
ng h don d o n gh
d ong
Tu Tu Tu
Figure 9-15 RP Seek: Mode 2

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
254
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
Creating a Program for the Position Module Chapter 9

4 .c om 4 .c om 4. c om 4.
oa2 : a
Default configurationo
2 RPS o a 2
ho a 2
ngh hNegative h RP
LMT–
n g n g n g
do Direction: Positive o udo
RP Seek Direction: Active Active

TRPuApproach Tud T
ÍÍ
Work Zone
Number of ZP pulses
Positive motion

. co m Negative motion

.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
RP Seek Direction: Positive RPS LMT+
RP Approach Direction: Positive Active Active
RP
om om m
ÍÍgho .co
Work Zone

2 4 .c 2 4 .c 2 4
Number of
24 .
ng hoa Positive motion

g hoa a
ZP pulses
g h o a
u d on
Negative motion
u d on u d on
T T T

4 .c om 4 .co m
4 .co m
4.
o a2 Figure 9-16
oa 2
RP Seek: Mode 3
o a 2 oa 2
ngh do ngh
d o n gh o ngh 9
Tu Tu Tud
Default configuration : RPS Active
RP Seek Direction: Negative LMT–
Active RP

.com .com mZone


RP Approach Direction: Positive
.c oWork .
ngh
o a24
gh
Positive motion

o n
o a24
o
ÍÍÍ
n g ho
4
a2 Number of ZP pulses
on g h o a 24
Tud
Negative motion
Tud T u d

.c o m . c o m . c o m .
o a24 hoa
24 oa 24 oa 24
ngh h gh
RP Seek Direction: Positive

on g g
RPS Active

donRP o n
LMT+

T u d
RP Approach Direction: Positive

Tu Tud
Active
Work Zone

m
Positive motion

m ÍÍÍ Number of
ZP pulses
om
2 4 .co Negative motion

2 4 .co 4 . c 4.
o a a a2 a2
ng h gho gh o
ng ho
Tu don Tu d o n
Tu d o
Figure 9-17 RP Seek: Mode 4

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 255
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
oSelecting .c omZone to Eliminate Backlash . c om
a 2 4 the Location
aof2 4
the Work
a 2 4 a 2 4.
o ozone in relationship to the reference point o the RPS Active zone, and the gho
ngh d o n g
Figure 9-18 shows the workhLMT–)
o n g h(RP),
the backlash. The second part of on
isdnot eliminated. Figure 9-18 shows RP seekud
limit switches (LMT+ and for an approach direction that eliminates

mode 3.T
u
the illustration places the work zone so that the backlashu
T although not recommended, for each of theT
A similar placement of the work zone is possible,
search sequences for each of the other RP seek modes.

. co m .c o m . c o m
24
Backlash is eliminated
24 a24 2 4.
hoa oa a
RP Seek Direction: Negative

ng RP Approach Direction:h
g Negative LMT–
ghRPo RPS
ng ho
u d on Active
do
u Zone
n Active
d o
T TWork Tu
Positive motion

.co m Negative motion


.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
Backlash is not eliminated
RP Seek Direction: Negative

4 .c om 4 .
RP Approach Direction: Negative
c om
LMT–
Active
RPS
4 . c
Active
om 4.
o9a 2 oa2
RP

o a2 a 2
ng h ngh n gh
Work Zone
ng ho
do d o o
Tu
Positive motion
Tu Tud
Negative motion

.co m .co m .co m .


a 2 4 a 2 4 a 2 4 a 24
o ho ho o
ngh n g
do of the Work Zone with and without theTu do n g
d on g h
TuPlacement
Figure 9-18 Elimination of Backlash 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
256
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
Creating a Program for the Position Module Chapter 9

4 .c om 4 .c om 4 . c om 4.
o a 2 Position Instructions
a 2 Created by the Position 2
Control
a Wizard
a 2
ngh The Positionn g howizard makes controlling the Positionnmodule
g hoeasier by creating unique instruction ngho
o on the position of the module and
Control
o o
Tud isbased
subroutines
instruction prefixed with a ”POSx_” where x isT
udconfiguration Tud is
options you selected. Each position
the module location. Because each position instruction
a subroutine, the 11 position instructions use 11 subroutines.

Tip

. co m .c o m . c o m
24
The position instructions increase the amount of memory required for your program by up to 1700 bytes.
24 a24 2 4.
hoa hoa a
You can delete unused position instructions to reduce the amount of memory required. To restore a

ng g gho
deleted position instruction, simply run the Position Control wizard again.
ng ho
Tu don
Guidelines for Using the Position Instructions Tu do n
Tu d o
You must ensure that only one position instruction is active at a time.

You can execute the POSx_RUN and POSx_GOTO from an interrupt routine. However, it is very important

4 .c om .co m .co m
that you do not attempt to start an instruction in an interrupt routine if the module is busy processing
4 4 .
2 2 2
another command. If you start an instruction in an interrupt routine, then you can use the outputs of the
24
ng hoa ho a ho a
POSx_CTRL instruction to monitor when the Position module has completed the movement.
n g g g h o a
o o n
values for the speed parameters (Speed andon
d
The Position
C_Speed)
d
Control wizard automatically configures the
Tu and the position parameters (Pos or TC_Pos) u according to the measurement systemTthat d
u you
selected. For pulses, these parameters are DINT values. For engineering units, the parameters are REAL
values for the type of unit that you selected. For example: selecting centimeters (cm) stores the position
parameters as REAL values in centimeters and stores the speed parameters as REAL values in

4 .c om centimeters per second (cm/sec).


4 .co m
4 .co m
4.
o a2 oa 2 a 2
The following position instructions are required for specific position control tasks:
a
hothe SM0.0 contact to execute it every ngho9
2
ngh n g
- Insert the
o
h
POSx_CTRL instruction in your program andguse
o n o
T-uTod specify motion to an absolute position,Tyouudmust first use either an POSx_RSEEK orTa ud
scan.

POSx_LDPOS instruction to establish the zero position.


- To move to a specific location, based on inputs from your program, use the POSx_GOTO

.com instruction.
. c om .c om 4.
o a24 a 2
- To run the motion profiles
instruction.ho
4 a 2
you configured with the Position Control
ho
4
wizard, use the POSx_RUN
ho a 2
ngh n g
oposition instructions are optional. udo n g o n g
Tud Tud
The other
T

.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 257
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
oPOSx_CTRL .c om . c om .
a2 4 Instruction 2 4
a(Control) a2 4 a 24
h o h o h o h o
ng The POSx_CTRL
Position moduleoby
d
g
nautomatically
instruction enables and initializes
d
commanding the Position module ng
the
o d on g
theu
to load T Tu changes
configuration/profile table each time the S7-200 T u
to RUN mode.
Use this instruction only once in your project, and ensure that your

. co m .c m
program calls this instruction every scan. Use SM0.0 (Always On)
o . c o m
4.
as the input for the EN parameter.
24 24 a24 2
ng hoa hoa
The EN parameter must be on to enable the other position
g gho ng ho a
don n
instructions to send commands to the Position module. If the EN

Tu
that is in progress. Tu do
parameter turns off, then the Position module aborts any command
Tu d o
The output parameters of the POSx_CTRL instruction provide the
current status of the Position module.

.co mThe Done parameter turns on when .thecoPosition


m module completes . c om
a 2 4 any instruction.
a 2 4 a 2 4 a 2 4.
o o the result of this instruction. See gho o
ngh g h
The Error parameter contains
n n n g h
udo udo udo
Table 9-13 on page 276 for definitions of the error codes.
T T T
The C_Pos parameter is the current position of the module. Based of the units of measurement, the value
is either a number of pulses (DINT) or the number of engineering units (REAL).

.c om . c m is a DINT value containing the.number


oC_Speed c omof
The C_Speed parameter provides the current speed of the module. If you configured the measurement

a 2 4 system for the Position module for pulses,


pulses/second. If you
a 2
configured 4
the measurement system for engineering
a 2 4
units, C_Speed is a REAL
a 2 4.
o ho engineering units/second (REAL). ngho ho
ngh 9
value containing the selected
n g
o indicates the current direction of theumotor.
o o ng
Tud T d Tud
The C_Dir parameter

Table 9-2 Parameters for the POSx_CTRL Instruction


Inputs/Outputs Data Type Operands

4 . c om Done, C_Dir
MOD_EN BOOL
4 .
I, Q, V,m
c o M, SM, S, T, C, L, Power Flow
4 .c om .
2 BOOL
a2 IB, QB, VB, MB, SMB, SB, LB, AC, *VD,
I, Q, V, M, SM, S, T, C, L
a2 24
ng hoa Error
g h o
BYTE h o
nAC,g *VD, *AC, *LD
*AC, *LD
g h o a
C_Pos, C_Speedon DINT, REAL ID, QD, VD, MD, SMD, SD,o on
Tu d Tu d LD,
T u d
Tip
The Position module reads the configuration/profile table only at power-up or when commanded to load

.c o mH the configuration.
. c o m . c o m .
a24 24 24 24
If you use the Position Control wizard to modify the configuration, then the POSx_CTRL instruction
o hoa hoa oa
automatically commands the Position module to load the configuration/profile table every time the

ngh d on g
S7-200 CPU changes to RUN mode.
d on g o n gh
Tud
H If you use the EM 253 Control Panel to modify the configuration, clicking the Update Configuration
T u T u
button commands the Position module to load the new configuration/profile table.
H If you use another method to modify the configuration, then you must also issue a Reload the
Configuration command to the Position module to load the configuration/profile table. Otherwise, the
Position module continues to use the old configuration/profile 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
258
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
Creating a Program for the Position Module Chapter 9

4 .c om POSx_MAN Instruction4.com 4. c om .
o a2 o a2 (Manual Mode) puts the Position hoa2 o a 24
ng h h
g mode. This allows the motor to be o
nmanual g g h
runn on
The POSx_MAN instruction
d o
module into
d at
d
Tu speeds or to be jogged in a positive orTnegative
different u direction.
While the POSx_MAN instruction is enabled, only the POSx_CTRL
T u
and POSx_DIS instructions are allowed.

. co m .c m
You can enable only one of the RUN, JOG_P, or JOG_N inputs at a
o . c o m
4.
time.
24 24 parameter commands to the Position a2
4 2
ng hoa n
o a
Enabling the RUN (Run/Stop)
gh to the specified speed (Speed parameter)
module to accelerate
n ghando
ng ho a
direction o parameter). You can change the value foro o
T ud while the motor is running, but the DirTparameter
parameter
(Dir
ud must
the Speed
Tu d
remain constant. Disabling the RUN parameter commands the
Position module to decelerate until the motor comes to a stop.

om m m
Enabling the JOG_P (Jog Positive Rotation) or the JOG_N (Jog

2 4 .c 2 4 .co
Negative Rotation) parameter commands the Position module to jog
2 4 .co 24.
hoa a a a
in either a positive or negative direction. If the JOG_P or JOG_N

gh o gh
parameter remains enabled for less than 0.5 seconds, the Position o h o
ng d o n
module issues pulses to travel the distance specified in
d o n d on g
Tu Tu
JOG_INCREMENT. If the JOG_P or JOG_N parameter remains
enabled for 0.5 seconds or longer, the motion module begins to T u
accelerate to the specified JOG_SPEED.
The Speed parameter determines the speed when RUN is enabled.

4 .c om 4 .co m
If you configured the measuring system of the Position module for
pulses, the speed is a DINT value for pulses/second. If you
4 .co m
4.
2 2 2 2
hoa oa a a
configured the measuring system of the Position module for
o o
ng do gh
can change this parameter while the motor is running.
d o n gh
engineering units, the speed is a REAL value for units/second. You
n do ngh 9
T u T u T u
The Dir parameter determines the direction to move when RUN is enabled. You cannot change this value
when the RUN parameter is enabled.

The Error parameter contains the result of this instruction. See Table 9-13 on page 276 for definitions of

.com the error codes.


.c om .c om 4.
oa24 The C_Pos parametera 2 4
hisoeither a number of pulses (DINT) or nthegnumber
contains a 2 4
ho of engineering units (REAL). ngho
the current position of the module. Based of the units of measurement a 2
ngh Theu
g
selected, the value
n
do parameter contains the current speed dof othe module. Based of the units of measurement
do
T C_Speed
T u T u
selected, the value is either the number of pulses/second (DINT) or the engineering units/second (REAL).

The C_Dir parameter indicates the current direction of the motor.

.c o m Table 9-3
c o m
Parameters for the POSx_MAN Instruction
. . c o m
a24 Inputs/Outputs
a 2
Data 4Type Operands a 2 4 a 2 4.
o ho BOOL hoFlow ho
ngh n g
RUN, JOG_P, JOG_N
Speeddo
n g
I, Q, V, M, SM, S, T, C, L, Power
ID, QD, VD, MD, d o SD, LD, AC, *VD, *AC, *LD, Constant udo n g
T u
Dir, C_Dir
DINT, REAL
BOOL
T u SMD,
I, Q, V, M, SM, S, T, C, L
T
Error BYTE IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *AC, *LD
C_Pos, C_Speed DINT, REAL ID, QD, VD, MD, SMD, SD, LD, AC, *VD, *AC, *LD

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 259
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
oPOSx_GOTO . c om . c om .
a2 4 Instruction 2 4
acommands a2 4 a 24
h o h o h o h o
ng The POSx_GOTO
d o ng
instruction
to a desired location.
the Position Module
d o
to
ng
go
d on g
TurningT
u
on the EN bit enables the instruction. Ensure T
u
that the EN bit T u
stays on until the DONE bit signals that the execution of the
instruction has completed.

. co mTurning on the START parameter sends .c am


o GOTO command to the
. c o m
a 24 Position module. For each scan
a 2 4
when the START parameter is on
a 24 a2 4.
o o
and the Position module is not currently busy, the instruction sends
o ho
ngh a GOTO command to
o
d on. n gtheh Position module. To ensure that onlyoonen gh ong
Tud d
GOTO command is sent, use an edge detection element to pulse
Tuparameter
the START Tu
The Pos parameter contains a value that signifies either the location
to move (for an absolute move) or the distance to move (for a

.co m .co m
relative move). Based of the units of measurement selected, the
value is either a number of pulses (DINT) or the engineering units
.co m .
a 2 4 (REAL).
a 2 4 a 2 4 a 24
o o o o
ngh n gh
The Speed parameter determines the maximum speed for this
d o d o
movement. Based of the units of measurement, the value is either an gh
d on g h
Tu Tu
number of pulses/second (DINT) or the engineering units/second
(REAL).
T u
The Mode parameter selects the type of move:

4 .c om 0 – Absolute position
1 – Relative position
4 .co m
4 .com
4.
h o
9 a2 oa 2
2 – Single–speed, continuous positive rotation
h
3 – Single–speed, continuous negative rotation
ho a 2
hoa 2
ng n g n g ng
udo turns on when the Position module
The Done parameter
T T do this instruction.
ucompletes Tud
o
The Error parameter contains the result of this instruction. See Table 9-13 on page 276 for definitions of
the error codes.

. c o mThe .c o m of the module. Based of the units of.cmeasurement,


C_Pos parameter contains current position
o m the
a 2 4 a 2 4
value is either a number of pulses (DINT)
a 2 4
or the number of engineering units (REAL).
a 2 4.
o hoof pulses/second hounits/second ho
ngh
The C_Speed parameter contains the current speed of the module. Based of the units of measurement,
the value is either n g n g n g
udo udo o
a number (DINT) or the engineering (REAL).

Table 9-4T Parameters for the POSx_GOTO Instruction T Tud


Inputs/Outputs Data Type Operands
START BOOL I, Q, V, M, SM, S, T, C, L, Power Flow

.c o m Pos, Speed .
DINT, REALc
ID, o
QD,mVD, MD, SMD, SD, LD, AC, *VD, *AC, *LD,.Constant
c o m .
2 4 BYTE a2
4 IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *AC,2*LD,4Constant 24
hoa o o a oa
Mode

ng Abort, Done
n h
gBOOL I, Q, V, M, SM, S, T, C, L
n gh n gh
o o o
Error
Tud BYTE
C_Pos, C_Speed DINT, REAL
T SB,dLB, AC, *VD, *AC, *LD
IB, QB, VB, MB, SMB,u
ID, QD, VD, MD, SMD, SD, LD, AC, *VD, *AC, *LD
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
260
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
Creating a Program for the Position Module Chapter 9

4 .c om POSx_RUN Instruction4.com 4. c om .
o a2 o a2 (Run Profile) commands the Positionhoa2 o a 24
ng h h
ng the motion operation in a specificdprofile g in
nstored g h
on
The POSx_RUN instruction
module tooexecute o
the
d
Tuconfiguration/profile table. Tu T u d
Turning on the EN bit enables the instruction. Ensure that the EN bit
stays on until the Done bit signals that the execution of the

. co m instruction has completed.


.c o m . c o m
24 24
Turning on the START parameter sends a RUN command to the
a24 2 4.
ng hoa hoa
Position module. For each scan when the START parameter is on
g gho ng ho a
don n
and the Position module is not currently busy, the instruction sends

Tu Tu do
a RUN command to the Position module. To ensure that only one
command is sent, use an edge detection element to pulse the Tu d o
START parameter on.
The Profile parameter contains the number or the symbolic name for

.co m .co m
the motion profile. You can also select the advanced motion
commands (118 to 127). For information about the motion
.co m .
a 2 4 a 2 4
commands, see Table 9-19 on page 284.
a 2 4 a 24
o o o o
ngh n gh n
Turning on the Abort parameter commands to the Position module
d o d o gh
to stop the current profile and decelerate until the motor comes to a d on g h
Tu
stop. Tu T u
The Done parameter turns on when the module completes this
instruction.

4 .c om .co m
The Error parameter contains the result of this instruction. See
4 4 .co m
4.
o a2 oa 2
Table 9-13 on page 276 for definitions of the error codes.
o a 2 oa 2
ngh ngh n gh
The C_Profile parameter contains the profile currently being executed by the Position module.
do d o o ngh 9
Tu Tu
The C_Step parameter contains the step of the profile currently being executed.
Tud
The C_Pos parameter contains the current position of the module. Based of the units of measurement, the
value is either a number of pulses (DINT) or the number of engineering units (REAL).

.co m .co m .co m


The C_Speed parameter contains the current speed of the module. Based of the units of measurement,
.
a 2 4 a 2 4 a 2 4
the value is either a number of pulses/second (DINT) or the engineering units/second (REAL).
a 24
o ho for the POSx_RUN Instruction ho o
ngh Table 9-5
n g
Parameters
n g on g h
T udo
Inputs/Outputs Data Type Operandsud
T
o
T u d
START BOOL I, Q, V, M, SM, S, T, C, L, Power Flow
Profile BYTE IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *AC, *LD, Constant

.c o m Abort, Done
. c o m
BOOL
I, Q, V, M, SM, S, T, C, L
c o
IB, QB, VB, MB, SMB, SB, LB, AC, *VD,.*AC,
m .
a24 4 REAL ID, QD, VD, MD, SMD, SD, LD,aAC,2*VD, 4 *AC, *LD 24
Error, C_Profile, C_Step BYTE *LD

o o a 2DINT, o oa
ngh gh gh gh
C_Pos, C_Speed

o n o n o n
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 261
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
oPOSx_RSEEK . c om . c om .
a2 4 Instruction
a2 4 a2 4 a 24
h o h o h o h o
ng The POSx_RSEEK
d o
initiates a reference
g seek operation, using the search method
npoint
instruction (Seek Reference Point Position)
d o ng d on g
Tu
in the configuration/profile Tu locates
table. When the Position module
the reference point and motion has stopped, the Position module
T u
loads the RP_OFFSET parameter value into the current position
and generates a 50-millisecond pulse on the CLR output.

. co mThe default value for RP_OFFSET is.c0. oYoumcan use the Position . c o m
a 24 Control wizard, the EM253 Control
a 24Panel, or the POSx_LDOFF
a 24 a2 4.
o (Load Offset) instruction toochange o ho
ngh gh gh
the RP_OFFSET value.

o n ENnbit
bit enables the instruction. Ensure that the o ong
stays onT udthe Done bit signals that the execution ofTtheud
Turning on the EN
until Tu d
instruction has completed.
Turning on the START parameter sends a RSEEK command to the

.co m .co m
Position module. For each scan when the START parameter is on
and the Position module is not currently busy, the instruction sends
.co m .
a 2 4 a 2 4
a RSEEK command to the Position module. To ensure that only one
a 2 4 a 24
o o o o
ngh gh gh h
command is sent, use an edge detection element to pulse the
o n
START parameter on.
o n on g
Tu d Tu d
The Done parameter turns on when the module completes this instruction. T u d
The Error parameter contains the result of this instruction. See Table 9-13 on page 276 for definitions of
the error codes.

4 .c omTable 9-6 Parameters for the POSx_RSEEK


4 . c om Instruction
4 . c om 4.
h o
9 a2 Inputs/Outputs
h o a2
Data Type Operands
h o a2 hoa 2
ng START
d o ng BOOL o ng Flow
I, Q, V, M, SM, S, T, C, L, Power
d o ng
Done Tu BOOL I, Q, V, M, SM,TS,uT, C, L Tud
Error BYTE IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *AC, *LD

.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
262
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
Creating a Program for the Position Module Chapter 9

4 .c om POSx_LDOFF Instruction 4 .c om 4. c om .
o a2 o a2 (Load Reference Point Offset) hoa2 o a 24
ng h h
g zero position that is at a different location
na new ngfrom g h
on
The POSx_LDOFF instruction
d o
establishes
d o d
Tureference point position.
the Tu T u
Before executing this instruction, you must first determine the
position of the reference point. You must also move the machine to

. co m .c m
the starting position. When the instruction sends the LDOFF
o . c o m
4.
command, the Position module computes the offset between the
24 24
starting position (the current position) and the reference point
a24 2
ng hoa hoa ho
position. The Position module then stores the computed offset to the
g g ng ho a
don n
RP_OFFSET parameter and sets the current position to 0. This

Tu Tu
establishes the starting position as the zero position. do Tu d o
In the event that the motor loses track of its position (such as on
loss of power or if the motor is repositioned manually), you can use
the POSx_RSEEK instruction to re-establish the zero position

.co m automatically.
.co m .co m .
a 2 4 a 2 4
Turning on the EN bit enables the instruction. Ensure that the EN bit
a 2 4 a 24
o o o o
ngh gh gh h
stays on until the Done bit signals that the execution of the
o n
instruction has completed.
d d o n d o ng
Tu on the START parameter sends a LDOFF
Turning Tucommand to the Position module. For eachTscan
u when
the START parameter is on and the Position module is not currently busy, the instruction sends a LDOFF
command to the Position module. To ensure that only one command is sent, use an edge detection
element to pulse the START parameter on.

4 .c om 4 . c om
The Done parameter turns on when the module completes this instruction.
4 . c om 4.
o a2 a 2
hocontains the result of this instruction.nSeegTablea 2 a
ho 9-13 on page 276 for definitions of ngho9
2
ngh
The Error parameter
o n g
the error codes.
o o
Tud
Table 9-7 Tud
Parameters for the POSx_LDOFF Instruction Tud
Inputs/Outputs Data Type Operands
START BOOL
I, Q, V, M, SM, S, T, C, L, Power Flow

24 .com Done BOOLco


4 . m I, Q, V, M, SM, S, T, C, L
4 .c om
24.
h o a Error
h o a2BYTE IB, QB, VB, MB, SMB, SB, LB, a
h o AC,2*VD, *AC, *LD
h o a
ng d o ng d o ng d on g
Tu Tu 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 263
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
oPOSx_LDPOS .c om . c om .
a2 4 Instruction
a2 4 a2 4 a 24
h o h o h o h o
ng The POSx_LDPOS
ngPosition module to a new value. You can
position value inothe
d
instruction (Load Position) changes the
d ng
current
oalso
d on g
use thisT u to establish a new zero position forTany
instruction u absolute T u
move command.
Turning on the EN bit enables the instruction. Ensure that the EN bit

. co m .c m
stays on until the Done bit signals that the execution of the
o . c o m
4.
instruction has completed.
24 24 a24 2
ng hoa hoa
Turning on the START parameter sends a LDPOS command to the
g gho ng ho a
don n
Position module. For each scan when the START parameter is on

Tu Tu do
and the Position module is not currently busy, the instruction sends
a LDPOS command to the Position module. To ensure that only one Tu d o
command is sent, use an edge detection element to pulse the
START parameter on.

.c o m om reportstheandvalue
The New_Pos parameter provides the new value to replace the
current position value that the Positioncmodule
. uses for
. c om .
a2 4 absolute moves. Based of the 4
a2or the engineering units (REAL). hoa2
units of measurement, is 4 a 24
ho either a number of pulses o
h (DINT)
h o
ng d o
The Done parameterngturns on when the module completesdthisong d on g
Tu
instruction. Tu T u
The Error parameter contains the result of this instruction. See Table 9-13 on page 276 for definitions of
the error codes.

4 .c omThe C_Pos parameter contains the4current. c om 4 . m


omeasurement,
position of the module. Based of the unitscof the
4.
o a 2 value is either a number of
a 2
pulses (DINT) or the number of engineering
a
units 2
(REAL).
a 2
ngh 9 n g ho n g ho ng ho
Table 9-8
o
Parameters for the POSx_LDPOS Instruction
o o
Tud Data Type Operands Tud
Inputs/Outputs Tud
START BOOL I, Q, V, M, SM, S, T, C, L, Power Flow
New_Pos, C_Pos DINT, REAL ID, QD, VD, MD, SMD, SD, LD, AC, *VD, *AC, *LD

4 . c om Error
Done BOOL
4 .
I, Q, V,m
c o M, SM, S, T, C, L
4 .c om .
2 BYTE
a2 a2
IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *AC, *LD
24
ng hoa ng h o
ng h o g h o a
d o d o d on
Tu Tu 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
264
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
Creating a Program for the Position Module Chapter 9

4 .c om POSx_SRATE Instruction 4 .c om 4. c om .
o a2 o a2 (Set Rate) commands the Positionhoa2 o a 24
ng h h
ng the acceleration, deceleration, anddjerk g
ntimes. g h
on
The POSx_SRATE instruction
module toochange o
d
Tu on the EN bit enables the instruction. Ensure
Tu that the EN bit T u d
Turning
stays on until the Done bit signals that the execution of the
instruction has completed.

. co m c o m
Turning on the START parameter copies the new time values to the
. . c o m
24 24
configuration/profile table and sends a SRATE command to the
a24 2 4.
ng hoa hoa
Position module. For each scan when the START parameter is on
g gho ng ho a
don n
and the Position module is not currently busy, the instruction sends

Tu Tu do
a SRATE command to the Position module. To ensure that only one
command is sent, use an edge detection element to pulse the Tu d o
START parameter on.
The ACCEL_Time, DECEL_Time, and JERK_Time parameters

.co m time in milliseconds (ms).


. c om
determine the new acceleration time, deceleration time, and jerk
. c om .
a 2 4 a 4
2on when the module completes this oa2 4 a 24
o o
The Done parameter turns
o
ngh instruction. g
o n h
o
d parameter contains the result of this instruction.
d Seen gh
d on g h
Theu u u
T Error
T
Table 9-13 on page 276 for definitions of the error codes.
T
Table 9-9 Parameters for the POSx_SRATE Instruction

4 .c om Inputs/Outputs
4
Datao
. c m
Type Operands
4 .co m
4.
o a2 START
oa2
BOOL I, Q, V, M, SM, S, T, C, L
o a 2 oa 2
ngh do ngh
ACCEL_Time, DECEL_Time, DINT

d o n gh
ID, QD, VD, MD, SMD, SD, LD, AC, *VD, *AC, *LD, Constant
o ngh 9
Tud
JERK_Time
Tu
Done BOOL Tu
I, Q, V, M, SM, S, T, C, L
Error BYTE IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *AC, *LD

.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 265
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
oPOSx_DIS . c om . c om .
a2 4 Instruction 4
a2the DIS output of the Position hoa2 4 a 24
h o h o h o
ng The POSx_DIS
d o ngallows you to use the DIS output for ddisabling
instruction
module on or off. This
turns
o ng d on g
Tua motor controller. If you use the DIS outputTonu the
or enabling
Position module, then this instruction can be called every scan or
T u
only when you need to change the value of the DIS output.

. co m . c m module. For more


When the EN bit turns on to enable the instruction, the DIS_ON
parameter controls the DIS output of theo
. c o m
4.
Position

o a 24 information about the DIS output,


fora
refer to the specifications o
24see Table 9-1 on page 244 or o a 24 a2
ngh n h
gcontains
the Position module in Appendix A.
gh ng ho
o the result of this instruction. Seeon o
Tuondpage 276 for definitions of the error codes. Tud d
The Error parameter
Table 9-13 Tu

.co m .c om . c om .
a 2 4 Table 9-10 Parameters for thea
4
2 Instruction a2 4 a 24
o o POSx_DIS
o o
ngh Inputs/Outputs ng
d o
h Data Type Operands
d o ng h
d on g h
DIS_ON u u SB, LB, AC, *VD, *AC, *LD, Constant u
Error
T BYTE
BYTE
T
IB, QB, VB, MB, SMB,
IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *AC, *LD
T

4 .c om 4 .co m
4 .co m
4.
h o
9 a2 oa 2 o a 2
hoa 2
ng o ngh o n gh o ng
Tu d Tu d 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
266
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
Creating a Program for the Position Module Chapter 9

4 .c om POSx_CLR Instruction4.com 4. c om .
o a2 o a2 (Pulse the CLR Output) commandshtheoa2 o a 24
ng h h
ngto generate a 50-ms pulse on the CLR ng g h
on
The POSx_CLR instruction
d o
Position module
d ooutput.
d
Tu on the EN bit enables the instruction. Ensure
Turning Tu that the EN bit T u
stays on until the Done bit signals that the execution of the
instruction has completed.

. co m c o m
Turning on the START parameter sends a CLR command to the
. . c o m
24 24
Position module. For each scan when the START parameter is on
a24 2 4.
ng hoa hoa ho
and the Position module is not currently busy, the instruction sends
g g ng ho a
don n
a CLR command to the Position module. To ensure that only one

Tu
START parameter on. Tu do
command is sent, use an edge detection element to pulse the
Tu d o
The Done parameter turns on when the module completes this
instruction.

.co m .co m
The Error parameter contains the result of this instruction. See
.co m .
a 2 4 2 4
Table 9-13 on page 276 for definitions of the error codes.
a a 2 4 a 24
o ho for the POSx_CLR Instruction ho o
ngh o n g o n g on g h
Tud Tud d
Table 9-11 Parameters
Inputs/Outputs Data Type Operands T u
START BOOL I, Q, V, M, SM, S, T, C, L, Power Flow
Done BOOL I, Q, V, M, SM, S, T, C, L

4 .c om Error
4 .co
BYTE m IB, QB, VB, MB, SMB, SB, LB, AC, *VD,.*AC,
4 c m
o*LD 4.
o a2 oa 2 o a2 oa 2
ngh o ngh o ng h
o ngh 9
Tud Tu d 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 267
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
oPOSx_CFG . c om . c om .
a2 4 Instruction 4
a2 Configuration) commands the hoa2 4 a 24
h o h o h o
ng Position moduleoton
The POSx_CFG
d
g
instruction (Reload
d o
read the configuration block from the location ng d on g
Tbyuthe configuration/profile table pointer. TheTPosition
specified u
module then compares the new configuration with the existing
T u
configuration and performs any required setup changes or
recalculations.

. co mTurning on the EN bit enables the instruction.


.c o mEnsure that the EN bit . c o m
a 24 24that the execution of the
stays on until the Done bit signals
instruction has completed.oa a 24 a2 4.
o o ho
ngh o n h
gparameter o n gh ong
PositionT ud For each scan when the START parameter
Turning on the START
module. udis on
sends a CFG command to the
T Tu d
and the Position module is not currently busy, the instruction sends
a CFG command to the Position module. To ensure that only one
command is sent, use an edge detection element to pulse the

.co m START parameter on.


.co m .co m .
a 2 4 a 2 4
The Done parameter turns on when the module completes this
a 2 4 a 24
o ho ho o
ngh h
instruction.
o n g o n g
Table 9-13 on page 276 for definitions of do
ng
u d
The Error parameter
Tcodes.
the error Tu d
contains the result of this instruction. See
Tu
Table 9-12 Parameters for the POSx_CFG Instruction

.c om Inputs/Outputs . c o m
Data Type
Operands
. c om
24 START
4 BOOL
I, Q, V, M, SM, S, T, C, L, Power Flow
a2 I, Q, V, M, SM, S, T, C, L hoa2 4 2 4.
g h o9a Done
h o
BOOL
hoa
n Error
do ng BYTE IB, QB, VB, MB, SMB, SB,n
d o gAC, *VD, *AC, *LD
LB,
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
268
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
Creating a Program for the Position Module Chapter 9

4 .c om 4 .c om 4 . c om 4.
o a 2 Sample Programs for
a 2 the Position Module
a 2 a 2
ngh n g ho shows a simple relative move thatng hothe POSx_CTRL and POSx_GOTO ngho
o
The first sample program
o does not require an RP seek modeuordao
uses

Tudprofile,to perform
instructions
motion
a cut-to-length operation. Thisd
and the length can be measuredT
u program
in either pulses or engineering units. Enter theTlength
(VD500) and target speed (VD504). When I0.0 (Start) turns on, the machine starts. When I0.1 (Stop) turns
on, the machine finishes the current operation and stops. When I0.2 (E_Stop) turns on, the machine
aborts any motion and immediately stops.

. co m .c o m . c o m
24 24 a24
The second sample program provides an example of the POSx_CTRL, POSx_RUN, POSx_RSEEK, and
2 4.
hoa hoa ho ho a
POSx_MAN instructions. You must configure the RP seek mode and a motion profile.

ng d 1:o
n g
d o n g
d ong
Tu TuNetwork 1 //Control instruction (module in slotT0).u
Sample Program Simple Relative Move (Cut to Length application)

LD SM0.0
= L60.0

.co m .co m LDN


=
I0.2
L63.7
.co m .
a 2 4 a 2 4 LD L60.0
a 2 4 a 24
o o CALL
o
POS0_CTRL, L63.7, M1.0, VB900, VD902, VD906,
o
ngh d o n gh
d o n gh
V910.0
d on g h
Tu TuNetwork 2 u
Tmode
//Start puts machine into automatic
LD I0.0
AN I0.2
EU

4 .c om 4 . c om S
S
Q0.2, 1
M0.1, 1
4 .co m
4.
2 2 2 2
ng hoa g h oa g h//E_Stop: a
o stops immediately and oa
ngh 9
don n
Network 3

Tu TuLD do //turns off automatic mode.


I0.2 Tud
o
R Q0.2, 1

Network 4 //Move to a certain point:

.com .com .co m


//Enter the length to cut.
.
a24 a24 4 24
//Enter the target speed into Speed.

o o o a 2
//Set the mode to 1 (Relative mode).
o a
ngh o n gh LD
o n gh
Q0.2
on g h
Tud d d
= L60.0
Tu LD
EU
M0.1
T u
= L63.7
LD L60.0

.c o m . c o m CALL
VB920, VD922, VD926
. c m
POS0_GOTO, L63.7, VD500, VD504, 1, I0.2, Q0.4,
o .
o a24 hoa
24
hoa
24 oa 24
ngh gh
Network 5 //When in position, turn on the cutter

on g o ng //for 2 seconds to finish the cut.


o n
T u d Tu dLDQ0.2
Tud
A Q0.4
TON T33, +200
AN T33
= Q0.3

.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 269
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 omProgram 1: Simple Relative Move (Cut4to.cLength


omapplication) , continued 4 . c om 4.
o a 2 Sample
a 2 a 2 a 2
ngh n g ho Network 6 //Whenh
n g ocut is finished then restart
the
n g ho
o do do
Tud
//unless the Stop is active.
LD
A
T u Q0.2
T33
T u
LPS
AN I0.1

. co m .c o m = M0.1

. c o m
4.
LPP
24 24 A I0.1
a24 2
ng hoa g hoa R Q0.2, 1
gho ng ho a
Tu don Tu do n
Tu d o

Sample Program 2: Program with POSx_CTRL, POSx_RUN, POSx_SEEK, and POSx_MAN

.co m .co m Network 1


.co m
//Enable the Position module
.
a 2 4 a 2 4 LD SM0.0
a 2 4 a 24
o o o o
ngh gh gh h
= L60.0

o n LDN
o
I0.1
n on g
Tu d =
Tu
LD
d
L63.7
L60.0 T u d
CALL POS0_CTRL, L63.7, M1.0, VB900, VD902,
VD906, V910.0

4 .c om 4 .co m Network 2
.co m
//Manual mode if not in auto mode
4 4.
a2 2 2 2
LD I1.0

h o
9 gh oa AN M0.0
gh o a hoa
ng do n =
n
L60.0
d o o ng
Tud
LD I1.1
Tu =
Tu
LD
L63.7
I1.2
= L63.6
LD I1.4

.co m .co m =
LD
L63.5
L60.0
.co m .
a 2 4 a 2 4 CALL
a 2 4
POS0_MAN, L63.7, L63.6, L63.5, +100000,
a 24
o o ho o
ngh gh h
I1.5, VB920, VD902, VD906, V910.0

o n n g on g
3 o //Enable auto mode
Tud Networkd
T
LD
u I0.0 T u d
EU
S M0.0, 2
S S0.1, 1

.c o m . c o m R S0.2, 8
. 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
270
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
Creating a Program for the Position Module Chapter 9

4 .c omSample Program 2: Program with POSx_CTRL,


4 .c om 4 . c om 4.
o a 2 a 2 POSx_RUN, POSx_SEEK, and
a 2
POSx_MAN, continued
a 2
ngh n g ho n g o
Network 4 h//Emergency Stop
n g ho
o do I0.1 do
Tud
//Disable the module and auto mode

TuLDR M0.0, 1
T u
R S0.1, 9
R Q0.3, 3

. co m .c o m . c o m
24 24
Network 5

a24
//When in auto mode:
2 4.
hoa hoa a
//Turn on the Running light
M0.0ho ho
ng g g ng
LD

Tu don = n
do Q0.1
TuNetwork 6 Tu d o
LSCR S0.1

.co m .co m Network 7


.co m
//Find the reference point (RP)
.
a 2 4 a 2 4 LD S0.1
a 2 4 a 24
o o o o
ngh gh gh h
= L60.0

o n LD
o n S0.1
on g
Tu d Tu
=
d
LD
L63.7
L60.0
T u d
CALL POS0_RSEEK, L63.7, M1.1, VB930

Network 8 //When at reference point (RP):

4 .c om 4 .co m
4 .co m
//Clamp the material and
//Go to the next step.
4.
o a2 oa 2 LD
ho0
M1.1 a 2 oa 2
ngh gh g ngh 9
LPS

do n n
do Q0.3, 1 o
Tud
AB= VB930,

Tu Tu S
SCRT S0.2
LPP
AB<> VB930, 0
SCRT S1.0

.co m .co m .co m .


a 2 4 a 2 4 Network 9
a 2 4 a 24
o o o o
ngh gh gh h
SCRE

o n o n on g
Tud d 10
TuNetwork
LSCR S0.2
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 271
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 omProgram 2: Program with POSx_CTRL,4.POSx_RUN,


c om POSx_SEEK, and POSx_MAN, continued
4. c om 4.
o a 2 Sample
a 2 a 2 a 2
ngh n g ho Network 11
n
//Useh
g o 1 to move into position.
profile
n g ho
o o do
Tud dS0.2
LD
=
LD
T u L60.0
S0.2
T u
= L63.7
LD L60.0

. co m .c o m CALL

. c o m
POS0_RUN, L63.7, VB228, I0.1, M1.2, VB940,

4.
VB941, VB942, VD944, VD948

o a 24 a 24 Network 12
toa
24turn on the cutter
//When positioned,
a2
ngh n g ho //and goo
M1.2 ng
h the next step.
n g ho
o o o
Tud LPS ud
Tud
LD

T VB940, 0
AB=
S Q0.4, 1
R T33, 1
SCRT S0.3

.co m .co m LPP


.co m .
a 2 4 a 2 4 AB<> VB940, 0
a 2 4 a 24
o o SCRT S1.0
o o
ngh d o n gh Network 13on
gh on g h
Tu Tud
SCRE T u d
Network 14 //Wait for the cut to finish

om m m
LSCR S0.3

4 .c 4 .co 4 .co 4.
h o
9 a2 oa 2 Network 15
o a 2
hoa 2
ng o ngh LD S0.3
o n gh o ng
Tu d TON

Tu d
T33, +200

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
272
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
Creating a Program for the Position Module Chapter 9

4 .c omSample Program 2: Program with POSx_CTRL,


4 .c om 4 . c om 4.
o a 2 a 2 POSx_RUN, POSx_SEEK, and
a 2
POSx_MAN, continued
a 2
ngh n g ho n g o STOP is on, restart
Network 16 h//Unless
n g ho
o do T33 do
Tud
//when the cut is finished.

TuLDLPS
T u
R Q0.3, 1
R Q0.4, 1

. co m .c o m AN I0.2

. c o m
4.
SCRT S0.1
24 24 LPP
a24 2
ng hoa g hoa A
gho
I0.2

ng ho a
don n
R M0.0, 4

Tu do 17
TuSCRE
Network
Tu d o
Network 18

4 .c om 4 .c om LSCR S1.0

4 . c om .
2 2 2the outputs. 24
hoa hoa o a o a
Network 19 //Reset

ng g g h g h
on R on on
LD S1.0

T u d Tu d Q0.3, 2
T u d
Network 20 //Flash the error light.
LD SM0.5
= Q0.5

4 .c om 4 .co m
4 .co m
4.
a2 2 2 2
Network 21 //Exit the error routine if STOP is on.
o oa h9o a oa
ngh gh ngh 9
LD I0.2

o n n g
do S0.1, 8 o
R M0.0,

Tu d Tu
R
Tud
Network 22
SCRE

.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 273
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 Monitoring the Position
a 2
Module with the EM 253 2
Control
a Panel
a 2
ngh n g ho of your Position Control solution, STEP
n g o
h7–Micro/WIN n g ho
udThe
Control Panel. o Operation, Configuration and Diagnostics
To aid you in the development
udtabso make it easy for you to monitor and udo
provides the EM 253

control T
the operation of the Position module during theTstartup and test phases of your developmentT
process.
Use the EM 253 Control Panel to verify that the Position module is wired correctly, to adjust the

. co mconfiguration data, and to test each movement


.c o m profile. . c o m
a 2 4 a 2 4 a 2 4 a2 4.
o o ho of the Position Module. ngho
ngh hcontrol
Displaying and Controlling the Operation of the Position Module
n g n g
dodisplays the current speed, the current
The Operation tab
The controlupanel
T
of the panel allows you to
do and the current direction of the Position
interact
T u
with
position
the operations
T u do
module. You can also see the status of the input and output LEDs (excluding the Pulse LEDs).

The control panel allows you to interact with the

.co m Position module by changing the speed and


.co m
direction, by stopping and starting the motion,
.co m .
a 2 4 2 4
and by jogging the tool (if the motion is stopped).
a a 2 4 a 24
o o o o
ngh n gh
You can also generate the following motion
commands:
d o d o n gh
d on g h
- Tu
Enable Manual Operation. This command Tu T u
allows you to use the manual controls for
positioning the tool.

4 .c om - 4 .co m
Run a Motion Profile. This command allows
you to select a profile to be executed. The 4 .co m
4.
h o
9 a2 oa 2
control panel displays the status of the
o a 2
hoa 2
ng o ngh
profile which is being executed by the
o n gh o ng
d
Position module.
Tu Tu d Tud
- Seek to a Reference Point. This command
finds the reference point by using the
configured search mode.
Figure 9-19 Operation Tab of the EM 253 Control Panel

.co m- .co m .co m


Load Reference Point Offset. After you use the manual controls to jog the tool to the new zero
.
a 2 4 a 2 4
position, you then load the Reference Point Offset.
a 2 4 a 24
o ho ho o
ngh -
n g n g ng
Reload Current Position. This command updates the current position value and establishes a new
d o
zero position.
d o d o
h
- Tu the DIS output and Deactivate the DISToutput.
Activate
u These commands turn the DIS output Tof u
the
Position module on and off.
- Pulse the CLR output. This command generates a 50 ms pulse on the CLR output of the Position

.c o m module.
. c o m . c o m
a24 -
a 2
Teach a Motion Profile. This4command allows you to save the target aposition
2 4 and speed for a motion a 2 4.
o ho ho ho
ngh
profile and step as you manually position the tool. The control panel displays the status of the profile
n g n g n g
do Configuration. This command loadsTua new doconfiguration by commanding the Position udo
which is being executed by the Position module.
- T
LoaduModule T
module to read the configuration block from the V memory of the S7-200.
- Move to an Absolute Position. This command allows you to move to a specified position at a target

.co m- . c om . c om
speed. Before using this command, you must have already established the zero position.

a2 4 a 2 4 a 2 4
Move by a Relative Amount. This command allows you to move a specified distance from the
a2 4.
o hoInterface. This command clears the command hobyte for the Position module
current position at a target speed. You can enter a positive or negative distance.
ho
ng h -
o n g
Reset the Command
and u d d n g
omodule appears to not be responding toudon g
T sets
commands. T u
the Done bit. Use this command if the Position
T

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
274
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
Creating a Program for the Position Module Chapter 9

4 .c om Displaying and Modifying 4 .c omConfiguration of the Position


4. c m
oModule 4.
o a 2 a 2 the
a 2 a 2
ngh g
The Configuration
n htabo ofthetheconfiguration
control panel allows
n g ho n g ho
u o module that are stored in the dataudo
dPosition
you to view and modify settings
u do
T
for the
block of the S7-200. T T
After you modify the configuration settings, you
simple click a button to update the settings in

. co m c o m
both the STEP 7–Micro/Win project and the data
. . c o m
24 block of the S7-200.
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
Figure 9-20 Configuration Tab of the EM 253 Control Panel g h
Tu Tu
Displaying the Diagnostics Information for the Position Module T u
The Diagnostics tab of the control panel allows
you to view the diagnostic information about the

4 .c om Position module.
4 . c om 4 . c om 4.
o a2 aas2the position
You can view specific information
o about the
o a2 oa 2
ngh ngh 9
Position module,h h
ngI/Onumber, ng
such of the
o
module in the
d chain, the module type and
d o o
Tuas the command byte for the module. Tu
firmware
used
version and the output byte
Tud
The control panel displays any error condition
that resulted from a commanded operation. Refer

.co m .co m
to Table 9-13 on page 276 for the instruction
.co m .
a 2 4 error conditions.
a 2 4 a 2 4 a 24
o o o o
ngh gh gh g h
You can also view any error condition reported
o n
by the Position module. Refer to Table 9-14 on
o n on
Tud
page 277 for the module error conditions.
Tu d T u d
Figure 9-21 Diagnostics Tab of the EM 253 Control Panel

.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 275
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 Error Codes for the Position
a 2 Module and the Position
a 2 Instructions
a 2
ngh n g ho n g ho n g ho
o
Table 9-13 Instruction Error Codes
o o
Tud Description
Error Code Tud Tud
0 No error
1 Aborted by user

.com c o m c o m
2 Configuration error

24 24 . . 4.
a24
Use the EM 253 Control Panel Diagnostics tab to view error codes
a 2
ng h o 3
g hoa
Illegal command
gho ng ho a
4

Tu don Aborted due to no valid configuration

Tu do n
Use the EM 253 Control Panel Diagnostics tab to view error codes
Tu d o
5 Aborted due to no user power
6 Aborted due to no defined reference point

4 .c om 7

4 . om
Aborted due to STP input active
c 4 . c om .
2 8 Aborted due to LMT– input active
2 a2 24
ng hoa 9
h o
Aborted due a
to LMT+ input active
ng due to problem executing motion dong h o g h o a
10
11Tu
d oAborted
d on
Tu
No profile block configured for specified profile T u
12 Illegal operation mode
13 Operation mode not supported for this command

4 .c om 14
4 . om
Illegal number of steps in profile block
c 4 . c om 4.
o9a 2 15
a2
Illegal direction change
o o a2 a 2
ng h 16 h
ngtrigger occurred before target speed reacheddong
Illegal distance h ng ho
do o
Tud
17 RPS
18T
u Insufficient RPS active region width Tu
19 Speed out of range
20 Insufficient distance to perform desired speed change

.com 21 Illegal position


.co m .co m .
o a24 22
oa 2 4
Zero position unknown
ho a 2 4
o a 24
ngh 23 to 127
d on g h
Reserved
Position module cannot process this instruction:d o n g
d o ng h
Tu instruction, or there was no Start pulse onTthisuinstruction
128 either
Tu
the Position module is busy with another

129 Position module error:


H The location of the Position module or the Q memory address that was configured with the

.c o m . c o m . c o m
Position Control wizard does not match the actual location or memory address
.
a24 24 24 24
H Refer to SMB8 to SMB21 (I/O Module ID and Error Register) for other error conditions

ngh
o 130
hoa
Position module is not enabled
ngthemodule or g
is not available due to a module errorn
hoa n gh oa
131
d oPosition
d o module not enabled
o
Tu (See POSx_CTRL status)
Tu 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
276
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
Creating a Program for the Position Module Chapter 9

4 .c om 4 .co m
4. c om .
o a2
Table 9-14
o a 2
Module Error Codes
o a2 o a 24
ngh g hDescription gh g h
Error Code
n n on
T ud0 o No error
1 No user power T ud o
T u d
2 Configuration block not present
3 Configuration block pointer error

24 .com 4
. c o m
Size of configuration block exceeds available V memory

24 block format . c o m
4.
h o a 5
a
Illegal configuration
o
hToo many profiles specified ho a24 ho a2
ng 6 g
d7 on Illegal STP_RSP specification do n g
d ong
Tu 8 Illegal LMT–_RPS specification
Tu Tu
9 Illegal LMT+_RPS specification

om
10 Illegal FILTER_TIME specification

4 .c 4 .c om 4 .co m .
24
11 Illegal MEAS_SYS specification
2 2 specification 2
ng hoa 12
hIllegala
o RP_CFG

ng Illegal PLS/REV value n gh o a


g h o a
o 13
o on
Tud14 15
Illegal UNITS/REV value
Illegal RP_ZP_CNT value
Tu d T u d
16 Illegal JOG_INCREMENT value

4 .c om 17

4 . c om
Illegal MAX_SPEED value

4 .co m
4.
2 18
2 value
Illegal SS_SPD value
2 2
ng hoa 19
h o aRP_FAST
Illegal
ng Illegal RP_SLOW value n gh o a oa
ngh 9
o o o
Tud21 d Tud
20
Illegal JOG_SPEED value Tu
22 Illegal ACCEL_TIME value
23 Illegal DECEL_TIME value

4 . c om 24
.co
Illegal JERK_TIME value
4
m
4 .co m .
2 2 2 24
hoa a a a
25 Illegal BKLSH_COMP value

gh o gh o h o
ng 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

.com .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 277
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 Advanced Topics
a 2 a 2 a 2
ngh n g ho n g ho n g ho
Understanding
T u dothe Configuration/ProfileTTable u do T u do
The Position Control wizard has been developed to make motion applications easy by automatically
generating the configuration and profile information based upon the answers you give about your position
control system. Configuration/profile table information is provided for advanced users who want to create

. co m their own position control routines.


.c o m . c o m
a 2 4 The configuration/profile table
a 2
is 4
located in the V memory area of the S7-200.
a 2As 4
shown in Table 9-15, the
a2 4.
o o
configuration settings are stored in the following types of information:
o ho
ngh o n
- The configuration
g hblock
o n g hmodule
on g
Tudcommands. Tud Tud
contains information used to set up the in preparation for executing
motion
- The interactive block supports direct setup of motion parameters by the user program.
- Each profile block describes a predefined move operation to be performed by the Position module.

4 .c om 4 .co
You can configure up 25 profile blocks. m
4 .co m .
2 2 2 24
hoa a a a
Tip
gh o gh o h o
ng To create more than 25 motion profiles, you can exchange configuration/profile tables by changing the
d o n
value stored in the configuration/profile table pointer.
d o n d on g
Tu Tu T u
Table 9-15 Configuration/Profile Table
Offset Name Function Description Type

4 .c o0 m MOD_ID
Configuration Block

4 . c om 4 . c om 4.
a2 5 CB_LEN aof2the configuration block in bytes (1 byte) hoa2 2
Module identification field ––

h o
9 h o
The length ––
hoa
ng 6 IB_LEN
PF_LEN ud
ongThe o ng
length of the interactive block in bytes (1 byte)
d
––
o ng
7
8
T
STP_LEN
Tu
The length of a single profile in bytes (1 byte)
The length of a single step in bytes (1 byte)
T––––ud
9 STEPS The number of steps allowed per profile (1 byte) ––
10 PROFILES Number of profiles from 0 to 25 (1 byte) ––

.com Reserved
11 Set to 0x0000
.com .com ––
.
a24 13 IN_OUT_CFG
a24
Specifies the use of the
a24 24
MSB LSB ––
o o 7 6 5 4
o3 2 1 0
o a
ngh gh gh h
module inputs and outputs

o n (1 byte) P/D POL 0


o n 0 STP RPS LMT– LMT+
on g
Tud P/D Tu
This bit specifies the use of P0 and P1.
d T u d
Positive Polarity (POL=0):
0 – P0 pulses for positive rotation

.c o m . c m
P1 pulses for negative rotation
o
1 – P0 pulses for rotation
. c o m .
a24 24 24 24
P1 controls rotation direction (0 – positive, 1 – negative)

ngh
o g hoa Negative Polarity (POL=1):
g hoa gh oa
d on 0 – P0 pulses for positive rotation
d on o n
u u Tud
P1 pulses for negative rotation
T 1 – P0 pulses for rotation T
P1 controls rotation direction (0 – positive, 1 – negative)
POL This bit selects the polarity convention for P0 and P1.
(0 – positive polarity, 1 – negative polarity)

.co m . c om . c om 4.
STP This bit controls the active level for the stop input.

a2 4 RPS This2 4 4
alimit2input.
a bit controls the active level for the RPS input.travel a2
o o o ho
ng h h This bit controls the active level for the negativeh
ngLMT+ This bit controls the active level for dtheopositive
ng travel limit input ng
LMT–

d o d o
Tu 0 – Active high
1 – Active low
Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
278
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
Creating a Program for the Position Module Chapter 9

4 .c om 4 . c om 4 . c om .
o a2 o a2 Description
Table 9-15 Configuration/Profile Table, continued
o a2 o a 24
ng h Offset Name
STP_RSP ng
h Function
h
nginput (1 byte)
Type
g h
14
d o o
Specifies the response of the drive to the STP
d d on ––

Tu 0 No action. Ignore the


1 Decelerate to a stop and Tuindicate that the STP input is active.
input condition.
T u
2 Terminate the pulses and indicate STP input
3 to 255 Reserved (error if specified)

. co m 15 LMT–_RSP

.c o m . c o m
Specifies the response of the drive to the negative limit input (1 byte) ––

24 24
0 No action. Ignore the input condition.
24 2 4.
hoa hoa oa a
1 Decelerate to a stop and indicate that the limit has been reached.

ng g gh
2 Terminate the pulses and indicate that the limit has been reached.
ng ho
d on on
3 to 255 Reserved (error if specified)
o
16
T u
LMT+_RSP
Tud
Specifies the response of the drive to the positive limit input (1 byte)
0 No action. Ignore the input condition.
Tu d ––

1 Decelerate to a stop and indicate that the limit has been reached.
2 Terminate pulses and indicate that the limit has been reached.

.co m17 .co m


3 to 255 Reserved (error if specified)

.co m .
a 2 4 FILTER_TIME

a 2 4
Specifies the filter time for the
STP, LMT–, LMT+, and RPS
MSB
7 6 5 4
a
3
2 4 2 1
LSB
0
––

a 24
o o o o
ngh gh gh h
inputs (1 byte)

o n
STP, LMT–, LMT+

o n
RPS

on g
Tu d ’0000’ 200 µsec
Tu
’0101’ d
3200 µsec
T u d
’0001’ 400 µsec ’0110’ 6400 µsec
’0010’ 800 µsec ’0111’ 12800 µsec
’0011’ 1600 µsec ’1000’ No filter
’0100’ 1600 µsec
om18 om om
’1001 ’ to ’1111’ Reserved (error if specified)

4 .c MEAS_SYS
4 . c
Specifies the measurement system (1 byte)
4 . c ––
4.
o a2 a0 2
a 2
Pulses (speed is measured in pulses/second, and the
ho 1 measured o position values are
a
o9 2
ngh
in pulses). Values are stored ash h
o ng n g DINT.
o in units/second, and the position values areudo ng
Tud T aredstored as single-precision REAL.
Engineering units (speed is measured
measured in units). Values u
2 to 255 Reserved (error if specified)
T
19 –– Reserved (Set to 0) ––
20 PLS/REV Specifies the number of pulses per revolution of the motor (4 bytes) DINT

.co m .co m
Only applicable when MEAS_SYS is set to 1.
.co m .
a 2 4 24 UNITS/REV
2 4 2 4
Specifies the engineering units per revolution of the motor (4 bytes)
a a REAL
a 24
o hoReserved for STEP 7–Micro/WIN to store n hounits string (4 bytes) o
ngh h
Only applicable when MEAS_SYS is set to 1.

o n g g ––ng
do o
28 UNITS a custom
32
Tud
RP_CFG Specifies the reference point
search configuration (1 byte) T u MSB
7 6 5 4 3 2 1
LSB
0
d
Tu ––
0 0 MODE

.c o m . c o m . c o m
RP_ADDR_DIR

4.
RP_SEEK_DIR

a2 4 a 2 4 (0 – positive direction, 1 – negative direction)


RP_SEEK_DIR This bit specifies the starting direction
a 2
for a4 point search.
reference
a 2
ho hoRP_APPR_DIR This bit specifies the approach o for terminating the reference
hdirection ho
ng o n g n g n g
Tud point search.
(0 – positiveT
udo
direction, 1 – negative direction) Tud
o
MODE Specifies the reference point search method.
’0000’ Reference point search disabled.

.co m .co m
’0001’ The reference point is where the RPS input goes active.

. com 4.
’0010’ The reference point is centered within the active region of the RPS input.

a2 4 a 2 4 a2 4
’0011’ The reference point is outside the active region of the RPS input.
a2
o gho o ho
ng h gh
’0100’ The reference point is within the active region of the RPS input.

don d o n
’0101’ to ’1111’ Reserved (error if selected)
d o ng
33
34 Tu
––
RP_Z_CNT
Reserved (Set to 0)
Tu
Number of pulses of the ZP input used to define the reference point (4 bytes) Tu ––
DINT

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 279
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
o9-15 .c om . c om .
4
a2 Offset Name
Table
2 4
Configuration/Profile Table, continued
aDescription a2 4 a 24
h o h o
Function
h o Type
h o
ng 38 RP_FAST
d o ngFast speed for the RP seek operation: MAX_SPD
d o norgless (4 bytes) DINT
d on g
42 Tu
RP_SLOW Slow speed for the RP seek operation:
u speed from which the motor can
Tmaximum T u
REAL
DINT
instantly go to a stop or less (4 bytes) REAL
46 SS_SPEED Start/Stop Speed. (4 bytes) DINT

. co m .c m . c o m
The starting speed is the maximum speed to which the motor can instantly go from a
o
REAL

4.
stop and the maximum speed from which the motor can instantly go to a stop. Operation
24 24 a24
below this speed is allowed, but the acceleration and deceleration times do not apply.
2
ng hoa 50 MAX_SPEED
n g hoa
Maximum operating speed of the motor (4 bytes)
n g ho DINT
ng ho a
d o d o d o
REAL
54
58
Tu
JOG_SPEED Jog speed. MAX_SPEED or less (4
Tu
bytes)
JOG_INCREMENT The jog increment value is the distance (or number of pulses) to move in response to a
u
TDINT
single jog pulse. (4 bytes) REAL
62 ACCEL_TIME Time required to accelerate from minimum to maximum speed in milliseconds (4 bytes) DINT

4 .c o6670 m DECEL_TIME 4 .co m


4 .co m
Time required to decelerate from maximum to minimum speed in milliseconds (4 bytes) DINT
.
o a2
BKLSH_COMP
a 2
o which jerk compensation is applied to thegbeginning a 2
Backlash compensation: the distance used to compensate for the system backlash on a DINT
a 24
ngh 74 JERK_TIME
n g
Time
direction change (4 bytes)
hduring n ho and ending portions of DINT ng REAL
h o
T udo ancompensation. The jerk time is given T
o (4 bytes)
udSpecifying
acceleration/deceleration curve (S curve).
in milliseconds.
a value of 0 disables jerk
T udo
Interactive Block
78 MOVE_CMD Selects the mode of operation (1 byte) ––
0 Absolute position

4 .c om .co
1 Relative position
4
m
4 .co m
4.
a2 2 2 2
2 Single-speed, continuous operation, positive rotation

h o
9 gh oa
3 Single-speed, continuous operation, negative rotation
gh o a hoa
ng do n 4 Manual speed control, positive rotation

d o n o ng
Tud
5 Manual speed control, negative rotation
Tu Tu
6 Single-speed, continuous operation, positive rotation with triggered stop
(RPS input signals stop)
7 Single-speed, continuous operation, negative rotation with triggered stop
(RPS input signals stop)
8 to 255 – Reserved (error if specified)

.co8079 m –– . c
Reserved. Set to 0 om .c om ––
.
a 2 4 TARGET_POS Target position 4
a2 to go to in this move (4 bytes) a2 4 DINT
a 24
o o o o
ngh h
ngTarget speed for this move (4 bytes) dong h g h
REAL
84
d
TARGET_SPEEDo DINT
d on
88
Tu
RP_OFFSET
Tu
Absolute position of the reference point (4 bytes)
T u
REAL
DINT
REAL
Profile Block 0
92 m STEPS m m
.c o . c o
Number of steps in this move sequence (1 byte)
. c o ––
.
a24 93 MODE 24 24 24
(+0)

ngh
o hoa hoa
Selects the mode of operation for this profile block (1 byte)
g01 g
––
gh oa
on on n
(+1)
d
Absolute position
d o
u u Tud
Relative position
T T
2 Single-speed, continuous operation, positive rotation
3 Single-speed, continuous operation, negative rotation
4 Reserved (error if specified)
5 Reserved (error if specified)

.co m .co m om
6 Single-speed, continuous operation, positive rotation with triggered stop
. c
a2 4 a 2 4
(RPS selects speed)
7 Single-speed, continuous operation, negative rotation
a2 4 a2 4.
o gho o ho
ng h gh
with triggered stop (RPS input signals stop)

don o n
8 Two-speed, continuous operation, positive rotation (RPS selects speed)
d d ong
Tu Tu Tu
9 Two-speed, continuous operation, negative rotation (RPS selects speed)
10 to 255 – Reserved (error if specified)

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
280
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
Creating a Program for the Position Module Chapter 9

4 .c om 4 . c om 4. c om .
o a2 o a2 Description
Table 9-15 Configuration/Profile Table, continued
o a2 o a 24
ng h Offset Name
h Function
ng Position to go to in move step 0 (4 bytes) ng h Type
ng h
94 0
d o
POS
d o d o
DINT
(+2)
98 T0u SPEED Target speed for move step 0 T u
(4 bytes) Tu REAL
DINT
(+6) REAL
102 1 POS Position to go to in move step 1 (4 bytes) DINT

. co m106
(+10)

.c o m . c o m REAL

24
1 SPEED
24
Target speed for move step 1 (4 bytes)

a24
DINT
2 4.
hoa a to go to in move step 2 (4 bytes) ho a
(+14) REAL
h oPosition ho
ng g ng ng
110 2 POS DINT
(+18)
d o n d o d o REAL
114
(+22)
T2u SPEED Target speed for move step 2 T u
(4 bytes)
Tu DINT REAL
118 3 POS Position to go to in move step 3 (4 bytes) DINT
(+26) REAL

4 .c om(+30)
122 3 SPEED
.co m
Target speed for move step 3 (4 bytes)
4 4 .co m DINT
.
24
REAL

o a2 Profile Block 1 a 2
hoNumber of steps in this move sequence (1nbyte) ho a 2 o a
ngh 126 STEPS
d o n g
d o g
d
–– g
o n h
(+34)
127 T u
MODE T u
Selects the mode of operation for this profile block (1 byte)
u
T ––
(+35)
128 0 POS Position to go to in move step 0 (4 bytes) DINT
(+36) REAL

4 .c om(+40)
132 0 SPEED
.co m
Target speed for move step 0 (4 bytes)
4 4 .co m DINT
4.
o a2 o...a 2 o a 2 REAL
a
ho9
2
ngh gh gh
... ... ... ...

o n o n ng
Tu d Tu d T udo
Special Memory Locations for the Position Module

.co m .co m .co m


The S7-200 allocates 50 bytes of special memory (SM) to each intelligent module, based on the physical
.
a 2 4 a 2 4 a 2 4
position of the module in the I/O system. See Table 9-16. When the module detects an error condition or a
a 24
o o o
change in status of the data, the module updates these SM locations. The first module updates SMB200
o
ngh n gh n gh
through SMB249 as required to report the error condition, the second module updates SMB250 through
o o on g h
Tud d d
SMB299, and so on.

Table 9-16 Special Memory Bytes SMB200 to SMB549


Tu T u
SM Bytes for an intelligent module in:

.c o m Slot 0 Slot 1
. c o m Slot 2 Slot 3 Slot 4
. c o m Slot 5 Slot 6
.
a24 24 24 24
SMB200 to SMB250 to SMB300 to SMB350 to SMB400 to SMB450 to SMB500 to

o hoa hoa oa
SMB249 SMB299 SMB349 SMB399 SMB449 SMB499 SMB549

ngh d on g
d on g o n gh
Tud
Table 9-17 shows the structure of the SM data area allocated for an intelligent module. The definition is
T u T u
given as if this were the intelligent module is located in slot 0 of the I/O system.

.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 281
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
o9-17 c o253mPosition Module c om
4 the.EM
Special Memory Area Definition for 4 4. .
o a2 SM Address Description hoa2
Table
o a2 o a 24
ng h n(16gASCII characters). SMB200 is the first character: h
g Position”
n“EM253 g h
SMB200 to
o
Module name
d d o d on
SMB215
SMB216 to Tu revision number (4 ASCII characters). SMB216
Software Tuis the first character. T u
SMB219
SMW220 Error code for the module. See Table 9-14 for a description of the error codes.

. co m
SMB222
.c o m
Input/output status. Reflects the status of the inputs MSB

. c o m LSB

4.
7 6 5 4 3 2 1 0

24 24 24
and outputs of the module.
2
hoa hoa hoa ho a
DIS 0 0 STP LMT– LMT+ RPS ZP

ng DIS
d on g
Disable outputs 0 = No current flowng 1 = Current flow
o 1 = Current flow ong
T u
STP Stop input
LMT– Negative travel limit input
udflow
0 = No current
0 = NoTcurrent flow 1 = Current flow Tu d
LMT+ Positive travel limit input 0 = No current flow 1 = Current flow
RPS Reference point switch input 0 = No current flow 1 = Current flow
ZP Zero pulse input 0 = No current flow 1 = Current flow

.co m
SMB223
.co m
Instantaneous module status. Reflects the status of MSB
.co m LSB
.
a 2 4 2 4
the module configuration and rotation direction status.
a
7 6 5

a 2
4
4 3 2 1 0

a 24
o ho ho o
ngh h
0 0 0 0 0 OR R CFG

n g
o speed out of range 0 = In range o n g on g
OR
Tu
R
dTarget
Direction of rotation
T u
0 = Positive
drotation 11 == Negative
Out of range
rotation
T u d
CFG Module configured 0 = Not configured 1 = Configured
SMB224 CUR_PF is a byte that indicates the profile currently being executed.
SMB225 CUR_STP is a byte that indicates the step currently being executed in the profile.

4 .c om
SMD226
c om c om
CUR_POS is a double-word value that indicates the current position of the module.
4 . 4 . 4.
o9a 2 SMD230
aSee2Table 9-13 for descriptions of the hoa2
CUR_SPD is a double-word value that indicates the current speed of the module.
o a 2
ng h SMB234
error codes. n
h
gconditions above 127 are generated by the ong
Result of the instruction. MSB
7 6
LSB
0
ng ho
d o Error
o
Tu
instruction

D
subroutines created by the wizard.

Done bit 0= Operation in progress


Tud D ERROR
Tud
1= Operation complete (set by the module during initialization)
SMB235 to Reserved

.com
SMB244
.co m .co m .
o a24 SMB245 o a 2 4
o a 2 4
Offset to the first Q byte used as the command interface to this module. The offset is supplied by the S7-200
o a 24
ngh gh gh h
automatically for the convenience of the user and is not needed by the module.
SMD246
o n o n
Pointer to the V memory location of the configuration/profile table. A pointer value to an area other than
on g
Tud Tu d
V memory is not valid. The Position module monitors this location until it receives a non-zero pointer value.
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
282
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
Creating a Program for the Position Module Chapter 9

4 .c om Understanding the Command 4 . c omByte for the Position Module 4 . c om 4.


o a 2 a 2
oprovides one byte of discrete outputs which a 2 a 2
ngh g hthe
The Position module
n n g hisothe
used as the command byte.
n g ho
T u do
Figure 9-22 shows command byte definition.
T u do
Table 9-18 shows Command_code
do
definitions.
T u
A write to the command byte where the R bit MSB LSB
7 6 5 4 3 2 1 0
changes from 0 to 1 is interpreted by the module
as a new command. QBx R Command_code

. co m o m
If the module detects a transition to idle (R bit
.c . c o m
4.
R 0= Idle

24 24
changes state to 0) while a command is active, 1=
a24
Execute the command specified
2
hoa hoa ho ho a
then the operation in progress is aborted and, if a in Command_code (See Table 9-18)

ng performed.
g
motion is in progress, then a decelerated stop is
don d o n g
d ong
Tu Tu Figure 9-22 Definition of the Command Byte
Tu
After an operation has completed, the module must see a transition to idle before a new command is
accepted. If an operation is aborted, then the module must complete any deceleration before a new
command is accepted. Any change in the Command_code value while a command is active is ignored.

.co m .co m
The response of the Position module to a .co m .
a 2 4 a 2 4
change in the operating mode of the S7-200 or
a 2 4
Table 9-18 Command_code Definitions
a 24
o o Command_code Command
o o
ngh gh gh g h
to a fault condition is governed by the effect that 000 0000 to
o n
the S7-200 exerts over the discrete outputs
d d o n
000 1111
0 to
24
Execute motion specified in
Profile Blocks 0 to 24
d on
Tu
according to the existing definition of the
S7-200 function: Tu111 0101
100 0000 to 25 to Reserved
117 (Error if specified)
T u
- If the S7-200 changes from STOP to 111 0110 118 Activate the DIS output
RUN: The program in the S7-200 111 0111 119 Deactivate the DIS output

4 .c om 4 .com
controls the operation of the Position 111 1000
4
Pulseo
. c mCLR output
the 120
4.
o a 2 module.
a 2 111 1001
a 2
121 Reload current position
a 2
ngh n hcanochanges
- If the S7-200
g from RUN to 111 1010
n g ho 122 Execute motion specified in the
ng ho9
do outputs are to go to on a Tu111d1011
STOP:
Tudiscrete
You select the state that the
o 123
Interactive Block
Capture reference pointu
T do
offset
transition to STOP or that the outputs are
111 1100 124 Jog positive rotation
to retain their last state.
111 1101 125 Jog negative rotation
– If the R bit is turned off when going 111 1110 126 Seek to reference point position

.com .com .co m


to STOP: The Position module
111 1111 127 Reload configuration
.
a24 a24 4 24
decelerates any motion in
o a 2 a
ho ho o
progress to a stop

ngh If g
n the R bit is turned on when going to STOP: n
o is in progress. If no command is inuprogress,

o g
The Position module completes any commandng
do
h
Tud that T dbits. the Position module executes theTucommand
which is specified by the Command_code
– If the R bit is held in its last state: The Position module completes any motion in progress.
- If the S7-200 detects a fatal error and turns off all discrete outputs: The Position module decelerates
.c o m . c o m . c o m
4.
any motion in progress to a stop.

a2 4 a 2 4 a watchdog timer that turns the outputsa 2 4 a 2


ho g theooutput watchdog timer expires, theoPosition
The Position module implements
S7-200 are lost. Ifh
ghomodule decelerates any motion in ongho
off if communications with the

ng progress o to n n
ud ud ud
a stop.

IfT
a fatal error in the hardware or firmware of theT
module is detected, the Position module setsT the P0, P1,
DIS and CLR outputs to the inactive state.

.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 283
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
o9-19 .co m . c om .
a2 4 Table Motion Commands
a 2 4 a2 4 a 24
o o ho o
ngh g hDescription g ng h
Command
Commands 0 to 24:
d o n d
When this command is executed, the Positiononmodule performs the motion operation
d o
Executes the motionTuspecified in specified
profile blocks 0 to 24 the command.
Tu block indicated by the Command_code portionTofu
in the MODE field of the profile

H In Mode 0 (absolute position), the motion profile block defines from one to four steps with
each step containing both the position (POS) and speed (SPEED) that describes the

. co m o m o m
move segment. The POS specification represents an absolute location, which is based
.c . c
24 24 a24
on the location designated as reference point. The direction of movement is determined
2 4.
hoa hoa a
by the relationship between the current position and the position of the first step in the

ng g g ho
profile. In a multi-step move a reversal of direction of travel is prohibited and results in an
ng ho
don H o n o
error condition being reported.

Tu u d Ttheu d
each step containing both the T
In Mode 1 (relative position), the motion profile block defines from one to four steps with
position (POS) and the speed (SPEED) that describes
move segment. The sign of the position value (POS) determines the direction of the
movement. In a multi-step move, a reversal of direction of travel is prohibited and results
in the reporting of an error condition.

.co m H
.co m .co m
In Modes 2 and 3 (single-speed, continuous operation modes), the position (POS)
.
a 2 4 a 2 4 a 2 4
specification is ignored and the module accelerates to the speed specified in the SPEED
a 24
o ho ho o
ngh h
field of the first step. Mode 2 is used for positive rotation, and Mode 3 is used for negative

o n g o n g
rotation. Movement stops when the command byte transitions to Idle.
operation modes with triggered stop), the do
ng
Tu d T
module accelerates to the speed
d
uspecified in the SPEED field of the first step. If andTu
H In Modes 6 and 7 (single-speed, continuous

when the RPS input becomes active, movement stops after completing the distance
specified in the POS field of the first step. (The distance specified in the POS field must
include the deceleration distance.) If the POS field is zero when the RPS input becomes

4 .c om 4 . om
and Mode 7 is used for negative rotation.
4 . om
active, the Position module decelerates to a stop. Mode 6 is used for positive rotation,
c c 4.
h o
9 a2 H Ina 2
hospecified by the first two steps in the profilenblock.
Modes
ho a
8 and 9, the binary value of the RPS input selects2 one of two speed values as
hoa 2
ng o ng – If the RPS is inactive: Step 0 controlso
g o ng
Tud Tudthe speed of the drive. Tud
the speed of the drive.
– If the RPS is active: Step 1 controls
Mode 8 is used for positive rotation, and Mode 9 is used for negative rotation. The
SPEED value controls the speed of movement. The POS values are ignored in this
mode.

4 . c om 118
Command
.co m .co
When this command is executed, the Position module activates the DIS output.
4 4
m .
o a2 Activates the DIS output a 2
o this command is executed, the Position module a 2
o the DIS output. o a 24
ngh Command 119
d o n g hWhen
d o n g hdeactivates
d o ng h
Command 120 T
u
Deactivates the DIS output
When this command is executed, T
u
the Position module generates a 50-millisecond pulseT
on
u
Pulses the CLR output the CLR output.

Command 121 When this command is executed, the Position module sets the current position to the value

.c o m o m
found in the TARGET_POS field of the interactive block.
. c . c o m
4.
Reloads the Current Position

a2 4
Command 122
a
When this2 4 is executed, the Position module performs
command
a 2 4 motion operation
the
a 2
o o in the MOVE_CMD field of the interactivegblock.ho a single step motion is ho
ngh Execute the motion specified in
o n g hspecified
H n
doand position information provided in the Tudo n g
Tud
the interactive block In Modes 0 and 1 (absolute and relative motion modes),
performed based upon the target u
T speed
TARGET_SPEED and TARGET_POS fields of the interactive block.
H In Modes 2 and 3 (single-speed, continuous operation modes), the position specification
is ignored, and the Position module accelerates to the speed specified in the

.co m . c om . c om
TARGET_SPEED field of the interactive block. Movement stops when the command byte

4.
transitions to Idle.

a2 4 a 2
H In Modes4 a 2 4
4 and 5 (manual speed control modes), the position specification is ignored and
a2
o hoyour program loads the value of speed changes intoo
ho
ng h g g h monitors g
the TARGET_SPEED field of the

o n o n
interactive block. The Position module continuously this location and responds
on
Tud appropriately when the speed value d
Tu changes. Tud

4 . com 4. c om 4 . com .
o a2 oa2 a2 a 24
ngh
284
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
Creating a Program for the Position Module Chapter 9

4 .c om 4 .co m
4. c om .
oa2
Table 9-19
2
Motion Commands, continued
a
o Description a2 a 24
ngh
Command
n gh n g ho g h o
o o o an
Command 123
T
Capture the ud Point
Reference
When this command is executed, the
d
Tu point position.
different location from the reference
Tu d
Position module establishes a zero position that is at

offset Before issuing this command, you must have determined the position of the reference point
and must also have jogged the machine to the work starting position. After receiving this
command, the Position module computes the offset between the work starting position (the

. co m o m o m
current position) and the reference point position and writes the computed offset to the
.c . c
24 24 a24
RP_OFFSET field of the Interactive Block. The current position is then set to 0 to establish
2 4.
hoa a a
the work starting position as the zero position.

ng n g ho Inthethestepper g hofoits position (for example, if power is lost or ho


the Seek to Reference Point Position command ng
event that the stepper motor loses track
n
o o o
Tud Tudzero position automatically. Tud
motor is repositioned manually)
can be issued to re-establish the
Command 124 This command allows you to manually issue pulses for moving the stepper motor in the
Jog positive rotation positive direction.
If the command remains active for less than 0.5 seconds, the Position module issues pulses

4 .c om 4 .co m
to travel the distance specified in JOG_INCREMENT.

4 .co m .
2 2 2
If the command remains active for 0.5 seconds or longer, the motion module begins to
24
hoa a
o When a transition to idle is detected, the Position a
homodule decelerates to a stop. o a
accelerate to the specified JOG_SPEED.

ng o n gh o n g o n g h
Tu
Command 125 d d
Tu issue pulses for moving the stepper motorTinuthe
This command allows you to manually d
Jog negative rotation negative direction.
If the command remains active for less than 0.5 seconds, the Position module issues pulses
to travel the distance specified in JOG_INCREMENT.

4 .c om 4 . om
accelerate to the specified JOG_SPEED.
4 . om
If the command remains active for 0.5 seconds or longer, the Position module begins to
c c 4.
o a 2 a 2 a 2 a 2
ho When this command is executed, the Position o initiates a reference point seek ho9
When a transition to idle is detected, the Position module decelerates to a stop.

ngh Command 126


o ng operation using the specified searcho n g hmodule
method. When the reference point has been locatedo n g
TudPoint position motion has stopped, the Position
Seek to Reference
Tudmodule loads the value read from the RP_OFFSET d and
Tufield
the interactive block into the current position and pulses the CLR output on for
of

50 milliseconds.
Command 127 When this command is executed, the Position module reads the configuration/profile table

.comReload the configuration .co m .co m


pointer from the appropriate location in SM memory and then reads the configuration block
.
a24 4 4 24
from the location specified by the configuration/profile table pointer. The Position module

o a 2 a 2 a
ho ho o
compares the configuration data just obtained against the existing module configuration and

ngh do n g
do n g
performs any required setup changes or recalculations. Any cached profiles are discarded.

d on g h
T u T u
Understanding the Profile Cache of the Position Module T u
The Position module stores the execution data for up to 4 profiles in cache memory. When the Position
module receives a command to execute a profile, it checks to see if the requested profile is stored in the

.c o m . c o m . c o m
cache memory. If the execution data for the profile is resident in the cache, the Position module
.
a24 24 24 24
immediately executes the profile. If the the execution data for the profile is not resident in the cache, the
o hoa hoa oa
Position module reads the profile block information from the configuration/profile table in the S7-200 and

ngh d on g
d on g
calculates the execution data for the profile before executing the profile.
o n gh
T u T u
Command 122 (Execute the motion specified in the interactive block ) does not use cache memory to
Tud
store the execution data, but always reads the interactive block from the configuration/profile table in the
S7-200 and calculates the execution data for the motion.

Reconfiguring the Position module deletes all of the execution data stored in the cache memory.

4 .c om 4 .co m
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 285
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
S7-200 Programmable Controller System Manual

.c m
oCreating . c om Instructions . c om
a 2 4 Your Own Position
a 2 4 Control
a 2 4 a 2 4.
o hoalso hothe ho
ngh o n g
The Position Control wizard
g
creates the position instructions for controlling
n operation of the Position
n g
udo for the Position module.
Tuofdhow you might create your own controlTinstructions Tud
o
module; however, you can create your own instructions. The following STL code segment provides
an example

This example uses an S7-200 CPU 224 with a Position module located in slot 0. The Position module is configured on
power-up. CMD_STAT is a symbol for SMB234, CMD is a symbol for QB2, and NEW_CMD is a symbol for the profile.

. co m Sample Program: Controlling the Position


.c o m . c o m
a 24 a 24state
Module

a24 a2 4.
o Network 1
o
//New move command
ho ho
ngh LSCR State_0
o n gh
do n g ong
NetworkT2
ud//CMD_STAT is a symbol for SMB234 Tu Tu d
//CMD is a symbol for QB2
//NEW_CMD is a symbol for the profile.
//

.co m .co m
//1. Clear the Done bit of the Position module.
.com .
a 2 4 a 2 4
//2. Clear the command byte of the Position module.
//3. Issue the new command.
a 2 4 a 24
o o o o
ngh gh gh g h
//4. Wait for the command to be executed.
SM0.0on o n on
LD
d
uCMD_STAT Tu d u d
BIW T0, CMD T
MOVB 0,

BIW NEW_CMD, CMD


SCRT State_1

4 .c om Network 3 4 . c om 4 . c om 4.
h o
9 a2 SCRE
h o a2 h o a2 hoa 2
ng d o nforgthe command to be completed. d o ng o ng
Tud
Network 4 //Wait
u
LSCR TState_1 Tu
Network 5 //If the command is complete without error, go to the idle state.
LDB= CMD_STAT, 16#80

.co m SCRT Idle_State


. c om .c om .
a 2 4 4
ais2complete with an error, go to the error handling a2 4 a 24
o o o o
ngh h h h
Network 6 //If the command state.
LDB>
o
CMD_STAT,
d ng16#80 d o ng d on g
SCRT
Tu Error_State
Tu T u
Network 7
SCRE

.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
286
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 .
o a2 Creating a o a2
Program for the o a2 o a 24
ng h g h
nModule ng h g h
Modem d o d o d on
Tu Tu T u

. co m .c o m . c o m
24
The EM 241 Modem module allows you to connect your S7-200 directly to an analog telephone line, and
24 a24 2 4.
hoa hoa a
supports communications between your S7-200 and STEP 7–Micro/WIN. The Modem module also

ng g g
ngho
supports the Modbus slave RTU protocol. Communications between the Modem module and the S7-200
ho
don doon
are made over the Expansion I/O bus.

Tu7–Micro/WIN provides a Modem Expansion


STEP Tuwizard to help set up a remote modem or T u d
a Modem
module for connecting a local S7-200 to a remote device.

4 .c om
In This Chapter
4 .c om 4 . c om 4 .
o a 2 a 2 a 2
o Module . . . . . . . . . . . . . . . . . . . . . . . . .g. .h. . o. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288gho a 2
ngh ghExpansion
Features of the Modem
Using theo
d n
Modem Wizard to Configure the Modem
d o n Module . . . . . . . . . . . . . . . . . . . . . . . . .do294 n
u u
T of Modem Instructions and RestrictionsT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .T. . . . . 298
Overview u
Instructions for the Modem Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
Sample Program for the Modem Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303

4 .c om . c o m . c o
S7-200 CPUs that Support Intelligent Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4the Modem Module . . . . . . . . . . . . . . . . .a. .2. .4. . . . . . . . . . . . . . . . . . . . . . 304
m 303
4.
o a 2 Advanced Topics . o a 2
Special Memory Location for
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .o a 2
ngh n g h. . .Number n g h. . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 306
n g ho
do Format . . . . . . . . . . . . . . . . . . . . . T. . .u. .d. . o. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .T. . .u. .do309
Messaging
TuMessage
Text
Telephone Format . . . . . . . . . . . . . . . . . . . . . 308

CPU Data Transfer Message Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310

.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 287
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
S7-200 Programmable Controller System Manual

4 .c om 4 .c om 4. c om 4.
o a 2 Features of the Modem
a 2
Module
a 2 a 2
ngh n g hoyou to connect your S7-200 directly tonanghanalog
o telephone line and provides
n g ho
The Modem module
the following d o allows
u features: udo udo
T
- Provides international telephone line
T T
interface

. co m - Provides a modem interface to


.c o m . c o m
4.
STEP 7–Micro/WIN for programming and
24 24 a24 2
hoa a protocol a
troubleshooting (teleservice)
h oRTU ho ho
ng - g
n and text paging
Supports the Modbus
d onumeric do n g
d ong
- u
Supports
T Tu Tu
- Supports SMS messaging
- Allows CPU-to-CPU or CPU-to Modbus
Country Code
om - m om
data transfers

4 .c 4
Provides password protection .c o Switches
4 . c 4.
oa 2 a 2 a 2 a 2
n g h n ho
- Provides security callback
g Figure 10-1
n g
EM h241oModem Module n g ho
udo module configuration is stored in theTCPU
- The Modem
T udo T udo
You can use the STEP 7–Micro/WIN Modem Expansion wizard to configure the Modem module. Refer to
Appendix A for the specifications of the Modem module.

.c m
oInternational Telephone Line c
. om
Interface
. c om
a 2 4 a
The Modem module is a standard 24V.34 Pin
a 2 4
Description
a 2 4.
o ho andPCismodems. 3 hoRing ho
ngh
1 2345 6

n g
(33.6 kBaud), 10-bit modem, compatible
n g Reverse connection
ng
T u
Modem module dodoes not communicate with
with most internal and external The
T u do 4 Tip is allowed.

T u do
10 11-bit modems. Figure 10-2 View of RJ11 Jack

You connect the Modem module to the Table 10-1 Countries Supported by the EM 241
telephone line with the six-position four-wire

.co m .co
RJ11 connector mounted on the front of the m Switch Setting
01
Country

.co
Austria
m .
a 2 4 module. See Figure 10-2.
a 2 4 a 2 4 a 24
o o 02

ghoCanada
Belgium
o
ngh n gh
An adapter may be required to convert the
o on
05
on g h
Tud d d
RJ11 connector for connection to the standard
telephone line termination in the various u
T 09
08 Denmark
Finland T u
countries. Refer to the documentation for your
adapter connector for more information. 10 France
11 Germany

.c o m The modem and telephone line interface is


. c o m
powered from an external 24 VDC supply. This
12 Greece
. c o m .
a24 24 24 24
16 Ireland
can be connected to the CPU sensor supply or

ngh
o hoa
to an external source. Connect the ground
ng
18
22
ng hoa Italy
Luxembourg
n gh oa
o
terminal on the Modem module to the system
d d o o
T u
earth ground.

The Modem module automatically configures


T u 25
27
Netherlands
Norway Tud
the telephone interface for country-specific 30 Portugal
operation when power is applied to the module. 34 Spain

4 .c om .com
The two rotary switches on the front of the 35 Sweden
. com 4.
2 24
module select the country code. You must set 36
a2 4
Switzerland
2
hoa oa o ho a
the switches to the desired country selection
gh h
38 U.K.
ng before the Modem module is powered up. Refer
don
to Table 10-1 for switch settings for the
d39 n
o g U.S.A.
d ong
Tu
countries supported.
T u Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
288
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
Creating a Program for the Modem Module Chapter 10

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


o a 2 a 2 a 2 a 2
ngh The Modem module
n g hdooallows g hoCPU toover
you to communicate with STEP 7–Micro/WIN
n a telephone line
n g ho
o o o
Tudmodem when used with STEP 7–Micro/WIN. Tud Tud
(teleservice). You not need to configure or program the S7-200 use the Modem module as the
remote

Follow these steps to use the Modem module with STEP 7–Micro/WIN:

1. Remove the power from the S7-200 CPU and attach the Modem module to the I/O expansion bus.

. co m o m
Do not attach any I/O modules while the S7-200 CPU is powered up.
.c . c o m
a 24 a 2
2. Connect the telephone4line to the Modem module. Use an adapter
a 2 if4necessary.
a2 4.
o o ho ho
ngh 3. Connectg
n 24hvolts DC to the Modem module terminal blocks.
do the Modem module terminal blockTuground n g
doconnection to the system ground. Tudon g
T4. uConnect
5. Set the country code switches.
6. Power up the S7-200 CPU and the Modem module.

.co m 7.
.co m
Configure STEP 7–Micro/WIN to communicate to a 10-bit modem.
.co m .
a 2 4 a 2 4 a 2 4 a 24
o ho ho o
ngh h
Modbus RTU Protocol
o n g o n g o ng
d
You can configure
d
the Modem module to respond as a Modbus
Tu requests over the modem interface, interprets
Modbus
d
RTU slave. The Modem module receives
Tu those requests and transfers data to orTfrom
u the
CPU. The Modem module then generates a Modbus response and transmits it out over the modem
interface.

4 .c om Tip
4 .co m
4 .co m
4.
2 2 2
If the Modem module is configured to respond as a Modbus RTU slave, STEP 7–Micro/WIN is not able
2
ng hoa n g h oa
n g ho
to communicate to the Modem module over the telephone line. a
ng hoa
udo module supports the Modbus functions
The Modem
T T do in Table 10-2.
ushown T udo
Modbus functions 4 and 16 allow reading or
writing a maximum of 125 holding registers
Table 10-2 Modbus Functions Supported by Modem Module
Function Description
10
(250 bytes of V memory) in one request. Function 01 Read coil (output) status

.com .com ominput status


Functions 5 and 15 write to the output image
Function 02
.c Read
.
a24 a24 4 24
register of the CPU. These values can be
o o
overwritten by user program. Function 03
ho a2 Read holding registers
o a
ngh o n gh
Modbus addresses are normally written as 5 or n
o 05 g
Function 04 Read input (analog input) registers
on g h
Tud dFunction d
Write single coil (output)
6 character values containing the data type and
the offset. The first one or two characters Tu Function 06 T u
Preset single register
determine the data type, and the last four Function 15 Write multiple coils (outputs)
characters select the proper value within the Function 16 Preset multiple registers
data type. The Modbus master device maps the
.c o m . c o m
addresses to the correct Modbus functions.
. 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 289
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 omTable 10-3 shows the Modbus addresses


4 . c om 4. c om .
o a2 o a2to the
supported by the Modem module, and the
o a2
Table 10-3 Mapping Modbus Addresses to the S7-200 CPU
o a 24
n g h n g h n gh
Modbus Address S7-200 CPU Address
g h
on
mapping of Modbus addresses S7-200
o o
000001 Q0.0

Tud ud d
CPU addresses.

Use the Modem Expansion wizard to create a


T 000002
000003
Q0.1
Q0.2 T u
... ...
configuration block in for the Modem module to 000127 Q15.6
support Modbus RTU protocol. The Modem 000128 Q15.7

. co m module configuration block must be


.c o m 010001
. c o mI0.0
24
downloaded to the CPU data block before you
24 010002
a24
I0.1
2 4.
hoa hoa a
can use the Modbus protocol.
ho ho
010003 I0.2

ng don
g
do n g
...
010127
...
I15.6
d ong
Tu Tu 030001
010128 I15.7
AIW0
Tu
030002 AIW2
030003 AIW4

.co m .co m ...


030032
. c om
...
AIW62
.
a 2 4 a 2 4 040001
a2 4 VW0
a 24
o o o o
ngh gh gh g h
040002 VW2

d o n d o n
040003 VW4
d on
Tu Tu ...
04xxxx
...
VW 2*(xxxx–1) T u
Paging and SMS Messaging

.c omService) messages to cellular phones c


. ommodule
The Modem module supports sending numeric and text paging messages, and SMS (Short Message
. c m and
odownloaded
a 2 4 telephone numbers are
a
stored 2
in 4
the
(where
Modem
supported by the cellular provider). The
configuration block
a
which2 4
must
messages
be to the
a 2 4.
o ho You can use the Modem Expansion hoto create the messages and ngho
ngh
data block in the S7-200 CPU. wizard
o n g n g
dosending of the messages. o
telephone numbers for the Modem module configuration block. The Modem Expansion wizard also

Tud code to allow your program to initiate


creates the program
Tuthe Tud
10 Numeric Paging
Numeric paging uses the tones of a touch tone telephone to send numeric values to a pager. The Modem

. c m
o module c om
dials the requested paging service,
. . c om
waits for the voice message to complete, and then sends the

a 2 4 2 4
tones corresponding to the digits in
a
the paging message. The digits 0 through 9, 4
a 2 asterisk (*), A, B, C and D
a 2 4.
o o
are allowed in the paging message.
o and the paging service
The actual characters displayed by a pager for the asterisk and A, B,
ho
ngh C, and D characters g
o n areh
n
not standardized, and are determined by the
o g hpager
o n g
Tud Tud Tud
provider.

Text Paging
Text paging allows alphanumeric messages to be transmitted to a paging service provider, and from there

.c o mtomodule . c o m a(TAP)
a pager. Text paging providers normally have
too
modem line that accepts text pages. The
. c mModem
a2 4 a 2 4
uses Telelocator Alphanumeric Protocol
a 2 4
to transmit the text messages the service
a 2 4.
o ho
provider. Many providers of text
ho
paging use this protocol to accept messages.
ho
ngh n g
doService (SMS) do n g
do n g
Short Message
T u T u
Short Message Service (SMS) messaging is supported by some cellular telephone services, generally
T u
those that are GSM compatible. SMS allows the Modem module to send a message over an analog
telephone line to an SMS provider. The SMS provider then transmits the message to the cellular

.co m .co m . com


telephone, and the message appears on the text display of the telephone. The Modem module uses the

a2 4 Telelocator Alphanumeric Protocol (TAP) and the Universal Computer Protocol (UCP) to send messages
a 2 4 a2 4
to the SMS provider. You can send SMS messages only to SMS providers that support these protocols on
a2 4.
o gho o ho
ng h gh
a modem line.

don d o n d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
290
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
Creating a Program for the Modem Module Chapter 10

4 .c om Embedded Variables in4Text .c om 4. c om 4.


o a 2 a 2 and SMS Messages
ocan embed data values from the CPU ingthehtext a 2
o messages and format the data gho a 2
ngh d
values based g
The Modem module
n on
ha specification in the message. You can n
o point, and whether the decimal pointuisdaoperiod or a comma.
specify the
d on
number of digits to the left and right
T u
of the decimal
commands the Modem module to transmit a text Tmessage, the Modem module retrieves the message
T
When the user program u
from the CPU, determines what CPU values are needed within the message, retrieves those values from
the CPU, and then formats and place the values within the text message before transmitting the message

. co m to the service provider.


.c o m . c o m
24 24 a24
The telephone number of the messaging provider, the message, and the variables embedded within the
2 4.
ng hoa hoa ho
message are read from the CPU over multiple CPU scan cycles. Your program should not modify
g g ng ho a
don n
telephone numbers or messages while a message is being sent. The variables embedded within a

Tu Tu do Tu
message can continue to be updated during the sending of a message. If a message contains multiple d o
variables, those variables are read over multiple scan cycles of the CPU. If you want all of the embedded
variables within a message to be consistent, the you must not change any of the embedded variables
after you send a message.

.co m Data Transfers . c om . c om


a 2 4 a 2 4
your program to transfer data to another a 2 4 a 2 4.
o odata transfers and telephone numbers aregconfigured
The Modem module allows
o with the Modem Expansion gho
CPU or to a Modbus device over the

ngh telephone line.g


d n
o are
wizard, and
h
The
d
stored in the Modem module configuration n h
o block.Expansion
The configuration block is then
d on
T u
downloaded to the data block in the S7-200 T
CPU. u
The Modem wizard also createsT u
program
code to allow your program to initiate the data transfers.

A data transfer can be either a request to read data from a remote device, or a request to write data to a

om om om
remote device. A data transfer can read or write between 1 and 100 words of data. Data transfers move

4 .c . c
data to or from the V memory of the attached CPU.
4 4 . c 4.
o a2 The Modem Expansion o a 2
wizard allows you to create a data transfer a 2
o and a write to the remote device. gho
consisting of a single read from the a 2
ngh remote device,g
d n ah single write to the remote device, or both a g
o use the configured protocol of the Modem d n hfrom
read
omodule. If the Modem module is configured d o n
T
Data utransfers T u T u to
support PPI protocol (where it responds to STEP 7–Micro/WIN), the Modem module uses the PPI protocol
to transfer data. If the Modem module is configured to support the Modbus RTU protocol, data transfers
10
are transmitted using the Modbus protocol.

.co m .co m .co m


The telephone number of the remote device, the data transfer request and the data being transferred are
.
a 2 4 a 2 4 a 2 4
read from the CPU over multiple CPU scan cycles. Your program should not modify telephone numbers or
a 24
o ho ho o
ngh h
messages while a message is being sent. Also, you should not modify the data being transferred while a

o n g
message is being sent.
o n g o ng
IfT
d d d
uremote device is another Modem module,Ttheupassword function can be used by the dataTtransfers
the u
by entering the password of the remote Modem module in the telephone number configuration. The
callback function cannot be used with data transfers.

.c o m Password Protection .com . c o m


a2 4 The password securitya of2
4 a 2 4 a 2 4.
o hisoa separate hoasmust
the Modem module is optional and is enabled with the Modem Expansion
ho
ngh dbeingn
module password
g
wizard. The password
8-character password n
that
g
used by the Modem module is not the same
the caller
the CPU password. The Modem
o allowed access to the attached CPU.uThedopassword is stored in the V memory of theuCPU
supply to the Modem
doas
module n g
T u
before
T
part of the Modem module configuration block. The Modem module configuration block must be
T
downloaded to the data block of the attached CPU.

om m om
If the CPU has the password security enabled in the System Data Block, the caller must supply the CPU

2 4 .c .co
password to gain access to any password protected functions.
2 4 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 n gh n gho 291
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
oSecurity . c om . c om
a 2 4 Callback
a 2 4 a 2 4 a 2 4.
o oModem module is optional and is configured howith ho
ngh The callback function ofh
o n
wizard. The callback g
dpredefined
the
function provides additional security for the n g
attached CPU
the Modem Expansion
do function is enabled, the Modem module
by allowing access to the
do n g
T u
CPU only from telephone numbers. When theu
T callback
T u
answers any incoming calls, verifies the caller, and then disconnects the line. If the caller is authorized, the
Modem module then dials a predefined telephone number for the caller, and allows access to the CPU.

The Modem module supports three callback modes:


. co m- .c o m . c o m
24 24
Callback to a single predefined telephone number
a24 2 4.
ng hoa - Callback to multiple
n g
a
hopredefined telephone numbers ngho n g ho a
- Callback
T u doto any telephone number T u do T u do
The callback mode is selected by checking the appropriate option in the Modem Expansion wizard and
then defining the callback telephone numbers. The callback telephone numbers are stored in the Modem
module configuration block stored in the data block of the attached CPU.

.co mThe simplest form of callback is to a .single


c om . c om
predefined telephone number. If only one callback number is
.
a 2 4 2 4
stored in the Modem module configuration
a block, whenever the Modem module 4
a 2 answers an incoming call,
a 2 4
o ho block. ho dials the callback number ho
ngh
it notifies the caller that callback is enabled, disconnects the caller, and then
n g
specified in the configuration
n g n g
The Modem T do also supports callback for multipleTpredefined
umodule udo telephone numbers. In this modeTtheudo
caller is asked for a telephone number. If the supplied number matches one of the predefined telephone
numbers in the Modem module configuration block, the Modem module disconnects the caller, and then
calls back using the matching telephone number from the configuration block. The user can configure up

4 .c om to 250 callback numbers.


4 . c om 4 . c om 4.
o a 2 Where there are multiple
a 2
predefined callback numbers, the callback number
a 2
supplied when connecting to
a 2
ngh
the Modem module must be
module except for n
hoan exact match of the number in thenconfiguration
thegfirst two digits. For example, if the configured g ho block of the Modem ng ho
doan outside line (9) and long distance T o supplied for the callback could beudo
callback is 91(123)4569999 because

Tufollowing:
of a need to dial
any of the
udnumber
(1), the
T
10 - 91(123)4569999

om - m m
- 1(123)4569999

2 4 . c (123)4569999
2 4 .co 2 4 .co 24 .
ng hoa n gh o a
n gh o a
g h o a
o o
All of the above telephone number are considered to be a callback match. The Modem module uses the
on
Tud Tu d T u
callback telephone number from its configuration block when performing the callback, in this example
91(123)4569999. When configuring multiple callback numbers, make sure that all telephone numbers are
d
unique excluding the first two digits. Only the numeric characters in a telephone number are used when
comparing callback numbers. Characters such as commas or parenthesis are ignored when comparing
callback numbers.
.c o m . c o m . c o m
a2 4 The callback to any telephone
a 2 4
number is set up in the Modem Expansion
2
wizard
option during the callback configuration. If a
4by selecting the “Enable
a 2 4.
o hanoincoming call and requests a callbackntelephone
callbacks to any phone number”
ho number. After the telephone ngho
this option is selected, the
ngh n
Modem module answers g
o provides a means to allow telephoneucharges g
o to bedials
callbackT udonly
number is supplied
mode
by the caller, the Modem module
d
disconnects
T
and that telephone number. This
billed to the Modem module’s T udo
telephone connection and does not provide any security for the S7-200 CPU. The Modem module
password should be used for security if this callback mode is used.

.c o mThe
module requires a caller to supply the c
. ompassword before handling the callback.
. c om
Modem module password and callback functions can be enabled at the same time. The Modem

a2 4 a 2 4 correct
a 2 4 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
292
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
Creating a Program for the Modem Module Chapter 10

4 .c om Configuration Table for4the .c m


oModem 4 . c om 4.
o a 2 a 2 Module
a 2 a 2
ngh g hinoa Modem
All of the text messages,
n g o callback numbers and other gho
hmust
telephone numbers, data transfer information,
n
u d
options areo stored module configuration
u d othrough the creation
table which
d on
loaded into the V memory of the
u
T
S7-200 CPU. The Modem Expansion wizard guides
configuration T the Modem module configuration table inTthe Data
table. STEP 7–Micro/WIN then places
you of a Modem module

Block which is downloaded to the S7-200 CPU.

The Modem module reads this configuration table from the CPU on startup and within five seconds of any
. co m .c o m . c o m
STOP-to-RUN transition of the CPU. The Modem module does not read a new configuration table from the
24 24 a24
CPU as long the Modem module is online with STEP 7–Micro/WIN. If a new configuration table is
2 4.
ng hoa hoa ho
downloaded while the Modem module is online, the Modem module reads the new configuration table
g g ng ho a
don n
when the online session is ended.

theuModem module detects an error in the configuration


IfT
do d o
Tu table, the Module Good (MG) LED onTuthe front
of the module flashes on and off. Check the PLC Information screen in STEP 7–Micro/WIN, or read the
value in SMW220 (for module slot 0) for information about the configuration error. The Modem module
configuration errors are listed in Table 10-4. If you use the Modem Expansion wizard to create the Modem

.co m . c om . c om
module configuration table, STEP 7–Micro/WIN checks the data before creating the configuration table.
.
a 2 4 4
a2 Errors (Hexadecimal) a2 4 a 24
o o o o
ngh h h h
Table 10-4 EM 241 Configuration
Error
d o ngNo error d o ng
Description
d on g
Tu0001 No 24 VDC external power
0000
Tu T u
0002 Modem failure
0003 No configuration block ID – The EM 241 identification at the start of the configuration table is not valid

4 .c om 0004
4 .co
for this module. m
4 .co m
Configuration block out of range – The configuration table pointer does not point to V memory, or some
4.
2 2 2 2
hoa oa a
hoof callback telephone numbers equals 0 or n oa
part of the table is outside the range of V memory for the attached CPU.

ng 0005
ng h
Configuration
n
error – Callback is enabled and the numberg it gh
o is greater than 250. The number of messageso
udo
Tud telephone uor dif length
is greater than 250. The number of messaging
T
numbers is greater than 250, of the messaging telephone numbers T
is greater

0006
than 120 bytes.
Country selection error – The country selection on the two rotary switches is not a supported value.
10
0007 Phone number too large – Callback is enabled and the callback number length is greater than the

.com om om
maximum.
. c .c 4.
a24 2 4 2 4 2
0008 to 00FF Reserved
o Erroroin a
callback number xx – There are illegal characterso in a a
ngh
01xx
n xxh
g n
is 1 for the first callback number, 2 for the second,g h
etc.
callback telephone number xx. The value
n g ho
do Error
Tu02xx in telephone number xx – One of the d
telephone number xx contains an illegalTuvalue.
o in a message telephone number xx or a datautransfer
fields
The value xx is 1 for the first telephone number,
o
T d2 for
the second, etc.
03xx Error in message xx – Message or data transfer number xx exceeds the maximum length. The value
xx is 1 for the first message, 2 for the second, etc.

.c o m 0400 to FFFF Reserved


. 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 293
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
oStatus .c om . c om
a 2 4 LEDs of the Modem
a 2 4Module
a 2 4 a 2 4.
o The Modem module hash8o o the status LEDs. ho
ngh n g status LEDs on the front panel. Table 10-5 h
do241 Status LEDs o n g describes
o n g
TuEM
Table 10-5 Tud Tud
LED Description
MF Module Fail – This LED is on when the module detects a fault condition such as:

. co m H
.c m
No 24 VDC external power
o . c o m
24
H
24
Timeout of the I/O watchdog
a24 2 4.
ng hoa n
H
Hg hoa
Modem failure
Communications error with the local CPU
n g ho ng ho a
d o d o fault condition. The Module Good LED flashesdo
Tu if there is a error in the configuration table, orTtheuuser has selected an illegal country setting for the
MG Module Good – This LED is on when there is no module
Tu
telephone line interface. Check the PLC Information screen in STEP 7–Micro/WIN or read the value in
SMW220 (for module slot 0) for information about the configuration error.
OH Off Hook – This LED is on when the EM 241 is actively using the telephone line.

4 .c om NT
.co m .co m
No Dial Tone – This LED indicates an error condition and turns on when the EM 241 has been
4 4 .
2 2 2 24
hoa a a a
commanded to send a message and there is no dial tone on the telephone line. This is only an error

ng n g ho n g ho
condition if the EM 241 has been configured to check for a dial tone before dialing. The LED remains
on for approximately 5 seconds after a failed dial attempt.
ng h o
d o d iso d o
Tu Carrier Detect – This LED indicates that a connection
RI
CD Tu has been established with a remote modem.Tu
Ring Indicator –This LED indicates that the EM 241 receiving an incoming call.

Rx Receive Data – This LED flashes on when the modem is receiving data.
Tx Transmit Data – This LED flashes on when the modem is transmitting data.

4 .c om 4 . c om 4 . c om 4.
o a 2 Using the Modem Expansion a 2 Wizard to Configure the a 2 Modem Module a 2
ngh n g howizard from the STEP 7–Micro/WINnTools g o
hmenu ng ho
Start the Modem oExpansion o or from the Tools portion of o
TudBar.
the Navigation
Tud Tud
10 To use this wizard, the project must be compiled and set to Symbolic Addressing Mode. If you have not
already compiled your program, compile it now.

4 . c om 1.
.co m .co
On first screen of the Modem Expansion wizard, select Configure an EM 241 Modem module and
4 4
m .
2 click Next>.
2 2 24
ng hoa 2.
n gh o a
n gh o a
The Modem Expansion wizard requires the Modem module’s position relative to the S7-200 CPU in
g h o a
o o
order to generate the correct program code. Click the Read Modules button to automatically read
on
Tud Tu d
the positions of the intelligent modules attached to the CPU. Expansion modules are numbered
sequentially starting at zero. Double-click the Modem module that you want to configure, or set the T u d
Module Position field to the position of the Modem module. Click Next>.
For an S7-200 CPU with firmware prior to version 1.2, you must install the intelligent module next to

.c o m o m
the CPU in order for the Modem Expansion wizard to configure the module.
. c . c o m
a24 3. The password protection2
a 4 allows you to enable password protection
screen
a 2 4for the Modem module a 2 4.
o and assign a 1 to 8 o
hoanyone who attempts to connect ngho
ngh h When the module is password-protected,
character password for the module. This password is independent of the
g
S7-200 CPUnpassword.
o CPU through the Modem module uis required n g
o to supply the correct password. Select o
TudS7-200
with the
password T dClick Next>.
protection if desired, and enter a password. Tud
4. The Modem module supports two communications protocols: PPI protocol (to communicate with
STEP 7–Micro/WIN), and Modbus RTU protocol. Protocol selection is dependent on the type of

.co m .co m . com


device that is being used as the remote communications partner. This setting controls the

a2 4 a 2 4 a2 4
communications protocol used when the Modem module answers a call and also when the Modem
module initiates a CPU data transfer. Select the appropriate protocol and click Next>.
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
294
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
Creating a Program for the Modem Module Chapter 10

4 .c om 4 .co m
4. c om .
oa2
5.
2 a2
You can configure the module to send numeric and text messages to pagers, or Short Message
a a 24
ngh n g ho n g ho
Service (SMS) messages to cellular telephones. Check the Enable messaging checkbox and click
the Configure Messaging... button to define messages and the recipient’s telephone numbers.
ng h o
d o setting up a message to be sent to a upager
6. uWhen d oor cellular phone, you must define the message
d o
T tab on the Configure Messaging screenTu
T and the telephone number. Select the Messages and click
the New Message button. Enter the text for the message and specify any CPU data values to insert
into the message. To insert a CPU data value into the message, move the cursor to the position for

. co m .c m . c o m
the data and click the Insert Data... button. Specify the address of the CPU data value (i.e. VW100),
o 4.
the display format (i.e. Signed Integer) and the digits left and right of the decimal point. You can also
24 24
specify if the decimal point should be a comma or a period.
a24 2
ng hoa n g
– Numeric
a
ho(*).paging g
messages are limited to the digits
n h0 too9,paging
the letters A, B, C and D, and the gho
message varies by serviceon
a
d o provider. d o
Tud
asterisk The maximum allowed length of a numeric
T u T u
– Text messages can be up to 119 characters in length and contain any alphanumeric
character.

4 .c om –

4 . om
Text messages can contain any number of embedded variables.
c 4 . c om
Embedded variables can be from V, M, SM, I, Q, S, T, C or AI memory in the attached CPU.
4 .
oa 2 a 2 a 2 a 2
n g h n g hono the data
– Hexadecimal
n g ho displays
is displayed with a leading ‘16#’. The number of characters in the value is
n g ho
o number of digits left of the decimalumust
based
dobe large enough to display the expected
size of the variable. For example, VW100 as 16#0123.
o
Tud– The T T u drange
of values, including the negative sign, if the data value is a signed integer or floating point
value.
– If the data format is integer and the number of digits right of the decimal point is not zero, the

4 .c om 4 . c om 4 . c
digits right of the decimal point, the data is displayed as ‘12.34’.
om
integer value is displayed as a scaled integer. For example, if VW100 = 1234 and there are 2
4.
o a 2 a 2 a 2 a 2
ngh n hoplaces
– If the data
g
module the # character in all charactern g hospecified
value is greater than can be displayed in the
positions
field size, the Modem
of data value. ng ho
do numbers are configured by selecting
T7. uTelephone T
o Phone Numbers tab on the Configureudo
udthe T
Messaging screen. Click the New Phone Number... button to add a new telephone number. Once a
telephone number has been configured it must be added to the project. Highlight the telephone
10
number in the Available Phone Numbers column and click the right arrow box to add the telephone

.co m .co m .co m


number to the current project. Once you have added the telephone number to the current project,
you can select the telephone number and add a symbolic name for this number to use in your .
a 2 4 program.
a 2 4 a 2 4 a 24
o ho ho o
ngh d o n g n g ng
The telephone number consists of several fields which vary based on the type of messaging
d o d o
h
Tu – The Messaging Protocol selection Ttellsuthe Modem module which protocol to useTwhen
u
selected by the user.

sending the message to the message service provider. Numeric pagers support only numeric
protocol. Text paging services usually require TAP (Telelocator Alphanumeric Protocol). SMS

.c o m . c m . c m
messaging providers are supported with either TAP or UCP (Universal Computer Protocol).
o o
There are three different UCP services normally used for SMS messaging. Most providers
.
o a24 hoa
24
hoa
24
support command 1 or 51. Check with the SMS provider to determine the protocol and
oa 24
ngh gh
commands required by that provider.

d o nTheg Description field allows you to add adtextondescription


g for the telephone number. on
Tud

Tu Tu

.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 oa2 a2 a 24
ngh n gh n gho 295
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 .co m
4. c om .
oa2

o a 2 o a2
The Phone Number field is the telephone number of the messaging service provider. For text
messages this is the telephone number of the modem line the service provider uses to accept
o a 24
ngh n gh n gh
text messages. For numeric paging this is the telephone number of the pager itself. The
o o on g h
T ud T ud
Modem module allows the telephone number field to be a maximum of 40 characters. The
following characters are allowed in telephone numbers that the Modem module uses to dial T u d
out:
0 to 9 allowed from a telephone keypad

. co m A, B, C, D, *, #
.c m
DTMF digits (tone dialing only)
o . c o m
4.
, pause dialing for 2 seconds
24 !
24
commands the modem to generate a hook flash
a24 2
ng hoa @
g hoa wait for 5 seconds of silence
gho ng ho a
don n
W wait for a dial tone before continuing

T–uThe Specific Pager ID or Cell Phone Number


( ) do
Tufield is where you enter the pager number or
ignored (can be used to format the telephone number)
Tu d o
cellular telephone number of the message recipient. This number should not contain any
characters except the digits 0 through 9. A maximum of 20 characters is allowed.

.co m –
.co m .co m
The Password field is optional for TAP message. Some providers require a password but
.
a 2 4 a 2 4 a 2 4
normally this field should be left blank. The Modem module allows the password to be up to
a 24
o 15 characters.o o o
ngh – o n gh o n gh
The Originating Phone Number field allows the Modem module to be identified in the SMS
d d d on g h
Tu Tu
message. This field is required by some service providers which use UCP commands. Some
service providers might require a minimum number of characters in this field. The Modem T u
module allows up to 15 characters.
– The Modem Standard field is provided for use in cases where the Modem module and the

4 .c om (33.6 kBaud). 4 . om 4 . om
service provider modem cannot negotiate the modem standard. The default is V.34
c c 4.
oa 2 a 2 a 2 a 2
ng h g haomessage
– The Data Format
n g housed
fields allow you to adjust the data bits and
n
parity used by the modem when
ng ho
dosome service providers use 8 data bitsTand
transmitting
Tubut udnooparity. UCP always uses 8 data bits T
to a service provider. TAP normally
udo
7 data bits and even parity,
with
no parity. Check with the service provider to determine which settings to use.
10 8. You can configure the Modem module to transfer data to another S7-200 CPU (if PPI protocol was
selected) or to transfer data to a Modbus device (if Modbus protocol was selected). Check the

.co m .co m .co m


Enable CPU data transfers checkbox and click the Configure CPU-to... button to define the data
.
a 2 4 a 2 4
transfers and the telephone numbers of the remote devices.
a 2 4 a 24
o o o o
ngh gh gh h
9. When setting up a CPU-to-CPU or a CPU-to-Modbus data transfer you must define the data to
o n o n
transfer and the telephone number of the remote device. Select the Data Transfers tab on the
on g
Tud Tu d
Configure Data Transfers screen and click the New Transfer button. A data transfer consists of a
T u
data read from the remote device, a data write to the remote device, or both a read from and a write
d
to the remote device. If both a read and a write are selected, the read is performed first and then the
write.

.c o m . c m . c m
Up to 100 words can be transferred in each read or write. Data transfers must be to or from the
o o .
a24 24 24 24
V Memory in the local CPU. The wizard always describes the memory locations in the remote

hoa hoa a
device as if the remote device is an S7-200 CPU. If the remote device is a Modbus device, the
o o
ngh ng g gh
transfer is to or from holding registers in the Modbus device (address 04xxxx). The equivalent
o
Modbus address (xxxx) is determined as follows:
d d on o n
TuModbus address T u
= 1 + (V memory address
V memory address = (Modbus address – 1) * 2
/ 2) 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
296
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
Creating a Program for the Modem Module Chapter 10

4 .c om 4 .co m
4. c om .
oa2 o 2 o a2
10. The Phone Numbers tab on the Configure CPU Data Transfers screen allows you to define the
a
telephone numbers for CPU-to-CPU or a CPU-to-Modbus data transfers. Click the New Phone
o a 24
ngh n gh n gh
Number... button to add a new telephone number. Once a telephone number has been configured it
o o on g h
T ud T ud
must be added to the project. Highlight the telephone number in the Available Phone Numbers
T u d
column and click the right arrow box to add the telephone number to the current project. Once you
have added the telephone number to the current project, you can select the telephone number and
add a symbolic name for this telephone number to use in your program.

. co m .c m . c o m
The Description and Phone Number fields are the same as described earlier for messaging. The
o 4.
Password field is required if the remote device is a Modem module and password protection has
24 24 a24
been enabled. The Password field in the local Modem module must be set to the password of the
2
ng hoa hoa ho
remote Modem module. The local Modem module supplies this password when it is requested by
g g ng ho a
don n
the remote Modem module.
do
T11.uCallback causes the Modem module to automatically
Tu disconnect and dial a predefined T u d o
telephone
number after receiving an incoming call from a remote STEP 7–Micro/WIN. Select the Enable
callback checkbox and click the Configure Callback... button to configure callback telephone
numbers. Click Next>.

.co m .co m .co m


12. The Configure Callback... screen allows you enter the telephone numbers the Modem module uses
.
a 2 4 a 2 4 a 2 4
when it answers an incoming call. Check the ‘Enable callbacks to only specified phone numbers’ if
a 24
o o o
the callback numbers are to be predefined. If the Modem module is to accept any callback number o
ngh d n gh
d o n gh
d on
supplied by the incoming caller (to reverse the connection charges), check the ‘Enable callbacks to
o g h
TuIf only specified callback telephone numbers
Tuare allowed, click the New Phone Number button to u
any phone number’ selection.
T
add callback telephone numbers. The Callback Properties screen allows you to enter the
predefined callback telephone numbers and a description for the callback number. The callback

om m m
number entered here is the telephone number that the Modem module uses to dial when performing

4 .c .co .co
the callback. This telephone number should include all digits required to connect to an outside line,
4 4 4.
o a2 oa 2 a 2
pause while waiting for an outside line, connect to long distance, etc.
hoadded to the project. Highlight the ngho a 2
ngh n g h a new callback telephone number, it must
After entering
dothe telephone n gbe
telephone
Tuadd udoNumbers column and click the rightTarrow
number in the Available Callback Phone
number to the current Tproject. udboxo to
13. You can set the number of dialing attempts that the Modem module makes when sending a 10
message or during a data transfer. The Modem module reports an error to the user program only
when all attempts to dial and send the message are unsuccessful.
.co m .co m .co m .
a 2 4 a 2 4 a 2 4
Some telephone lines do not have a dial tone present when the telephone receiver is lifted.
a 24
o ho ho
Normally, the Modem module returns an error to the user program if a dial tone is not present when
o
ngh d o g
d o n g
a line with no dial tone, check the box, Enable Dialing Without Dial Tone Selection.
d o ng
the Modem module is commanded to send a message or perform a callback. To allow dialing out on
n h
T14.uThe Modem Expansion wizard creates a Tconfiguration
u block for the Modem module andT
u
requires
the user to enter the starting memory address where the Modem module configuration data is
stored. The Modem module configuration block is stored in V Memory in the CPU.
STEP 7–Micro/WIN writes the configuration block to the project Data Block. The size of the

.c o m . c o m . c o m
configuration block varies based on the number of messages and telephone numbers configured.
.
a24 24 24 24
You can select the V Memory address where you want the configuration block stored, or click the

ngh
o hoa hoa
Suggest Address button if you want the wizard to suggest the address of an unused V Memory
g g gh oa
on on n
block of the correct size. Click Next>.
d d o
T u T u
15. The final step in configuring the Modem module is to specify the Q memory address of the
command byte for the Modem module. You can determine the Q memory address by counting the Tud
output bytes used by any modules with discrete outputs installed on the S7-200 before the Modem
module. Click Next>.

.co m .co m om
16. The Modem Expansion wizard now generates the project components for your selected
. c
a2 4 a 2 4 a2 4
configuration (program block and data block) and makes that code available for use by your
a2 4.
o gho o
program. The final wizard screen displays your requested configuration project components. You
ho
ng h S7-200 CPU.
d o n gh
must download the Modem module configuration block (Data Block) and the Program Block to the
don d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 297
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 Overview of Modem
a 2
Instructions and Restrictions
o makes controlling the Modem modulegh o a 2 a 2
ngh n g hwizard n n g ho
o on the position of the module and configuration
The Modem Expansion
o easier by creating unique instruction
o
Tuwithda “MODx_”
subroutines based
is prefixed Tud options you selected. Each instruction
where x is the module location. Tud
Requirements for Using the EM 241 Modem Module Instructions

. co mConsider these requirements when you


.c o
usemModem module instructions: . c o m
a 2 4 a 2
- The Modem module instructions
4 use three subroutines. a 2 4 a2 4.
o hoinstructions increase the amount of memory o for your program by up to gho
ngh - The Modemn
d
g
module
d
g hrequired
o you can rerun the Modem Expansion udon
oIf you delete an unused instruction subroutine, n
u
370 bytes.
T to recreate the instruction if needed. T
wizard
u T
- You must make sure that only one instruction is active at a time.
-
om -
The instructions cannot be used in an interrupt routine.
.c .co m .co m .
2 4 4 4
The Modem module reads the configuration table information when it first powers up and after a
2 2 24
hoa o a o a o a
STOP-to-RUN transition. Any change that your program makes to the configuration table is not

ng gh gh
seen by the module until a mode change or the next power cycle.
o n o n on g h
Tu d
Using the EM 241 Modem Module Instructions Tu d T u d
To use the Modem module instructions in your S7-200 program, follow these steps:

1. Use the Modem Expansion wizard to create the Modem module configuration table.
om .co m .co m
24.c 4 4 4.
2. Insert the MODx_CTRL instruction in your program and use the SM0.0 contact to execute it every
2 2 2
hoa oa a a
scan.
gh gh o ho
ng 3. n n
Insert a MODx_MSG instruction for each message you need to send.
do d o o ng
4. Tu Tu
Insert a MODx_XFR instruction for each data transfer. Tud
10
.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
298
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
Creating a Program for the Modem Module Chapter 10

4 .c om 4 .c om 4. c om .
o a2 Instructions for the
o a2
Modem Module
o a2 o a 24
ng h h
ngInstruction ng h g h
d
MODx_CTRL o d o d on
Tu Tu
The MODx_CTRL (Control) instruction is used to enable and
T u
initialize the Modem module. This instruction should be called every
scan and should only be used once in the project.

. 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
MODx_XFR Instruction Tu T u
The MODx_XFR (Data Transfer) instruction is used to command the
Modem module to read and write data to another S7-200 CPU or a

4 .c om 4 . om
Modbus device. This instruction requires 20 to 30 seconds from the
c
time the START input is triggered until the Done bit is set.
4 . c om 4.
o a2 beoona
2 o a2 hoa 2
ngh
The EN bit must h h
onAngonXFR ngonof g
to enable a command to the module, and
should remain
d o
until the Done bit is set, signaling completion
d o n
the u
T process.
Tu
command is sent to the Modem module
each scan when START input is on and the module is not currently Tud
busy. The START input can be pulsed on through an edge detection 10
element, which only allows one command to be sent.

4 . c om 4 .co m
Phone is the number of one of the data transfer telephone numbers.
4 .co m .
2 You can use the symbolic name you assigned to each data transfer
2 2 24
hoa ho a ho a o a
telephone number when the number was defined with the Modem

ng g
Expansion wizard.
n n g g h
u isd
o u doYou can u d on
T
Data
T
the number of one of the defined data transfers.
use the symbolic name you assigned to the data transfer when the T
request was defined using the Modem Expansion wizard.

Done is a bit that comes on when the Modem module completes the data transfer.

.c o m . c o m . c o m .
2 4 24 24
Error is a byte that contains the result of the data transfer. Table 10-4 defines the possible error conditions
24
hoa hoa hoa oa
that could result from executing this instruction.

ng o g for the MODx_XFR Instruction ong


nParameters o n gh
d
Table 10-6
Tu Tud Tud
Inputs/Outputs Data Type Operands
START BOOL I, Q, M, S, SM, T, C, V, L, Power Flow
Phone, Data BYTE VB, IB, QB, MB, SB, SMB, LB, AC, Constant, *VD, *AC, *LD

4 .c om Done BOOL
.com
I, Q, M, S, SM, T, C, V, L
. com 4.
2 24 4
a2*AC, *LD 2
hoa oa o ho a
Error BYTE VB, IB, QB, MB, SB, SMB, LB, AC, *VD,

ng on gh o ng h
ong
T u d Tu d Tu d

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 299
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
oMODx_MSG .c om . c om .
a2 4 Instruction 4
a2 instruction is used to send a hoa2 4 a 24
h o h o h o
ng The MODx_MSG
paging or SMS o
d ng from Modem module. This instruction
(Send
message
Message)
d o ng d on g
requiresT uto 30 seconds from the time the START input
20 Tuis T u
triggered until the Done bit is set.
The EN bit must be on to enable a command to the module, and

. co m .c m
should remain on until the Done bit is set, signaling completion of
o . c o m
4.
the process. A MSG command is sent to the Modem module on
24 24
each scan when START input is on and the module is not currently
a24 2
ng hoa hoa
busy. The START input can be pulsed on through an edge detection
g gho ng ho a
don n
element, which only allows one command to be sent.

Tu Tu
Phone is the number of one of the message telephone numbers.
do Tu d o
You can use the symbolic name you assigned to each message
telephone number the when the number was defined with the
Modem Expansion wizard.

.co mMsg is the number of one of the defined m You can use the
.comessages. . c om
a 2 4 symbolic name you assigned to2
a 4
the message when the message
a 2 4 a 2 4.
o ho Expansion wizard. ho ho
ngh
was defined using the Modem
n g n g n g
u thatocomes on when the Modem moduleTcompletes
Done is a bit d
service T
provider. udo the sending of the message to theTudo
Error is a byte that contains the result of this request to the module. Table 10-8 defines the possible error
conditions that could result from executing this instruction.

4 .c omTable 10-7 Parameters for the MODx_MSG


4 . c m
oInstruction 4 . c om 4.
h o a2 Inputs/Outputs
h
Data o a2 Operands
Type
h o a2 hoa 2
ng START
d o ngBOOL o
I, Q, M, S, SM, T, C, V, L, Power
d
g
nFlow o ng
Phone, T u
Msg BYTE VB, IB, QB, MB, SB, u LB, AC, Constant, *VD, *AC, *LD
TSMB, Tud
10 Done BOOL I, Q, M, S, SM, T, C, V, L
Error BYTE VB, IB, QB, MB, SB, SMB, LB, AC, *VD, *AC, *LD

.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
300
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
Creating a Program for the Modem Module Chapter 10

4 .c om 4 .co m
4. c om .
o a2
Table 10-8
o a 2
Error Values Returned by MODx_MSG and MODx_XFR Instructions
o a2 o a 24
ngh g hDescription gh g h
Error
n n on
T ud0o No error
Telephone line errors T ud o
T u d
1 No dial tone present
2 Busy line

24 .com 3
. c
Dialing error

24
o m
24. c o m
2 4.
h o a 4
a
No answer
o o a ho a
ng 5
o n ghConnect timeout (no connection within 1 minute)
o n gh ong
Tud 6 Connection
Errors in the command
aborted or an
Tud
unknown response
Tu d
7 Numeric paging message contains illegal digits

om
8 Telephone number (Phone input) out of range

4 .c 4 . c om 4 . c om .
24
9 Message or data transfer (Msg or Data input) out of range
2 ain2text message or data transfer message hoa2
ng hoa 10
h o
Error
11 ng Error in messaging or data transfer telephone g
nnumber g h o a
d
u 12 o Operation not allowed (i.e. attemptsu d o u d on
T
Service provider errors
T set to zero)
T
13 No response (timeout) from messaging service

4 .c om 14

4 . om
Message service disconnected for unknown reason
c 4 . c om 4.
2 15
a2message errors returned by service providerhoa2
User aborted message (disabled command bit)
2
ng hoa h o
TAP – Text paging and SMS
ng Remote disconnect received (service provider g session)
naborted ng hoa
d o d o o
Tud
16
Tu 17 Login not accepted by messageT u (incorrect password)
service
18 Block not accepted by message service (checksum or transmission error) 10
19 Block not accepted by message service (unknown reason)

.com .co m
UCP – SMS message errors returned by service provider
.co m .
a 2 4 20
a 2 4
Unknown error
a 2 4 a 24
o o error ho o
ngh n g
21hChecksum
o Syntax error do n g on g h
Tud23 u u d
22
T
Operation not supported by system (illegal command) T
24 Operation not allowed at this time
25 Call barring active (blacklist)

.c o m 26
. c o m
Caller address invalid
. c o m .
2 4 24 failure 24 24
hoa o a hoa oa
27 Authentication

ng 28
o n ghLegitimization code failure on g o n gh
Tud29 30
GA not valid
Repetition not allowed
T u d Tud
31 Legitimization code for repetition, failure

om om om
32 Priority call not allowed

2 4 .c 33
4 . c 4
Legitimization code for priority call, failure. c 4.
hoa 34
h o a2message not allowed
Urgent
h o a2 ho a2
ng d35 ng Legitimization code for urgent message, failure
o d o ng d ong
Tu 36 Reverse charging not allowed Tu Tu
37 Legitimization code for reverse charging, failure

4 . com 4. c om 4 . com .
o a2 oa2 a2 a 24
ngh n gh n gho 301
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 omTable 10-8 4 .co m


4. c om .
o a2 2
Error Values Returned by MODx_MSG and MODx_XFR Instructions, continued
a a2 a 24
ngh
Error
n g ho
Description
n g ho g h o
o errors returned by service provider (continued)o on
T38ud Deferred delivery not allowed Tud d
UCP – SMS message
T u
39 New AC not valid
40 New legitimization code not allowed

24 .com 41
. c o m
Standard text not valid
4
2valid 24. c o m
2 4.
h o a 42
a
Time period not
o o a ho a
ng 43 gh type not supported by system
nMessage n gh ng
44 do Message too long o o
T45u Requested standard text not valid Tud Tu d
46 Message type not valid for pager type

om
47 Message not found in SMSC

.c .co m .co m .
2 4 48
4
Reserved
2 2 4 24
ng hoa 49 Reserved a

n g ho hang up n gh o a
g h o a
50
do
Subscriber
d o d on
T5152u Fax group not supported
Fax message type not supported
Tu T u
Data transfer errors

4 .c om 53

4 . om
Message timeout (no response from remote device)
c 4 . c om 4.
2 54
2 out of range, illegal data type) oa2
Remote CPU busy with upload or download
2
ng hoa 55 Access o
ng h a(memory
error
n gh ng hoa
o o o
T57ud Checksum or CRC error in response Tud Tud
56 Communications error (unknown response)

10 58 Remote EM 241 set for callback (not allowed)


59 Remote EM 241 rejected the provided password

. c o m 60 to 127 Reserved
. c om .c om
a 2 4 Instruction use errors
a 2 4 a 2 4 a 2 4.
o hoprocess o with another request, or there was ho
ngh 128
n g
Cannot

do Modem module error:


this request. Either the Modem module ish
o n g busy
o n g
Tud Tud
no START pulse on this request.
129u
T
H The location of the Modem module or the Q memory address that was configured with the
Modem Expansion wizard does not match the actual location or memory address
H

.c o m . c m
Refer to SMB8 to SMB21 (I/O Module ID and Error Register)
o . c o m .
2 4 24 24 24
ng hoa g hoa g hoa gh oa
d on 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
302
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
Creating a Program for the Modem Module Chapter 10

4 .c om 4 .c om 4 . c om 4.
o a 2 Sample Program for
o a 2
the Modem Module
a 2 a 2
ngh n g hModule n g ho n g ho
o
Example: Modem
o udo
Tud Tud Network 1 //// Call T
the MOD0_CTRL subroutine
on every scan.
LD SM0.0
CALL MOD0_CTRL, M0.0, VB10

. co m .c o m . c o m
24 24 Network 2
24 // Send a text message to a cell phone.
2 4.
ng hoa g hoa LD
h o
I0.0 a ho a
on o= ng L63.7 ng
EU
d o
T u Tud LD CALL
I0.0 Tu
MOD0_MSG, L63.7, CellPhone, Message1,
d
M0.0, VB10

4 .c om 4 .c om Network 3

4 .co m
// Transfer data to a remote CPU.
.
2 2 LD I0.1
2 24
hoa hoa o a o a
EU

ng g =
g hL63.7 ng h
Tu don Tu
n
do I0.1
LD
CALL
Tu d o
MOD0_XFR, L63.7, RemoteCPU, Transfer1,
M0.0,
VB10

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
S7-200 CPUs that Support Intelligent Modules
10

4 . c om 4 .co m
4 .co m
The Modem module is an intelligent expansion module designed to work with the S7-200 CPUs shown in
.
24
Table 10-9.
2 2 2
ng hoa gh
Table 10-9
n
o a
EM 241 Modem Module Compatibility with S7-200 CPUs
n gh o a
g h o a
o o on
Tud d d
CPU Description

CPU 222 Rel. 1.10 or greater Tu


CPU 222 DC/DC/DC
CPU 222 AC/DC/Relay
T u
CPU 224 DC/DC/DC
CPU 224 Rel. 1.10 or greater
CPU 224 AC/DC/Relay

.c o m . c o m
CPU 226 DC/DC/DC
. c o m .
a24 24 24 24
CPU 226 Rel. 1.00 or greater
CPU 226 AC/DC/Relay

ngh
o g hoa CPU 226XM DC/DC/DC
g hoa gh oa
on on n
CPU 226XM Rel. 1.00 or greater

d
CPU 226XM AC/DC/Relay
d o
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 303
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
S7-200 Programmable Controller System Manual

4 .c om 4 . c om 4 . c om 4.
o a 2 Special Memory Location
a 2 for the Modem Module
a 2 a 2
ngh n g ho (SM) are allocated to each intelligentngmodule
ho based on its physical position ngho
o bus. When an error condition or a change
Fifty bytes of special memory
udoinposition.
status is detected, the module indicatesdo
Tud the SM
in the I/O expansion
this by updating Tmodule’s
locations corresponding to the Tu
If it is the first module, it updates
SMB200 through SMB249 as needed to report status and error information. If it is the second module, it
updates SMB250 through SMB299, and so on. See Table 10-10.

. co mTable 10-10 c o m
Special Memory Bytes SMB200 to SMB549
. . c o m
24 24 a24 2 4.
hoa hoa a
Special Memory Bytes SMB200 to SMB549

ng
Intelligent
g Intelligent Intelligent Intelligent
gho
Intelligent Intelligent Intelligent
ng ho
don do n o
Module in Module in Module in Module in Module in Module in Module in

Tu
Slot 0 Slot 1 Slot 2
Tu
Slot 3 Slot 4 Slot 5
Tu
Slot 6 d
SMB200 to SMB250 to SMB300 to SMB350 to SMB400 to SMB450 to SMB500 to
SMB249 SMB299 SMB349 SMB399 SMB449 SMB499 SMB549

Table10-11 shows the Special Memory data area allocated for the Modem module. This area is defined as

4 .c omif this were the intelligent module located


4 .c oinm
Slot 0 of the I/O system.
4 . c om .
o a2 o a2 o a2 o a 24
ng h Table 10-11 SM Locationsh
ng
for the EM 241 Modem Module
ng h g h
SM Address
d oDescription
d o d on
SMB200 Ttou T
Module name (16 ASCII characters) SMB200 uis the first character. T u
SMB215 “EM241 Modem”
SMB216 to S/W revision number (4 ASCII characters) SMB216 is the first character.
SMB219

4 .c om SMW220 Error code


4 .co m
4 .co m
4.
a2 2 2 2
0000 – No error
o oa
0001 – No user power
o a hoa
ngh do ngh
0002 – Modem failure
d o n gh o ng
Tud
0003 – No configuration block ID
Tu 0004 – Configuration block out of range
Tu
10 0005 – Configuration error
0006 – Country code selection error
0007 – Phone number too large

.co m 0008 – Message too large

.co
0009 to 00FF – Reserved m .co m .
a 2 4 a 2 4
01xx – Error in callback number xx
a 2 4 a 24
o ho ho o
ngh h
02xx – Error in pager number xx
n g n g on g
do do
03xx – Error in message number xx

T u 0400 to FFFF – Reserved


T u T u d
SMB222 Module status – reflects the LED status
MSB LSB
7 6 5 4 3 2 1 0

.c o m F G H

. c o m
T R C 0 0

. c o m .
o a24 oa 24 1 – fault ho
a 24 oa 24
ngh g h g gh
F – EM_FAULT 0– no fault
on
G – EM_GOOD 0– not good 1 –n
d1o– off hook
good
o n
Tud H – OFF_HOOK
T – NO DIALTONE
0–
0–
on hook,
dial tone Tu 1 – no dial tone Tud
R – RING 0– not ringing 1 – phone ringing
C – CONNECT 0– not connected 1 – connected

.co m SMB223 .co m


Country code as set by switches (decimal value)
. com
a2 4 SMW224
2 4
Baud rate at which the connection was established (unsigned decimal value).
a 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
304
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
Creating a Program for the Modem Module Chapter 10

4 .c om 4 .co m
4. c om .
oa2 2
Table 10-11 SM Locations for the EM 241 Modem Module, continued
a a2 a 24
ngh
SM Address
n g ho
Description
n gh o g h o
udo
SMB226 Result of the user command
ud o u d on
T MSB
7 6 5
T LSB
0
T
D 0 ERROR

. co m .c o m . c o m
24
D – Done bit;
24 a24 2 4.
hoa hoa a
0 – operation in progress

ng n g
1 – operation complete
n g ho ng ho
d o o
ERROR : Error Code Description, see Table 10-8
d d o
Tu
SMB227 Telephone number selector – This
T1uthrough 250.
byte
sending a message. Valid values are
specifies which messaging telephone number to
Tu
use when

SMB228 Message selector – This byte specifies which message to send. Valid values are 1 through 250.
SMB229 to Reserved

4 .c om SMB244

4 .co m
4 .co m .
2 SMB245 Offset to the first Q byte used as the command interface to this module. The offset is supplied by the
2 2 24
hoa a
ho to the configuration table for the Modemnmodule a
hinoV memory. A pointer value to an area otherng o a
CPU for the convenience of the user and is not needed by the module.

ng n
SMD246gPointer g h
o than V memory is not accepted and theumoduleo continues to examine this location, waiting foruda o
Tud non-zero pointer value. T d 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
10
.com .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 305
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 Advanced Topics
a 2 a 2 a 2
ngh n g ho n g ho n g ho
T u dothe ConfigurationTable Tudo
Understanding
T u do
The Modem Expansion wizard has been developed to make modem applications easy by automatically
generating the configuration table based upon the answers you give about your system. Configuration
table information is provided for advanced users who want to create their own Modem module control

. co m routines and format their own messages.


.c o m . c o m
a 2 4 The configuration table is
a 2
located 4 from the location pointed to by the configuration
in the V memory area of the S7-200. In
2
Table
a 4 area pointer
10-12, the Byte Offset
a2 4.
o hotable information is divided into four sections.
column of the table is the byte offset
ho in SM
ho
ngh n g
memory. The configuration
do Block contains information toTconfigure n g n g
- Theu
T Configuration udo the module. Tud
o
- The Callback Telephone Number Block contains the predefined telephone numbers allowed for
callback security.

4 .c om -

4 . om
messaging services or CPU data transfers.
4 . om
The Message Telephone Number Block contains the telephone numbers used when dialing
c c 4 .
oa 2 - The Message Blocko a 2 a 2 a 2
n g h n g h contains the predefined messages tonsend
g htoothe messaging services. n g ho
T do Table for the Modem Module Tudo
Table 10-12uConfiguration
T u do
Configuration Block
Byte Offset Description
0 to 4 Module Identification – Five ASCII characters used for association of the configuration table to an

4 .c om 4 . om 4 . om
intelligent module. Release 1.00 of the EM 241 Modem module expects “M241A”.
c c 4.
2 5
a2number length – Valid values are 0 throughh40.
The length of the Configuration Block – Currently 24.
a2 2
ng hoa 6
h o
Callback telephone
n g telephone number length – Valid values oaren g 120.o
ng hoa
7
doMessaging
d
0 through
o
8 u
Tuvalues are 0 through 250.
T Number of callback telephone numbers – Valid Tud
10 9
10
Number of messaging telephone numbers – Valid values are 0 through 250.
Number of messages – Valid values are 0 through 250.
11 to 12 Reserved (2 bytes)

.com 13
.co m
This byte contains the enable bits for the features supported.
.co m .
o a24 ho
MSB
a 2 4 LSB
o a 2 4
o a 24
ngh gh h
7 6 5 4 3 2 1 0

o n g PD CB PW MB BD 0 0 0
o n on g
Tud PD – 0 = tone dialing d
T1 =upulse dialing T u d
CB – 0 = callback disabled 1 = callback enabled
PW – 0 = password disabled 1 = password enabled
MB – 0 = PPI protocol enabled 1 = Modbus protocol enabled

.c o m BD –
c o m
0 = blind dialing disabled
. 1 = blind dialing enabled
. c o m .
o a24 hoa
24
Bits 2, 1 and 0 are ignored by the module

hoa
24 oa 24
ngh gh
14 Reserved
15
d o ng –before
Attempts This value specifies the number of times then
d o g is to attempt to dial and send a
modem
d on
T u
16 to 23
message returning an error. A
Password – Eight ASCII characters
T
value of u
0 prevents the modem from dialing out.
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 oa2 a2 a 24
ngh
306
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
Creating a Program for the Modem Module Chapter 10

4 .c om 4 .co m
4. c om .
oa2 2
Table 10-12 Configuration Table for the Modem Module, continued
a a2 a 24
ngh ho
Callback Telephone Number Block (optional)
n g n g ho ng h o
d o
Byte Offset
Description
d o d o
Tu24 Turepresenting the first telephone number that is T
Callback Telephone Number 1 – A string u for
authorized
callback access from the EM 241 Modem module. Each callback telephone number must be allocated
the same amount of space as specified in the callback telephone number length field (offset 6 in the
Configuration Block).

. co m 24+ callback
.c m
Callback Telephone Number 2
o . c o m
24
number
24 a24 2 4.
hoa oaTelephone Number n a
: :

ng :
n g h
Callback
n gho ng ho
doTelephone
TuOffset
Messaging
Byte
Number Block (optional)
Description Tud
o
Tu d o
M Messaging Telephone Number 1 – A string representing a messaging telephone number which
includes protocol and dialing options. Each telephone number must be allocated the same amount of
space as specified in the messaging telephone number length field (offset 7 in the Configuration

.co m Block).
.co m .co m .
a 2 4 2 4
The messaging telephone number format is described below
a a 2 4 a 24
o o o o
ngh gh gh h
M+ Messaging Telephone Number 2

o
messagingn o n on g
Tu : d
number length
Tu d T u d
:
: Messaging Telephone Number n
Message Block (optional)

4 .c om Byte Offset
4 . c om
Description
4 .co m
4.
2 N
aof 2message 1 2
V memory offset (relative to VB0) for the first message (2 bytes)
2
ng hoa N+2
h o
Length
N+3 ngLength of message 2 n g ho a
ng hoa
o o o
Tud:: Tud Tud
P
Length of message n
Message 1 – A string (120 bytes max.) representing the first message. This string includes text and
10
embedded variable specifications or it could specify a CPU data transfer.

4 . c om 4 .co m
4 .co m
See the Text Message Format and the CPU Data Transfer Format described below.
.
2 P + length of Message 2
2 2 24
ng hoa message 1

n g:h
o a
n gh o a
g h o a
:
o Message n o on
Tud: Tu d T u d
The Modem module re-reads the configuration table when these events occur:

.c o m -
o m o m
Within five seconds of each STOP-to-RUN transition of the S7-200 CPU (unless the modem is
. c . c .
a24 24 24 24
currently online)

ngh
o -
hoa hoa
Every five seconds until a valid configuration is found (unless the modem is currently online)
g g gh oa
d on d on o n
Tud
- Every time the modem transitions from an online to an offline condition
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 307
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
S7-200 Programmable Controller System Manual

4 .c om 4 .c om 4 . c om 4.
o a 2 Messaging Telephone 2
Number
a Format
a 2 a 2
ngh n g hoNumber is a structure which containsntheginformation
ho needed by the Modem ngho
omessage. The Messaging Telephone Number
The Messaging Telephone
o is an ASCII string with a leading lengthudo
TudbyaASCII
module to send
byte followed Tuofda Messaging
characters. The maximum length Telephone Number is 120 T bytes
(which includes the length byte).
The Messaging Telephone Number contains up to 6 fields separated by a forward slash (/) character.

. co mBack-to-back .c o mfield. Null fields are set to default values


slashes indicate an empty (null)
. c
in m
o the Modem

a 2 4 module.
a 2 4 a 2 4 a2 4.
o ho ho ho
ngh g g g
Format: <Telephone Number>/<ID>/<Password/<Protocol>/<Standard>/<Format>
n
doNumber n n
TuIf the
The Telephone
message.
udoModem module dials when sending a udo
field is the telephone number that the
message being sent is a text or SMS T
message, this is the telephone number of the T
service provider. If the message is a numeric page, this field is the pager telephone number. If the
message is a CPU data transfer, this is the telephone number of the remote device. The maximum
number of characters in this field is 40.

.co mThe ID is the pager number or cellular.ctelephone


om number. This field should consist4.ofctheom
a 2 4 If the protocol is a CPU data a 2 4 a
digits 0 to 9 only.
of2the remote device. Up to a 2 4.
o hoin this field.
transfer,
ho
this field is used to supply the address
ho
ngh g
20 characters are allowed
n
o is used to supply the a password for umessages
dfield n g
do sent via TAP if a password is required do n g
T
The Passwordu T
by the service provider. For messages sent via UCP this field is used as the originating address or T u
telephone number. If the message is a CPU data transfer to another Modem module, this field can be
used to supply the password of the remote Modem module. The password can be up to 15 characters in
length.

4 .c omThe Protocol field consists of one 4 . c m which tells the Modem module how
ocharacter 4 . c m format and
oit should 4.
o a 2 o a 2 ASCII
a 2 a 2
ngh
transmit the message. The following

1 –o n ghpaging
values are allowed:
n g ho ng ho
Tu23d–– TAP
Numeric protocol (default)
T u do T u do
10 UCP command 1
4 – UCP command 30
5 – UCP command 51

.co m 6 – CPU data transfer


.co m .co m .
a 2 4 a 2 4 a 2 4
The Standard field forces the Modem module to use a specific modem standard. The standard field is one
a 24
o o
ASCII character. The following values are allowed:
o o
ngh o n gh o n gh on g h
Tud d d
1 – Bell 103
2 – Bell 212
3 – V.21
Tu T u
4 – V.22
5 – V.22 bit

.c o m 6 – V.23c
7 – V.32
. c o m . c o m .
o a24 8 – V.32 bit
hoa
24
hoa
24 oa 24
ngh gh
9 – V.34 (default)
on g on g o n
T u d T u d
The Format field is three ASCII characters which specify the number of data bits and parity to be used
Tud
when transmitting the message. This field does not apply if the protocol is set to numeric paging. Only the
following two settings are allowed:

8N1 – 8 data bits, no parity, one stop bit (default)

.co m .co m
7E1 – 7 data bits, even parity, one stop bit
. 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
308
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
Creating a Program for the Modem Module Chapter 10

4 .c om 4 .c om 4 . c om 4.
o a 2 Text Message Format
a 2
o defines the format of text paging orgSMS a 2 a 2
ngh n g hFormat n homessages. These types of messagesngho
o text and embedded variables. The textumessage
The Text Message
o is an ASCII string with a leading length o
Tudby ASCII
can contain
followed T ofda text message
characters. The maximum length Tudthebyte
is 120 bytes (which includes
length byte).
Format: <Text><Variable><Text><Variable>...

4 .com .c o m
The Text field consists of ASCII characters.
24 . c o m
4 reads from the local CPU, 4.
h o a2 a
hoin the message. The percent (%) character
The Variable field defines an embedded data value which the Modem a 2
his oused to mark the start and the end of angho
module a2
n g n g
formats, and places
o The address and the left fields are separated n g
dfield.
uRight
variable
T
and T
fields can be either a period or a comma
dois used
uand T u Lefto
with a colon. The delimiter between thed
as the decimal point in the formatted
variable. The syntax for the variable field is:

%Address:Left.Right Format%

.co m .co m .co m


The Address field specifies the address, data type and size of the embedded data value (i.e. VD100,
.
a 2 4 a 2 4 a 2 4
VW50, MB20 or T10). The following data types are allowed: I, Q, M, S, SM, V, T, C, and AI. Byte, word
a 24
o ho ho o
ngh h
and double word sizes are allowed.

o n g
defines the number of digits to display lefto n g o ng
d
The Left field
Tu to handle the expected range of the embedded
enough
d d
of the decimal point. This value should be large
Tu variable including a minus sign if needed. TuIf Left is
zero the value is displayed with a leading zero. The valid range for Left is 0 to 10.

The Right field defines the number of digits to display right of the decimal point. Zeros to the right of the

om om om
decimal point are always displayed. If Right is zero the number is displayed without a decimal point. The

4 .c .
valid range for Right is 0 to 10.
4 c 4 . c 4.
o a2 ho a 2
ho a 2
hoa 2
ngh
The Format field specifies the display format of the embedded value. The following characters are allowed
n g
for the format field:
o n g n g
Tud iu––signed integer T udo T udo
unsigned integer
h – hexadecimal
10
f – floating point/real

.co m .co m
Example: “Temperature = %VW100:3.1i% Pressure = %VD200:4.3f%”
.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 309
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 CPU Data Transfer Message
a 2 Format
a 2 a 2
ngh n g hoa CPU-to-CPU or a CPU-to-Modbus ndatagh o
n g ho
u o Format. A CPU Data TransferTMessage udofospecifications
is an ASCII string which can specify any do
A CPU data transfer, either transfer, is specified using the CPU
Data TransferdMessage
numberT of data transfers between devices, up to the number that fit in the maximumT
u
message length of 120 bytes (119 characters plus a length byte). An ASCII space can be used to
separate the data transfer specifications, but is not required. All data transfer specifications are executed
within one connection. Data transfers are executed in the order defined in the message. If an error is

. co m c o m c o m
detected in a data transfer, the connection to the remote device is terminated and subsequent
. .
24 transactions are not processed.
24 a24 2 4.
ng hoa n g hothen
If the operation is specified
a
g
as a read, Count number of words are read
n
o the remote device starting at
hfrom n g ho a
o udoare read from the local CPU starting atTtheudo
Tud is specified as a write, Count number ofTwords
the Remote_address, and written to V Memory in the local CPU starting at the Local_address.

If the operation
Local_address, and then written to the remote device starting at Remote_address.

Format: <Operation>=<Count>,<Local_address>,<Remote_address>

4 .c omThe Operation field consists of one4ASCII


.c m and defines the type of transfer..com
ocharacter 4 4.
o a 2 R – Read data fromo a 2 a 2 a 2
ngh n g toh
the remote device
n g ho n g ho
ufielddospecifies the number of words to be transferred.
udo The valid range for the count field isT1 uto do
W – Write data the remote device

T
The Count
100 words.
T
The Local_address field specifies the V Memory address in the local CPU for the data transfer (i.e.

omThe Remote_address field specifies4.thecoaddress


m om(i.e. VW500).
VW100).

2 4 .c 2 2 4
in the remote device for the data . c
transfer
2 4.
o a a
ho device, the conversion between VnMemory a
ho address and Modbus address ngho a
ngh
This address is always specified as a V Memory address even if the data transfer is to a Modbus device. If
the remote device is g g
is as follows: do
n a Modbus

T u T udo T udo
10 Modbus address = 1 + (V Memory address / 2)
V Memory address = (Modbus address – 1) * 2
Example: R=20,VW100, VW200 W=50,VW500,VW1000 R=100,VW1000,VW2000
. c o m .c om .c om .
a2 4 a2 4 a2 4 a 24
h o h o h o h o
ng d o ng d o ng d on g
Tu Tu 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
310
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 a2 Using theghUSS
o a 2 Protocol Library
ho a 2 to Control ho a 2
ngh a on
MicroMaster Drive Tudon g o n g
Tud Tud
STEP 7–Micro/WIN Instruction Libraries makes controlling MicroMaster drives easier by including

.com m m
preconfigured subroutines and interrupt routines that are specifically designed for using the USS protocol
.c o . c o 4.
24 24 a24
to communicate with the drive. With the USS instructions, you can control the physical drive and the
a 2
hoa a
read/write drive parameters.
h o ho ho
ng don
g
do n g
You find these instructions in the Libraries folder of the STEP 7–Micro/WIN instruction tree. When you
d ong
Tu Tu
select a USS instruction, one or more associated subroutines (USS1 through USS7) are added
automatically. Tu

4 .c om In This Chapter
4 . c om 4 . c om 4.
oa 2 a 2
Requirements for Using the USS Protocol . . . . . . . . . . . . . . . . . . . . . . . . .2
a ........................ 312
a 2
n g h Calculating theg
n hoRequired for Communicating with thenDrive
Time g ho. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313 n g ho
u doUSS Instructions . . . . . . . . . . . . . . . . . T. . .u. .d. . o. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .T. . .u. .do314
Using the
T
Instructions for the USS Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
Sample Programs for the USS Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
USS Execution Error Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323

4 .c om 4 . c om 4 . c om 324
4.
Connecting and Setting Up the MicroMaster Series 3 Drive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

o a2 a 2
Connecting and Setting Up
ho
the MicroMaster Series 4 Drive . . . . . . . . . .2
ho a ........................ 327
hoa 2
ngh o n g o n g o n g
Tud Tud Tud

.com .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 311
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 Requirements for Using
a 2
the USS Protocol
o Libraries provides 14 subroutines, a 2 a 2
ngh n g hInstruction n g h3 ointerrupt routines, and 8 n g ho
u o the USS protocol. The USS instructions udouse the following resources in the S7-200:
udo
The STEP 7–Micro/WIN
instructions todsupport
T T
- Initializing the USS protocol dedicates Port 0 for the USS communications.
T
You use the USS_INIT instruction to select either USS or PPI for Port 0. (USS refers to the USS

. co m .c m . c o m
protocol for SIMOTION MicroMaster drives.) After selecting to use the USS protocol for
o 4.
communicating with drives, you cannot use Port 0 for any other purpose, including communicating
24 24 a24 2
hoa a a
with STEP 7–Micro/WIN.

ng n ho of the program for an application nusing


g226XM,
During the development g htheoUSS protocol, you should use a ngho
CPU 226,o oSTEP 7–Micro/WIN
to a PROFIBUS CP card in o
T u
your
d CPU
computer. This second communications T
port
d
or EM 277 PROFIBUS–DP module
u
allows
connected
to monitor the Tu
d
application while USS protocol is running.
- The USS instructions affect all of the SM locations that are associated with Freeport
communications on Port 0.
.co m- .co m .co m .
a 2 4 a 2 4
The USS instructions use 14 subroutines and 3 interrupt routines.
a 2 4 a 24
o o o o
ngh gh gh h
- The USS instructions increase the amount of memory required for your program by up to
o n o n
3450 bytes. Depending on the specific USS instructions used, the support routines for these
on g
Tu d Tu d
instructions can increase the overhead for the control program by at least 2150 bytes, up to
3450 bytes. T u d
- The variables for the USS instructions require a 400-byte block of V memory. The starting address
for this block is assigned by the user and is reserved for USS variables.

4 .c om - .co m .co m
Some of the USS instructions also require a 16-byte communications buffer. As a parameter for the
4 4 4.
o a2 oa 2 a 2
instruction, you provide a starting address in V memory for this buffer. It is recommended that a
ho AC0 to AC3. You can also ngho a 2
ngh hcalculations, the USS instructions use accumulators
unique buffer be assigned for each instance of USS instructions.
- o n g n g
o in the accumulators will be changedubydo
thedaccumulators in your program; however, the dvalues
When performing
use u u
T
the USS instructions.
T T
- The USS instructions cannot be used in an interrupt routine.

11 4.com Tip
To change the operation of Port 04 . c oto m 4 .c m
o7–Micro/WIN, 4.
o a 2 a 2 back
a 2
PPI so that you can communicate with STEP
a 2
ngh
use another USS_INIT
theg
You can also set n
ho
instruction to reassign Port 0.
n g o
hresets n g ho
o mode switch on the S7-200 to STOP mode.
dostops the drives.
This the parameters for Port 0.
o
T thatdstopping the communications to the drives
Be awareu
Tualso 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
312
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
Using the USS Protocol Library to Control a MicroMaster Drive Chapter 11

4 .c om 4 . c om 4 . c om 4.
o a 2 Calculating the Time
a 2Required for Communicating
a 2 with the Drive
a 2
ngh n g hwithothe drive are asynchronous to the S7-200
n g o The S7-200 typically completes gho
hscan.
u o before one drive communications transaction
Communications
severaldscans
u d o is completed. The following factors help
u d on
T the amount of time required: the number
determine T of drives present, the baud rate, and the scan
T time of
the S7-200.
Some drives require longer delays when using Table 11-1 Communications Times

.com .com o m
the parameter access instructions. The amount

24 24
Baud
. c
Time Between Polls of Active Drives
4.
a24
of time required for a parameter access is
o a o a Rate
mso
(with No Parameter Access Instructions Active)
a2
ho
dependent on the drive type and the parameter

ng h g
being accessed.
n h 1200 240 h
n g (maximum) times the number of drives
g
o o (maximum) times the number of drives on
Afteruad d d
2400 130 ms
T the USS Protocol, the S7-200 regularly Tu 4800 75 ms (maximum) times the number ofTdrives
use
USS_INIT instruction assigns Port 0 to u
polls all active drives at the intervals shown in 9600 50 ms (maximum) times the number of drives
Table 11-1. You must set the time-out
19200 35 ms (maximum) times the number of drives
parameter of each drive to allow for this task.

4 .c om 4 .c om . c om
38400 30 ms (maximum) times the number of drives
4 4.
oa 2 a 2 a 2
57600 25 ms (maximum) times the number of drives
a 2
n g h n g ho n g
115200 25 ms
o
h(maximum) times the number of drives
n g ho
o o o
Tud
Tip Tud Tud
Only one USS_RPM_x or USS_WPM_x instruction can be active at a time. The Done output of each
instruction should signal completion before user logic initiates a new instruction.

om m m
Use only one USS_CTRL instruction for each drive.

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

.co m .co m .co m 11 4.


a 2 4 a 2 4 a 2 4 a2
o o o o
ngh o n gh o n gh o n g h
Tud Tu d 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 313
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 the USS Instructions
o a 2 a 2 a 2
ngh n g hinstructions n g ho n g ho
doUSS_INIT instruction in your programTandudexecute
o udo
To use the USS protocol in your S7-200 controller program, follow these steps:

T uthe
1. Insert the USS_INIT instruction for oneT
scan
only. You can use the USS_INIT instruction either to initiate or to change the USS communications
parameters.

. co m .c m . c o m
When you insert the USS_INIT instruction, several hidden subroutines and interrupt routines are
o 4.
automatically added to your program.

oa 24 a 24 a 2 4 a2
n g h 2.
You can addn g ho
Place only one USS_CTRL
n g hoas required, but only one of
instruction in your program for each active drive.
n g ho
T dobe active at a time.
ucan
these
as

T udo
many USS_RPM_x and USS_WPM_x instructions

T udo
3. Allocate the V memory for the library instructions by
right-clicking (to get the menu) on the Program Block
node in the instruction tree.

.co m .co m
Select the Library Memory option to display the Library
.co m .
a 2 4 2 4
Memory Allocation dialog box.
a a 2 4 a 24
o o o o
ngh gh gh g h
4. Configure the drive parameters to match the baud rate Figure 11-1 Allocating V Memory for the
o n
and address used in the program.
d d o n Instruction Library
d on
5. Tu Tu
Connect the communications cable between the S7-200 and the drives. T u
Ensure that all of the control equipment, such as the S7-200, that is connected to the drive be
connected by a short, thick cable to the same ground or star point as the drive.

4 .c om 4 . c om 4 . c om 4.
o a2 Caution
howitha 2 a 2
hocommunications hoa 2
ngh g g g
Interconnecting equipment different reference potentials can cause unwanted currents to flow
o n
through the interconnecting
o
cable. These unwanted currents can n cause errors or
o n
Tud
damage equipment.
Tud
Ensure that all equipment that is connected with a communications cable either shares a common
Tud
circuit reference or is isolated to prevent unwanted current flows.
The shield must be tied to chassis ground or pin 1 on the 9-pin connector. It is recommended that you
m .c omdrive to chassis ground.
11 4.co tie wiring terminal 2–0V on the MicroMaster .c om
a 2 a 2 4 a 2 4 a 2 4.
o ho ho ho
ngh o n g o n g 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
314
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
Using the USS Protocol Library to Control a MicroMaster Drive Chapter 11

4 .c om 4 .c om 4. c om .
o a2 Instructions for the
o a2USS Protocol
o a2 o a 24
ng h ng h ng h g h
USS_INITd o
Instruction d o d on
Tu Tu
The USS_INIT instruction is used to enable and initialize, or to
T u
disable MicroMaster Drive communications. Before any other USS
instruction can be used, the USS_INIT instruction must be executed

. co m .c m
without errors. The instruction completes and the Done bit is set
o . c o m
24
immediately, before continuing to the next instruction.
24 a24 2 4.
ng hoa hoa ho
The instruction is executed on each scan when the EN input is on.
g g ng ho a
don do n
Execute the USS_INIT instruction only once for each change in
Tu Tu
communications state. Use an edge detection instruction to pulse Tu d o
the EN input on. To change the initialization parameters, execute a
new USS_INIT instruction.

om m m
The value for Mode selects the communications protocol: an input

2 4 .c 2 4 .co
value of 1 assigns port 0 to USS protocol and enables the protocol,
and an input value of 0 assigns port 0 to PPI and disables the USS
2 4 .co 24.
ng hoa protocol.
n g ho a
n g ho a
g h o a
othe baud rate at 1200, 2400, 4800, 9600,ud19200,
o 38400, on
Tudor 115200. d
Baud sets
57600, T T u
Active indicates which drives are active. Some drives only support addresses 0 through 30.

4 .c om Table 11-2

4 . om
Parameters for the USS_INIT Instruction
c 4 . c om 4.
o a 2 Inputs/Outputs
a 2 Data Type
Operands
a 2 a 2
ngh
Mode
ng ho BYTE n g ho
VB, IB, QB, MB, SB, SMB, LB, AC, Constant, *VD, *AC, *LD
ng ho
o o o
Tud TuT,dC, V, L Tud
Baud, Active DWORD VD, ID, QD, MD, SD, SMD, LD, Constant, AC *VD, *AC, *LD
Done BOOL I, Q, M, S, SM,
Error BYTE VB, IB, QB, MB, SB, SMB, LB, AC, *VD, *AC, *LD

om om
Figure 11-2 shows the description and format of
om
MSB LSB

4 . c 4 .c
the active drive input. Any drive that is marked as 31 30
4 .
29
c 28 3 2 1 0 11 4.
o a 2 a 2
Active is automatically polled in the background D31 D30
a2
D29 D2 D1 D0
a2
ngh n g ho
to control the drive, collect status, and prevent
n g ho n g h o
o
serial link time-outs in the drive.
o D0
o
Drive 0 active bit; 0 – drive not active, 1 – drive active

TutodTable 11-1 to compute the time betweenTud Tud


D1 Drive 1 active bit; 0 – drive not active, 1 – drive active
...
Refer
status polls. Figure 11-2 Format for the Active Drive Parameter

When the USS_INIT instruction completes, the Done output is turned on. The Error output byte contains

.c o m . c o m . c o m
the result of executing the instruction. Table 11-6 defines the error conditions that could result from
.
2 4 executing the instruction.
24 24 24
ng hoa g h a
oSubroutine g hoa gh oa
on on n
Example: USS_INIT
d d o
T u T u Network 1
LD I0.0 Tud
EU
CALL USS_INIT, 1, 9600, 16#00000001, M0.0, VB10

.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 315
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 USS_CTRL Instruction
o 2
aused o a2 o a 24
ng h h
nginstruction places the selected commands ning h g h
on
The USS_CTRL instruction is to control an active MicroMaster
d o
drive. The USS_CTRL
d o d
Tu buffer, which is then sent to the addressed
a communications Tu drive
(Drive parameter), if that drive has been selected in the Active
T u
parameter of the USS_INIT instruction.

. co m .c m
Only one USS_CTRL instruction should be assigned to each drive.
o . c o m
a 24 Some drives report speed only
a 24 as positive but reverses the oa24
as a positive value. If the speed is
a2 4.
o o
negative, the drive reports the speed
ho
ngh D_Dir (direction) bit. gh
o n
d be on to enable the USS_CTRL instruction. o n gh ong
The EN bitu
T should
instruction
must
always be enabled. TudThis Tu d
RUN (RUN/STOP) indicates whether the drive is on (1) or off (0).
When the RUN bit is on, the MicroMaster drive receives a command

.co m .co m
to start running at the specified speed and direction. In order for the
.co m .
a 2 4 2 4
drive to run, the following must be true:
a a 2 4 a 24
o ho o o
ngh -
g
Drive must be selected as Active in USS_INIT.
o n o n gh on g h
-

-
Tud OFF3 must be set to 0.
OFF2 and
Fault and Inhibit must be 0.
Tu d T u d

When RUN is off, a command is sent to the MicroMaster drive to


.c om . c omto a stop. The OFF2 bit . c om 4.
ramp the speed down until the motor comes

a2 4 4
a2 drive to stop quickly.
is used to allow the MicroMaster drive to coast to a stop. The OFF3
a2 4 a 2
h o h
bit is used to command theo MicroMaster
h o ho
ng d o ng received) bit acknowledges a response d o ng o ng
Tud
The Resp_R (response
from the u All the Active drives are polled for the latest
Tdrive. Tu drive
status information. Each time the S7-200 receives a response from
the drive, the Resp_R bit is turned on for one scan and all the
following values are updated.

11 4.comThe F_ACK (fault acknowledge) bit is c


4 . om
used
.c om
to acknowledge a fault in the drive. The drive
4 clears the fault
4.
o a 2 (Fault) when F_ACK goes
a
from 20 to 1.
a 2 a 2
ngh n g
The DIR (direction) bit ho in which direction the drive shouldng
indicates ho
move.
n g ho
T
The Drive
doaddress) input is the address of the MicroMaster
u(drive T udo drive to which the USS_CTRL command T udo
is to be sent. Valid addresses: 0 to 31

The Type (drive type) input selects the type of drive. For a MicroMaster 3 (or earlier) drive, set Type to 0.

.c o m For a MicroMaster 4 drive, set Type to 1.


. c o m . c o m .
o a24 Table 11-3
a 24 Instruction
Parameters of the USS_CTRL
o o a 24 oa 24
ngh Inputs/Outputs
RUN, OFF 2, d o ngh Data Types Operands
I, Q, M, S, SM,dT,o
ngh o n gh
Tu OFF 3, F_ACK, DIR BOOL
Resp_R, Run_EN, D_Dir, Inhibit, BOOL
Tu C, V, L, Power Flow
I, Q, M, S, SM, T, C, V, L
Tud
Fault
Drive, Type BYTE VB, IB, QB, MB, SB, SMB, LB, AC, *VD, *AC, *LD, Constant

4 .c om Error BYTE omVB, IB, QB, MB, SB, SMB, LB, AC, *VD, *AC,o
4 . c 4 . c m
*LD
4.
o a2 Status
a 2WORD VW, T, C, IW, QW, SW, MW, SMW, 2
a LW, AC, AQW, *VD, *AC, *LD
a2
ng h Speed_SP
n g ho REAL VD, ID, QD, MD, SD,nSMD, g hLD,o AC, *VD, *AC, *LD, Constant n g ho
o o o
Speed
Tud REAL
Tud SD, SMD, LD, AC, *VD, *AC, *LD
VD, ID, QD, MD,
Tud

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
316
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
Using the USS Protocol Library to Control a MicroMaster Drive Chapter 11

4 .c om 4 .co m
4. c om .
oa2 o 2
cause the drive to reverse its direction of rotation. Range: –200.0% to 200.0%
o a2
Speed_SP (speed setpoint) is drive speed as a percentage of full speed. Negative values of Speed_SP
a o a 24
ngh on gh on gh on g h
ud ud d
Error is an error byte that contains the result of the latest communications request to the drive. Table 11-6
T T
defines the error conditions that could result from executing the instruction.
T u
Status is the raw value of the status word returned by the drive. Figure 11-3 shows the status bits for
Standard Status Word and Main Feedback.

. co m c o m
Speed is drive speed as a percentage of full speed. Range: –200.0% to 200.0%
. . c o m
a24 Run_EN (RUN enable)a 2 4 whether the drive is running (1) or stopped
a 2 4(0). a2 4.
o ho
indicates
ho ho
ngh o n g n g n g
ud(0o– not inhibited, 1 – inhibited). To clearTtheuinhibit
do
D_Dir indicates the drive’s direction of rotation.
Tudindicates the state of the inhibit bit on theTdrive
Inhibit
bit, the Fault bit must be off, and the RUN, OFF2, and OFF3 inputs must also be off.

Fault indicates the state of the fault bit (0 – no fault, 1 – fault). The drive displays the fault code. (Refer to

4 .c om 4 .co m
4 .co m
the manual for your drive). To clear the Fault bit, correct the cause of the fault and turn on the F_ACK bit.
.
2 2 2 24
ng hoa n g ho a
n g ho a
g h o a
on
High byte Low byte

Tu do15 14 13 12 11 10 9 8 7 6 o
Tud
5 4 3 2 1 0
T u d
1 = Ready to start
1 = Ready to operate
1 = Operation enabled

4 .c om 4 .co m
4 .co m
1 = Drive fault present

4.
a2 2 2 2
0 = OFF2 (Coast stop command present)
o oa o a hoa
ngh gh gh
0 = OFF3 (Quick stop command present)

o n o n
1 = Switch-on inhibit
o ng
Tu d Tu d
1 = Drive warning present
Tud
1 = Not used (always 1)
1 = Serial operation allowed
0 = Serial operation blocked – local operation only

4 . c om 4 .c o m
1 = Frequency reached
0 = Frequency not reached
4 .c om 11 4.
o a 2 o a21 = 1Converter
= Converter output is clockwise
o a2 o a2
ngh d o ng h output is
ng
counter-clockwise
d o
h
o n g h
Tu Reserved for future use: These bits might
Tunot always be zero
Tud
Figure 11-3 Status Bits for Standard Status Word for MicroMaster 3 and Main Feedback

.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 317
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 .co m
4. c om .
oa2 a
o 11 2
High byte Low byte

o1 a2 o a 24
ngh gh gh g h
15 14 13 12 10 9 8 7 6 5 4 3 2 0
on on on
T ud T ud 1 = Ready to start
1 = Ready to operate T u d
1 = Operation enabled
1 = Drive fault present

. co m .c o m . c o m
0 = OFF2 (Coast stop command present)

24 24 a24
0 = OFF3 (Quick stop command present)
2 4.
hoa hoa a
1 = Switch-on inhibit

ng g gho
1 = Drive warning present
ng ho
Tu don do n
1 = Not used (always 1)
Tu
1 = Serial operation allowed Tu d o
0 = Serial operation blocked – local operation only
1 = Frequency reached
0 = Frequency not reached

.co m . c
0=om
Warning: Motor current limit
. c om .
a 2 4 4
a2 holding brake active
0= Motor
a2 4 a 24
o 0=ho o o
ngh d o n g Motor overload
1 = Motor running direction right
d o ng h
d on g h
Tu 0= Inverter overload Tu T u
Figure 11-4 Status Bits for Standard Status Word for MicroMaster 4 and Main Feedback

4 .c om 4 . c om 4 .co m
4.
h o a2 Example: USS_CTRL Subroutine2
h oa ho a 2
hoa 2
ng on g n g
To display in STL only:
o 1 //Control box for drive 0 o ng
T u d TuLDd SM0.0
Network
Tud
CALL USS_CTRL, I0.0, I0.1, I0.2, I0.3, I0.4, 0, 1,
100.0, M0.0, VB2, VW4, VD6, Q0.0, Q0.1, Q0.2, Q0.3

11 4.com om m
To display in LAD or FBD:

4 .c Network 1
.co
//Control box for drive 0
4 24.
h o a2 hoa
2 LD SM0.0
o a 2 o a
ng o ng
=
LD
o n gh L60.0
I0.0
on g h
Tud Tu =d
LD
L63.7
I0.1 T u d
= L63.6
LD I0.2
= L63.5

.c o m . c o m LD I0.3
. c o m .
a24 24 24 24
= L63.4

o hoa hoa oa
LD I0.4

ngh g g gh
= L63.3

d on d on o n
Tud
LD L60.0

T u T u CALL USS_CTRL, L63.7, L63.6, L63.5, L63.4,


L63.3, 0, 1, 100.0, M0.0, VB2, VW4, VD6, Q0.0, Q0.1,
Q0.2, Q0.3

.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
318
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
Using the USS Protocol Library to Control a MicroMaster Drive Chapter 11

4 .c om 4 .c om 4. c om .
o a2 USS_RPM_x
a2 for the USS protocol:
Instruction
o o a2 o a 24
ng h h h h
ong instruction reads an unsigneduword ng on g
There are three read instructions
d
- uUSS_RPM_W d oparameter. u d
T- USS_RPM_D instruction reads an unsigned
T double word T
parameter.

. co m -
.c m
USS_RPM_R instruction reads a floating-point parameter.
o . c o m
24 24
Only one read (USS_RPM_x) or write (USS_WPM_x) instruction
a24 2 4.
ng hoa hoa
can be active at a time.
g gho ng ho a
don do
The USS_RPM_x transactions complete when the MicroMaster
Tu Tu
n
drive acknowledges receipt of the command, or when an error
Tu d o
condition is posted. The logic scan continues to execute while this
process awaits a response.
The EN bit must be on to enable transmission of a request, and

4 .c om .co m
should remain on until the Done bit is set, signaling completion of
4 4 .co m .
2 2
the process. For example, a USS_RPM_x request is transmitted to
2 24
ng hoa o a
the MicroMaster drive on each scan when XMT_REQ input is on.
n gh n gh o a
g h o a
Therefore, the XMT_REQ input should be pulsed on through an
d o d o d on
Tu Tu u
edge detection element which causes one request to be transmitted
for each positive transition of the EN input. T
The Drive input is the address of the MicroMaster drive to which the
USS_RPM_x command is to be sent. Valid addresses of individual

4 .c om drives are 0 to 31.

4 . c om 4 . c om 4.
o a2 a 2
Param is the parameter number.
htheoUSS_RPM_x a
Index is the index value of the parameter2 that is to be read. Value is the
osupplied to the DB_Ptr input. This gho a 2
ngh
parameter value returned. The address of a 16-byte buffer musth be
n g
o drive.
buffer is used by instruction to store the n
o g
results of the command issued to the
on
u d
MicroMaster
T T u d T u d
When the USS_RPM_x instruction completes, the Done output is turned on and the Error output byte and
the Value output contain the results of executing the instruction. Table 11-6 defines the error conditions
that could result from executing the instruction. The Error and Value outputs are not valid until the Done

.co m output turns on.


. c om .c om 11 4.
a 2 4 2 4
a for the USS_RPM_x a 2 4 a2
o o
Table 11-4 Valid Operands
o o
ngh d o
Inputs/Outputs
h
ng Data Type Operands d o ng h
d o ng h
Tu
XMT_REQ BOOL I, Q, M, S, SM, T
element
uV, L, Power Flow conditioned by a rising edge detection
T, C, Tu
Drive BYTE VB, IB, QB, MB, SB, SMB, LB, AC, *VD, *AC, *LD, Constant

.c o m Param, Index WORD


c
DWORD 4. &VB
om o m
VW, IW, QW, MW, SW, SMW, LW, T, C, AC, AIW, *VD, *AC, *LD, Constant
. c
a24
DB_Ptr
a 2 a 2 4 a 2 4.
o o ho ho
ngh hDWORD,
Value WORD VW, IW, QW, MW, SW, SMW, LW, T, C, AC, AQW, *VD, *AC, *LD

o n g REAL VD, ID, QD, MD, SD, SMD,n g n g


Tud uV,dLo Tud
o
LD, *VD, *AC, *LD
Done BOOL I, Q, M, S, SM, T
T, C,
Error BYTE VB, IB, QB, MB, SB, SMB, LB, AC. *VD, *AC, *LD

.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 319
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
oUSS_WPM_x .c om . c om .
a2 4 Instruction 4
a2for the USS protocol: a2 4 a 24
h o h o h o h o
ng There are three
d o nginstruction writes an unsigned word parameter.
write instructions
d o ng d on g
Tu
- USS_WPM_W
Tu
- USS_WPM_D instruction writes an unsigned double word
T u
parameter.

. co m .c m
- USS_WPM_R instruction writes a floating-point parameter.
o . c o m
a 24 Only one read (USS_RPM_x)
a 24
or write (USS_WPM_x) instruction
a 24 a2 4.
o can be active at a time.
o o ho
ngh o n gh o n gh ong
Tud receipt of the command, or whenTanuerror d d
The USS_WPM_x transactions complete when the MicroMaster
drive acknowledges
condition is posted. The logic scan continues to execute while this
Tu
process awaits a response.
The EN bit must be on to enable transmission of a request, and

4 .c omshould c
remain on until the Done bit is set,
4 . m completion of
osignaling 4 . c om .
o a2 o a2
the process. For example, a USS_WPM_x request is transmitted to
o a2 o a 24
ng h h
the MicroMaster drive on each
ng which
scan when XMT_REQ input is on.
input should be pulsed on through an g h g h
Therefore, the XMT_REQ
u
edge detectiond o
element
u d on
causes one request to be transmitted
u d on
for eachT positive transition of the EN input. T T
The Drive input is the address of the MicroMaster drive to which the
USS_WPM_x command is to be sent. Valid addresses of individual

4 .c omParam is the parameter number. Index


drives are 0 to 31.

4 . c om 4 . c om 4.
h o a2 h o
parameter that is to be written. a2 is the index value of the
Value is the parameter value to be
h o a2 hoa 2
ng written to the RAM ing
o ntothethedrive.
also write thisdvalue
For MicroMaster 3 drives, you can g
EEPROM of the drive, based ond onyou o ng
u u Tud
how
T P971 (EEPROM Storage Control). T
have configured

The address of a 16-byte buffer must be supplied to the DB_Ptr input. This buffer is used by the

11 4.comWhen the USS_WPM_x instruction4completes, om the Done output is turned on and4the.cError omoutput byte
USS_WPM_x instruction to store the results of the command issued to the MicroMaster drive.

2 2 . c 2 2 4.
o a ho a
contains the result of executing the instruction. Table 11-6 defines the errora
ho conditions that could result
ho a
ngh n g
from executing the instruction.
do input is turned on, the instructionTwrites n g
dtooboth the RAM and the EEPROM of theTudo n g
When the u u
T EEPROM
drive. When the the input is turned off, the instruction writes only to the RAM of the drive. Because the
MicroMaster 3 drive does not support this function, you must ensure that this input is off in order to use
this instruction with a MicroMaster 3 drive.

.c o mTable 11-5 Valid Operands for the USS_WPM_x


. c o mInstructions . c o m
a2 4 4
Inputs/Outputs Data Type a2Operands a 2 4 a 2 4.
o ho I, Q, M, S, SM, T, C, V, L, Power Flowngconditioned
ho by a rising edge detection ho
ngh XMT_REQ
do n g
BOOL
do do n g
EEPROM T u BOOL
element
T u
I, Q, M, S, SM, T, C, V, L, Power Flow T u
Drive BYTE VB, IB, QB, MB, SB, SMB, LB, AC, *VD, *AC, *LD, Constant

om DB_Ptr om om
Param, Index WORD VW, IW, QW, MW, SW, SMW, LW, T, C, AC, AIW, *VD, *AC, *LD, Constant

2 4 .c 4
DWORD . c &VB
4 . c 4.
hoa Value WORD
h oa2VW, IW, QW, MW, SW, SMW, LW, T, C, AC,
h o a2*VD, *AC, *LD
AQW,
ho a2
ng d o ng REAL VD, ID, QD, MD, SD, SMD, LD,
DWORD,
d o
*VD, g *LD
n*AC, d ong
Done
Error
Tu BOOL
BYTE
I, Q, M, S, SM, T, C, V, L u
T
VB, IB, QB, MB, SB, SMB, LB, AC. *VD, *AC, *LD
Tu

4 . com 4. c om 4 . com .
o a2 oa2 a2 a 24
ngh
320
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
Using the USS Protocol Library to Control a MicroMaster Drive Chapter 11

4 .c om 4 .co m
4. c om .
oa2 Caution
o a 2 o a2 o a 24
ngh gh gh h
When you use an USS_WPM_x instruction to update the parameter set stored in drive EEPROM, you
on on
must ensure that the maximum number of write cycles (approximately 50,000) to the EEPROM is not
on g
ud
exceeded.
T T ud T u d
Exceeding the maximum number of write cycles will result in corruption of the stored data and
subsequent data loss. The number of read cycles is unlimited.
If frequent writes to the drive parameters are required, then you should first set the EEPROM storage

. co m o m o m
control parameter in the drive to zero (for MicroMaster 3 drives) and turn off the EEPROM input for
.c . c
24 MicroMaster 4 drives.
24 a24 2 4.
ng hoa hoa
g USS_WPM_x
nand n gho ng ho a
d o
Example: USS_RPM_x
do d o
Tu Network 1Tu//The two contacts must have the same address. Tu
LD I0.0
= L60.0

.co m .co m LD
EU
I0.0

.co m .
a 2 4 a 2 4 = L63.7
a 2 4 a 24
o o o o
ngh gh gh h
LD L60.0

o n CALL
n on
USS_RPM_W, L63.7, 0, 3, 0, &VB100, M0.0, VB10, VW200
o g
Tu d u d
Network 2T //The two contacts must have the same address
T u d
LD I0.1
= L60.0
LD I0.1

4 .c om 4 .co m EU
= L63.7
4 .co m
4.
o a2 oa 2 LDN SM0.0
o a 2
hoa 2
ngh gh gh g
= L63.6

do n d o n o n
Tud
LD L60.0

Tu CALL
Tu USS_WPM_W, L63.7, L63.6, 0, 971, 0, 1, &VB120, M0.1, VB11

.co m .co m .co m 11 4.


a 2 4 a 2 4 a 2 4 a2
o o o o
ngh o n gh o n gh o n g h
Tud Tu d 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 321
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 Sample Programs for
o a2
the USS Protocol
o a2 o a 24
ng h h
ng Sample Program that Correctly Displays h
ningSTL g h
d o d o d on
Tu u 1 //Initialize USS Protocol: u
Example: USS Instructions
TNetwork T
//On the first scan, enable USS protocol
//for port 0 at 19200 with drive address
//”0” active.

. co m .c o m . c o m
24 24
LD SM0.1

a24 2 4.
hoa hoa a
CALL USS_INIT, 1, 19200, 16#00000001, Q0.0,

ng g
VB1
gho ng ho
Tu don d o
TLDu SM0.0
Network 2
n //Control parameters for Drive 0
Tu d o
CALL USS_CTRL, I0.0, I0.1, I0.2, I0.3, I0.4, 0, 1,
100.0, M0.0, VB2, VW4, VD6, Q0.1, Q0.2, Q0.3, Q0.4

.co m .co m Network 3


.co m
//Read a Word parameter from Drive 0.
.
a 2 4 a 2 4 a 2 4
//Read parameter 5 index 0.
a 24
o o o o
ngh gh gh h
//1. Save the state of I0.5 to a temporary

o n o n // location so that this network displays


on g
Tu d Tu d // in LAD.
T u
//2. Save the rising edge pulse of I0.5
d
// to a temporary L location so that
// it can be passed to the subroutine.
LD I0.5

4 .c om 4 .com
=
LD
L60.0
I0.5
4 .co m
4.
2 oa2 2 2
hoa o a hoa
EU

ng o ngh =
LD
o n gh
L63.7
L60.0
o ng
Tu d Tu
CALLd USS_RPM_W, L63.7, 0, 5, 0, &VB20, M0.1,
VB10, VW12 Tud
Network 4 //Write a Word parameter to Drive 0.
//Write parameter 2000 index 0.

11 4.com om m
LD I0.6

4 .c = L60.0
4 .co 24.
h o a2 hoa
2 LD I0.6
o a 2 o a
ng o ng
EU
=
o n gh
L63.7
on g h
Tud Tu
LDN
=
d SM0.0
L63.6 T u d
LD L60.0
CALL USS_WPM_R, L63.7, L63.6, 0, 2000, 0, 50.0,
&VB40, M0.2, VB14

.c o m . c o m . c o m .
o a24 hoa
24
hoa
24 oa 24
ngh gh
Note: This STL code does not compile to LAD or FBD.

on g on g o n
T u d 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
322
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
Using the USS Protocol Library to Control a MicroMaster Drive Chapter 11

4 .c om 4 .c om 4. c om .
o a2 USS Execution Error
o a2Codes
o a2 o a 24
ng h Table 11-6 n
h
g Error Codes for the USS Instructions ong h g h
d o Execution
on
TuCodes Description
Error Tud T u d
0 No error
1 Drive did not respond

.com c o m c o m
2 A checksum error in the response from the drive was detected

24 2was .
4 in the response from the drive was detecteda24. 2 4.
h o a 3

h o a
A parity error
caused by interference from the userh o ho a
ng g g ng
4 An error program
5o
n An illegal command was attempted do
n o
Tud6 Tu
An illegal drive address was supplied Tu d
7 The communications port was not set up for USS protocol
8 The communications port is busy processing an instruction

4 .c om 9
. c om
The drive speed input is out of range
4 4 . c om 4.
oa 2 a 2
o first character of the drive response is incorrect a 2 a 2
ho ho
10 The length of the drive response is incorrect

n g h 11
n g hThe n g n g
o The length character in the drive response
udois not supported by USS instructions Tudo
Tud1213 The wrong drive responded
T
14 The DB_Ptr address supplied is incorrect

om om om
15 The parameter number supplied is incorrect

2 4 .c 16
4 . c
An invalid protocol was selected
4 . c 4.
hoa 17
h o
USSais2active; change is not allowed h o a2 hoa 2
ng d18 ng An illegal baud rate was specified
o d o ng o ng
Tu 19 No communications: the drive is notu
T ACTIVE Tud
20 The parameter or value in the drive response is incorrect or contains an error code
21 A double word value was returned instead of the word value requested

4 . c om 22
.co m .co
A word value was returned instead of the double word value requested

4 4
m 11 4.
o a 2 o a 2 o a 2 o a2
ngh o n gh o n gh o n g h
Tud Tu d 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 323
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 Connecting and Setting
a 2
Up the MicroMaster Series
a32 Drive
a 2
ngh n g ho n g ho n g ho
Connecting d
u o MicroMaster 3 Drive
the
u do u do
T T T
You can use the standard PROFIBUS cable and connectors to connect the S7-200 to the MicroMaster
Series 3 (MM3) drive. See Figure 11-5 for the proper cable bias and termination of the interconnecting
cable.

. co m Caution . c o m . c o m
a 2 4 a 4 reference potentials can cause unwanted
Interconnecting equipment with2different
a 2 4 currents to flow a2 4.
o ho cable. ho ho
ngh g g g
through the interconnecting
n
do that you are about to connect T n n
These unwanted
Be sure
currents
Talluequipment
can cause communications
udo
errors or damage equipment.
with a communications cable either shares a T
udo
common circuit reference or is isolated to prevent unwanted current flows.
The shield must be tied to chassis ground or pin 1 on the 9-pin connector. It is recommended that you

.co m .co m
tie wiring terminal 2–0V on the MicroMaster drive to chassis ground.
.co m .
a 2 4 a 2 4 a 2 4 a 24
o o o o
ngh d o n gh
Cable must be terminated Switch position = On
Terminated and biased n gh
Switch position = Off

d o
No termination or bias
Switch position = On
Terminated and biased
d on g h
Tu TuOff u
and biased at both ends.
On On T

Ó Ó Ó
ABAB ABAB A B AB

om om om
a2 4 .c 2Ó
4 . c Ó Ó2 4 . c 2 4.
ngh
o
ng hoa n g hoa ng hoa
do o
Bare shielding: approximately 12 mm (1/2 in.) must contact the
o
Tu Tudof all locations.
metal guides
Tud
Switch position = On: Terminated and biased Switch position = Off: No termination or bias
B
TxD/RxD +
11 4.com om m
Pin # Pin #

4 .6c
TxD/RxD -
A
4 .co 24.
a2 aΩ 2 3 2 6

h o o
B 390
h
Cable shield
o a o a
ng TxD/RxD +
o ng Network
TxD/RxD +
o n gh B
3
Network
on g h
Tud- d d
220 Ω
Tu u
A connector A connector
TxD/RxD
390 Ω
8 TxD/RxD - 8
T
5 5
Cable shield 1 Cable shield 1

.c o m .com . c o m .
o a24 Figure 11-5
a 24
Bias and Termination of the Network Cable
o hoa
24 oa 24
ngh d on g h
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
324
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
Using the USS Protocol Library to Control a MicroMaster Drive Chapter 11

4 .c om Setting Up the MicroMaster 4 . c o3mDrive 4 . c om 4.


o a 2 a 2 a 2 a 2
ngh g htheoakeypad
Before you connect
n drive to the S7-200, you must ensure thath
n g odrive has the following system
the
n g ho
do
parameters.
T1. uReset
Use on the drive to set
T
the
u do
parameters:
T u do
the drive to factory settings (optional). Press the P key: P000 is displayed. Press the up or
down arrow key until the display shows the P944. Press P to enter the parameter.
P944=1

24 .com 2.
.c o m . c o m
Enable the read/write access to all parameters. Press the P key. Press the up or down arrow key
24 4.
h o a hoa
until the display shows P009. Press P to enter the parameter.
ho a24 ho a2
ng d n g
P009=3
o motor settings for your drive. The settings
3. uCheck d o n g
d o ng
Tukey until the display shows the motor setting
T Press the P key. Press the up or down arrow will vary according to the motor(s)
Tufor your
being used.

drive. Press P to enter the parameter.


P081=Nominal frequency of motor (Hz)

4 .c om 4 .co m
P082=Nominal speed of motor (RPM)
4 .co m .
2 P083=Nominal current of motor (A)
2 2 24
hoa ho a ho a o a
P084=Nominal voltage of motor (V)

ng g
P085=Nominal power of motor (kW/HP)
n n g ng h
d o Po
the Local/Remote control mode. Press thed d o
Tudisplay shows P910. Press P to enter theTparameter.
4. Set
u Tu
key. Press the up or down arrow key until the

P910=1 Remote control mode


5. Set the Baud Rate of the RS–485 serial interface. Press the P key. Press the up or down arrow key

4 .c om .co m .co m
until P092 appears. Press P to enter the parameter. Press the up or down arrow key until the
4 4 4.
2 2 2
display shows the number that corresponds to the baud rate of your RS–485 serial interface. Press
2
ng hoa g3 h
P to enter.
n
oa
n gh o a
ng hoa
do d o o
Tud
P092 (1200 baud)
Tu 4
5
(2400 baud)
(4800 baud)
Tu
6 (9600 baud – default)
7 (19200 baud)

.co m 6.
.co m .co m
Enter the Slave address. Each drive (a maximum of 31) can be operated over the bus. Press the P
11 4.
a 2 4 a 2 4 a 2 4
key. Press the up or down arrow key until P091 appears. Press P to enter the parameter. Press the
a2
o ho ho
up or down arrow key until the display shows the slave address you want. Press P to enter.
o
ngh d o n g
P091=0 through 31.
d o n g
d on g h
u u u
T7. Ramp up time (optional). This is the timeTin seconds that it takes the motor to accelerateTto
maximum frequency. Press the P key. Press the up or down arrow key until P002 appears. Press P
to enter the parameter. Press the up or down arrow key until the display shows the ramp up time
you want. Press P to enter.

.c o m P002=0–650.00
. c o m . c o m .
o a24 8.
hoa
24
hoa
24
Ramp down time (optional). This is the time in seconds that it takes the motor to decelerate to a
oa 24
ngh d on g
d on g
complete stop. Press the P key. Press the up or down arrow key until P003 appears. Press P to
o n gh
Tud
enter the parameter. Press the up or down arrow key until the display shows the ramp down time
T u you want. Press P to enter. T u
P003=0–650.00

.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 325
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 9. 4 .co m
4. c om .
o a2 o 2 o a2
Serial Link Time-out. This is the maximum permissible period between two incoming data
a
telegrams. This feature is used to turn off the inverter in the event of a communications failure.
o a 24
ngh on gh on gh
Timing starts after a valid data telegram has been received. If a further data telegram is not received
on g h
T ud T ud T u d
within the specified time period, the inverter will trip and display fault code F008. Setting the value to
zero switches off the control. Use Table 11-1 to calculate the time between the status polls to the
drive.
Press the P key. Press the up or down arrow key until P093 appears. Press P to enter the

.com o m o m
parameter. Press the up or down arrow key until the display shows the serial link time-out you want.

24 24 .c . c 4.
a24
Press P to enter.
o a a a2
ng h n g ho time is in seconds)
P093=0–240 (0 is default;
n g ho n g ho
oNominal
udwhich
10. Serial Link System Setpoint. This value can d oPVsbutorwillSPs.typically
u forvary, correspond to 50 Hz or do
T
60 Hz, T
defines the corresponding 100% value Tu
Press the P key. Press the
or down arrow key until P094 appears. Press P to enter the parameter. Press the up or down arrow
up

key until the display shows the serial link nominal system setpoint you want. Press P to enter.

om 11. m m
P094=0–400.00

2 4 .c 4 .co 4 .co
USS Compatibility (optional). Press the P key. Press the up or down arrow key until P095 appears.
2 2 24 .
hoa ho a o a o a
Press P to enter the parameter. Press the up or down arrow key until the display shows the number

ng g gh
that corresponds to the USS compatibility you want. Press P to enter.
n
o Hz resolution (default) o n on g h
Tu=d01 0.1
P095
0.01 Hz resolution Tu d T u d
12. EEPROM storage control (optional). Press the P key. Press the up or down arrow key until P971
appears. Press P to enter the parameter. Press the up or down arrow key until the display shows

4 .c om 4 .co m
4 .co
the number that corresponds to the EEPROM storage control you want. Press P to enter. m
4.
o a2 P971 = 0 2 2
Changes to parameter settings (including P971) are lost when power is removed.
oa o a hoa 2
ngh gh gh
1 (default) Changes to parameter settings are retained during periods when power is

o n removed.
o n o ng
Tu d Tu d
13. Operating display. Press P to exit out of parameter mode. Tud

11 4.com 4 .co m
4 .co m .
o a2 o a 2 o a 2 o a 24
ng h n gh n gh g h
o o on
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
326
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
Using the USS Protocol Library to Control a MicroMaster Drive Chapter 11

4 .c om 4 .c om 4 . c om 4.
o a 2 Connecting and Setting
a 2 Up the MicroMaster Series
a 2 4 Drive
a 2
ngh n g ho n g ho n g ho
T u do the MicroMaster 4 DriveTudo
Connecting
T u do
To make the connection to the MicroMaster Series 4 (MM4) drive, insert the ends of the RS-485 cable into
the two caged clamp, screwless terminals provided for USS operation. The standard PROFIBUS cable
and connectors can be used to connect the S7-200.

. co m .c o m . c o m
24
Caution
24 a24 2 4.
hoa hoa a
Interconnecting equipment with different reference potentials can cause unwanted currents to flow

ng g
through the interconnecting cable.
gho ng ho
don do n
These unwanted currents can cause communications errors or damage equipment.
Tusure all equipment that you are about to connect
Be Tu with a communications cable either shares
Tua d o
common circuit reference or is isolated to prevent unwanted current flows.
The shield must be tied to chassis ground or pin 1 on the 9-pin connector. It is recommended that you

.co m .c om
tie wiring terminal 2–0V on the MicroMaster drive to chassis ground.
. c om .
a 2 4 As shown in Figure 11-6,2 4
a thecable
two wires at the
a2 4 a 24
o o o
B (P) A (N)
o
ngh h h h
opposite end of the RS-485 must be
inserted inton
o gMM4 drive terminal blocks. To
the
o ng on g
d
Tu the drive cover(s) to access the terminalTu
make the cable connection on a MM4 drive, d T u d
remove
blocks. See the MM4 user manual for details
about how to remove the covers(s) of your
specific drive.

4 .c om 4 .co m
The terminal block connections are labeled
4 .co m
4.
o a2 oa 2
numerically. Using a PROFIBUS connector on
o a 2
hoa 2
ngh do gh
the S7-200 side, connect the A terminal of the
n d o n gh o ng
Tud
cable to the drive terminal 15 (for an MM420) or
Tu
terminal 30 (MM440). Connect the B terminal of
the cable connector to terminal 14 (MM420) or
Tu
terminal 29 (MM440). Figure 11-6 Connecting to the MM420 Terminal Block

4 . c om m m
If the S7-200 is a terminating node in the network, or if the connection is point-to-point, it is necessary to
.co .co
use terminals A1 and B1 (not A2 and B2) of the connector since they allow the termination settings to be
4 4 11 4.
o a 2 a 2
set (for example, with DP connector type 6ES7 972–0BA40–0X40).
o o a 2 o a2
ngh o n
Caution gh o n gh o n g h
Tud Tu d
Make sure the drive covers are replaced properly before supplying power to the unit.
Tud
If the drive is configured as the terminating node in the 14
network, then termination and bias resistors must be also be 120 ohm

.c o m . c m
wired to the appropriate terminal connections. For example,
o
15
. c 1Km
o ohm
1K ohm
.
a24 24 2 4
24
Figure 11-7 shows an example of the connections
2
hoa hoa a
necessary for termination and bias for the MM4, model
o o
ngh ng g gh
6SE6420 drive.

d o o n 1
o n
T u T ud Figure 11-7 Tud
Sample Termination and Bias

.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 327
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
oSetting .c om . c om
a 2 4 Up the MM4 Drive
a 2 4 a 2 4 a 2 4.
o hotoonthetheS7-200, hohas the following system ho
ngh do
parameters. Use n
the g
Before you connect a drive
keypad drive to set the
do
parameters: g
you must ensure that the drive
n do n g
T u
1. Reset the drive to factory settings (optional): T u P0010=30 T u
P0970=1
If you skip this step, ensure that the following parameters are set to these values:

.com o m o m
USS PZD length: P2012 Index 0=2

24 24 .c . c 4.
a24
USS PKW length: P2013 Index 0=127
a 2
ng h o 2.
hoa
Enable the read/write access to all parameters (Expert mode):
g gho P0003=3
ng ho a
3.
don
Check motor settings for your drive:
Tu Tu do n
P0304=Rated motor voltage (V)
P0305=Rated motor current (A) Tu d o
P0307=Rated motor power (W)
P0310=Rated motor frequency (Hz)
P0311=Rated motor speed (RPM)

.co m .c om . c om 4.
The settings will vary according to the motor(s) being used.

a 2 4 a 2 4 a 2 4 a 2
o o
In order to set the parameters
o the parameters, set
P304, P305, P307, P310, and P311, you must first set parameter
o
ngh g h
P010 to 1 (quick commissioning
n
doP010 to 0. mode.
mode). When you are finished h
n g setting
o and P311 can only be changed in theudo n g h
Tud
parameter Parameters P304, P305, P307, P310,
Tucommissioning
quick
T
4. Set the local/remote control mode: P0700 Index 0=5
5. Set selection of frequency setpoint to USS on COM Link: P1000 Index 0=5

4 .c om 6. Ramp up time (optional):


4 . c om P1120=0 to 650.00
4 . c om 4.
o a2 o a2that it takes the motor to accelerate hto o
This is the time in seconds a2 frequency.
maximum
hoa 2
ngh 7. Ramp downn
d o time h
g (optional):
d o ngto 650.00
P1121=0
o ng
Tuis the time in seconds that it takes the motorTtoudecelerate to a complete stop.
This Tud
8. Set the serial link reference frequency: P2000=1 to 650 Hz
9. Set the USS normalization: P2009 Index 0=0

11 4.com 10. Set the baud rate of the RS–485


4 .c ominterface: P2010 Index 0= 544.(4800
serial c om
(2400 baud)
4.
o a 2 a 2 a 2 baud)
a 2
ngh n g ho n g ho 67 (19200
(9600 baud)
n g ho
o o baud
udo
Tud Tud 8 (38400 baud)
9 (57600 baud) T
12 (115200 baud)
11. Enter the Slave address: P2011 Index 0=0 to 31

.c o m Each drive (a maximum of 31).can c o moperated over the bus. . c o m


4.
be

a2 4 a 2 4 a 2 4 ms a 2
o ho
12. Set the serial link timeout:
o
P2014 Index 0=0 to 65,535
ho
ngh n g (0=timeouth
n g disabled)
n g
toT
u theomaximum permissible period betweenTtwo
This isd o data telegrams. This feature is used
udincoming
turn off the inverter in the event of a communications failure. Timing starts after a valid dataT
udo
telegram has been received. If a further data telegram is not received within the specified time
period, the inverter will trip and display fault code F0070. Setting the value to zero switches off the
control. Use Table 11-1 to calculate the time between the status polls to the drive.

.co m 13. Transfer the data from RAM to.EEPROM:


c om . com
a2 4 a2 4 4
ato2EEPROM a2 4.
o o o ho
ng h h h
P0971=1 (Start transfer) Save the changes to the parameter settings

d o ng d o ng d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
328
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 .
oa2 Using oa2
theghModbus Protocol a2
Library
o o a 24
ngh d on d ong h
d on g h
Tu Tu T u
STEP 7–Micro/WIN Instruction Libraries makes communicating to Modbus master devices easier by
including pre-configured subroutines and interrupt routines that are specifically designed for Modbus

. co m o m o
communications. With the Modbus Slave Protocol Instructions, you can configure the S7-200 to act as a
.c . c m
24 24
Modbus RTU slave device and communicate to Modbus master devices.
a24 2 4.
ng hoa g
a
hocan make
You find these instructions
n n g hoWhen youinstruction
in the Libraries folder of the STEP 7–Micro/WIN tree. With these
n g ho a
o do o
Tud one or more associated subroutinesTareuautomatically Tud
new instructions you the S7-200 act as a Modbus slave. select a Modbus Slave
instruction, added to your project.

In This Chapter
4 .c om 4 . c om 4 . c om
Requirements for Using the Modbus Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330
4 .
oa 2 a 2 a 2 a 2
n g h n g ho. . . . . .Time
Initialization and Execution for the Modbus Protocol . . . . . . . o
. .g
. . . . . . . . . . . . . . . . . . . . . . . . . . .n
h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
330
n g ho
T
UsinguthedoModbus Slave Protocol Instructions T. . .u. .d. . o. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .T. . .u. .do332
Modbus Addressing .................................

Instructions for the Modbus Slave Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333

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

.com .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 329
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
S7-200 Programmable Controller System Manual

4 .c om 4 .c om 4 . c om 4.
o a 2 Requirements for Using
a 2
the Modbus Protocol
a 2 a 2
ngh The Modbus Slaven g hoinstructions use the following resources
n g hothe S7-200: n g ho
o Protocol
ud0 o
from
o
Tud the Modbus Slave Protocol dedicatesTPort
- Initializing Tud
for Modbus Slave Protocol communications.
When Port 0 is being used for Modbus Slave Protocol communications, it cannot be used for any
other purpose, including communications with STEP 7–Micro/WIN. The MBUS_INIT instruction

. co m- .c m
controls assignment of Port 0 to Modbus Slave Protocol or PPI.
o . c o m
24 24 a24
The Modbus Slave Protocol instructions affect all of the SM locations associated with Freeport
2 4.
ng hoa hoa
communications on Port 0.
g gho ng ho a
-

-
don
TuModbus Slave Protocol instructions requireT1857
The
do n
The Modbus Slave Protocol instructions use 3 subroutines and 2 interrupts.
u bytes of program space for the two Modbus
Tu d o
Slave instructions and the support routines.
- The variables for the Modbus Slave Protocol instructions require a 779-byte block of V memory. The

.co m .co m .co m


starting address for this block is assigned by the user and is reserved for Modbus variables.
.
a 2 4 Tip
a 2 4 a 2 4 a 24
o o o o
ngh gh gh g h
To change the operation of Port 0 back to PPI so that you can communicate with STEP 7-Micro/WIN,
o n
use another MBUS_INIT instruction to reassign Port 0.
d d o n d on
T
You can u
also set the mode switch on the S7-200 to T u
STOP mode. This resets the parameters for T
Port u
0.

Initialization and Execution Time for the Modbus Protocol


4 .c omModbus communications utilize a 4CRC.c(cyclic
omredundancy check) to insure the integrity
4 . c oofmthe 4.
o a 2 communications messages. The
a 2 a 2
Modbus Slave Protocol uses a table of precalculated values to decrease
a 2
ngh g hoa message.
the time required to process
milliseconds. This n
The initialization of this CRCh
n g o requires about 425
table
ng ho
scan of theu
T doprogram after entering RUN mode. You
user
initialization
T u o
is done inside the MBUS_INIT subroutine and is normally done in the first
aredresponsible for resetting the watchdog timer
T u do
and keeping the outputs enabled (if required for expansion modules) if the time required by the
MBUS_INIT subroutine and any other user initialization exceeds the 500 millisecond scan watchdog. The
output module watchdog timer is reset by writing to the outputs of the module. See the Watchdog Reset
Instruction in Chapter 6.
.co mThe scan time is extended when the .MBUS_SLAVE
c om subroutine services a request. .c om
2 4 2 4 2 4 Since most of the time
2 4.
g h oa g hin o
is spent calculating the Modbus a a
o or write of 120 words)
CRC, the scan time is extended by about 650
g h(read microseconds for every
g ho a
n 12 n
byte in the request and
n
the response. A maximum request/response
otime by approximately 165 milliseconds.udo o n
Tud Tud
extends the scan
T

.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
330
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
Using the Modbus Protocol Library Chapter 12

4 .c om 4 .c om 4 . c om 4.
o a 2 Modbus Addressing
a 2 a 2 a 2
ngh n g hoare normally written as 5 or 6 characternvalues
g hocontaining the data type and the offset.ngho
o or two characters determine the datautype,
Modbus addresses
done doand the last four characters select the proper
udo
Tuwithin
The first
value the data type. The Modbus masterT device then maps the addresses to the correctT functions.
The following addresses are supported by the Modbus Slave instructions:
- 000001 to 000128 are discrete outputs mapped to Q0.0 - Q15.7

4 .com -
.c o m
010001 to 010128 are discrete inputs
24
Table 12-1
. c o m
4.
Mapping Modbus Address to the S7-200
4
h o a2 ho a
mapped to I0.0 - I15.7
ho a
Modbus Address2 S7-200 Address
ho a2
n g -
n g
030001 to 030032 are analog input
o o n g
000001 Q0.0
on g
d registers mapped to AIW0 to AIW62
T-u040001 Tud 000002 Q0.1 ud
T
to 04xxxx are holding registers
000003 Q0.2
mapped to V memory.
... ...
All Modbus addresses are one-based.

4 .c om 4 . om
Table 12-1 shows the mapping of Modbus
c
000127

4 . c om Q15.6
.
2 addresses to the S7-200 addresses.
2 000128
2 Q15.7
24
ng hoa The Modbus Slave
the amount n g h oa allows you to limit
Protocol 010001 oa
n gh
I0.0
n g h o a
and u
o of inputs, outputs, analog inputs,
o 010002
d registers (V memory) accessible toTud 010003 I0.1
u d o
aT
I0.2T
holding
Modbus master.
... ...
The MaxIQ parameter of the MBUS_INIT
010127 I15.6
instruction specifies the maximum number of

4 .c om c om
discrete inputs or outputs (Is or Qs) the Modbus
4 .
010128
4 . c om I15.7
4.
2 2
master is allowed to access. 030001
2 AIW0
2
ng hoa g h
The MaxAI parameter o a
of the MBUS_INIT
n the maximum number of g
030002h oa AIW2
g hoa
d ospecifies
instruction
inputuregisters u d on030003 AIW4
ud o n
T (AIWs) the Modbus master is
allowed to access.
T ... ... T
030032 AIW62
The MaxHold parameter of the MBUS_INIT
instruction specifies the maximum number of 040001 HoldStart

24 .com 24 .com
holding registers (V memory words) the
Modbus master is allowed to access.
040002
24 .comHoldStart+2 24 .
h o a o a 040003
o a HoldStart+4
o a
ng n gh of the MBUS_INIT
See the description
o o n g... h ...
o n gh 12
ud restrictions for the Modbus slave. Tud 04xxxx
instruction
Tmemory
the
for more information on setting up
Tud
HoldStart+2 x (xxxx–1)

Configuring the Symbol Table

.c o m . c m
remainder of the symbols in the table.
. c m
After you enter an address for the first symbol, the table automatically calculates and assigns the
o o .
o a24 hoa
24
hoa
24 oa 24
ngh gh
You should assign a starting V location for the table which occupies 779 bytes. Be sure that the

on g on g
assignment of the Modbus Slave symbols do not overlap with the V memory assigned to the Modbus
o n
T u d T u d Tud
holding registers with the HoldStart and MaxHold parameters on the MBUS_INIT instruction. If there is any
overlap of the memory areas, the MBUS_INIT instruction returns an error.

.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 331
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 the Modbus Slave
a 2Protocol Instructions
a 2 a 2
ngh g
To use the ModbusnSlaveho n g hofollow these steps: n g ho
doMBUS_INIT instruction in your programTuanddexecute
o udo
Protocol instructions in your S7-200 program,

T uthe
1. Insert the MBUS_INIT instruction forT
one
scan only. You can use the MBUS_INIT instruction either to initiate or to change the Modbus
communications parameters.

. co m .c m . c o m
When you insert the MBUS_INIT instruction, several hidden subroutines and interrupt routines are
o 4.
automatically added to your program.

oa 24 a 24
for the 779 bytes of consecutive V memorya 2 4 for Modbus Slave a2
n g h 2.
n g ho
Assign a starting address
Protocol instructions.
n g ho required
n g ho
3. doone MBUS_SLAVE instruction in yourTprogram.
Tuonly
Place udo This instruction is called every scanTtoudo
service any requests that have been received.
4. Connect the communications cable between Port 0 on the S7-200 and the Modbus master devices.

.co m Caution .c om . c om
a 2 4 a 4 a 2 4
Interconnecting equipment with2different reference potentials can cause unwanted currents to flow
a 2 4.
o ho cable. These unwanted currents canncause hocommunications errors or ho
ngh
through the interconnecting
n g g n g
udalloequipment that is connected with a communications
udo cable either shares a common Tudo
damage equipment.
EnsureT that T
circuit reference or is isolated to prevent unwanted current flows.

The accumulators (AC0, AC1, AC2, AC3) are utilized by the Modbus slave instructions and appear in the

.c omCross Reference listing. Prior to execution,m


. c o c o m ensuring
the values in the accumulators of a Modbus Slave
before the Modbus Slave instruction is.complete,
instruction

a 2 4 a 2 4 is preserved while executing a Modbusa2


are saved and restored to the accumulators
4 a 2 4.
o hoinstructions support the Modbus RTUnprotocol.
that all user data in the accumulators
ho These instructions utilize the ngho
Slave instruction.

ngh n g
doof the S7-200 to support the most common
The Modbus Slave Protocol g
o functions. The following Modbus udo
dModbus
T u
Freeport utilities
functions are supported: T u T
Table 12-2 Modbus Slave Protocol Functions Supported

4 . c om Function Description
4 .co m
4 .co m .
oa 2 1
o a 2 o a 2
Read single/multiple coil (discrete output) status. Function 1 returns the on/off status of any number of
o a 24
g h
n 12 n gh
output points (Qs).
n gh g h
2
o o
Read single/multiple contact (discrete input) status. Function 2 returns the on/off status of any number of
on
3
Tud input points (Is).
Tu d T
Read single/multiple holding registers. Function 3 returns the contents of V memory. Holding registers are
u d
word values under Modbus and allow you to read up to 120 words in one request.
4 Read single/multiple input registers. Function 4 returns Analog Input values.

.c o m 5
. c o m . c o m
Write single coil (discrete output). Function 5 sets a discrete output point to the specified value. The point
.
2 4 24 24
is not forced and the program can overwrite the value written by the Modbus request.
24
ng hoa 6
S7-200.ng
h o
Write single holding
aregister. Function 6 writes a single holding
n gh o
register
a
value to the V memory of the
n gh oa
d o
15 TuWrite multiple coils (discrete outputs). Function 15
o
ud the multiple discrete output values to the QTimage
ud o
Twrites
register of the S7-200. The starting output point must begin on a byte boundary (for example, Q0.0 or
Q2.0) and the number of outputs written must be a multiple of eight. This is a restriction for the Modbus
Slave Protocol instructions. The points are not forced and the program can overwrite the values written by

.co m the Modbus request.


.co m . com
a2 4 16
a 2 4 a2 4
Write multiple holding registers. Function 16 writes multiple holding registers to the V memory of the
a2 4.
o gho
S7-200. There can be up to 120 words written in one request.
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
332
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
Using the Modbus Protocol Library Chapter 12

4 .c om 4 . c om 4. c om .
o a2 Instructions for the
o a2
Modbus Slave Protocol
o a2 o a 24
ng h g h
nInstruction ng h g h
MBUS_INIT
d o d o d on
TuMBUS_INIT instruction is used to enable and
The Tuinitialize, or to
disable Modbus communications. Before the MBUS_SLAVE
T u
instruction can be used, the MBUS_INIT instruction must be
executed without errors. The instruction completes and the Done

. co m o m
bit is set immediately, before continuing to the next instruction.
.c . c o m
24 24on each scan when the EN input is on.oa24 2 4.
hoa a a
The instruction is executed
o
hinstruction should be executed exactly oncegforh ho
ng n
The MBUS_INIT
o gcommunications o n ong
Tudbe pulsed on through an edge detectionTelement, ud or Tu d
each change in state. Therefore, the EN input
should
executed only on the first scan.
The value for the Mode input selects the communications protocol:

4 .c om 4 .co m
an input value of 1 assigns port 0 to Modbus protocol and enables
4 .co m .
24
the protocol, and an input value of 0 assigns port 0 to PPI and
2 2 2
hoa a a a
disables Modbus protocol.
gh o gh o h o
ng d o n d o n
The parameter Baud sets the baud rate at 1200, 2400, 4800, 9600,
d on g
Tu
19200, 38400, 57600, or 115200.
Tu
The parameter Addr sets the address at inclusive values between 1
T u
and 247.

4 .c om 4 .co m
4 .co m
4.
o a2 Table 12-3
oa 2
Parameters for the MBUS_INIT Instruction

ho a 2
hoa 2
ngh o ngh
Inputs/Outputs Data Type Operands
n g
oMB, SB, SMB, LB, AC, Constant, *VD, *AC, u*LDdo ng
Tud
VB, IB,d
Mode, Addr, Parity
Baud, HoldStart
BYTE
DWORD T u QB,
T *LD
VD, ID, QD, MD, SD, SMD, LD, AC, Constant, *VD, *AC,
Delay, MaxIQ, MaxAI, MaxHold WORD VW, IW, QW, MW, SW, SMW, LW, AC, Constant, *VD, *AC, *LD
Done BOOL I, Q, M, S, SM, T, C, V, L

.com Error
.com
BYTE
.co m
VB, IB, QB, MB, SB, SMB, LB, AC, *VD, *AC, *LD
.
o a24 o a24 o a 2 4
o a 24
ngh gh gh gh 12
The parameter Parity is set to match the parity of the Modbus master. The accepted values are:
o n
d parity o n o n
T--u0-no T ud T ud
1-odd parity
- 2-even parity

.c o m . c o m . c o m
The parameter Delay extends the standard Modbus end-of-message timeout condition by adding the
.
a24 24 24 24
specified number of milliseconds to the standard Modbus message timeout. The typical value for this
o hoa hoa oa
parameter should be 0 when operating on a wired network. If you are using modems with error correction,

ngh d on g
d on g
set the delay to a value of 50 to 100 milliseconds. If you are using spread spectrum radios, set the delay to
o n gh
Tuandd
a value of 10 to 100 milliseconds. The Delay value can be 0 to 32767 milliseconds.
T u T u
The parameter MaxIQ sets the number of I and Q points available to Modbus addresses 00xxxx
01xxxx at values of 0 to 128. A value of 0 disables all reads and writes to the inputs and outputs. The
suggested value for MaxIQ is 128, which allows access to all I and Q points in the S7-200.

.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 333
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 omThe parameter MaxAI sets the number4 .c om 4 . c m


oaddress 4.
o a 2 a 2 a 2
of word input (AI) registers available to Modbus 03xxx at
a 2
ngh n g hoanalog inputs, is as follows:
values of 0 to 32. A value of 0
access to all of the S7-200
disables
n g ho
reads of the analog inputs. The suggested value for MaxAI to allow
n g ho
- 0 foru
T CPU do221 Tud
o
Tud
o
- 16 for CPU 222
- 32 for CPU 224, 226, and 226XM

. co mThe parameter MaxHold sets the number . c oofm


. c o m
4.
word holding registers in V memory available to Modbus

a 2 4 address 04xxx. For example,


ato
2 4
allow the master to access 2000 bytes of V
a 2 4
memory, set MaxHold to a
a2
o ho ho ho
ngh
value of 1000 words (holding registers).
n g n g n g
T
generally udto oVB0, so theis the
The parameter HoldStart
set parameter HoldStart is setT
do registers in V memory. This value is do
address of the start of the holding
tou&VB0 (address of VB0). Other V memory Tu
addresses can be specified as the starting address for the holding registers to allow VB0 to be used
elsewhere in the project. The Modbus master has access to MaxHold number of words of V memory
starting at HoldStart.

.co mWhen the MBUS_INIT instruction completes,


. c omthe Done output is turned on. The Error . c ombyte contains
a 2 4 a 2 4
the result of executing the instruction.
a 2 4
Table 12-5 defines the error conditions that
output
could result from
a 2 4.
o ho ho ho
ngh
executing the instruction.
o n g o n g o n g
Tud Tud Tud

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 .


2 4 2 4 2 4 24
g h oa gh o a
gh o a
g h o a
n 12 o n o n on
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
334
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
Using the Modbus Protocol Library Chapter 12

4 .c om MBUS_SLAVE Instruction 4 .c om 4. c om .
o a2 o a2 is used to service a request fromhtheoa2 o a 24
ng h h
ngand must be executed every scan todallow
nitgto g h
on
The MBUS_SLAVE instruction
d o
Modbus master o d
Tu for and respond to Modbus requests. Tu
check T u
The instruction is executed on each scan when the EN input is on.
The MBUS_SLAVE instruction has no input parameters.

. co m .c o m . c o m
24 24
The Done output is on when the MBUS_SLAVE instruction
a24 2 4.
hoa hoa a
responds to a Modbus request. The Done output is turned off if

ng g
there was no request serviced.
n n gho ng ho
dooutput
Tuoutput
The Error
This
contains the result of executing the d
is only valid if Done is on. If Done isT
o
u instruction.
off, the error Tu d o
parameter is not changed. Table 12-5 defines the error conditions
that could result from executing the instruction.

.co m .c om . c om .
a 2 4 for2
Table 12-4 Parametersa
4 a2 4 a 24
o o the MBUS_SLAVE Instruction
o o
ngh Parameter ng
d o
h Data Type Operands
d o ng h
d on g h
T u
Done BOOL I, Q, M, S, SM,u
T T, C, V, L
T u
Error BYTE VB, IB, QB, MB, SB, SMB, LB, AC, *VD, *AC, *LD

om m m
Table 12-5 Modbus Slave Protocol Execution Error Codes

2 4 .c Error Codes
4 .co
Description
2 2 4 .co 2 4.
ng hoa ngh
0 oaNo Error
n gh oa
ng hoa
do 1 Memory range error
d o o
Tu 2 Illegal baud rate or parity Tu Tud
3 Illegal slave address
4 Illegal value for Modbus parameter

4 . c om 5
.co m
Holding registers overlap Modbus Slave symbols
4 4 .co m .
2 6
2
Receive parity error
2 24
ng hoa gh 7
a
o Receive CRC error gho a o a
gh 12
o8n o n o n
Tud 9 Tud ud
Illegal function request/function not supported
Illegal memory address in request T
10 Slave function not enabled

.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 335
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 Example of Programming the Modbus


4 .c om 4 . c om 4.
o a 2 a 2 Slave Protocol
a 2 a 2
ngh n g ho Network 1 ho
n g n g ho
o o //Initialize the Modbus Slave Protocol on the o
Tud Tud //first scan. Set the slave address to 1,Tset
// port 0 to 9600 baud with even parity, all
ud
//access to all I, Q and AI values, allow
//access to 1000 holding registers (2000

. co m .c o m . c o m
// bytes) starting at VB0.

24 24
LD SM0.1

a24 2 4.
hoa hoa a
CALL MBUS_INIT,1,1,9600,2,0,128,32,1000,

ng g gho &VB0,M0.1,MB1
ng ho
don do n o
Network 2

Tu Tu //Execute the Modbus Slave Protocol on


Tu d
//every scan.
LD SM0.0
CALL MBUS_SLAVE,M0.2,MB2

.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 .co m .


2 4 2 4 2 4 24
g h oa gh o a
gh o a
g h o a
n 12 o n o n on
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
336
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 .
o a2 Technical a2
Specifications
o o a2 o a 24
ng h ng h ng h g h
d o d o d on
Tu Tu T u

. co m
In This Chapter
. c o m . c o m
a 2 4 a 2 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .a. .2. .4. . . . . . . . . . . . . . . . . . . . . . 338
General Technical Specifications
a2 4.
o ho. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .n. .g. .h. . o. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340 ho
ngh n g
CPU Specifications
Digital d o Modules Specifications . . . . . . .u. .d. . o. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .u. .do346 n g
T u Expansion
Analog Expansion Modules Specifications . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .T ..... 351
Thermocouple and RTD Expansion Modules Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
EM 277 PROFIBUS–DP Module Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373

4 .c om o m o m
4.c . . . . . . . . . . . . . . . . . . . . . . . . .a. .2. .4. . .. .c. . . . . . . . . . . . . . . . . . 387
EM 241 Modem Module Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
4.
oa 2 a 2
o Module Specifications . . . . . . . . . . .g. .h. . o. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393gho
EM 253 Position Module Specifications a 2
n g h n g
AS–Interface (CP h243–2) n n
u d
Optional o
Cartridges . . . . . . . . . . . . . . . . . . . . . . . . . .u . .o
. .d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .u. .do395
T T T 395
I/O Expansion Cable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
PC/PPI Cable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396
Input Simulators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398

4 .c om 4 . c om 4 . c om 4.
2 oa2 2 2
ng hoa ngh g hoa g hoa
o on o n
Tud T u d 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 337
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 General Technical 2
Specifications
a a 2 a 2
ngh n g ho n g ho n g ho
T do
Standards Compliance
u T u do T u do
The national and international standards listed below were used to determine appropriate performance
specifications and testing for the S7-200 family of products. Table A-1 defines the specific adherence to
these standards.

. co m- c o m
European Community (CE) Low Voltage Directive 73/23/EEC
. . c o m
24 24
EN 61131–2: Programmable controllers – Equipment requirements
a24 2 4.
ng hoa -
g h
European Communityoa(CE) EMC Directive 89/336/EEC gho
ng ho a
u d on emission standard u d on d o
Tu
Electromagnetic
T50081–1: residential, commercial, and lightTindustry
EN
EN 50081–2: industrial environment
Electromagnetic immunity standards

.co m EN 61000–6–2: industrial environment


.co m .co m .
a 2 4 -
a 2 4
Underwriters Laboratories, Inc.: UL 508 Listed (Industrial Control Equipment)
a 2 4 a 24
o o
Registration number E75310
o o
ngh -
o n gh o n gh
Canadian Standards Association: CSA C22.2 Number 142 Certified (Process Control Equipment)
d d d on g h
- u
T Mutual Research: FM Class I, Division T
Factory u
2, Groups A, B, C, & D Hazardous Locations, T u
T4A
and Class I, Zone 2, IIC, T4.

Maritime Approvals Agency Certificate Number

4 .c omThe 4 . c
following table identifies the maritimeom Lloyds Register of Shipping (LRS)
4 . c om 4.
99 / 20018(E1)

h o a2 h
at the time this manual was o a2
agency and the associated certificate
printed.
number
ho a 2
American Bureau of Shipping (ABS) 01–HG20020–PDA
hoa 2
ng d o ngapprovals, contact your
For the latest product n g
Germanischer Lloyd (GL)
o (DNV)
dVeritas
12 045 – 98 HH

do ng
Tu distributor or sales office. u u
Det Norske A–8071
local Siemens T
Bureau Veritas (BV) 09051 / A2 BV T
Nippon Kaiji Kyokai (NK) A–534

. c m
Technical
o Specifications
. c m
oconform . c oinm
a 2 4 All S7-200
2 4
CPUs and expansion modules
a to the technical specifications4
a 2 listed Table A-1.
a 2 4.
o ho ho ho
ngh Notice n g
do contact turns on output power toTtheuS7-200 n g
do CPU, or any digital expansion module, do n g
T u
When a mechanical
it sends a “1” signal to the digital outputs for approximately 50 microseconds. You must plan for this, T u
especially if you are using devices which respond to short duration pulses.
A
. c o m Electrical Service Life.com
Relay
. c o m 4000

a 2 4 The typical performance data


a 2 4
supplied by relay
a 2 4 a 2 4.
250 VAC resistive load

o o upon your ho ho
30 VDC resistive load

ngh hdepending
vendors is shown in Figure A-1. Actual
n g n g n g
Service life (x 103 operands)

performance may vary


udo
specific application.
T T udo T udo
An external protection circuit that is adapted to
the load will enhance the service life of the
contacts.

om om om
250 VAC inductive load (p.f.=0.4)

2 4 .c 2 4 . c . c
30 VDC inductive load (L/R=7ms)
4 4.
hoa a a2 a2
ng gho gh o
ng ho
don n 0 1 2 3 4 5 6 7

d o Rated Operating Current (A)


d o
Tu Tu
Figure A-1 Relay Electrical Service Life Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
338
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
Technical Specifications Appendix A

4 .c om 4 .co m
4. c om .
oa2
Table A-1 Technical Specifications
o a 2 o a2 o a 24
ngh gh gh g h
Environmental Conditions — Transport and Storage

on on on
ud ud d
IEC 68–2–2, Test Bb, Dry heat and –40° C to +70° C

T
IEC 68–2–1, Test Ab, Cold
IEC 68–2–30, Test Db, Damp heat
T
25° C to 55° C, 95% humidity
T u
IEC 68–2–31, Toppling 100 mm, 4 drops, unpacked
IEC 68–2–32, Free fall 1 m, 5 times, packed for shipment

. co m .c o m . c o m
24 2 4 Environmental Conditions — Operating

a24 2 4.
hoa hoa ho ho a
Ambient Temperature Range 0° C to 55° C horizontal mounting, 0° C to 45° C vertical mounting

ng g g ng
(Inlet Air 25 mm below unit) 95% non-condensing humidity
IEC 68–2–14, Test Nb

Tu don
IEC 68–2–27 Mechanical shock
do
5° C to 55° C, 3° C/minute

Tu
n
15 G, 11 ms pulse, 6 shocks in each of 3 axis Tu d o
IEC 68–2–6 Sinusoidal vibration Panel mount: 0.30 mm from 10 to 57 Hz; 2 G from 57 to 150 Hz
DIN rail mount: 0.15 mm from 10 to 57 Hz; 1 G from 57 to 150 Hz
10 sweeps each axis, 1 octave/minute

.co m
EN 60529, IP20 Mechanical protection
.co m .co m
Protects against finger contact with high voltage as tested by standard probes. External
.
a 2 4 a 2 4 diameter.
a 2 4
protection is required for dust, dirt, water, and foreign objects of less than 12.5 mm in

a 24
o o o o
ngh d o n gh
d o n gh
Electromagnetic Compatibility — Immunity per EN61000–6–21

d on g h
Tu Tu u
EN 61000–4–2 Electrostatic discharge 8 kV air discharge to all surfaces and communications port,

EN 61000–4–3 Radiated electromagnetic field


4kV contact discharge to exposed conductive surfaces
80 MHz to 1 GHz 10 V/m, 80% modulation with 1 kHz signal
T
EN 61000–4–4 Fast transient bursts 2 kV, 5 kHz with coupling network to AC and DC system power
2 kV, 5 kHz with coupling clamp to digital I/O

4 .c om 4 .co m
1 kV, 5 kHz with coupling clamp to communications

4 .co m
4.
a2 2 2 2
EN 61000–4–5 Surge immunity Power supply: 2 kV asymmetrical, 1 kV symmetrical

o oa I/O 1 kV symmetrical
o a hoa
ngh gh gh g
(24 VDC circuits require external surge protection)

do n d o n o n
Tud
EN 61000–4–6 Conducted disturbances 0.15 to 80 MHz 10 V RMS 80% amplitude modulation at 1kHz

Tu
EN 61000–4–11 Voltage dips, short interruptions and
voltage variations
Tu
>95% reduction for 8.3 ms, 83 ms, 833 ms, and 4167 ms

VDE 0160 Non-periodic overvoltage At 85 VAC line, 90° phase angle, apply 390 V peak, 1.3 ms pulse
At 180 VAC line, 90° phase angle, apply 750 V peak, 1.3 ms pulse

4 . c om .co m
Electromagnetic Compatibility — Conducted and Radiated Emissions per EN50081 –12 and –2
4 4 .co m .
2 EN 55011, Class A, Group 1, conducted1
2 2 24
ng hoa 0.15 MHz to 0.5 MHz

n gh o a
n gh o
< 79 dB (µV) Quasi-peak; < 66 dB (µV) Average a
g h o a
on
0.5 MHz to 5 MHz < 73 dB (µV) Quasi-peak; < 60 dB (µV) Average
o o
Tud d d
5 MHz to 30 MHz < 73 dB (µV) Quasi-peak; < 60 dB (µV) Average
EN 55011, Class A, Group 1, radiated1
30 MHz to 230 MHz
Tu
30 dB (µV/m) Quasi-peak; measured at 30 m
T u
230 MHz to 1 GHz 37 dB (µV/m) Quasi-peak; measured at 30 m
EN 55011, Class B, Group 1, conducted2 A
.c o m 0.15 to 0.5 MHz

. c o m . c m
< 66 dB (µV) Quasi-peak decreasing with log frequency to 56 dB (µV);
o
< 56 dB (µV) Average decreasing with log frequency to 46 dB (µV)
.
a24 24 24 24
0.5 MHz to 5 MHz < 56 dB (µV) Quasi-peak; < 46 dB (µV) Average

o hoa hoa oa
5 MHz to 30 MHz < 60 dB (µV) Quasi-peak; < 50 dB (µV) Average

ngh on g
EN 55011, Class B, Group 1, radiated2

d d on g o n gh
Tud
30 MHz to 230 kHz 30 dB (µV/m) Quasi-peak; measured at 10 m

T u
230 MHz to 1 GHz
T u
37 dB (µV/m) Quasi-peak; measured at 10 m
High Potential Isolation Test
24 V/5 V nominal circuits 500 VAC (optical isolation boundaries)
115/230 V circuits to ground 1,500 VAC

4 .c om 115/230 V circuits to 115/230 V circuits


4 . c om 1,500 VAC
4 . com 4.
2 2 a2 2
hoa a a
230 V circuits to 24 V/5 V circuits 1,500 VAC

ng gho
115 V circuits to 24 V/5 V circuits 1,500 VAC
gh o
ng ho
1
2
Tu don Tu d o n
Tu d o
Unit must be mounted on a grounded metallic frame with the S7-200 ground connection made directly to the mounting metal. Cables are routed along metallic supports.
Unit must be mounted in a grounded metal enclosure. AC input power line must be equipped with a EPCOS B84115–E–A30 filter or equivalent, 25 cm max. wire length
from filters to the S7-200. The 24 VDC supply and sensor supply wiring must be shielded.

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 339
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 CPU Specifications
o a2 o a2 o a 24
ng h ng h n gh g h
Table A-2
d o
CPU Order Numbers
ud o d on
Tu
Order Number CPU Model
CPU Power Supply
(Nominal)
T CPU Inputs CPU Outputs T u
Removable
Connector
6ES7 211–0AA22–0XB0 CPU 221 24 VDC 6 x 24 VDC 4 x 24 VDC No

. co m
6ES7 211–0BA22–0XB0 CPU 221

.c o m
120 to 240 VAC 6 x 24 VDC 4 x Relay

. c o m No

24
6ES7 212–1AB22–0XB0 CPU 222
4 24 VDC 8 x 24 VDC
4
6 x 24 VDC No
4.
hoa
6ES7 212–1BB22–0XB0
oa2
CPU 222
h
120 to 240 VAC 8 x 24 VDC

gh oa2 6 x Relay No
ho a2
ng 6ES7 214–1AD22–0XB0
d o ng CPU 224 24 VDC
n
14 x 24 VDC
o 10 x 24 VDC Yes
ong
6ES7 214–1BD22–0XB0
6ES7 216–2AD22–0XB0
T u CPU 224
CPU 226
120 to 240 VAC
24 VDC
T ud
14 x 24 VDC
24 x 24 VDC
10 x Relay
16 x 24 VDC
Tu
Yes
Yes
d
6ES7 216–2BD22–0XB0 CPU 226 120 to 240 VAC 24 x 24 VDC 16 x Relay Yes
6ES7 216–2AF22–0XB0 CPU 226XM 24 VDC 24 x 24 VDC 16 x 24 VDC Yes

4 .c om
6ES7 216–2BF22–0XB0 CPU 226XM
4 .c om120 to 240 VAC 24 x 24 VDC
4 .com
16 x Relay Yes
.
2 2 oa2 24
ng hoa Table A-3
g h oa
CPU General Specifications
ng h g h o a
Order Number
u d on Module Name and Description
u d o
Dimensions (mm)
Weight Dissipation
VDC Available
u d on
6ES7 211–0AA22–0XB0
T CPU 221 DC/DC/DC 6 Inputs/ 4 Outputs
T (W x H x D)
90 x 80 x 62 270 g 3W
+5 VDC
0 mA
T
+24 VDC
180 mA
6ES7 211–0BA22–0XB0 CPU 221 AC/DC/Relay 6 Inputs/ 4 Relays 90 x 80 x 62 310 g 6W 0 mA 180 mA

om om om
6ES7 212–1AB22–0XB0 CPU 222 DC/DC/DC 8 Inputs/ 6 Outputs 90 x 80 x 62 270 g 5W 340 mA 180 mA

2 4 .c
6ES7 212–1BB22–0XB0
4 . c
CPU 222 AC/DC/Relay 8 Inputs/ 6 Relays 90 x 80 x 62 310 g
4 .
7Wc 340 mA 180 mA
4.
hoa
6ES7 214–1AD22–0XB0

gh oa2
CPU 224 DC/DC/DC 14 Inputs/ 10 Outputs 120.5 x 80 x 62
hoa
360 g 2 7W 660 mA 280 mA
hoa 2
ng 6ES7 214–1BD22–0XB0
o n CPU 224 AC/DC/Relay14 Inputs/ 10 Relays
on
120.5 x 80 x 62 g 410 g 10 W 660 mA 280 mA
o ng
6ES7 216–2AD22–0XB0
6ES7 216–2BD22–0XB0
Tud CPU 226 DC/DC/DC 24 Inputs/16 Outputs
CPU 226 AC/DC/Relay 24 Inputs/16 Relays
T u d
196 x 80 x 62
196 x 80 x 62
550 g
660 g
11 W
17 W
1000 mA
1000 mA
Tud
400 mA
400 mA
6ES7 216–2AF22–0XB0 CPU 226XM DC/DC/DC 24 Inputs/16 Outputs 196 x 80 x 62 550 g 11 W 1000 mA 400 mA
6ES7 216–2BF22–0XB0 CPU 226XM AC/DC/Relay 24 Inputs/16 Relays 196 x 80 x 62 660 g 17 W 1000 mA 400 mA

.com
24 Table A-4 24 .com 24 .com 24.
h o a CPU Specifications
h o a h o a h o a
ng d o ng CPU 221 CPU 222

d o ng CPU 224 CPU 226 CPU 226XM

d on g
Memory
T
User program size (EEPROM)
u 2048 words T u 4096 words 4096 words T u
8192 words

A User data (EEPROM) 1024 words (stored permanently) 2560 words


(stored permanently)
2560 words
(stored
5120 words
(stored

.c o m . c o m . c o m
permanently) permanently)
.
a24 24 24 24
Backup (super cap) 50 hours typical (8 hours min. at 40°C) 190 hours typical (120 hours min. at 40°C)

o hoa hoa oa
(optional battery) 200 days typical 200 days typical

ngh I/O

d on g
d on g o n gh
u u Tud
Built-in digital inputs/outputs 6 inputs/4 outputs 8 inputs/6 outputs 14 inputs/10 outputs 24 inputs/16 outputs
Digital I/O image sizeT 256 (128 In/128 Out) T
Analog I/O image size None 32 (16 In/16 Out) 64 (32 In/32 Out)
Max. expansion modules None 2 modules 7 modules
allowed

.co m .co m . com


a2 4 Max. intelligent modules allowed None

a 2 4 2 modules 7 modules

a2 4 a2 4.
o Pulse Catch inputs 6

gho
8 14
o ho
ng h High-Speed Counters
Single phase
don
4 counters total
4 at 30 kHz n gh
6 counters total

d o
6 at 30 kHz
d ong
Two phase
Pulse outputs
Tu 2 at 20 kHz
2 at 20 kHz (DC outputs only)
Tu 4 at 20 kHz
Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
340
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
Technical Specifications Appendix A

4 .c om 4 .co m
4. c om .
o a2 o a 2
CPU 221 CPU 222

o a2
CPU 224 CPU 226 CPU 226XM

o a 24
ngh gh gh h
General

on on on g
ud ud d
Timers 256 total timers; 4 timers (1 ms); 16 timers (10 ms); 236 timers (100 ms)
Counters
T T
256 (backed by super capacitor or battery)
T u
Internal memory bits 256 (backed by super capacitor or battery)
Stored on power down 112 (stored to EEPROM)
Timed interrupts 2 with 1 ms resolution

.com c o m c o m
Edge interrupts 4 up and/or 4 down

24 24 . . 4.
a24 2
Analog adjustment 1 with 8 bit resolution 2 with 8 bit resolution

h o a Boolean execution speed


hoa
0.37 µs per instruction
ho ho a
ng Time-of-Day clock
don
g Optional cartridge
do n gBuilt-in
d ong
Tu
Cartridge options
Communications Built-in
Tu
Memory, battery and Time-of-Day Clock Memory and battery
Tu
Ports 1 RS–485 port 2 RS–485 ports

.co m
PPI, DP/T baud rates
Freeport baud rates
9.6, 19.2, 187.5 kbaud

.co
1.2 kbaud to 115.2 kbaud
m .co m .
a 2 4 Max. cable length per segment
a 2 4 a 2 4
With isolated repeater: 1000 m up to 187.5 kbaud, 1200 m up to 38.4 kbaud
a 24
o o o o
ngh gh gh g h
Without isolated repeater: 50 m

d
Max. number of stations
o n 32 per segment, 126 per network
d o n d on
Tu
Max. number of masters
Peer to Peer (PPI Master Mode)
32
Yes (NETR/NETW)
Tu T u
MPI connections 4 total, 2 reserved (1 for a PG and 1 for an OP)

4 .c om
Table A-5 CPU Power Specifications
4 .co m
4 .co m
4.
o a2 oa 2 DC
o a 2 AC
hoa 2
ngh Input Power

do ngh
d o n gh o ng
Tu Tu Tud
Input voltage 20.4 to 28.8 VDC 85 to 264 VAC (47 to 63 Hz)
Input current CPU only at Max. load at CPU only Max. load
24 VDC 24 VDC
CPU 221 80 mA 450 mA 30/15 mA at 120/240 VAC 120/60 mA at120/240 VAC

om om om
CPU 222 85 mA 500 mA 40/20 mA at 120/240 VAC 140/70 mA at 120/240 VAC

2 4 . c CPU 224 110 mA


2 4 .c 700 mA
.
60/30 mA at 120/240 VAC
2 4 c 200/100 mA at 120/240VAC
24.
hoa hoa hoa a
CPU 226/CPU 226XM 150 mA 1050 mA 80/40 mA at 120/240 VAC 320/160 mA at 120/240VAC

h o
ng Inrush current

d o ng 10 A at 28.8 VDC

d o ng 20 A at 264 VAC

d on g
T u
Isolation (field to logic)
Hold up time (loss of power)
Not isolated
10 ms at 24 VDC T u 1500 VAC
20/80 ms at 120/240 VAC T u
Fuse (non-replaceable) 3 A, 250 V Slow Blow 2 A, 250 V Slow Blow
24 VDC Sensor Power A
.c o m Sensor voltage
c o m
L+ minus 5 V
.
20.4 to 28.8 VDC
. c o m .
o a24 Current limit

hoa
24
1.5 A peak, thermal limit non-destructive

hoa
24 oa 24
ngh g g gh
Ripple noise Derived from input power Less than 1 V peak-to-peak

don
Isolation (sensor to logic)

Tu
Not isolated

T u d on
Tud
o n
Table A-6 CPU Input Specifications
General 24 VDC Input

.co m
Type
.co m
Sink/Source (IEC Type 1 Sink)
. com
a2 4 Rated voltage
a 2 4 24 VDC at 4 mA typical
a2 4 a2 4.
o gho
Max. continuous permissible voltage 30 VDC
o ho
ng h Surge voltage

don
35 VDC for 0.5 s

d o n gh
d ong
Tu Tu Tu
Logic 1 (min.) 15 VDC at 2.5 mA
Logic 0 (max.) 5 VDC at 1 mA
Input delay Selectable (0.2 to 12.8 ms)
CPU 226, CPU 226XM: points I1.6 to I2.7 have fixed delay (4.5 ms)

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 341
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
S7-200 Programmable Controller System Manual

.c m
oA-6 .co m . c om .
a2 4 Table CPU Input Specifications, continued
a 2 4 a2 4 a 24
o o o o
ngh gh gh g h
General 24 VDC Input

on on on
ud ud d
Connection of 2 wire proximity sensor
(Bero)
T
Permissible leakage 1 mA
T T u
current (max.)
Isolation (field to logic) Yes

. co m Optical (galvanic)

.c m
500 VAC for 1 minute
o . c o m
24
Isolation groups
24
See wiring diagram

a24 2 4.
hoa hoa a
High speed input rate (max.) Single phase Two phase

ng
Logic1 = 15 to 30 VDC
g 20 kHz 10 kHz
gho ng ho
Logic1 = 15 to 26 VDC
Inputs on simultaneously
Tu don 30 kHz
All at 55° C
20 kHz

Tu do n
Tu d o
Cable length (max.)
Shielded 500 m normal inputs, 50 m HSC inputs
Unshielded 300 m normal inputs

.c m
oA-7 .co m .co m .
2 4 Table CPU Output Specifications
2 4 2 4 24
ng hoa General
n gh o a 24 VDC Output
n gh o a Relay Output
g h o a
Type
d o Solid State-MOSFET1
d o Dry contact
d on
Rated voltage
Voltage range
Tu 24 VDC
20.4 to 28.8 VDC
Tu 24 VDC or 250 VAC
5 to 30 VDC or 5 to 250 VAC
T u
Surge current (max.) 8 A for 100 ms 7 A contacts closed

4 .c om
Logic 1 (min.)
Logic 0 (max.)
4 . om
20 VDC at maximum current
c
0.1 VDC with 10 K Ω Load


4 .co m
4.
2 oa2 2 2
ng hoa Rated current per point (max.)

ngh
0.75 A

n gh
2.0 A
o a
ng hoa
Rated current per common (max.)
do 6A
d o 10 A
o
Leakage current (max.)
Lamp load (max.)
Tu 10 µ A
5W
Tu –
30 W DC; 200 W AC
Tud
Inductive clamp voltage L+ minus 48 VDC, 1 W dissipation –
0.3 Ω max. 0.2 Ω (maximum when new)

.com .com m
On State resistance (contact)

.co .
a24 a24 4 24
Isolation

o Optical (galvanic, field to logic)


o 500 VAC for 1 minute –
o a 2 o a
ngh Logic to contact
o n gh –
o n gh 1500 VAC for 1 minute
on g h
Tud d d
Contact to contact – 750 VAC for 1 minute
Resistance (logic to contact)
Isolation groups

See wiring diagram
Tu 100 M Ω
See wiring diagram
T u
A Delay Off to On/On to Off (max.) 2/10 µs (Q0.0 and Q0.1)
15/100 µs (all other)

.c o m Switching (max.) –
. c o m 10 ms
. c o m .
o a24 Pulse frequency (max.) Q0.0 and Q0.1

hoa
24
20 kHz 1 Hz

hoa
24 oa 24
ngh g g gh
Lifetime mechanical cycles – 10,000,000 (no load)
Lifetime contacts

Tu
Outputs on simultaneously
don –
All at 55° C Tu don 100,000 (rated load)
All at 55° C Tud
o n
Connecting two outputs in parallel Yes No
Cable length (max.)

om om om
Shielded 500 m 500 m

2 4 .c Unshielded 150 m

2 4 . c 150 m
4 . c 4.
hoa
1
a a2
When a mechanical contact turns on output power to the S7-200 CPU, or any digital expansion module, it sends a “1” signal to the digital outputs for approximately
a2
gho o ho
50 microseconds. You must plan for this, especially if you are using devices which respond to short duration pulses.

ng gh ng
Tu don Tu d o n
Tu d o

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
342
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
Technical Specifications Appendix A

4 .c om Wiring Diagrams 4 .c om 4. c om .
o a2 o a2 o a2 o a 24
ng h ng h n gh g h
d o 24 VDC Input
ud o
24 VDC Input
d on
Tu Used as Sinking Inputs T Used as Sourcing Inputs T u
+
+

. co m .c o m . c o m
24 24 a24 2 4.
ng hoa g hoa gho ng ho a
don n
1M .0 .1 .2 .3

do o
1M .0 .1 .2 .3

Tu Tu Tu d

.co m .co m .co m .


a 2 4 a 2 4 a 2 4 a 24
o o
24 VDC Output Relay Output
o o
ngh d o n gh
d o n gh
d on g h
Tu Tu T u
+

N(–)

L(+)

4 .c om 4 .co m
4 .co m
4.
o a2 1M 1L+ .0
oa 2 .1 .2
o a 2
hoa 2
ngh gh gh g
1L .0 .1 .2

do n d o n o n
Tu Tu Tud

.co m Figure A-2 CPU Inputs and Outputs


.co m .co m .
a 2 4 a 2 4 a 2 4 a 24
o o o o
ngh o n gh
CPU 221 DC/DC/DC
o n gh CPU 221 AC/DC/Relay
on g h
Tud d d
(6ES7 211–0AA22–0XB0) (6ES7 211–0BA22–0XB0)
24 VDC Power
Tu T u
120/240 VAC Power

N(–) N(–)

L(+) L(+)
A
m m m
+ +

.c o . c o . c o .
o a24 hoa
24
hoa
24 oa 24
ngh M

d o ng
L+ 0.0 0.1 0.2 0.3 M L+ DC

d o ng 1L 0.0 0.1 0.2 2L 0.3 N L1


o
AC
n gh
1M 0.0 T u
0.1 0.2 0.3 2M 0.4 0.5 M L+ T u 1M 0.0 0.1 0.2 0.3 2M 0.4 0.5 M Tud
L+

.co m .co m . com


a2 4 a 2 4 a2 4 24 VDC
a2 4.
o gho
24 VDC Sensor
o ho
+ + + +
Sensor Power

ng h gh ng
Power Output
Output

Figure A-3 don


u 221 Wiring Diagrams
TCPU 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 343
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 .co m
4. c om .
oa2 CPU 222 DC/DC/DC
o a 2 CPU 222 AC/DC/Relay
o a2 o a 24
ngh gh gh h
(6ES7 212–1AB22–0XB0) 24 VDC Power (6ES7 212–1BB22–0XB0) 120/240 VAC Power

on on on g
T ud N(–)

T ud N(–)

T u d
+ + L(+) L(+)

. co m .c o m . c o m
24
M L+ 0.0 0.1 0.2 0.3 0.4 0.5
24
M L+ DC 1L 0.0 0.1 0.2
a24
2L 0.3 0.4 0.5 N L1 AC
2 4.
ng hoa g hoa gho ng ho a
don n
1M 0.0 0.1 0.2 0.3 2M 0.4 0.5 0.6 0.7 M L+ 1M 0.0 0.1 0.2 0.3 2M 0.4 0.5 0.6 0.7 M L+

Tu Tu do Tu d o

24 VDC Sensor

om m m
+ + +

.co .co
+
Power Output

2 4 .c 2 4 2 4
24 VDC Sensor
Power Output
24 .
ng hoa n gh o a
n gh o a
g h o a
d o CPU 224 DC/DC/DC
d o d on
Tu Tu u
(6ES7 214–1AD22–0XB0)
24 VDC Power
T
+ + +

4 .c om 4 .co m
4 .co m
4.
o a2 oa 2 o a 2
hoa 2
ngh do ngh 1M 1L+ 0.0 0.1 0.2 0.3 0.4 2M 2L+ 0.5 0.6 0.7 1.0 1.1

d o n gh M L+ DC

o ng
Tu Tu
1M 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 2M 1.0 1.1 1.2 1.3 1.4 1.5 M L+
Tud

.co m .co m .co m .


a 2 4 +
a 2 4 +
2 4
24 VDC Sensor
a a 24
o o o Power Output
o
ngh o n gh o n gh on g h
Tud CPU 224 AC/DC/Relay
Tu
(6ES7 214–1BD22–0XB0)
d 120/240 VAC Power T u d
A N(–) N(–) N(–)

.c o m L(+)

. c o m
L(+) L(+)

. c o m .
o a24 hoa
24
hoa
24 oa 24
ngh d on g
d on g o n gh
Tud
1L 0.0 0.1 0.2 0.3 2L 0.4 0.5 0.6 3L 0.7 1.0 1.1 N L1 AC

T u T u
1M 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 2M 1.0 1.1 1.2 1.3 1.4 1.5 M L+

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h gh ng
+ + 24 VDC Sensor

don o n o
Power Output

Tu Tu d Tu d
Figure A-4 CPU 222 and CPU 224 Wiring Diagrams

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
344
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
Technical Specifications Appendix A

4 .c om 4 .co m
4. c om .
oa2 o a 2 CPU 226 DC/DC/DC (6ES7 216–2AD22–0XB0)
o a2 o a 24
ngh gh gh g h
CPU 226XM DC/DC/DC (6ES7 216–2AF22–0XB0)

on on 24 VDC Power
on
T ud T ud T u d
+ + +

. co m .c o m . c o m
24 24 a24 2 4.
hoa hoa a
M 1L+ 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 2M 2L+ 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 M L+ DC

ng g gho ng ho
Tu don 1M 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 1.0 1.2 1.2 1.3 1.4

Tu do n 2M 1.5 1.6 1.7 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7

Tu dM
o L+

.co m +

.co m +

.co m .
a 2 4 a 2 4 a 2 4 a 24
o o o 24 VDC
o
ngh gh gh g h
Sensor Power Output

d o n d o n d on
Tu Tu
CPU 226 AC/DC/Relay (6ES7 216–2BD22–0XB0)
CPU 226XM AC/DC/Relay (6ES7 216–2BF22–0XB0)
T u
N(–) N(–) N(–)
120/240 VAC

4 .c om L(+) L(+)
.com L(+)
.com
Power

4.
2 24 24 2
ng hoa ngh oa
g h o a
g hoa
do d on o n
Tu 1L 0.0 0.1 0.2 0.3 2L 0.4 0.5 0.6 0.7 1.0
T u3L 1.1 1.2 1.3 1.4 1.5 1.6 1.7 M L+ DC
Tud
1M 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 1.0 1.2 1.2 1.3 1.4 2M 1.5 1.6 1.7 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 M L+

.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
24 VDC
Sensor Power Output
Figure A-5 CPU 226 and CPU 226XM Wiring Diagrams
A
.c o m Table A-8
. c o m
Pin Assignments for the S7-200 Communications Port
. c o m .
o a24 Connector
o a 24
Pin Number PROFIBUS Signal
hoa
2Port40/Port 1 oa 24
ngh d on gh 1 Shield
d on g Chassis ground
o n gh
T u
Pin 1
2
3
T
24 V Return u
RS-485 Signal B
Logic common
RS-485 Signal B
Tud
Pin
4 Request-to-Send RTS (TTL)

4 .c om 46.c
om5 5 V Return

4 . com
Logic common
+5 V, 100 Ω series resistor 4.
2 2 +5 V
a2 2
hoa a a
Pin

ng
Pin 5
gho 7 +24 V
gh o +24 V
ng ho
Tu don 8
9
ud
RS-485 Signal
Not T
o
applicable
An RS-485 Signal A
Tu
10-bit protocol select (input)
d o
Connector shell Shield Chassis ground

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 345
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 Digital Expansion Modules
o a2 Specifications
o a2 o a 24
ng h h
g Order Numbers
nModules ng h g h
Table A-9
d o
Digital Expansion
d o d on
Tu
Order Number Tu Expansion Model EM Inputs EM Outputs T u
Removable
Connector
6ES7 221–1BF22–0XA0 EM 221 Digital Input 8 x 24 VDC 8 x 24 VDC – Yes

. co m
6ES7 221–1EF22–0XA0

.c o m
EM 221 Digital Input 8 x AC 120/230 V 8 x AC 120/230V –

. c o m Yes

24
6ES7 222–1BF22–0XA0
2 4
EM 222 Digital Output 8 x 24 VDC –

a2 48 x 24 VDC Yes
2 4.
hoa hoa o ho a
6ES7 222–1HF22–0XA0 EM 222 Digital Output 8 x Relays – 8 x Relay Yes

ng ng h
ong ng
6ES7 222–1EF22–0XA0 EM 222 Digital Output 8 x AC 120/230 V – 8 x AC 120/230 V Yes

d o o
6ES7 223–1BF22–0XA0
6ES7 223–1HF22–0XA0
T u EM 223 24 VDC Digital Combination 4 Inputs/4 Outputs
Tud
EM 223 24 VDC Digital Combination 4 Inputs/4 Relay Outputs
4 x 24 VDC
4 x 24 VDC
4 x 24 VDC
4 x Relay
Tu
Yes
Yes
d
6ES7 223–1BH22–0AX0 EM 223 24 VDC Digital Combination 8 Inputs/8 Outputs 8 x 24 VDC 8 x 24 VDC Yes
6ES7 223–1PH22–0XA0 EM 223 24 VDC Digital Combination 8 Inputs/8 Relay Outputs 8 x 24 VDC 8 x Relay Yes

4 .c om
6ES7 223–1BL22–0XA0
.c om
EM 223 24 VDC Digital Combination 16 Inputs/16 Outputs
4
16 x 24 VDC
4 .com
16 x 24 VDC Yes
.
2 2 oa2 24
hoa hoa a
6ES7 223–1PL22–0XA0 EM 223 24 VDC Digital Combination 16 Inputs/16 Relay 16 x 24 VDC 16 x Relay Yes
Outputs
h h o
ng d o ng d o ng d on g
Table A-10
Tu Modules General Specifications
Digital Expansion
Dimensions (mm)
T u
VDC Requirements
T u
Order Number Module Name and Description Weight Dissipation
(W x H x D) +5 VDC +24 VDC
6ES7 221–1BF22–0XA0 EM 221 DI 8 x 24 VDC 46 x 80 x 62 150 g 2W 30 mA –

4 .c om
6ES7 221–1EF22–0XA0

4 .co
EM 221 DI 8 x AC 120/230 V m
71.2 x 80 x 62 160 g 3W

4 .co
30 mA m–

4.
o a2 6ES7 222–1BF22–0XA0
oa 2
EM 222 DO 8 x 24 VDC 46 x 80 x 62 150 g 2W
o a 2 50 mA –

hoa 2
ngh gh gh g
6ES7 222–1HF22–0XA0 EM 222 DO 8 x Relays 46 x 80 x 62 170 g 2W 40 mA ON: 9 mA/output,

do n d o n o
20.4 to 28.8 VDC n
6ES7 222–1EF22–0XA0
6ES7 223–1BF22–0XA0
Tu EM 222 DO 8 x AC 120/230 V
EM 223 24 VDC 4 In/4 Out
71.2 x 80 x 62
46 x 80 x 62
Tu 165 g
160 g
4W
2W
110 mA
40 mA


Tud
6ES7 223–1HF22–0XA0 EM 223 24 VDC 4 In/4 Relays 46 x 80 x 62 170 g 2W 40 mA ON: 9 mA/output,
20.4 to 28.8 VDC

4 . c om
6ES7 223–1BH22–0AX0 EM 223 24 VDC 8 In/8 Out

4 .c om 71.2 x 80 x 62 200 g 3W

4 .c om
80 mA –
.
2 6ES7 223–1PH22–0XA0
2
EM 223 24 VDC 8 In/8 Relays 71.2 x 80 x 62 300 g 3W
2 80 mA ON: 9 mA/output,
24
ng hoa g hoa g hoa 20.4 to 28.8 VDC
g h o a
6ES7 223–1BL22–0XA0

ud on EM 223 24 VDC 16 In/16 Out 137.3 x 80 x 62

u d on
360 g 6W 160 mA –

u d on
6ES7 223–1PL22–0XA0
T EM 223 24 VDC 16 In/16 Relays 137.3 x 80 x 62
T 400 g 6W 150 mA
T
ON: 9 mA/output,
20.4 to 28.8 VDC

A Table A-11 Digital Expansion Modules Input Specifications

.c o m General
. c o m24 VDC Input
. c o m
120/230 VAC Input (47 to 63 HZ)
.
o a24 Type

hoa
24
Sink/Source (IEC Type 1 sink)

hoa
IEC Type I 24 oa 24
ngh Rated voltage

don
g 24 VDC at 4 mA

don
g 120 VAC at 6 mA or 230 VAC at 9 mA nominal
o n gh
Tu Tu Tud
Maximum continuous permissible 30 VDC 264 VAC
voltage
Surge voltage (max.) 35 VDC for 0.5 s –
Logic 1 (min.) 15 VDC at 2.5 mA 79 VAC at 2.5 mA

om om om
Logic 0 (max.) 5 VDC at 1 mA 20 VAC or 1 mA AC

2 4 .c Input delay (max.) 4.5 ms


2 4 . c 15 ms
4 . c 4.
hoa a a2 a2
gho o ho
Connection of 2 wire proximity sensor

ng (Bero)
gh ng
Permissible leakage
current (max.)
Tu don 1 mA

Tu d o n 1 mA AC

Tu d o
Isolation
Optical (galvanic, field to logic) 500 VAC for 1 minute 1500 VAC for 1 minute
Isolation groups See wiring diagram 1 point

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
346
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
Technical Specifications Appendix A

4 .c om 4 .co m
4. c om .
oa2 Table A-11
a 2
Digital Expansion Modules Input Specifications, continued
o o a2 o a 24
ngh n gh
General
o
24 VDC Input
on gh 120/230 VAC Input (47 to 63 HZ)
on g h
T ud
Inputs on simultaneously
Cable length (max.)
All at 55° C
T ud All at 55° C
T u d
Shielded 500 m 500 m
Unshielded 300 m 300 m

. co m .c o m . c o m
24
Table A-12 Digital Expansion Modules Output Specifications
24 a24 2 4.
hoa hoa ho ho a
General 24 VDC Output Relay Output 120/230 VAC Output

ng Type
don
g Solid state-MOSFET1
do n g
Dry contact Triac, zero-cross turn-on2
d ong
Rated voltage
Voltage range
Tu 24 VDC
20.4 to 28.8 VDC
Tu 24 VDC or 250 VAC
5 to 30 VDC or 5 to 250 VAC
120/230 VAC
Tu
40 to 264 VAC (47 to 63 Hz)
24 VDC coil power voltage range – 20.4 to 28.8 VDC –
Surge current (max.) 8 A for 100 ms 7 A with contacts closed 5 A rms for 2 AC cycles

4 .c om Logic 1 (min.) 20 VDC


4 .c om –
4 .co m
L1 (–0.9 V rms)
.
2 2 2 24
hoa hoa o a o a
Logic 0 (max.) 0.1 VDC – –

ng g gh g h
don n on
Rated current per point (max.) 0.75 A 2.00 A 0.5 A AC3

d o d
Tu Tu u
Rated current per common (max.) 6A 8A 0.5 A AC
Leakage current (max.) 10 µA – T
1.1 mA rms at 132 VAC and
1.8 mA rhesus at 264 VAC
Lamp load (max.) 5W 30 W DC/200 W AC 60 W

4 .c om Inductive clamp voltage

4 . c om
L+ minus 48 V
0.3 Ω (maximum)

0.2 Ω maximum when new
4 . c om –
410 Ω maximum when load
4.
2 On state resistance (contact)
2 2 2
hoa oa hoa hoa
current is less than 0.05 A

ng g h g g
don on n
Isolation

d o
Tu u Tud
Optical (galvanic, field to logic) 500 VAC for 1 minute – 1500 VAC for 1 minute
Coil to logic
Coil to contact


T None
1500 VAC for 1 minute


Contact to contact – 750 VAC for 1 minute –
100 M Ω min. when new

.com .com m
Resistance (coil to contact) – –
Isolation groups See wiring diagram 4 points
.co 1 point
.
o a24 Delay Off to On/On to Off (max.)
o a24
50 µs max./200 µs –
o a 2 4 0.2 ms + 1/2 AC cycle
o a 24
ngh gh gh g h
Switching (max.) – 10 ms –

o n o n on
Tud d d
Switching frequency (max.) – 1 Hz 10 Hz
Lifetime mechanical cycles – Tu 10,000,000 (no load) – T u
Lifetime contacts – 100,000 (rated load) –
Output on simultaneously All at 55 °C All at 55 °C All at 55 °C A
.c o m Connecting two outputs in parallel Yes
. c o m No
. c o m No
.
a24 24 24 24
Cable length (max.)

ngh
o Shielded
g hoa 500 m 500 m
g hoa 500 m
gh oa
on on n
Unshielded 150 m 150 m 150 m

d d o
u u Tud
1 When a mechanical contact turns on output power to the S7-200 CPU, or any digital expansion module, it sends a “1” signal to the digital outputs for approximately

2
T T
50 microseconds. You must plan for this, especially if you are using devices which respond to short duration pulses.
When a mechanical contact turns on output power to the AC expansion module, it sends a “1” signal to the AC outputs for approximately 1/2 AC cycle. You must plan
for this.
3 Load current must be full wave AC and must not be half-wave because of the zero-cross circuitry. Minimum load current is 0.05 A AC. With a load current between 5 mA
and 50 mA AC, the current can be controlled, but there is an additional voltage drop due to series resistance of 410 Ohms.

.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 347
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 .co m
4. c om .
oa2 o a 2 o a2 o a 24
ngh gh gh g h
24 VDC Input 24 VDC Output Relay Output

on on on
ud ud d
Used as Sinking Inputs

T + T T u
+ N(–)

. co m .c o m L(+)

. c o m
24 2 4 a24 2 4.
ng hoa 1M .0 .1
g
.2 .3
hoa 1M 1L+ .0 .1 .2
gho ng ho a
don do n o
1L .0 .1 .2

Tu Tu Tu d

.co m .co m .co m .


a 2 4 24 VDC Input
a 2 4 120/230 AC Input
a 2 4 120/230 AC Output
a 24
o o o o
ngh gh gh h
Used as Sourcing Inputs

o n L1
o n N
on g
Tu+
d N
Tu d L1
T u d

4 .c om 1M .0 .1 .2 .3
4 .co m
4 .co
0L 0L
m
.0
4.
a2 2 2 2
0N 0N .0

o oa o a hoa
ngh do ngh
d o n gh o ng
Tu Tu Tud

om m m
Figure A-6 S7-200 Digital Expansion Modules Inputs and Outputs

2 4 . c 2 4 .co 2 4 .co 24.


ng hoa n gh o a
n gh o a
g h o a
o o on
Tud Tu d T u d
A
.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
348
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
Technical Specifications Appendix A

4 .c om 4 .co m
4. c om .
oa2
Wiring Diagrams
o a 2 o a2 o a 24
ngh on gh on gh on g h
T ud
EM 221 Digital Input 8 x 24 VDC
(6ES7 221–1BF22–0XA0) T ud
EM 222 Digital Output 8 x 24 VDC
(6ES7 222–1BF22–0XA0)
EM 222 Digital Output 8 x Relay
(6ES7 222 1HF22–0XA0) T u d
+ N(–)

. co m .c o m . c o m L(+)

24 2 4 a2 4 2 4.
ng hoa g hoa h o ho a
d on
1M .0 .1 .2 .3 1M 1L+ .0 .1
ong
.2 .3 1L .0 .1
ong
.2 .3

T u 2M .4 .5 .6 .7 Tud
2M 2L+ .4 .5 .6 .7 M L+ 2L .4 Tu
.5
d .6 .7

4 .c om 4 .c om 4 . c om L

.
24
+ (+)

2 2 2
hoa hoa hoa o a
+
+ 24 VDC Coil

ng g g power
N

g h
on on on
(–)

T u d EM 221 Digital Input 8 x AC 120//230 V


(6ES7 221–1EFF22–0XA0) T u d EM 222 Digital Output 8 x AC 120/230 V T u d
(6ES7 222–1EFF22–0CAB0)
L1 N
N L1

4 .c om 4 .com 4 .co m
4.
2 oa2 2 2
ng hoa ngh n gh o a
ng hoa
do d o o
Tu Tu Tud
0N 0N .0 1N 1N .1 2N 2N .2 3N 3N .3 0L 0L .0 1L 1L .1 2L 2L .2 3L 3L .3

4N .4 5N 5N .5 6N 6N .6 7N 7N .7 4L .4 5L 5L .5 6L 6L .6 7L 7L .7

.com .co m .co m .


a 2 4 a 2 4 a 2 4 a 24
o o o o
ngh gh gh g h
N L1

o n o n on
Tud d d
L1 N

Tu T u
EM 223 24 VDC Digital Combination 4 Inputs/ 4 Outputs EM 223 24 VDC Digital Combination 4 Inputs/4 Relay Outputs
(6ES7 223–1BF22–0CAB0) (6ES7 223–1HF22–0CAB0)
A
.c o m . c o m .
N(–)
c o m .
o a24 +

hoa
24
hoa
24 oa 24
ngh gh
L(+)

on g on g o n
T u d T u d Tud
1M 1L+ .0 .1 .2 .3 1L .0 .1 .2 .3

1M .0 .1 .2 .3 M L+ 1M .0 .1 .2 .3

4 .c om .com .com 4.
2 24 24 2
ng hoa gh oa
g h o a
ng ho a
u d on u d on 24 VDC Coil
d o
Tu
Power
T T
+ + +

Figure A-7 Wiring Diagrams for EM 221, EM 222, and EM 223 Expansion Modules

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 349
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 .co m
4. c om .
oa2 EM 223 24 VDC Digital Combination 8 Inputs/8 Outputs
o a 2 o a2
EM 223 24 VDC Digital Combination 8 Inputs/8 Relay Outputs
o a 24
ngh gh gh g h
(6ES7 223–1BH22–0XA0) (6ES7 223–1PH22–0XA0)

on on on
T ud T ud N(–)
N(–)
T u d
+ +
L(+) L(+)

. co m .c o m . c o m
24 24 a24 2 4.
ng hoa 1M 1L+ .0 .1

g
.2 .3
hoa 2M 2L+ .4 .5 .6 .7

gho 1M 1L .0 .1 .2 .3 2L .4 .5 .6 .7

ng ho a
Tu don
1M .0 .1 .2 .3 2M .4 .5 .6 .7

Tu do n M L+ 1M .0 .1 .2 .3 2M .4 .5 .6

Tu
.7
d o

24VDC

4 .c om +

4 .c om Coil
Power
4 .co
+ m .
24
+ +

2 2 2
+

ng hoa g hoa gh o a
g h o a
Tu don EM 223 24 VDC Digital Combination 16 Inputs/16 Outputs
(6ES7 223–1BL22–0XA0)
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 1M 1L+ .0

do ngh .1 .2 .3 2M 2L+ .4 .5 .6 .7
n gh
3M 3L+ .0

d o
.1 .2 .3 .4 .5 .6 .7

o ng
Tu 1M .0 .1 .2 .3 .4 .5 .6 .7
Tu 2M .0 .1 .2 .3 .4 .5 .6 .7
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
EM 223 24 VDC Digital Combination 16 Inputs/16 Relay Outputs
A (6ES7 223–1PL22–0XA0)

.c o m N(–) N(–)

. c o m N(–) N(–)

. c o m .
o a24 L(+)

hoa
24
L(+) L(+)

hoa
L(+) 24 oa 24
ngh d on g
d on g o n gh
T u 1L .0 .1 .2 .3 2L .4 .5 .6 .7 T u3L .0 .1 .2 .3 4L .4 .5 .6 .7 Tud
M L+ 1M .0 .1 .2 .3 .4 .5 .6 .7 2M .0 .1 .2 .3 .4 .5 .6 .7

.co m .co m . com


a2 4 a 2 4 a2 4 a2 4.
o gho o ho
ng h 24VDC
Coil
don
+ +
d o n gh +
d ong
Power
Tu Tu Tu
Figure A-8 Wiring Diagrams for EM 223 Expansion Modules

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
350
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
Technical Specifications Appendix A

4 .c om 4 .c om 4. c om .
o a2 Analog Expansion
o a2
Modules Specifications
o a2 o a 24
ng h h
ng Modules Order Numbers ng h g h
Table A-13 Analogo
d Expansion
d o d on
Tu
Order Number Tu Expansion Model EM Inputs EM Outputs T u
Removable
Connector
6ES7 231–0HC22–0XA0 EM 231 Analog Input, 4 Inputs 4 – No

. co m 6ES7 232–0HB22–0XA0

.c o m
EM 232 Analog Output, 2 Outputs –

. c o m 2 No

24
6ES7 235–0KD22–0XA0 EM 235 Analog Combination 4 Inputs/1 Output
2 4 a2
4
4 11 No
2 4.
hoa hoa o ho a
1 The CPU reserves 2 analog output points for this module.

ng g h
d on ong ong
u Tud Tu d
Table A-14 Analog Expansion Modules General Specifications
T
Order Number Module Name and Description
Dimensions (mm)
Weight Dissipation
VDC Requirements
(W x H x D) +5 VDC +24 VDC
6ES7 231–0HC22–0XA0 EM 231 Analog Input, 71.2 x 80 x 62 183 g 2W 20 mA 60 mA
4 Inputs

.co m 6ES7 232–0HB22–0XA0


.co
EM 232 Analog Output, m 46 x 80 x 62 148 g 2W
.co m
20 mA 70 mA (with both
.
a 2 4 2 Outputs
a 2 4 a 2 4 outputs at 20 mA)
a 24
o o o o
ngh gh gh h
6ES7 235–0KD22–0XA0 EM 235 Analog Combination 71.2 x 80 x 62 186 g 2W 30 mA 60 mA (with

o n 4 Inputs/1 Output
o n on
output at 20 mA) g
Tu d Tu d T u d
Table A-15 Analog Expansion Modules Input Specifications
General 6ES7 231–0HC22–0XA0 6ES7 235–0KD22–0XA0

4 .c om Data word format

4 .co m
(See Figure A-11)
.co
(See Figure A-11)

4
m
4.
a2 2 2 2
Bipolar, full-scale range –32000 to +32000 –32000 to +32000

o Unipolar, full-scale range


oa 0 to 32000
o a0 to 32000
hoa
ngh DC Input impedance

do ngh ≥10 MΩ voltage input,

d o n gh ≥ 10 MΩ voltage input,
o ng
Tud
250 Ω current input 250 Ω current input

Tu
Input filter attenuation
Maximum input voltage
–3 db at 3.1 Khz
30 VDC
Tu –3 db at 3.1 Khz
30 VDC
Maximum input current 32 mA 32 mA
Resolution 12 bit A/D converter 12 bit A/D converter

.co m Isolation (field to logic)


Input type
.co
None
m
Differential
None

.co
Differential m .
a 2 4 Input ranges
a 2 4 a 2 4 a 24
o o o o
ngh gh gh g h
Voltage (unipolar) 0 to 10 V, 0 to 5 V 0 to 10 V, 0 to 5 V

o n o n 0 to 1 V, 0 to 500 mV,
on
Tud Tu d u d
0 to 100 mV, 0 to 50 mV
Voltage (bipolar) ±5 V, ± 2.5 V T
±10 V, ±5V, ±2.5 V, ±1 V, ±500 mV, ±250 mV,
±100 mV, ±50 mV, ±25 mV

Current
Input resolution
0 to 20 mA
See Table A-18
0 to 20 mA
See Table A-19
A
.c o m Voltage (unipolar)
. c o m . c o m .
o a24 Voltage (bipolar)

hoa
24
hoa
24 oa 24
ngh gh
Current

on g
Analog to digital conversion time < 250 µs
on g < 250 µs
o n
T u d
Analog input step response
Common mode rejection
1.5 ms to 95%
40 dB, DC to 60 Hz T u d 1.5 ms to 95%
40 dB, DC to 60 Hz Tud
Common mode voltage Signal voltage plus common mode voltage Signal voltage plus common mode voltage
must be ≤ ±12 V must be ≤ ±12 V
24 VDC supply voltage range 20.4 to 28.8 20.4 to 28.8

4 .c om 4 .co m
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 351
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
S7-200 Programmable Controller System Manual

.c m
oA-16 .co m . c om .
a2 4 Table
a 2 4
Analog Expansion Modules Output Specifications
a2 4 a 24
o o o o
ngh General
on gh 6ES7 232–0HB22–0XA0
on gh 6ES7 235–0KD22–0XA0
on g h
ud ud d
Isolation (field to logic) None None
Signal range
T T T u
Voltage output ± 10 V ± 10 V
Current output 0 to 20 mA 0 to 20 mA
Resolution, full-scale

. co m Voltage 12 bits
.c o m 12 bits
. c o m
24 Current
24
11 bits 11 bits
a24 2 4.
hoa hoa ho ho a
Data word format

ng Voltage

don
g –32000 to +32000

do n g –32000 to +32000

d ong
Tu Tu Tu
Current 0 to +32000 0 to +32000
Accuracy
Worst case, 0° to 55° C
Voltage output ± 2% of full-scale ± 2% of full-scale
Current output ± 2% of full-scale ± 2% of full-scale

4 .c om
Typical, 25° C
4 .c om 4 .co m .
2 2
± 0.5% of full-scale
2
± 0.5% of full-scale
24
hoa hoa a a
Voltage output
± 0.5% of full-scale
gh o
± 0.5% of full-scale
h o
ng g g
Current output

don o n on
Setting time

Tu
Voltage output 100 µS
Tu d 100 µS
T u d
Current output 2 mS 2 mS
Maximum drive
Voltage output 5000 Ω minimum 5000 Ω minimum

om om m
Current output 500 Ω maximum 500 Ω maximum

2 4 .c 4 . c 4 .co 4.
hoa gh oa2 gh o a 2
hoa 2
ng do n d o n o ng
Tud
EM 231 Analog Input, EM 235 Analog Combination EM 232 Analog Output,
4 Inputs
Tu
(6ES7 231–0HC22–0XA0)
4 Inputs/1 Output
(6ES7 235–0KD22–0XA0) Tu 2 Outputs
(6ES7 232–0HB22–0XA0)

V LOAD

I LOAD
V LOAD

I LOAD
+– +–

.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
RA A+ A– RB B+ B– RC C+ C– RD D+ D– RA A+ A– RB B+ B– RC C+ C– RD D+ D–
Tu d M0 V0 I0 M1 V1 L1
T u d
M L+ Gain Configuration M L+ M0 V0 I0 Gain Offset Configuration M L+

A
.c o m . c o m . c o m .
o a24 hoa
24
hoa
24 oa 24
V LOAD

ngh gh
I LOAD

+
g g
+ +

d on d on o n
24
VDC
T u 24
VDC
T u 24
VDC
Tud
Power Power Power

4 .c om
Figure A-9
4 .co
Wiring Diagrams for Analog Expansion Modules
m
4 . com 4.
o a2 a 2 a2 a2
ng h 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
352
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
Technical Specifications Appendix A

4 .c om 4 .co m
4. c om .
oa2
Analog LED Indicators
a 2 a2 a 24
ngh ho gh
The LED indicators for the analog modules are shown in Table A-17.
n g n
o g h o
do Analog LED Indicators ud o d on
TuA-17
Table
LED Indicator
T
ON OFF
T u
24 VDC Power Supply Good No faults No 24 VDC power

. co m .c o m . c o m
a24 Input Calibration
a 24affect the instrumentation amplifier stagea 2 4follows the analog multiplexer a2 4.
o hoDiagram for the EM 231 in Figure A-12nand
The calibration adjustments
hEMo 235 in Figure A-13). Therefore, ngho
that
ngh (see the Input g
d n Block
ocircuit preceding the analog multiplexeruwilldcause g
o slightvariations in the component values ofo
calibration
T
eachu input
affects all user input channels. Even
T
after calibration,
differences in the readingsT ud
between
channels connected to the same input signal.

To meet the specifications, you should enable analog input filters for all inputs of the module. Select 64 or

.co m .co m
more samples to calculate the average value.
.co m .
a 2 4 2 4
To calibrate the input, use the following steps.
a a 2 4 a 24
o ho ho o
ngh 1.
n g n g
Turn off the power to the module. Select the desired input range.
d o d o d o n g h
T2.3. uTurn on the power to the CPU and module. u
T Allow the module to stabilize for 15 minutes. u
T
Using a transmitter, a voltage source, or a current source, apply a zero value signal to one of the
input terminals.

4 .c om 4.

4 . om
Read the value reported to the CPU by the appropriate input channel.
c 4 . c om 4.
o a 2 5.
a 2
o value signal to one of the input terminals. a 2
Adjust the OFFSET potentiometer until the reading is zero, or the desired digital data value.
a 2
ngh
6. Connect a h
n g full-scale
n g ho Read the value reported to the CPU.ngho
o the GAIN potentiometer until the reading iso32000, or the desired digital data value. do
Tud Tud Tu
7. Adjust
8. Repeat OFFSET and GAIN calibration as required.

Calibration and Configuration Location for EM 231 and EM 235

4 . c om 4 .co m
4 .co m
Figure A-10 shows the calibration potentiometer and configuration DIP switches located on the right of the
.
2 bottom terminal block of the module.
2 2 24
ng hoa n gh o a
n gh o a
g h o a
o o on
Tud Tu d T u d
A
.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 353
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 .co m
4. c om .
o a2
EM 231
o a 2 o a2
EM 235
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
↑On ↑On
↓Off ↓Off

.co m .co m .co m .


a 2 4 a 2 4 a 2 4 a 24
o oGain o o
ngh o n gh
Fixed Terminal Block
d
Configuration
d o n gh
Fixed Terminal Block Gain Offset Configuration
d on g h
TuCalibration Potentiometer and Configuration DIPTSwitch
Figure A-10 u Location for the EM 231 and EM 235 T u

.c omConfiguration for EM 231


. c om 231 module using the configuration DIP.c om Switches 1,
a 2 4 a
2, and 3 select the analog input2 4
Table A-18 shows how to configure the EM
2 4
range. All inputs are set to the same analogainput
switches.
range. In this table, ON a 2 4.
o ho ho ho
ngh g g g
is closed, and OFF is open.
n
do231 Configuration Switch Table to Select Analog n
doRange o n
TuEM
Table A-18
Unipolar
TuInput Tud
Full-Scale Input Resolution
SW1 SW2 SW3
OFF ON 0 to 10 V 2.5 mV

4 .com ON
4 ON .com OFF
0 to 5 V

24 .com 1.25 mV

24.
oa2 oa2
0 to 20 mA 5 µA

o a o a
ngh gh h h
Bipolar

n g Full-Scale Input Resolution


g
don on
SW1 SW2 SW3
o
Tud Tu u d
OFF ON ±5 V 2.5 mV
OFF
ON OFF ± 2.5 V 1.25 mV T
A
.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
354
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
Technical Specifications Appendix A

4 .c om 4 .co m
4. c om .
oa2
Configuration for EM 235
o a 2 o a2 o a 24
ngh gh gh h
Table A-19 shows how to configure the EM 235 module using the configuration DIP switches. Switches 1
on on
through 6 select the analog input range and resolution. All inputs are set to the same analog input range
on g
ud ud
and format. Table A-20 shows how to select for unipolar/bipolar (switch 6), gain (switches 4 and 5), and
T T
attenuation (switches 1, 2, and 3). In these tables, ON is closed, and OFF is open. T u d
Table A-19 EM 235 Configuration Switch Table to Select Analog Range and Resolution

. co m .c m
Unipolar
o . c o m
Full-Scale Input Resolution

24
SW1 SW2 SW3
24
SW4 SW5 SW6

a24 2 4.
hoa hoa a
ON OFF OFF ON OFF ON 0 to 50 mV 12.5 mV

ng
OFF
g ON OFF ON OFF
gho
ON 0 to 100 mV 25 mV
ng ho
Tu
ON
OFF
don OFF
ON
OFF
OFF
OFF
OFF
ON

Tu
ON
do n ON
ON
0 to 500 mV
0 to 1 V
Tu d o
125 mV
250 mV
ON OFF OFF OFF OFF ON 0 to 5 V 1.25 mV
ON OFF OFF OFF OFF ON 0 to 20 mA 5 mA
OFF ON OFF OFF OFF ON 0 to 10 V 2.5 mV

.co m .co
Bipolar m .co m .
a 2 4 SW1 SW2
a 2
SW34 SW4 SW5 SW6
a 4
Full-Scale Input
2
Resolution

a 24
o o o o
ngh gh gh h
ON OFF OFF ON OFF OFF +25 mV 12.5 mV
OFF
o n ON OFF ON OFF
o nOFF +50 mV 25 mV
on g
TuOFF d OFF ON ON
Tu
OFF d OFF +100 mV
T u d
50 mV
ON OFF OFF OFF ON OFF +250 mV 125 mV
OFF ON OFF OFF ON OFF +500 mV 250 mV
OFF OFF ON OFF ON OFF +1 V 500 mV

4 .c om ON
OFF
OFF
ON
4 .co
OFF
OFF
m
OFF
OFF
OFF
OFF
OFF
OFF
4 .co
+2.5 V
+5 V
m 1.25 mV
2.5 mV
4.
o a2 OFF OFF
oa 2 ON OFF OFF
ho
OFF a 2+10 V 5 mV
hoa 2
ngh n g h n g
Table A-20o EM 235 Configuration Switch Table to Select Unipolar/Bipolar,
o o ng
Tud Tud Tud
Gain, Attenuation
EM 235 Configuration Switches Unipolar/Bipolar
Gain Select Attenuation Select
SW1 SW2 SW3 SW4 SW5 SW6 Select
ON Unipolar
OFF Bipolar

.com OFF
.com
OFF
.co
x1 m .
o a24 o a24
OFF ON
o a 2 4x10
o a 24
ngh gh gh h
ON OFF x100

o n ON ON
o n invalid
on g
Tud
ON
OFF
OFF
ON
OFF
OFF Tu d T u d
0.8
0.4
OFF OFF ON 0.2
A
.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 355
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 omInput Data Word Format for EM 4 .c om 4 . c om 4.


o a 2 a 2 231 and EM 235
a 2 a 2
ngh
Figure A-11 shows
n g ho
where the 12-bit data value is placed within the
n ho
analog
g input word of the CPU.
n g ho
o udo udo
Tud MSB
T LSB
T
15 14 3 2 0
AIW XX 0 Data value 12 Bits 0 0 0

. co m .c o mUnipolar data . c o m
24 2 4 a24 LSB 2 4.
hoa hoa15 h4o3 ho a
MSB

ng g g ng
0

Tu donAIW XX Data value 12 Bits


Tu do n 0 0 0 0
Tu d o
Bipolar data

Figure A-11 Input Data Word Format for EM 231 and EM 235

.co m .co m .co m .


a 2 4 Tip
a 2 4 a 2 4 a 24
o o o o
ngh gh gh g h
The 12 bits of the analog-to-digital converter (ADC) readings are left-justified in the data word format.
o n
The MSB is the sign bit: zero indicates a positive data word value.
d d o n d o n
u
T format, the three trailing zeros cause the
In the unipolar u
T data word to change by a count of eight forT u
each one-count change in the ADC value.
In the bipolar format, the four trailing zeros cause the data word to change by a count of sixteen for each
one count change in the ADC value.

4 .c om 4 . c om 4 . c om 4.
h o a2 Input Block Diagram fora
h o EM2 231 and EM 235
h o a2 hoa 2
ng d o ng d o ng o ng
Tu Tu Tud
A+
R EM 231
RA C
C
Rloop C
A– GAIN ADJUST

.com .com m
A=1

.co
R
.
a24 a24 4 24
+

o
B+
R
o o a 2 o a
ngh gh gh h
Instrumentation
RB

o n
C
C
AMP
o n BUFFER
on g
Tud d d
Rloop
Tu u
C
B–
R A=2

T
A/D Converter

11 0
A C+
R

.c o m RC C
C
. c o m . c o m .
2 4 Rloop C
24 24 24
ng hoa C–
g hoa g hoa gh oa
don on n
R A=3

d o
D+
RD
Tu R C
T u Tud
C
Rloop C

4 .c om D–
R
4 . c om
A=4
4 . com 4.
2 a2
MUX 4 to 1
a2 2
hoa a
Input filter

h o gh o ho
ng d o ngDiagram for the EM 231
Figure A-12 Input Block
d o n d ong
Tu Tu Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
356
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
Technical Specifications Appendix A

4 .c om 4 .co m
4. c om .
oa2 o a 2 o a2 o a 24
ngh gh gh h
EM 235
A+

on R
on on g
T ud
RA

Rloop
C

C
C
T ud T u d
A– GAIN ADJUST
A=1
R

. co m B+
.c o m +

. c o m
24 RB
R
24 Instrumentation
a24 2 4.
hoa hoa a
C

ho ho
AMP
C BUFFER

ng g g ng
Rloop

don n
C

do o
– A/D Converter

Tu
B–
R A=2
Tu Tu d DATA
11 0
C+
R C REF_VOLT
RC
C +

4 .c om Rloop C

4 .c om Buffer
4 .co m .
2 C–
2 –
2 24
hoa hoa o a o a
R A=3

ng g Offset Adjust
gh g h
Tu don
D+
RD
R
C
Tu d o n
T u d on
C
Rloop C
D–
A=4

om om om
R

2 4 .c Input filter
4 . cMUX 4 to 1
4 . c 4.
hoa a2 for the EM 235
Figure A-13 Input Block Diagram
h o h o a2 hoa 2
ng d o ng d o ng o ng
Tu Data Word Format for EM 232 and
Output TuEM 235 Tud
Figure A-14 shows where the 12-bit data value is placed within the analog output word of the CPU.

.com .co m .c om .
a 2 4 a 2 4 a2 4 a 24
o hoAQW XX
MSB
o LSB
o
ngh g gh g h
15 14 4 3 0
o n o n on
Tud d d
0 Data value 11 Bits 0 0 0 0

MSB Tu
Current output data format
4 3
LSB
0
T u
15
AQW XX Data value 12 Bits
Voltage output data format
0 0 0 0
A
.c o m . c o m . c o m .
o a24 hoa
24
hoa
24 oa 24
ngh gh
Figure A-14 Output Data Word Format for EM 232 and EM 235

on g on g o n
T u d T u d Tud
Tip
The 12 bits of the digital-to-analog converter (DAC) readings are left-justified in the output data word
format. The MSB is the sign bit: zero indicates a positive data word value. The four trailing zeros are

.co m .co m . com


truncated before being loaded into the DAC registers. These bits have no effect on the output signal

a2 4 value.
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 357
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
S7-200 Programmable Controller System Manual

4 .c omOutput Block Diagram for EM4232


.c m
oand 4. c om .
o a2 o a2
EM 235
o a2 o a 24
ng h ng h ng h g h
d o d o d on
Tu Tu u
+24 Volt

R 100
T

. co m .c o m . c o m
24 24 –
a24 2 4.
hoa hoa ho ho a
+

ng don
g +
do n g
d ong
Tu –
Tu
Voltage-to-current converter
Iout
Tu
R
0..20 mA

.co m Vref
.co m .co m .
a 2 4 D/A converter
a 2 4 +
a 2 4 a 24
o o +/– 2V
o Vout
o
ngh gh gh h

DATA
11

o n
0

o n
–10.. +10 Volts

on g
d
Digital-to-analog converter
Tu Tu d R

T u d
1/4 R Voltage output buffer

omFigure A-15 om om
M

2 4 .c 4 . c 4 . c 4.
a2 a2 2
Output Block Diagram for the EM 232 and EM 235

ng hoa ng h o
ng h o
ng hoa
d o d o o
Tu Guidelines
Installation Tu
Use the following guidelines to ensure accuracy and repeatability:
Tud
- Ensure that the 24-VDC Sensor Supply is free of noise and is stable.

.co m- c om
Use the shortest possible sensor wires.
. .c om .
a 2 4 - Use shielded twisted pair2 4
a wiring for sensor wires. a2 4 a 24
o o o o
ngh - h
ng at the Sensor location only. dong
Terminate the shield
d o
h
d on g h
-
Tuthe inputs for any unused channels, as shown
Short
Tuin Figure A-9. T u
- Avoid bending the wires into sharp angles.
A - Use wireways for wire routing.

.c o m- . c o m . c o m
Avoid placing signal wires parallel to high-energy wires. If the two wires must meet, cross them at
.
o a24 right angles.
o a 24 o a 24 oa 24
ngh -
o n gh
Ensure that the input signals are within the common mode
o gofhthe analog module.
voltage
n specification by isolating the
o n gh
Tud Tud Tud
input signals or referencing them to the external 24V common

Tip
The EM 231 and EM 235 expansion modules are not recommended for use with thermocouples.

.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
358
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
Technical Specifications Appendix A

4 .c om 4 .co m
4. c om .
oa2 o a 2
Understanding the Analog Input Module: Accuracy and Repeatability
o a2 o a 24
ngh gh gh h
The EM 231 and EM 235 analog input modules are low-cost, high-speed 12 bit analog input modules. The
n n
modules can convert an analog signal input to its corresponding digital value in 149 µsec. The analog
o o on g
ud ud
signal input is converted each time your program accesses the analog point. These conversion times
T T
must be added to the basic execution time of the instruction used to access the analog input. T u d
The EM 231 and EM 235 provide an unprocessed digital Average Value Signal Input
value (no linearization or filtering) that corresponds to the

. co m .c o m
analog voltage or current presented at the module’s input
. c o m Mean

24 24
terminals. Since the modules are high-speed modules, they
a24
(average)
2 4.
ng hoa hoa
can follow rapid changes in the analog input signal
g gho Accuracy

ng ho a
don n
(including internal and external noise).

Tu Tu do
You can minimize reading-to-reading variations caused by
Tu d o
noise for a constant or slowly changing analog input signal
by averaging a number of readings. Note that increasing the Repeatability limits
number of readings used in computing the average value (99% of all readings fall within these limits)

.co m changes in the input signal. .co m


results in a correspondingly slower response time to
. c omDefinitions .
a 2 4 a 2 4 a2 4
Figure A-16 Accuracy
a 24
o o o o
ngh d o gh
the mean accuracy in a graphical form.
d o n gh
Figure A-16 shows the 99% repeatability limits, the mean or average value of the individual readings, and
n d on g h
Tu Tu T u
The specifications for repeatability describe the reading-to-reading variations of the module for an input
signal that is not changing. The repeatability specification defines the limits within which 99% of the
readings will fall. The repeatability is described in this figure by the bell curve.

4 .c om .co m .co m
The mean accuracy specification describes the average value of the error (the difference between the
4 4 4.
a2 2 2 2
average value of individual readings and the exact value of the actual analog input signal).
o oa a
ho as they relate to each of the nghoa
ngh Table A-21 gives h
o n g o n g
the repeatability specifications and the mean accuracy
o
Tud Tud Tud
configurable ranges.

.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
A
.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 359
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 omDefinitions of the Analog Specifications


4 .c om 4. c om .
o a2 - Accuracy: deviationo a2the expected value on a given point hoa2 o a 24
ng h h from
nthegeffect of an LSB change reflected on dtheooutput.
ng g h
d o
- Resolution:
d on
Tu Tu T u
Table A-21 EM 231 and EM 235 Specifications

Repeatability1 Mean (average) Accuracy1,2,3,4

.com .com o m
Full Scale Input Range
% of Full Scale Counts
. c
% of Full Scale Counts
4.
o a24 o a24 EM 231 Specifications

ho a24 ho a2
ngh gh
0 to 5 V

o n n g ng
do o
0 to 20 mA ± 24 ± 0.1%

Tu d
0 to 10 V
± 2.5 V
± 0.075%
Tu ± 32
Tu d
± 48 ± 0.05%
±5V
EM 235 Specifications

om om om
0 to 50 mV ± 0.25% ± 80

2 4 .c 0 to 100 mV

2 4 .c 2 4 . c
± 0.2% ± 64

24 .
hoa hoa hoa a
0 to 500 mV
0 to 1 V ± 0.075% ± 24
h o
ng don
0 to 5 V g
d on g ± 0.05% ± 16
d on g
Tu
0 to 20 mA
0 to 10 V T u T u
± 25 mV ± 0.25% ± 160
± 50 mV ± 0.2% ± 128

om om om
± 100 mV ± 0.1% ± 64

2 4 .c ± 250 mV
4 . c 4 . c 4.
hoa oa2 hoa
2 a 2
± 500 mV ± 0.075% ± 48

ng ngh
±1V
g g ho
on n
± 0.05% ± 32
o± 2.5 V
o
Tud ±5V
± 10 V T u d Tud
1 Measurements made after the selected input range has been calibrated.
2 The offset error in the signal near zero analog input is not corrected, and is not included in the accuracy specifications.
3

.co m 4
of the difference between channels.

.co m .co m
There is a channel-to-channel carryover conversion error, due to the finite settling time of the analog multiplexer. The maximum carryover error is 0.1%

.
a 2 4 a 2 4
Mean accuracy includes effects of non-linearity and drift from 0 to 55 degrees C.

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
A
.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
360
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
Technical Specifications Appendix A

4 .c om 4 . c om 4. c om 4.
o a 2 Thermocouple and
a 2
RTD Expansion Modules 2
Specifications
a a 2
ngh n g ho n g ho n g ho
o o o
Tud Tud Tud
Table A-22 Thermocouple and RTD Modules Order Numbers
Removable
Order Number Expansion Model EM Inputs EM Outputs
Connector
6ES7 231–7PD22–0XA0 EM 231 Analog Input Thermocouple, 4 Inputs 4 Thermocouple – No

. co m 6ES7 231–7PB22–0XA0

.c o m
EM 231 Analog Input RTD, 2 Inputs 2 RTD

. c

o m No

24 Table A-23 2 4 a2 4 2 4.
hoa hoa a
Thermocouple and RTD Modules General Specifications
h o ho
ng d on g ong
Dimensions (mm)
ong
VDC Requirements

Tud d
Order Number Module Name and Description Weight Dissipation

T u
6ES7 231–7PD22–0XA0 EM 231 Analog Input
(W x H x D)
71.2 x 80 x 62 210 g 1.8 W
+5 VDC
87mA Tu
+24 VDC
60 mA
Thermocouple, 4 Inputs
6ES7 231–7PB22–0XA0 EM 231 Analog Input RTD, 2 Inputs 71.2 x 80 x 62 210 g 1.8 W 87 mA 60 mA

4 .c om 4 .co m
4 .co m .
24
Table A-24 Thermocouple and RTD Modules Specifications

o a 2 o a 2 o a 2 o a
ngh gh gh h
6ES7 231–7PD22–0XA0 6ES7 231–7PB22–0XA0
General
o n Thermocouple
o n RTD
on g
Isolation
Tu d
Field to logic 500 VAC Tu d 500 VAC T u d
Field to 24 VDC 500 VAC 500 VAC
24 VDC to logic 500 VAC 500 VAC
Common mode input range 120 VAC 0

om m m
(input channel to input channel)

4 .c Common mode rejection


4 .co > 120 dB at 120 VAC
.co
> 120 dB at 120 VAC
4 4.
o a2 Input type
oa 2 Floating TC
o a 2
Module ground referenced RTD

hoa 2
ngh gh gh
Input ranges1 TC types (select one per module) RTD types (select one per module):

o n S, T, R, E, N, K, J
o n Pt –100Ω, 200Ω, 500Ω, 1000Ω
o ng
Tu d Tu
Voltage range : +/– 80 mV d (with α = 3850 ppm, 3920 ppm,
Tud
3850.55 ppm, 3916 ppm, 3902 ppm)

Pt –10000Ω (α = 3850 ppm)


Cu –9.035Ω (α = 4720 ppm)

.co m .co m .co m


Ni –10Ω, 120Ω, 1000Ω
(with α = 6720 ppm, 6178 ppm)
.
a 2 4 a 2 4 a 2 4
R –150Ω, 300Ω, 600Ω FS
a 24
o Input resolution
o o o
ngh Temperature
o n gh 0.1° C / 0.1° F
o n gh 0.1° C / 0.1° F
on g h
Tud Tu d u d
Voltage 15 bits plus sign –
Resistance
Measuring Principle

Sigma-delta
15 bits plus sign
Sigma-delta
T
Module update time: All channels
Wire length
405 ms
100 meters to sensor max.
405 ms (700 ms for Pt10000)
100 meters to sensor max.
A
.c o m Wire loop resistance
. c o m
100Ω max.
o m
20Ω, 2.7Ω for Cu max.
. c .
a24 24 24 24
Suppression of interference 85 dB at 50 Hz/60 Hz/ 400 Hz 85 dB at 50 Hz/60 Hz/400 Hz

o hoa hoa oa
Data word format Voltage: –27648 to + 27648 Resistance: –27648 to +27648

ngh on
Maximum sensor dissipation

d
g –

d on g 1m W
o n gh
Tud
Input impedance ≥1 MΩ ≥ 10 MΩ

T u
Maximum input voltage 30 VDC
T u 30 VDC (sense), 5 VDC (source)
Input filter attenuation –3 db at 21 kHz –3 db at 3.6 kHz
Basic error 0.1% FS (voltage) 0.1% FS (resistance)
Repeatability 0.05% FS 0.05% FS

.co m Cold junction error

.co
±1.5 ° C
m –

. com
a2 4 24 VDC supply voltage range

a 2 4 20.4 to 28.8 VDC

a2 4
20.4 to 28.8 VDC

a2 4.
o gho o ho
1 The input range selection (temperature, voltage on resistance) applies to all channels on the module.

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 361
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 .co m
4. c om .
o a2 a 2
EM 231 Analog Input Thermocouple, 4 Inputs
o a2
EM 231 Analog Input RTD, 2 Inputs
o o a 24
ngh gh gh h
(6ES7 231–7PD22–0XA0) (6ES7 231–7PB22–0XA0)

on on on g
T ud
+ – + – + – + –
T ud T u d

. co m .c o m . c o m
24 24 a24 2 4.
hoa hoa a
A+ A – B+ B– C+ C– D+ D– A+ A – a+ a– B+ B– b+ b–

ng
EM 231
g gho
EM 231

ng ho
don n
AI 4 AI 2 x RTD

Tu Tu do Configuration Tu d o
M L+ Configuration M L+

.co m .co m .co m .


a 2 4 +
a 2 4 +

a 2 4 a 24
o –
o –
o o
ngh 24 VDC
d o n gh
d o n gh
24 VDC
power
d on g h
TuConnector Terminal Identification for EM 231 Thermocouple
Tu and EM 231 RTD Modules u
power
Figure A-17 T

.c omCompatibility . c m to work with the CPU 222, CPU.c224,


odesigned om
a 2 4 a 2 4
The RTD and Thermocouple modules are
a 2 4 CPU 226 and
a 2 4.
o CPU 226XM.
ho ho ho
ngh do n g
do n g
do ng
Tip
T u T u T u
The RTD and Thermocouple modules are designed to give maximum performance when installed in a
stable temperature environment.

.co m The EM 231 Thermocouple module,.for c m has special cold junction compensation
oexample, .c oto m circuitry that

a 2 4 measures the temperature at the4


a 2 module
2
connectors and makes necessary changes
a 4 the
a 2 4.
o hoIf the ambient temperature is changing
measurement to compensate for
ho in the area where the EM 231 ngho
temperature differences between the reference temperature and the
ngh n g
temperature at the module.
Thermocoupleo
d moduleaccuracy o n g rapidly
o
Tudrecommends that the S7-200 RTD and Tud
is installed, additional errors are introduced.
Tumaximum
To achieve and repeatability, Siemens
thermocouple modules be mounted in locations that have stable ambient temperature.
A
.c o mNoise Immunity . c o m . c o m
a2 4 Use shielded wires for best
a 2
noise 4
immunity. If a thermocouple input channel
a
is
2 4
not used, short the unused
a 2 4.
o ho
channel inputs, or connect them in parallel to another channel.
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
362
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
Technical Specifications Appendix A

4 .c om EM 231 Thermocouple4Module .c om 4 . c om 4.
o a 2 a 2 a 2 a 2
ngh g hotypes: J,module
The EM 231 Thermocouple
n n g
provides a convenient, isolated ointerface for the S7-200 family to gho
hS7-200 to connect to low level analog on
d o tod
o
Tud
seven thermocouple K, E, N, S, T, and R. It allows the
T u
signals, ±80mV range. All thermocouples attachedu
T the module must be of the same type.

Thermocouple Basics
Thermocouples are formed whenever two dissimilar metals are electrically bonded to each other. A

. co m c o m c o m
voltage is generated that is proportional to the junction temperature. This voltage is small; one microvolt
. .
24 24 a24
could represent many degrees. Measuring the voltage from a thermocouple, compensating for extra
2 4.
ng hoa hoa ho
junctions, and then linearizing the result forms the basis of temperature measurement using
g g ng ho a
don n
thermocouples.

Tuyou connect a thermocouple to the EM 231


When do
TuThermocouple Module, the two dissimilar metal d
Tuwires
o
are attached to the module at the module signal connector. The place where the two dissimilar wires are
attached to each other forms the sensor thermocouple.

om m m
Two more thermocouples are formed where the two dissimilar wires are attached to the signal connector.

2 4 .c 2 4 .co 2 4 .co
The connector temperature causes a voltage that adds to the voltage from the sensor thermocouple. If this
voltage is not corrected, then the temperature reported will deviate from the sensor temperature.
24 .
ng hoa n gh o a
n gh o a
g h o a
on
Cold junction compensation is used to compensate for the connector thermocouple. Thermocouple tables
d o d o
are based on a reference junction temperature, usually zero degrees Celsius. The cold junction d
Tu Tu
compensation compensates the connector to zero degrees Celsius. The cold junction compensation
restores the voltage added by the connector thermocouples. The temperature of the module is measured
T u
internally, then converted to a value to be added to the sensor conversion. The corrected sensor
conversion is then linearized using the thermocouple tables.

4 .c om 4 . c om 4 . c om 4.
o a2 a 2
Configuring the EM 231 Thermocouple Module
a
ho temperature scale, and cold junctionncompensation.
2
ho For the DIP switch settings tongho a 2
ngh
Configuration DIP switches located on the bottom of the module allow you to select the thermocouple
type, open wiregdetect, g
n
oyou need to power cycle the PLC and/orud theo o
Tud Tud
take effect, user 24V power supply.
T
DIP switch 4 is reserved for future use. Set DIP switch 4 to the 0 (down or off) position. Table A-25 shows
other DIP switch settings.

.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
A
.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 363
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 omTable A-25 4 .co m


4. c om .
oa2 o a 2
Configuring the Thermocouple Module DIP Switches
o a2 o a 24
ngh n gh
Switches 1,2,3
o
Thermocouple Type
n gh
Setting
o
Description
on g h
T
SW1, 2, 3ud J (Default)

K T ud000

001 T u
(or mV operation) for all channels on the
module. For example, for an E type,
d
Switches 1 to 3 select the thermocouple type

Configuration thermocouple SW1 = 0, SW2 = 1, SW3 = 1.


T 010
↑ – On
↑1
1 2 3 4* 5 6 7 8 E 011

. co m ↓0 – Off

.c o m . c o m
24 2 4 R 100

a24 2 4.
hoa hoa a
* Set DIP switch 4

ho ho
S 101
to the 0 (down) position.

ng don
g N
do n
110 g
d ong
Tu Switch 5
+/–80mV

Open Wire Detect


Tu 111

Setting Description
Tu
Direction
Upscale 0 0 indicates positive on open wire

om om m
SW5

.co
(+3276.7 degrees) 1 indicates negative on open wire

2 4 .c 2 4 .c
Configuration
2 4 24 .
hoa hoa a a

↑1 – On
↓0 – Off
Downscale 1
gh o h o
ng g g
1 2 3 4 5 6 7 8

don n on
(–3276.8 degrees)

d o d
Tu Switch 6 Open Wire Detect
Enable
Tu Setting Description T u
SW6 Enable 0 Open wire detection is performed by injecting
a 25 µA current onto the input terminals. The

4 .c om .co
Configuration

4
↑1 – On
m .co m
open wire enable switch enables or disables
the current source. The open wire range
4 4.
o a2 1 2 3 4 5 6 7 8
oa 2
↓0 – Off
o 2
check is always performed, even when the
a
current source is disabled. The EM 231
hoa 2
ngh gh gh g
Disable 1

do n d o n Thermocouple module detects open wire if


o n
Tud
the input signal exceeds approximately

Tu Tu ±200mV. When an open wire is detected, the


module reading is set to the value selected
by the Open Wire Detect.

Switch 7 Temperature Scale Setting Description

.co m SW7

.co m
Celsius (_C) 0
m
The EM 231 Thermocouple module can

.co
report temperatures in Celsius or Fahrenheit.
.
a 2 4 a 2 4
Configuration
a 2 4
The Celsius to Fahrenheit conversion is
a 24
o o o
performed inside the module.
o
ngh gh gh h

↑1 – On

n
1 2 3 4 5 6 7 8
o
↓0 – Off
Fahrenheit (_F) 1

o n on g
Tud Switch 8 Cold Junction Tu dSetting Description T u d
SW8 Cold junction 0 Cold junction compensation must be enabled
A compensation enabled when you are using thermocouples. If cold
junction compensation is not enabled, the

.c o m Configuration
↑1 – On
. c o m o m
conversions from the module will be in error
. c .
2 4 1 2 3 4 5 6 7 8
24
↓ – Off
↓0
24
because of the voltage that is created when
24
hoa hoa hoa a
Cold junction 1 the thermocouple wire is connected to the
compensation disabled module connector. Cold junction is
gh o
ng d on g
d on g automatically disabled when you select the
o n
Tud
±80mV range.

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
364
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
Technical Specifications Appendix A

4 .c om 4 .co m
4. c om .
oa2 Tip
a 2 a2 a 24
ngh ho ho
H The open wire current source could interfere with signals from some low level sources such as
n g n g ng h o
o
thermocouple simulators.
d d o d o
Tuopen
H Tu will trigger open wire detection even when
Input voltages exceeding approximately ±200mV
wire current source is disabled.
Tuthe
Tip

. co m c o m c o m
H Module error could exceed specifications while the ambient temperature is changing.
. .
a24 a
H Exceeding the module 2 4ambient temperature range specificationacould
2 4cause the module cold a2 4.
o junction to behino ho ho
ngh g g g
error.
o n o n on
Tudthe Thermocouple: Status Indicators
Using Tud Tud
The EM 231 Thermocouple module provides the PLC with data words that indicate temperatures or error
conditions. Status bits indicate range error and user supply/module failure. LEDs indicate the status of the

.co m .co m
module. Your program should have logic to detect error conditions and respond appropriately for the
application. Table A-26 shows the EM 231 Thermocouple status indicators.
.co m .
a 2 4 a 2 4 a 2 4 a 24
o o o o
ngh gh gh h
Table A-26 EM 231Thermocouple Status Indicators

o n o n on g
Tu d Error Condition Channel Data
Tu d
SF LED
Red
24 V LED
Green
Range Status Bit1
u d
24 VDC User
Power Bad2
T
No errors Conversion data OFF ON 0 0
24 V missing 32766 OFF OFF 0 1
Open wire and current source enabled –32768/32767 BLINK ON 1 0

4 .c om Out of range input


4 .com –32768/32767 BLINK ON
.com
1 0
4.
hoa
2 Diagnostic error3
oa2
0000 ON OFF
o a24 0 note 3

hoa 2
ng 1
ngh n gh
Range status bit is bit 3 in module error register byte (SMB9 for Module 1, SMB11 for Module 2, etc.)
o o o ng
2
3

Tu d d
User Power Bad status bit is bit 2 in module error register byte (SMB 9, SMB 11, etc., refer to Appendix D)

Tu Tud
Diagnostic errors cause a module configuration error. The User Power Bad status bit may or may not be set before the module configuration error.

Tip
The channel data format is two’s complement, 16-bit words. Temperature is presented in 0.1 degree

.co m .co m
units. For example, if the measured temperature is 100.2 degrees, the reported data is 1002. Voltage
.co m .
a 2 4 a 2 4
data are scaled to 27648. For example, –60.0mV is reported as –20736 (=–60mV/80mV * 27648).
a 2 4 a 24
o o o o
ngh n gh n gh
All four channels are updated every 405 milliseconds if the PLC has read the data. If the PLC does not
o o on g h
Tud d d
read the data within one update time, the module reports old data until the next module update after the
Tu
PLC read. To keep channel data current, it is recommended that the PLC program read data at least as
often as the module update rate.
T u
Tip
A
.c o m . c o m
When you are using the EM 231 Thermocouple module, you should disable analog filtering in the PLC.
. c o m .
a24 24 24 24
Analog filtering can prevent error conditions from being detected in a timely manner.

ngh
o g hoa g hoa gh oa
d on 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 365
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
S7-200 Programmable Controller System Manual

.c m
oA-27 .co m . c om .
a2 4 Table
2 4
Temperature Ranges (°C) and Accuracy for Thermocouple Types
a a2 4 a 24
o o o o
ngh gh gh h
Data Word (1 digit = 0.1_C)
Dec Hex
on Type J Type K Type T
n
Type E
o
Type R, S Type N 
80mV
on g
32767 7FFF
T ud >1200.0 _C >1372.0 _C >400.0 _C
T ud
>1000.0_C >1768.0_C >1300.0_C >94.071mV
T
OFu d
↑ ↑ ↑ ↑
32511 7EFF 94.071mV
: : OR

. co m .c o m . c o m
4.
27649 6C01

24 4 4 80.0029mV
2 a2 2
hoa hoa a
27648 6C00 ↑ 80mV

h o ho
ng g ong ng
: :

d on o
Tud d
17680 4510 ↑ 1768.0_C
: : T u Tu NR
13720 3598 1372.0_C ↑
: : overrange

om ↑
om m
13000 32C8 1300.0_C 1300.0_C

2 4 .c
: :
2 4 .c 2 4 .co 24 .
hoa hoa o a o a
12000 2EE0 1200.0_C ↑

ng g gh g h
don n on
: :
d o d
Tu ↑
Tu u
10000 2710 1000.0_C
: : T
4000 0FA0 400.0_C 400.0_C
: :

4 .c
1
om 0001 0.1_C 0.1_C

4 . c om0.1_C 0.1_C 0.1_C 0.1_C

4 . c om 0.0029mV

4.
2 0 0000 0.0_C
2
0.0_C 0.0_C 0.0_C 0.0_C
2
0.0_C 0.0mV
2
ng hoa –1 FFFF
g h oa
–0.1_C –0.1_C –0.1_C –0.1_C
g
–0.1_C
hoa –0.1_C –0.0029mV
g hoa
don don o n
: : underrange
–500
–1500
FE0C
FA24
Tu –150.0_C
Tu –50.0_C
#
Tud
: :
–2000 F830 underrange –200.0_C

.com
: :
.co m .co m .
o a24 –2100 F7CC –210.0_C
o a 2 4
o a 2 4
o a 24
ngh gh gh g h
: : underrange

o n o n on
Tud d d
–2550 F60A –255.0_C –255.0_C
:
–2700
:
F574 # –270.0_C
underrange
–270.0_C
Tu
underrange
–270.0_C –270.0_C
T u
A :
–27648
:
9400 # # # # –80.mV

.c o m
–27649 93FF
. c o m . c o m–80.0029mV
.
2 4 2 4 2 4 24
hoa hoa hoa oa
: :

ng –32512 8100
on g on g o n gh
# #
T u d T u d –94.071mV
#
Tud
UR
#
–32768 8000 <–210.0_C <–270.0_C <–270.0_C <–270.0_C <–50.0_C <–270.0_C <–94.071mV UF
Accuracy over full span ±0.1% ±0.3% ±0.6% ±0.1% ±0.6% ±0.1% ±0.1%
Accuracy (nominal range
±1.5_C ±1.7_C ±1.4_C ±1.3_C ±3.7_C ±1.6_C ±0.10%

om .com om
without cold junction)

2 4 .c Cold junction error ±1.5_C


24
±1.5_C ±1.5_C ±1.5_C ±1.5_C
. c
±1.5_C
4 N/A
4.
hoa a
*OF = Overflow; OR = Overrange; NR = Nominal range; UR = Underrange; UF = Underflow
o o a2 ho a2
ng gh gh
↑ indicates that all analog values greater than this and below the open wire threshold report the overflow data value, 32767 (0x7FFF).
ng
Tu don Tu d o n
# indicates that all analog values less than this and greater than the open wire threshold report the underflow data value, –32768 (0x8000).

Tu d o

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
366
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
Technical Specifications Appendix A

4 .c om 4 .co m
4. c om .
oa2
Table A-28
o a 2
Temperature Ranges (°F) for Thermocouple Types
o a2 o a 24
ngh gh gh h
Data Word
(1 digit = 0.1°F)
on Type J Type K Type T
on
Type E Type R, S Type N 80 mV
on g
ud ud d
Dec Hex
32767

T↑
7FFF >2192.0 _F >2502.0 _F >752.0 _F
T >1832.0_F >3214.0_F

>2372.0_F
T u
>94.071mV

OF

32511 7EFF 94.071mV
32140 7D90 3214.0_F OR

. co m .c o m . c o m
4.
27649 6C01 80.0029mV

24 2 4 a2 4 2
hoa hoa a
27648 6C00 ↑
h o 2764.8_F 80mV
ho
ng : :

d on g ong ong
u Tud Tu d
25020 61B8 2502.0_F ↑
: T: overrange
NR

23720 5CA8 ↑ 2372.0_F 2372.0_F


: :

.co m
21920 55A0 2192.0_F
.co m ↑
.co m .
a 2 4 : :
a 2 4 a 2 4 a 24
o o o o
ngh gh ↑
gh g h
18320 4790

d o n 1832.0_F

d o n d on
Tu Tu u
: :
7520 1D60 752.0_F 752.0_F T
: :
320 0140 underrange 32.0_F

4 .c om : :
4 .co m
4 .co m
4.
o a2 1 0001 0.1_F
oa 2 0.1_F 0.1_F 0.1_F 0.1_F
o a 2 0.1_F 0.0029mV

hoa 2
ngh gh gh g
0 0000 0.0_F 0.0_F 0.0_F 0.0_F 0.0_F 0.0_F 0.0mV

do n d o n o n
Tud
–1 FFFF –0.1_F –0.1_F –0.1_F –0.1_F –0.1_F –0.1_F –0.0029mV
: Tu
: Tu
–580 FDBC –58.0_F
: :

4 . c om –2380 F6B4 –238.0_F

4 .co m
4 .co m .
2 : :
2 2 24
ng hoa –3280 F330

n gh
underrange o a –328.0_F

n gh o a underrange
g h o a
: :
o o on
–3460
:
Tud
F27C
:
–346.0_F
underrange
Tu d #
T u d
–4270 EF52 –427.0_F –427.0_F A
.c o m : :

. c o m underrange underrange

. c o m .
a24 24 24 24
–4540 EE44 # –454.0_F –454.0_F –454.0_F –454.0_F

o hoa hoa oa
: :

ngh –27648 9400

d o ng # # #

d o ng # –80mV
o n gh
–27649

:
T93FF

:
u T u Tud
–80.0029mV

–32512 8100 –94.071mV OR

4 .c om # #
.com .com
# #

4.
2 –3268 8000 <–346.0° F
24 <–454.0° F <–454.0° F <–454.0° F
24
<–58.0° F <–454.0° F <–94.07 mV UF
2
hoa oa o a ho a
*OF = Overflow; OR = Overrange; NR = Normal range; UR = Underrange; UF = Underflow

ng gh gh
↑ indicates that all analog values greater than this and below the open wire threshold report the overflow data value, 32767 (0x7FFF).
on on ong
# indicates that all analog values less than this and greater than the open wire threshold report the underflow data value, –32768 (0x8000).

T u d T u d Tu d

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 367
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
S7-200 Programmable Controller System Manual

4 .c oEMm231 RTD Module 4 . c om 4 . c om 4.


o a 2 a 2 a 2 a 2
ngh The EM 231 RTD module
n g htooprovides n g
a convenient interface for the S7-200ofamily to several different RTDs. gho
hBoth RTDs attached to the module on
d o d o
Tud
It also allows the S7-200 measure three different resistance ranges.
must be ofu u
T the same type.
T
Configuring the EM 231 RTD Module
DIP switches enable you to select RTD type, wiring
. co m .c o mdirection. The . c o m Configuration
↑1 – On
4.
configuration, temperature scale, and burnout

o a 24 DIP switches are located


shown in Figure A-18. Foro
on
a 24
the bottom of the module as
o a 24 ↓0 – Off
a2
ngh n gh cycle the PLC and/or the user 24V ongh
effect, you need to power
the DIP switch settings to take
ng ho
o o
Tud Tud Tu d
power supply.
1 2 3 4 5 6 7 8
Select RTD type by setting DIP switches 1, 2, 3, 4, and 5 to
correspond to the RTD as shown in Table A-29. Refer to
Table A-30 for other DIP switch settings. Figure A-18 DIP Switches for the EM 231

.co m .c om . c om RTD Module


.
a 2 4 Table A-29 Selecting the RTD a
4
2 DIP Switches 1 to 5 a2 4 a 24
o o Type:
o o
ngh RTD Type and Alpha

d o
h
ng 0 0 0 0 0 100ΩdPto0.00302
SW1 SW2 SW3 SW4 SW5
ng hRTD Type and Alpha SW1 SW2 SW3 SW4 SW5

d on g h
Tu
100Ω Pt 0.003850
(Default) Tu 1 0 0 0
T u
0

200Ω Pt 0.003850 0 0 0 0 1 200Ω Pt 0.003902 1 0 0 0 1


500Ω Pt 0.003850 0 0 0 1 0 500Ω Pt 0.003902 1 0 0 1 0

4 .c om 1000Ω Pt 0.003850 0
41
0
.0com
1 1 1000Ω Pt 0.003902
4
1
.c0 om0 1 1
4.
2 oa2 oa21 2
hoa hoa
100Ω Pt 0.003920 0 0 0 0 SPARE 0 1 0 0

ng 200Ω Pt 0.003920
o ngh0 0 1 0 1
o n gh
100Ω Ni 0.00672 1 0 1 0 1
o ng
Tud
500Ω Pt 0.003920
1000Ω Pt 0.003920
0
0
0
0
1
1
1
1
0
1
udNi 0.00672
T120Ω
1000Ω Ni 0.00672
1
1
0
0
1
1
1
1
Tu0 d1
100Ω Pt 0.00385055 0 1 0 0 0 100Ω Ni 0.006178 1 1 0 0 0

4 . c om 500Ω Pt 0.00385055 0 1 4.0com


200Ω Pt 0.00385055 0 1 0 0 1 120Ω Ni 0.006178 1
1 4.c
om0 1 0 0 1
.
o a 2 a 2 1 0 1000Ω Ni 0.006178
10000Ω Pt 0.003850oa 1
2 1 1 0
a 24
ngh
1000Ω Pt 0.00385055
n g h00o 11 01 10 1
n gh 1 1 0 1 1
g h o
udo 0 1 1 0
100Ω Pt 0.003916 0 10Ω Cu o
udFS Resistance 1
0.004270 1 1 0
u d on
0
200Ω PtT0.003916 1 T150Ω 1 1 0 T1
500Ω Pt 0.003916 0 1 1 1 0 300Ω FS Resistance 1 1 1 1 0
A 1000Ω Pt 0.003916 0 1 1 1 1 600Ω PHYS 1 1 1 1 1

. c o m . c o m Resistance
.com .
a2 4 a2 4 a 24 a 24
ho h o h o gh o
ng d o ng d on g o n
Tu 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
368
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
Technical Specifications Appendix A

4 .c om 4 .co m
4. c om .
oa2
Table A-30
o a 2
Setting RTD DIP Switches
o a2 o a 24
ngh gh gh h
Switch 6 Open Wire Detect Setting Description

on on on g
ud ud d
SW6 Upscale 0 Indicates positive on open wire

T Configuration T
(+3276.7 degrees)
T u
↑ – On
↑1 Downscale 1 Indicates negative on open wire
1 2 3 4 5 6 7 8 ↓0 – Off (–3276.8 degrees)

. co m .c o m . c o m
4.
Switch 7 Temperature Scale Setting Description

24 24 a24 2
hoa hoa a
SW7 Celsius (_C) 0 The RTD module can report temperatures in

ng g gho Celsius or Fahrenheit. The Celsius to

ng ho
don n
Configuration Fahrenheit conversion is performed inside

Tu 1 2 3 4 5 6 7 8
↑ – On
↑1
↓0 – Off
Tu
Fahrenheit (_F) do 1
the module.

Tu d o
Switch 8 Wiring Scheme Setting Description

.co m SW8

.co m3-wire 0

.co m
You can wire the RTD module to the sensor
in three ways (shown in the figure). The most
.
a 2 4 a 4
Configuration
2↑1 – On
a 2 4
accurate is 4 wire). The least accurate is 2
a 24
o o ↓0 – Off
o wire, which is only recommended if errors
o
ngh gh gh h
2-wire or 4-wire 1
1 2 3 4 5 6 7 8

o n o n
due to wiring can be ignored in your
application.
on g
Tu d Tu d T u d
RTD 4 Wire RTD 3 Wire RTD 2 Wire
(most accurate)

4 .c om A+ Sense +
4 . c om A+ Sense +
4 . c om
A+ Sense +
Set switch to
4-wire mode.
4.
2 2 2 2
ng hoa g
A– Sense –
h oa A– Sense –
g hoa A– Sense –
g hoa
Tu don
a+ Source +
RL1

RL2 RTD
a+ Source +
Tu don
RL1

RL2 RTD
a+ Source + RL1

RL2 Tud
o n
RTD
a– Source – a– Source – a– Source –
RL1+RL2=Error
If RL1=RL2, error is minimal.
Note: RL1 = Lead resistance from a+ terminal to the RTD

.com c om c om
RL2 = Lead resistance from a– terminal to the RTD
. . .
o a24 o
Figure A-19 Wiring the RTD 4
a2to the Sensor by 4, 3, and 2 Wire hoa2 4
o a 24
ngh d o ng h
d o ng d on g h
Tu Tu T u
A
.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 369
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 omEM 231 RTD Status Indicators4.com 4 . c om 4.


o a 2 a 2 a 2 a 2
ngh
The RTD module
bits indicate rangen g handouser supply/module failure. LEDs indicate
provides the PLC with data words that indicate
n htheo status of the module. Your
temperatures
g or error conditions. Status
n g ho
dohave ud231oRTDappropriately o
error

Tushows
program should
Table A-31
logic to detect error conditions and respond
the status indicators provided by the TEM module.
for the application.
Tud
Tip

. co m .c m
The channel data format is twos complement, 16-bit words. Temperature is presented in 0.1 degree
o . c o m
24
units. (For example, if the measured temperature is 100.2 degrees, the reported data is 1002.)
24 a24
Resistance data are scaled to 27648. For example, 75% of full scale resistance is reported as 20736. 2 4.
ng hoa (225Ω / 300Ω * 27648 h
g oa
= 20736)
gho ng ho a
u d on do n d o
T 231 RTD Status Indicators
Table A-31 EM Tu Tu
SF LED 24 V LED
Error Condition Channel Data Range Status Bit1 24 VDC User Power Bad2
Red Green
No errors Conversion data OFF ON 0 0

4 .c om 24 V missing 32766
4 .c om OFF OFF 0
4 .com 1
.
2 2 oa2 24
hoa hoa a
SW detects open wire –32768/32767 BLINK ON 1 0
h h o
ng Out of range input

d o ng –32768/32767 BLINK ON

d o ng 1 0

d on g
1
Diagnostic
T u
error3 0000 ON OFF
T u 0 note3
T u
Range status bit is bit 3 in module error register byte (SMB9 for Module 1, SMB11 for Module 2, etc.)
2 User Power Bad status bit is bit 2 in module error register byte (such as SMB 9, SMB 11, refer to Appendix D.)
3 Diagnostic errors cause a module configuration error. The User Power Bad status bit may or may not be set before the module
configuration error.

4 .c omChannel data is updated every 4054milliseconds,


. c om if the PLC has read the data. If4the.cPLC om 4.
o a 2 a 2 a 2 does not read
a 2
ngh
the data within one
n
read. To keep channelg hocurrent, it is recommended that the PLC
update
data
time, the module reports old data until
n
the
g ho read data at least as often ngho
next module
program
update after the PLC

o rate.
udupdate
as the module
udo udo
Tip
T T T
When you are using the RTD module, be sure to disable analog filtering in the PLC. Analog filtering can
prevent error conditions from being detected in a timely manner.

.co m .co m .co m .


a 2 4 a 2 4 a 2
Open wire detection is performed by software internal to the RTD module. Out of range inputs are4 a 24
o o o o
ngh gh gh h
declared and open wire data is reported as burnout data. Open wire detection takes a minimum of three
o n o n
module scan cycles and can take longer, depending on which wire(s) are open. Open Source+ and/or
on g
Tud Tu d
Source– wires are detected in the minimum time. Open Sense+ and/or Sense– wires can take 5 seconds
or more to detect. Open sense lines can randomly present valid data, with open wire detected T u d
intermittently, especially in electrically noisy environments. Electrical noise can also extend the time it
A takes to detect the open wire condition. It is recommended that open wire/out of range indications be
latched in the application program after valid data has been reported.

.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
370
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
Technical Specifications Appendix A

4 .c om 4 .co m
4. c om .
o a2
EM 231 RTD Module Ranges
o a 2 o a2 o a 24
ngh gh gh h
EM 231 RTD temperature ranges and accuracy for each type of RTD module ar shown in Tables A-32 and
A-33.
on on on g
ud
TTemperature Ranges (°C) and Accuracy for RTD Types
T ud T u d
Table A-32
System Word
(1 digit = 0.1 _C) Pt10000
Pt100, Pt200, Ni100, Ni120,
Cu9.035 0 – 150Ω 0 – 300Ω 0 – 600Ω

.com .com m
Pt500, Pt1000 Ni1000
Decimal Hex
. c o 4.
o a 24 32767 7FF.

o a 24 a24 a2
ng h 32766
g
7FFE
h gho ↑ ↑ ↑

ng ho
don do n o
32511 7EFF 176.383Ω 352.767Ω 705.534Ω
29649
Tu 6C01
Tu 150.005Ω 300.011Ω
Tu d
600.022Ω
27648 6C00 150.000Ω 300.000Ω 600.000Ω
25000 61A8 ↑
18000 4650 OR

.co m
15000 3A98
.co m .co m .
a 2 4 13000 32C8 ↑
a 2 4 ↑
a 2 4 a 24
o 10000 2710
o
1000.0_C 1000.0_C
o o
ngh d o n gh
d o n gh
d on g h
Tu Tu u
8500 2134 850.0_C
6000 1770 600.0_C ↑ T
3120 0C30 ↑ 312.0_C
2950 0B86 295.0_C

4 .c om 2600
2500
0A28
09C4
4 . c om 250.0_C
260.0_C

4 .co m
4.
2 oa2 2 2
ng hoa 1
ngh 0001 0.1_C 0.1_C 0.1_C
n gh
0.1_C
o a 0.005Ω 0.011Ω 0.022Ω
ng hoa
do d o o
Tu Tu Tud
0 0000 0.0_C 0.0_C 0.0_C 0.0_C 0.000Ω 0.000Ω 0.000Ω
–1 FFFF –0.1_C –0.1_ –0.1_C –0.1_C (negative values are not possible)
↓ ↓ ↓ N
–600 FDA8 –60.0_C R

.co m .co m .co m .


a 2 4 –1050 FBE6

a 2 4 –105.0_C

a 2 4 a 24
o o o o
ngh –2000
o n gh F830 –200.0_C –200.0_
o n gh
–200.0_C
on g h
Tud Tu d u d
–2400 F6A0 –240.0_C
–2430 F682 –243.0_C

–243.0_C

↓ T
–5000 EC78
A
.c o m –6000
–10500
E890
D6FC
. c o m . c o m UR

.
o a24 –12000 D120

hoa
24
hoa
24 oa 24
ngh g g gh
–20000 4E20

d on d on o n
–32767
–32768 T u 8001
8000 T u Tud
Accuracy over full span ±0.4% ±0.1% ±0.2% ±0.5% ±0.1% ±0.1% ±0.1%
Accuracy (nominal range) ±4_C ±1_C ±0.6_C ±2.8_C ±0.15Ω ±0.3Ω ±0.6Ω

4 .c om .com
*OF = Overflow; OR = Overhang; KNURL = Nominal range; OUR = Underhung; OUI = Underflow
.com 4.
2 24 24
↑ or ↓ indicate that all analog values exceeding the limits report the selected burnout value, 32767 (0x7FF.) or –32768 (0x8000).
2
ng hoa gh oa
g h o a
ng ho a
u d on u d on d o
T T Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 371
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
oA-33 .co m . c om .
a2 4 Table
2 4
Temperature Ranges (°F) for RTD Types
a a2 4 a 24
o o o o
ngh gh gh h
System Word (1 digit = 0.1 _F)
Decimal
on
Hexadecimal
PT1000
PT100, Pt200,
Pt500, Pt1000
on
Ni100, Ni120,
Ni1000
Cu 9.035
on g
32767
T ud
7FF.
T ud T u d
32766 7PHAGE

. co m .c o m . c o m Overhang

24 ↑
24 ↑
24 2 4.
ng hoa 18320 4790
g hoa
1832.0_F 1832.0 _F
gh oa
ng ho a
d on on o
15620 T u
3D04 1562.0_F Tud Tu d
11120 2B70 1112.0_F

.co m .co m .co m .


a 2 4 a 2 4 ↑
a 2 4 a 24
o o o o
ngh gh gh h

5936 1730

o n o n
593.6_F

on g
5630

5000 Tu
15FE

1388
d Tu d
563.0_F

500.0_F T u d
4820 12D4 482.0_F

4 .c om 4 .co m
4 .co m Normal Range
4.
o a2 1 0001
oa 2
0.1_F 0.1_F 0.1_F
o a 2
0.1_F

hoa 2
ngh gh gh g
0 0000 0.0_F 0.0_F 0.0_F 0.0_F

do n d o n o n
Tu Tu Tud
–1 FFFF –0.1_F –0.1_F –0.1_F –0.1_F

–760 FD08 –76.0_F

.co m .co m .co m .


a 2 4–1570 F9DE
a 2 4 –157.0_F
a 2 4 a 24
o o o o
ngh o n gh ↓
o n gh on g h
Tud Tu d u d
–3280 F330 –328.0_F –328.0_F –328.0_F
T
A –4000
–4054
F060
F02A –405.4_F –405.4_F
–400.0_F

.c o m ↓
.com ↓
. c o m .
o a24 –5000 EC78
o a 24
hoa
24 oa 24
ngh –6000 E890

d o ng h
d o ng Underrange
o n gh
–10500
T u
D6FC
T u ↓
Tud
–32767 8001
–32768 8000

4 .c om .co m . com
↑ or ↓ indicate that all analog values exceeding the limits report the selected burnout value, 32767 (0x7FFF) or –32768 (0x8000).
4 4 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
372
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
Technical Specifications Appendix A

4 .c om 4 . c om 4. c om .
o a2 EM 277 PROFIBUS–DP
o a2 Module Specifications
o a2 o a 24
ng h ng h ng h g h
Table A-34
o
EM 277 PROFIBUS–DP
d Module Order Number
d o d on
Tu Order Number
Tu
Expansion Model EM Inputs EM Outputs
T u
Removable
Connector
6ES7 277–0AA22–0XA0 EM 277 PROFIBUS–DP – – No

. co m .c o m . c o m
24 Table A-35 24
EM 277 PROFIBUS–DP Module General Specifications
a24 2 4.
ng hoa Order Number
g hoa
Module Name and Description
Dimensions (mm)
gho
Weight Dissipation
VDC Requirements

ng ho a
don n
(W x H x D) +5 VDC +24 VDC

Tu
6ES7 277–0AA22–0XA0 EM 277 PROFIBUS–DP
Tu
71 x 80 x 62 do 175 g 2.5 W 150mA
Tu d o
See below

Table A-36 EM 277 PROFIBUS–DP Module Specifications

om
General
om
6ES7 277–0AA22–0XA0

.c Number of Ports
.c 1
.co m .
2 4 Electrical interface
2 4 RS–485
2 4 24
ng hoa PROFIBUS–DP/MPI baud rates
g hoa gh o a
9.6, 19.2, 45.45, 93.75, 187.5, and 500 kbaud; 1, 1.5, 3, 6, and
g h o a
don n on
(set automatically) 12 Mbaud
Protocols
d o
PROFIBUS–DP slave and MPI slave
d
Cable Length
Tu
Up to 93.75 kbaud
Tu 1200 m
T u
187.5 kbaud 1000 m
500 kbaud 400 m

4 .c om 1 to 1.5 Mbaud
3 to 12 Mbaud
4 .co m 200 m
100 m
4 .co m
4.
o a2 Network Capabilities
oa 2 o a 2
hoa 2
ngh gh gh g
Station address settings 0 to 99 (set by rotary switches)

o n
Maximum stations per segment
d 32
d o n o n
Tu
Maximum stations per network
MPI Connections Tu 126, up to 99 EM 277 stations
6 total, 2 reserved (1 for PG and 1 for OP) Tud
24 VDC Input Power Requirements
Voltage range 20.4 to 28.8 VDC (Class 2 or sensor power from PLC)

.co m Maximum current


Module only with port active
.co m 30 mA
.co m .
a 2 4 Add 90 mA of 5V port load
a 2 4 60 mA
a 2 4 a 24
o Add 120 mA of 24V port load
o 180 mA
o o
ngh gh gh g h
Ripple noise (<10 MHz) <1 V peak to peak (maximum)

o n
Isolation (field to logic)1
o n on
Tud d d
500 VAC for 1 minute
5 VDC Power on Communications Port
Maximum current per port
Tu 90 mA
T u
Isolation (24 VDC to logic) 500 VAC for 1 minute
24 VDC Power on Communications Port A
.c o m Voltage range
Maximum current per port
. c o m 20.4 to 28.8 VDC
120 mA
. c o m .
o a24 Current limit

hoa
24 0.7 to 2.4 A

hoa
24 oa 24
ngh gh
Isolation Not isolated, same circuit as input 24 VDC

on g on g o n
1 No
d d
power is supplied to module logic by the 24 VDC supply. 24 VDC supplies power for the communications port.

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 373
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
oS7-200 .c om Modules . c om
a 2 4 CPUs that Support
a 2 4Intelligent
a 2 4 a 2 4.
o o slave module is an intelligent expansion o designed to work with the ho
ngh do
S7-200 CPUs shown g
in
hTable
The EM 277 PROFIBUS–DP
n A-37.
do n g hmodule
do n g
T u T u
Table A-37 EM 277 PROFIBUS–DP Module Compatibility with S7-200 CPUs T u
CPU Description
CPU 222 DC/DC/DC
CPU 222 Rel. 1.10 or greater

. co m o m
CPU 222 AC/DC/Relay

.c . c o m
24 24
CPU 224 DC/DC/DC

a24 2 4.
hoa hoa a
CPU 224 Rel. 1.10 or greater

ho ho
CPU 224 AC/DC/Relay

ng don
g
CPU 226 Rel. 1.00 or greater
CPU 226 DC/DC/DC

do n g
d ong
Tu Tu Tu
CPU 226 AC/DC/Relay
CPU 226XM DC/DC/DC
CPU 226XM Rel. 1.00 or greater
CPU 226XM AC/DC/Relay

.co m
Address Switches and LEDs
.c om . c om
a 2 4 a
The address switches and status2 4
LEDs are located on the front of the module2
a 4
as shown in Figure A-20.
a 2 4.
o hoport connector is also shown. ngho ho
ngh
The pin-out for the DP slave
o n g o o n g
Tud
Front View of EM 277 PROFIBUS–DP Tud Tud
Address Switches:
x10=sets the most significant digit of the address
x1= sets the least significant digit of the address

4 .c om 4 .co m
4 .co m
4.
o a2 oa 2 9-Pin Sub D Connector Pin-out
o a 2
hoa 2
ngh do ngh
d o n gh o ng
Tu Tu
9-pin D
Pin #
1
Description
Tud
Chassis ground, tied to the connector shell
Female 2 24V Return (same as M on terminal block)
Connector 3 Isolated Signal B (RxD/TxD+)
4 Isolated Request to Send (TTL level)

4 . c om 4 .c om 5 5
6
.co
Isolated +5V Return
m
Isolated +5V (90 mA maximum)
4 .
24
9
2 2 2
hoa hoa a a
7 +24V (120 mA maximum, with reverse

gh o
voltage protection diode)
h o
ng d o ng 6
d o n1
8
9
Isolated Signal A (RxD/TxD–)
No Connection
d on g
Tu Tu T u
A Note: Isolated means 500V of isolation from
digital logic and 24V input power.

.c o m . c o m . c o m .
o a24 hoa
24
hoa
24 oa 24
ngh ng
DP Slave Port Connector
d o d on g o n gh
TuEM 277 PROFIBUS–DP
Figure A-20 T u Tud
Distributed Peripheral (DP) Standard Communications

.c o mPROFIBUS–DP . c otomthis standard are compatible even though . cotheymare


(or DP Standard) is a remote I/O communications protocol defined by the European

a2 4 Standard EN 50170. Devices that adhere


a 2 4
manufactured by different companies.
a 2
DP stands for distributed peripherals, that4is, remote I/O.
a2 4.
o ho Field Bus. ho ho
ng h
PROFIBUS stands for Process
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
374
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
Technical Specifications Appendix A

4 .c om 4 .co m
4. c om .
o a2 o 2
devices in the following communications protocol standards:
o a2
The EM 277 PROFIBUS–DP module has implemented the DP Standard protocol as defined for slave
a o a 24
ngh on gh on gh on g h
ud ud d
- EN 50 170 (PROFIBUS) describes the bus access and transfer protocol and specifies the
T properties of the data transfer medium.
T T u
- EN 50 170 (DP Standard) describes the high-speed cyclic exchange of data between DP masters
and DP slaves. This standard defines the procedures for configuration and parameter assignment,
explains how cyclic data exchange with distributed I/O functions, and lists the diagnostic options

. co m which are supported.


.c o m . c o m
24 24 a24 2 4.
ng hoa g hoa gho ng ho a
don do n o
A DP master is configured to know the addresses, slave device types, and any parameter assignment

Tu Tu Tu d
information that the slaves require. The master is also told where to place data that is read from the slaves
(inputs) and where to get the data to write to the slaves (outputs). The DP master establishes the network
and then initializes its DP slave devices. The master writes the parameter assignment information and I/O
configuration to the slave. The master then reads the diagnostics from the slave to verify that the DP slave
accepted the parameters and the I/O configuration. The master then begins to exchange I/O data with the

.co m .co m .co m


slave. Each transaction with the slave writes outputs and reads inputs. The data exchange mode
.
a 2 4 a 2 4 a 2 4
continues indefinitely. The slave devices can notify the master if there is an exception condition and the
a 24
o o
master then reads the diagnostic information from the slave. o o
ngh d o
Once a DP n g h
d o n g h
master has written the parameters and I/O configuration to a DP slave, and the slave has on
d
g h
Tu the parameters and configuration fromTtheumaster, the master owns that slave. The T
accepted u only
slave
accepts write requests from the master that owns it. Other masters on the network can read the slave’s
inputs and outputs, but they cannot write anything to the slave.

4 .c om Using the EM 277 to Connect 4 . c oman S7-200 as a DP Slave 4.com 4.


o a 2 The S7-200 CPU can be 2
a a
connected to a PROFIBUS–DP network through2 the EM 277 PROFIBUS–DP
a 2
ngh g hois connected
expansion slave module.
PROFIBUS n n g
The EM 277 is connected to the S7-200 oCPU through the serial I/O bus. The gho
hmodule through its DP communicationsn
port.u d oport operates at any PROFIBUS baud rate
network
u d o
to the EM 277 PROFIBUS–DP
u do
T This
T between 9600 baud and 12 Mbaud. See the
Specifications for EM 277 PROFIBUS–DP Module for the baud rates supported. T
As a DP slave device, the EM 277 module accepts several different I/O configurations from the master,
allowing you to tailor the amount of data transferred to meet the requirements of the application. Unlike

.co m .co m .co m


many DP devices, the EM 277 module does not transfer only I/O data. Inputs, counter values, timer
.
a 2 4 a 2 4 a 2 4
values, or other calculated values can be transferred to the master by first moving the data to the variable
a 24
o ho ho
memory in the S7-200 CPU. Likewise, data from the master is stored in variable memory in the S7-200
o
ngh n g
CPU and can be moved to other data areas.
d o d o n g
d o ng h
Theu
T DP port of the EM 277 PROFIBUS–DP module Tucan be attached to a DP master on the network
Tu and
still communicate as an MPI slave with other master devices such as SIMATIC programming devices or
S7-300/S7-400 CPUs on the same network. Figure A-21 shows a PROFIBUS network with a CPU 224
and an EM 277 PROFIBUS–DP module. A
.c o m - . c o m . c o m .
a24 24 24 24
The CPU 315–2 is the DP master and has SIMATIC S7-300 with

hoa hoa a
programming CPU 315-2 DP ET 200B
been configured by a SIMATIC
o o
ngh gh
device

d o ng
programming device with STEP 7
d o ng o n
Tud
programming software.
T-uThe CPU 224 is a DP slave owned by theTu
CPU 315–2. The ET 200 I/O module is
EM 277
PROFIBUS–DP
CPU 224
also a slave owned by the CPU 315–2.
CPU 400
-
om .com om
The S7-400 CPU is attached to the

2 4 .c PROFIBUS network and is reading data


24 4 . c 4.
hoa a
from the CPU 224 by means of XGET
o o a2 ho a2
ng gh
instructions in the S7-400 CPU user
gh ng
Tu don
program.
d o n
TuFigure A-21 Tu d o
EM 277 PROFIBUS–DP Module and CPU
224 on a PROFIBUS Network

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 375
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 .
a2 Configuration a2 a2 CPU 224 CPU 315-2 DP
a 24
h o h o
ÏÏÏÏ h o h o
V memory I/O address areas

ng g station address of the DP ng g


EM 277 P000
To use the EM
nthe
277 PROFIBUS–DP as a DP
on
u the address in the configuration of Tu ÏÏÏÏ
VB0

d
slave, you mustoset d o PROFIBUS–DP
Module
u d
port to T T
Offset:

ÏÏÏÏ
match 5000 bytes PI256
the master. The station address is set with the

ÏÏÏÏ om
I/O input area:
VB4999 16 bytes PI271
rotary switches on the EM 277 module. You must VB5000 Output buffer
power cycle the CPU after you have made a (Receive mail-

o m o m
switch change in order for the new slave address VB5015 box):16 bytes

. c .c
ÏÏÏÏ .c 4.
VB5016 Input buffer

24 to take effect.
24 2 4
(Send mailbox): PQ256
2
hoa oa datafromwithitseach
ÏÏÏÏ oa a
VB5031

ho
16 bytes I/O output area:

ng g h
The master device exchanges of VB5032
gh 16 bytes PQ271

ng
n
do output buffer (called a ÏÏÏÏ
on o
its slaves by sending information output
area to theuslave’s
Tmailbox”). T d
VB5119

u VB: variable memory byte


P: peripheral
Tu d
“Receive The slave responds to the PI: peripheral input
message from the master by returning an input PQ: peripheral output

buffer (called a “Send mailbox”) which the master


stores in an input area. Figure A-22
V Memory and I/O Address Area

c o m o m omMaster.
4 . Figure A-22 shows an example of 4 the.c 4 . c 4.
o a 2 a 2 a 2
V memory and I/O address area of a PROFIBUS–DP
a 2
ngh n g
The EM 277 PROFIBUS–DP ho can be configured by the DP masterntogaccept
ho output data from the master ngho
and return inputo
data to the master. The output and input datao
memory)T uthed S7-200
of CPU. When you configure theT DP
d buffers
umaster, reside in the variable memory (V
you define the byte location in V Tu
do
memory where the output data buffer should start as part of the parameter assignment information for the
EM 277. You also define the I/O configuration as the amount of output data to be written to the S7-200
CPU and amount of input data to be returned from the S7-200 CPU. The EM 277 determines the size of

4 .c om 4
m
the input and output buffers from the I/O configuration. The DP master writes the parameter assignment
.co 4 .co
and I/O configuration information to the EM 277 PROFIBUS DP module. The EM 277 then transfers the V
m
4.
o a2 oa 2
memory address and input and output data lengths to the S7-200 CPU.
ho a 2
hoa 2
ngh Figure A-22 showsn
master CPU.d
ag
h
memory model of the V memory in a CPU 224n g
o example, the DP master has defineduandI/Ooconfiguration of 16 output bytes and 16udo
and the I/O address areas of a DP ng
TuandIn this
input bytes, Tbuffer and input buffer lengths in the CPU 224T
a V memory offset of 5000. The output
(determined from the I/O configuration) are both 16 bytes long. The output data buffer starts at V5000; the
input buffer immediately follows the output buffer and begins at V5016. The output data (from the master)
is placed in V memory at V5000. The input data (to the master) is taken from the V memory at V5016.

.co m .co m .co m .


a 2 4 Tip
a 2 4 a 2 4 a 24
o o o o
ngh gh gh h
If you are working with a data unit (consistent data) of three bytes or data units greater than four bytes,
o n o n
you must use SFC14 to read the inputs of the DP slave and SFC15 to address the outputs of the DP
on g
Tud Tu d
slave. For more information, see the System Software for S7-300 and S7-400 System and Standard
Functions Reference Manual. T u d
A
.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
376
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
Technical Specifications Appendix A

4 .c om 4 .co m
4. c om .
oa2 2 a2
Table A-38 lists the configurations that are supported by the EM 277 PROFIBUS–DP module. The default
a a 24
ngh n g ho n gh o
configuration for the EM 277 module is two words of input and two words of output.
g h o
do EM 277 Configuration Options ud o d on
TuA-38
Table
Configuration Inputs to Master T Outputs from Master T u
Data Consistency
1 1 word 1 word
2 2 words 2 words

. co m 3
.c o m
4 words 4 words
. c o m
24
4
24
8 words 8 words

a24 2 4.
hoa hoa ho ho a
5 16 words 16 words

ng don
g 6 32 words

do n g 32 words
Word Consistency
d ong
Tu Tu Tu
7 8 words 2 words
8 16 words 4 words
9 32 words 8 words
10 2 words 8 words

om om m
11 4 words 16 words

2 4 .c 12
2 4 .c 8 words 32 words
2 4 .co 24 .
hoa hoa o a o a
13 2 bytes 2 bytes

ng g gh g h
don n on
14 8 bytes 8 bytes

d o Byte Consistency
d
Tu Tu u
15 32 bytes 32 bytes
16 64 bytes 64 bytes T
17 4 bytes 4 bytes
18 8 bytes 8 bytes
Buffer Consistency

om .com om
19 12 bytes 12 bytes

2 4 .c 20

2 4 16 bytes 16 bytes
2 4 . c 2 4.
o a a a
o location of the input and output buffersgtohbeoanywhere in the V memory of the gho a
ngh
You can configurehthe
o
S7-200 CPU. n g
The default address for the input and outputn
o buffers is VB0. The location of the input and n
o
T u
output d
buffers is part of the parameter assignmentu
T d
information
TudCPU.
that the master writes to the S7-200
You configure the master to recognize its slaves and to write the required parameters and I/O
configuration to each of its slaves.

Use the following tools to configure the DP master:

.com .co m .co m .


a24 4 4 24
- For SIMATIC S5 masters, use COM PROFIBUS Windows software
o a 2 a 2 a
ngh
-
ho
For SIMATIC S7 masters, use STEP 7 programming software
n g n g ho ng h o
- Foro SIMATIC 505 masters, use COM PROFIBUSo o
d d
Tudetailed information about using these configuration
and either TISOFT2 or SoftShop
d
Tu and programming software packages,Trefer
u to the
For
manuals for these devices. For detailed information about the PROFIBUS network and its components,
refer to the ET 200 Distributed I/O System Manual. A
.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 oa2 a2 a 24
ngh n gh n gho 377
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
oData .c om . c om .
a2 4 Consistency
a2 4 a2 4 a 24
h o h o h o h o
ng d o ng
PROFIBUS supports three types of data consistency:
d ong d on g
- Byteu
T consistency ensures that bytes are Tu
transferred as whole units.
Master
Byte 0
Slave
Byte 0 T u
Byte 1 Byte 1 Byte consistency
- Word consistency ensures that word Byte 2 Byte 2
transfers cannot be interrupted by other Byte 3 Byte 3

. co m .c o m
processes in the CPU (the two bytes Byte 0
. c o m
Byte 0

24 24
composing the word are always moved Byte 1
a24
Byte 1 Word consistency
2 4.
hoa hoa ho ho a
Byte 2 Byte 2
together and cannot be split). Use Word
ng g g ng
Byte 3 Byte 3

don n
consistency if the data values being

Tu
transferred are integers.
Tu do
Byte 0
Byte 1
Byte 2
Byte 0
Byte 1
Byte 2 Tu d o
- Buffer consistency ensures that the entire
Byte 3 Byte 3 Buffer consistency
buffer of data is transferred as a single Byte 4 Byte 4
unit, uninterrupted by any other process in Byte 5 Byte 5

.co m the CPU. Buffer consistency should be


.co m
used if the data values are double words
Byte 6
Byte 7
Byte 6

.co
Byte 7 m .
a 2 4 a 2 4
or floating point values or when a group of
a 2 4 a 24
o o o and Buffer Data Consistency o
ngh gh g hWord, ng h
values all relate to one calculation or item.

d o n Figure A-23
d o nByte,
d o
You setT theudata consistency as part of the I/O configuration
Tu in the master. The data consistency selection
Tu
is written to the DP slave as part of the initialization of the slave. Both the DP master and the DP slave use
the data consistency selection to be sure that data values (bytes, words, or buffers) are transferred
uninterrupted within master and slave. The different types of consistency are shown in Figure A-23.

.c m
oUser . c om . c om
a 2 4 Program 2
Considerations
a 4 a 2 4 a 2 4.
o o module has been successfully configured hothe master ho
ngh g hdata g g
Once the EM 277 PROFIBUS–DP by a DP master, the EM 277
do
and the DP master nenter exchange mode. In data exchange n
doresponds with most current S7-200 CPU
mode, writes output data to
do n
T
the EM 277 u PROFIBUS–DP module, the EM 277 moduleuthen
T T
input data. The EM 277 module continuously updates its inputs from the S7-200 CPU in order to provide
u
the most recent input data to the DP Master. The module then transfers the output data to the S7-200
CPU. The output data from the master is placed into V memory (the output buffer) starting at the address

.co m .c om . c om
that the DP master supplied during initialization. The input data to the master is taken from the V memory

4.
locations (the input buffer) immediately following the output data.

a 2 4 a 2 4 a 2 4 a 2
o o it is to be used. Likewise, the input datahtoothe master must be moved from ngho
ngh hwhere
The output data from the master must be moved by the user program in the S7-200 CPU from the output
n g
buffer to the data areas
n g
udoareas to the input buffer for transfer toTtheumaster.
the various data
T do T udo
Output data from the DP master is placed into V memory immediately after the user program portion of the
A scan has been executed. Input data (to the master) is copied from V memory to the EM 277 for transfer to
the master at the same time.

.c o mOutput data from the master is only written


. c o m . c o mfrom the
4.
into V memory when there is new data available

a2 4 master.
a 2 4 a 2 4 a 2
o hareotransmitted to the master on the nextndata o with the master. ho
ngh n g
Input data to the master
do of the data buffers in V memory and
g hexchange
o of the buffers must be known at the time n g
T uaddress
The starting T uthedsize T udo
the user program for the S7-200 CPU is created.

Status Information
.c o m c om allocated to each intelligent module basedo
c onm
SM. locations corresponding to the modules’ relative . .
There are 50 bytes of special memory (SM) its physical

a2 4 position. The module updates the 4


a 2 a 2 4 position to the CPU
a2 4
o hoSMB250 othrough ho
ng h hTable
(with respect to other modules). If it is the first module, it updates SMB200 SMB249. If it is the
second module, it n
o g
updates through SMB299, and so on.
o n g
See A-39.
on g
Tud Tud Tud

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
378
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
Technical Specifications Appendix A

4 .c om 4 .co m
4. c om .
o a2 Notice
a 2 a2 a 24
ngh g ho g ho
The manner of assigning SM locations for Intelligent modules changed for Version 2.2 and later.
n n ng h o
d o
If you are using a CPU prior to version 2.2, you shouldo
d d o
place all intelligent modules in slots adjacent to
TuCPU and before all non-intelligent modulesTtouensure compatibility.
the Tu
Table A-39 Special Memory Bytes SMB200 to SMB549
Special Memory Bytes SMB200 to SMB549

.com c o m c o m
Intelligent Intelligent Intelligent Intelligent Intelligent Intelligent Intelligent

24 24 . . 4.
a24
Module in Module in Module in Module in Module in Module in Module in
a 2
o hoa ho ho a
Slot 0 Slot 1 Slot 2 Slot 3 Slot 4 Slot 5 Slot 6

ng h g g ng
don n
SMB200 to SMB250 to SMB300 to SMB350 to SMB400 to SMB450 to SMB500 to
SMB249

Tu
SMB299 SMB349 SMB399

Tu do SMB449 SMB499 SMB549

Tu d o
These SM locations show default values if DP communications have not been established with a master.
After a master has written parameters and I/O configuration to the EM 277 PROFIBUS–DP module, these
SM locations show the configuration set by the DP master. You should check the protocol status byte (for

.co m .co m
example SMB224 for slot 0) to be sure that the EM 277 is currently in data exchange mode with the
master before using the information in the SM locations shown in Table A-40, or data in the V memory .co m .
a 2 4 buffer.
a 2 4 a 2 4 a 24
o o o o
ngh Tip
d o n gh
d o n gh
d on g h
Tu Tu
You cannot configure the EM 277 PROFIBUS–DP I/O buffer sizes or buffer location by writing to SM
memory locations. Only the DP master can configure the EM 277 PROFIBUS–DP module for DP
T u
operation.

4 .c om 4 .co m
4 .co m
4.
a2 2 2 2
Table A-40 Special Memory Bytes for the EM 277 PROFIBUS–DP

o oa o a hoa
ngh gh gh
Intelligent ... Intelligent
Module in
o n Module in
o n Description
o ng
Tu d
Slot 0
SMB200 to ...
Slot 6
SMB500 to Tu
Module name (16 ASCII characters)
d Tud
SMB215 SMB515 “EM277 ProfibusDP”
SMB216 to ... SMB516 to S/W revision number (4 ASCII characters)
SMB219 SMB519 xxxx

4 . c om SMW220 ... SMW520

4 .co
Error code m
4 .co m .
24
16#0000 No error
2 2 2
hoa a a a
16#0001 No user power

gh o 16#0002 to 16#FFFF Reserved


gh o h o
ng o n o n on g
Tud d d
SMB222 ... SMB522 DP slave module’s station address as set by address switches (0 – 99 decimal)
SMB223 ... SMB523 Reserved Tu T u
SMB224 ... SMB524 DP standard protocol status byte
MSB
0 0 0 0 0 0 S1
LSB
S0
A
.c o m . c o m . c o m .
a24 24 24 24
S1 S0 DP Standard status byte description

o hoa hoa oa
0 0 DP communications not initiated since power on

ngh g g gh
0 1 Configuration/parameterization error detected

d on 1 0
on
Currently in data exchange mode
d o n
u u Tud
1 1 Dropped out of data exchange mode
T
SMB225 ... SMB525 T
DP standard protocol – address of the slave’s master (0 to 126)
SMW226 ... SMW526 DP standard protocol – V memory address of the output buffer as an offset from VB0.
SMB228 ... SMB528 DP standard protocol – number of bytes of output data

4 .c om SMB229 ... SMB529


4 .co m
DP standard protocol – number of bytes of input data
4 . com 4.
2 2 a2 2
hoa a a
SMB230 to ... SMB530 to

gho o ho
Reserved – cleared on power up

gh
SMB249 SMB549
ng don d o n
Note: SM locations are updated each time the DP slave module accepts configuration/ parameterization information. These locations
d ong
Tu Tu
are updated even if a configuration/parameterization error is detected. The locations are cleared on each power up.
Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh n gh n gho 379
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
S7-200 Programmable Controller System Manual

.c m
oLED .c om . c om
a 2 4 Status Indicators for
a 2 4
the EM 277 PROFIBUS–DP
a 2 4 a 2 4.
o ho module has four status LEDs on thenfront o to indicate the operational ho
ngh The EM 277 PROFIBUS–DP
do n
state of the DP port: g
do
g hpanel
do n g
T u T u T
- After the S7-200 CPU is turned on, the DX MODE LED remains off as long as DP communications
u
are not attempted.
- Once DP communications have been successfully initiated (the EM 277 PROFIBUS–DP module

.com o m o m
has entered data exchange mode with the master), the DX MODE LED turns green and remains on

24 24 .c . c 4.
a24
until data exchange mode is exited.
a 2
ng h o -
hoa ho
If DP communications are lost, which forces the EM 277 module to exit data exchange mode, the
g g ng ho a
don do n o
DX MODE LED turns OFF and the DP ERROR LED turns red. This condition persists until the

Tu
S7-200 CPU is powered off or data exchange is resumed.
Tu Tu d
- If there is an error in the I/O configuration or parameter information that the DP master is writing to
the EM 277 module, the DP ERROR LED flashes red.
- If user 24 VDC is not provided, the POWER LED will be off.

.c o m .c omsignified by the EM 277 status LEDs.


. c om .
a2 4 4
Table A-41 summarizes the status indications
a2 a2 4 a 24
ho h o h o h o
ng d o ng
Table A-41 EM 277 PROFIBUS–DP Module Status LEDs
d o ng d on g
LED
Tu OFF
CPU FAULT
RED
Module is good Tu FLASHING RED GREEN
Internal Module Failure –– –– T u
POWER No 24 VDC User Power –– –– 24 VDC User Power Good
Left Data Exchange Parameterization/
DP ERROR No Error ––

om .com m
Mode Configuration Error

2 4 .c DX MODE Not in Data Exchange Mode


4
–– ––
4 .co 4.
In Data Exchange Mode

hoa oa2 a 2 a 2
Note: When the EM 277 PROFIBUS–DP module is used exclusively as an MPI slave, only the green Power LED is on.

h h o h o
ng n g n g ng
The EMT
udo
Additional Configuration Features
277 PROFIBUS–DP module can be used as T
udo Tud
a communications interface to other MPI masters,
o
whether or not it is being used as a PROFIBUS–DP slave. The module can provide a connection from the
S7-300/400 to the S7-200 using the XGET/XPUT functions of the S7-300/400. STEP 7–Micro/WIN and a
network card (such as the CP5611) using the MPI or PROFIBUS parameter set, an OP device or the TD

.co m .co m
200 (Rel. 2.0 or greater, order number 6ES7 272–0AA20–0YA0) can be used to communicate with the
.co m .
a 2 4 2 4
S7-200 through the EM 277 PROFIBUS–DP module.
a a 2 4 a 24
o o o o
ngh gh gh
A maximum of six connections (six devices) in addition to the DP master can be connected to the EM 277
o n o n on g h
Tud d d
PROFIBUS–DP module. One connection is reserved for a programming device (PG) and one is reserved
Tu
for an operator panel (OP). The other four connections can be used by any MPI master. In order for the
EM 277 PROFIBUS–DP module to communicate with multiple masters, all masters must be operating at
T u
the same baud rate. See the Figure A-24 for one possible network configuration.
A When the EM 277 PROFIBUS–DP module is used for MPI communications, the MPI master must use the
.c o m . c o m that are sent to the S7-200 to which.the
c o m is
4.
station address of the module for all messages module

a2 4 connected. MPI messages sent


a 2to4the EM 277 PROFIBUS–DP module are
a 2 4 the S7-200.
passed on to
a 2
o ho module is a slave module and cannot o ho
ngh n
The EM 277 PROFIBUS–DP
do
g o n gbehused for communications between
o n g
Tud Tud
S7-200 PLCs using the NETR and NETW functions. The EM 277 PROFIBUS–DP module cannot be used
Tucommunications.
for Freeport

.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
380
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
Technical Specifications Appendix A

4 .c om 4 .co m
4. c om .
oa2 o a
PROFIBUS–DP 2 S7-300
o a2 o a 24
ngh gh gh h
XPUTS/XGETS STEP 7–Micro/WIN1 TD 2001,2

on Master
Functions
on on g
T ud PROFIBUS–DP MPI T ud MPI MPI T u d
PROFIBUS–DP/MPI

PROFIBUS–DP
MPI

. co m .c o mEM 277 . c o m
a24 a 24 PROFIBUS–DP
a 2 4 are possible only to the
1) Communications
a2 4.
o ho ho CPUs and the EM 277. ho
ngh
Module

o n g 2)gTD 200 must be Rel 2.0 or greater.


n
S7-200
n g
S7-22x CPUdo o
Tud Tu Tud
Figure A-24 PROFIBUS–DP/MPI Network

.co m .c om . c om
a 2 4 Device Database File: a 2 4GSD a 2 4 a 2 4.
o hodevices have different performance characteristics.
ho These characteristics differ withngho
ngh respectdtoo
n g
Different PROFIBUS
d o n g
signals and diagnostic messages) or bus do
T u T u
functionality (for example, the number of I/O
parameters, such as transmission speed and time monitoring. These parameters vary for each
u
Tdevice
type and vendor, and are usually documented in a technical manual. To help you achieve a simple
configuration of PROFIBUS, the performance characteristics of a particular device are specified in an
electronic data sheet called a device database file, or GSD file. Configuration tools based on GSD files

4 .c om 4 . c om 4 . c om
allow simple integration of devices from different vendors in a single network.
4.
o a2 a 2
o These GSD files are prepared by thegvendor
The device database file a 2
ho forsystem
provides a comprehensive description of the characteristics of a device in a
hoa 2
ngh precisely definedh
to n
available o
g format. n each type of device and made
do when configuring the network.Tudo ng
Tud of a PROFIBUS device and useTthisuinformation
the PROFIBUS user. The GSD file allows the configuration to read in the
characteristics

The latest versions of the COM PROFIBUS or STEP 7 software include configuration files for the EM 277
PROFIBUS–DP Module. If your version of software does not include a configuration file for the EM 277,

.co m .co m
you can access the latest GSD file (SIEM089D.GSD) at website www.profibus.com.
.co m .
a 2 4 a 2 4 a 2 4
If you are using a non-Siemens master device, refer to the documentation provided by the manufacturer
a 24
o o
on how to configure the master device by using the GSD file.
o o
ngh o n gh o n gh on g h
Tud Tu d T u d
A
.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 381
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 .co m
4. c om .
oa2 o 2
;================================================
a
; GSD File for the EM 277 PROFIBUS–DP with a DPC31
o a2 o a 24
ngh gh gh g h
; MLFB : 6ES7 277–0AA2.–0XA0 ;================================================

on
; DATE : 26–March–2001
on
; Continuation of GSD File
on
T ud
;================================================
#Profibus_DP
;General parameters T ud
; Module Definition List T u d
;================================================

GSD_Revision = 1 Module = ”2 Bytes Out/ 2 Bytes In –” 0x31


Vendor_Name = ”Siemens” EndModule
Model_Name = ”EM 277 PROFIBUS–DP” Module = ”8 Bytes Out/ 8 Bytes In –” 0x37

. co m Revision
Ident_Number
= ”V1.02”
= 0x089D
.c o m EndModule

. c o
Module = ”32 Bytes Out/ 32 Bytesm In –”

24
Protocol_Ident = 0
24
0xC0,0x1F,0x1F

a24 2 4.
hoa hoa a
Station_Type = 0 EndModule

ng
FMS_supp
g
= 0
gho
Module = ”64 Bytes Out/ 64 Bytes In –”

ng ho
don n
Hardware_Release = ”1.00” 0xC0,0x3F,0x3F
Software_Release

Tu
9.6_supp
19.2_supp
= ”1.02”
= 1
= 1 Tu do
EndModule
Module = ”1 Word Out/ 1 Word In
EndModule Tu
–” 0x70 d o
45.45_supp = 1 Module = ”2 Word Out/ 2 Word In –” 0x71
93.75_supp = 1 EndModule
187.5_supp = 1 Module = ”4 Word Out/ 4 Word In –” 0x73
500_supp = 1 EndModule

4 .c om 1.5M_supp = 1

4 .c om Module = ”8 Word Out/ 8 Word In


EndModule
4 . c om –” 0x77
.
24
3M_supp = 1
2 6M_supp = 1
2 2
Module = ”16 Word Out/ 16 Word In –” 0x7F

hoa hoa hoa o a


12M_supp = 1 EndModule

ng
MaxTsdr_9.6
ng
= 60
ng
Module = ”32 Word Out/ 32 Word In –”
g h
MaxTsdr_19.2

u d
MaxTsdr_45.45 o = 60
= 250
u d o
0xC0,0x5F,0x5F
EndModule
u d on
T
MaxTsdr_93.75
MaxTsdr_187.5
= 60
= 60
TModule = ”2 Word Out/ 8 Word In
0xC0,0x41,0x47 T –”

MaxTsdr_500 = 100 EndModule


MaxTsdr_1.5M = 150 Module = ”4 Word Out/ 16 Word In –”
MaxTsdr_3M = 250 0xC0,0x43,0x4F

om m m
MaxTsdr_6M = 450 EndModule

4 .c MaxTsdr_12M = 800
4 .co 4 .co
Module = ”8 Word Out/ 32 Word In –”
4.
a2 2 2 2
Redundancy = 0 0xC0,0x47,0x5F

o Repeater_Ctrl_Sig = 2
oa EndModule
o a hoa
ngh gh gh g
24V_Pins = 2 Module = ”8 Word Out/ 2 Word In –”

do n d o n
0xC0,0x47,0x41
o n
Tud
; Slave–Specification: EndModule

Tu
OrderNumber=”6ES7 277–0AA2.–0XA0”
Periphery=”SIMATIC S5”
Slave_Family=10@TdF@SIMATIC
Tu
Module = ”16 Word Out/ 4 Word In
0xC0,0x4F,0x43
EndModule
–”

Module = ”32 Word Out/ 8 Word In –”


Freeze_Mode_supp = 1 0xC0,0x5F,0x47
Sync_Mode_supp = 1 EndModule

4 . c om Set_Slave_Add_Supp = 0

4 .c om Module = ”4 Byte buffer I/O

4 .c om –” 0xB3
.
24
Auto_Baud_supp = 1 EndModule
2 2 2
hoa hoa hoa a
Min_Slave_Intervall = 1 Module = ”8 Byte buffer I/O –” 0xB7
Fail_Safe = 0 EndModule
h o
ng Modul_Offset
d o ng
Max_Diag_Data_Len =
=
6
0
d o
EndModuleng
Module = ”12 Byte buffer I/O –” 0xBB

d on g
T
Max_Moduleu
Modular_Station

Max_Input_len
=
=
=
1
1
128
T u
Module = ”16 Byte buffer I/O
EndModule
–” 0xBF
T u
Max_Output_len = 128
A Max_Data_len = 256

.c o m ; UserPrmData–Definition

. c o m
ExtUserPrmData=1 ”I/O Offset in the V–memory”
. c o m .
a24 24 24 24
Unsigned16 0 0–10239

o hoa hoa oa
EndExtUserPrmData

ngh g g gh
; UserPrmData: Length and Preset:

on
User_Prm_Data_Len=3
d d on o n
u u Tud
User_Prm_Data= 0,0,0

T
Max_User_Prm_Data_Len=3
Ext_User_Prm_Data_Const(0)=0x00,0x00,0x00
Ext_User_Prm_Data_Ref(1)=1
T

.co mFigure A-25 .co m


Listing of the GSD File for the EM 277 PROFIBUS Module
. 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
382
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
Technical Specifications Appendix A

4 .c om Sample Program for DP4.Communications


c om 4 . c om 4.
o a 2 a 2 to a
oStatement List for the PROFIBUS–DP module
CPU
a 2 a 2
ngh g
A sample program
n hSM
in
n g hoin slotthe0 forlocation
a CPU that uses the DP
n g ho
fromu
T do and the sizes of the buffers fromTSMB228
port information
SMW226
in memory is shown below. The
u doand SMB229. This information is usedTuto dcopyo
program determines of the DP buffers

the data in the DP output buffer to the process-image output register of the CPU. Similarly, the data in the
process-image input register of the CPU are copied into the V memory input buffer.

. co m Notice
.c o m . c o m
24 24 a24
The manner of assigning SM locations for Intelligent modules changed for Version 2.2 and later.
2 4.
ng hoa hoa ho
If you are using a CPU prior to version 2.2, you should place all intelligent modules in slots adjacent to
g g ng ho a
don do n o
the CPU and before all non-intelligent modules to ensure compatibility.

InT
u Tinuposition 0, the DP configuration data in theTSM
the following sample program for a DP module
u d
memory area provides the configuration of the DP slave. The program uses the following data:

SMW220 DP Module Error Status

4 .c om SMB224 DP Status
4 .co m
4 .co m .
2 SMB225 Master Address
2 2 24
hoa o a o a o a
SMW226 V memory offset of outputs

ng SMB228
o n gh Number of bytes of output data
o n gh on g h
Tu d
SMB229
VD1000
Number of bytes of input data
Output Data Pointer
Tu d T u d
VD1004 Input Data Pointer

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
A
.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 383
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 Example of DP Communications to4a CPU


.c om 4 . c om 4.
o a 2 a 2 a 2 a 2
ngh n g ho Network 1
g hodata pointer. If in data exchange
//Calculate the Output
n n g ho
o do buffer is an offset from VB0 do
Tud
//mode:
u
T//1. Output
//2. Convert Vmem offset to double integer T u
//3. Add to VB0 address to get output data pointer.
LDB= SMB224, 2

. co m .c o m
MOVD &VB0, VD1000
. c o m
24 24
ITD SMW226, AC0

a24 2 4.
hoa hoa a
+D AC0, VD1000

ng g Network 2
gho
//Calculate the Input data pointer. If in data exchange
ng ho
don do n o
//mode:

Tu Tu
//1. Copy the output data pointer
//2. Get the number of output bytes Tu d
//3. Add to output data pointer to get starting input data
// pointer.
LDB= SMB224, 2

4 .c om 4 .c m
oMOVD VD1000, VD1004
4 .co m .
2 2 BTI SMB228, AC0
2 24
ng hoa g hoa ITD AC0, AC0
g ho a
ng h o a
don n
+D AC0, VD1004
//Set d o d o
Tu u Tu
Network 3 amount of data to be copied. If in data exchange
T//mode:
//1. Get number of output bytes to copy
//2. Get number of input bytes to copy
LDB= SMB224, 2

4 .c om 4 . c om MOVB SMB228, VB1008


MOVB SMB229, VB1009
4 . c om 4.
o a2 oa2 Network 4 a 2
oinputs. If in data exchange mode:
//Transfer Master outputs to CPU outputs. Copy CPU
oa 2
ngh o ngh n g h
//inputs to the Master

doCPU ng h
Tud udo
//1. Copy Master outputs to CPU outputs
T uCopy
//2. inputs to Master inputs
T
LDB= SMB224, 2
BMB *VD1000, QB0, VB1008
BMB IB0, *VD1004, VB1009

.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
A
.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
384
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
Technical Specifications Appendix A

4 .c om 4 .c om 4. c om .
o a2 EM 241 Modem
a2
Module
o
Specifications
o a2 o a 24
ng h h
ng Module Order Number ng h g h
Table A-42
o
EM 241 Modem
d d o d on
Tu
Order Number
Tu Expansion Model EM Inputs EM Outputs
T u
Removable
Connector
6ES7 241–1AA22–0XA0 EM 241 Modem Module – 81 No
1 Eight Q outputs are used as logical controls of the modem function and do not directly control any external signals.

. co m .c o m . c o m
24 24 a24 2 4.
ng hoa Table A-43
hoa
EM 241 Modem Module General Specifications
g gho ng ho a
Tu
Order Number don Module Name and Description
Tu
Dimensions (mm)
(W x H x D)
do n Weight Dissipation
Tu d
VDC Requirements
+5 VDC +24 VDC
o
6ES7 241–1AA22–0XA0 EM 241 Modem Module 71.2 x 80 x 62 190 g 2.1 W 80 mA 70 mA

Table A-44 EM 241 Modem Module Specifications

4 .c om 4 .co m
4 .co m .
2 General
2 2
6ES7 241–1AA22–0XA0
24
ng hoa Telephone Connection
n gh o a
n gh o a
g h o a
Isolation
d o d o d on
Tu
(phone line to logic and field power)
Physical connection Tu 1500 VAC (Galvanic)
RJ11 (6 position, 4 wire) T u
Modem standards Bell 103, Bell 212, V.21, V.22, V.22 bis, V.23c, V.32, V.32 bis,
V.34 (default)
Security features Password

4 .c om
Dialing
4 .co m Callback
Pulse or Tone
4 .co m
4.
2 2 2 2
hoa oa o a hoa
Messaging Protocols Numeric

ng o ngh o n gh
TAP (alphanumeric)
UCP commands 1, 30, 51
o ng
Tu
Industrial Protocols d Tu d
Modbus
PPI Tud
24 VDC Input Power Requirements
Voltage range 20.4 to 28.8 VDC
Isolation (field power to logic) 500 VAC for 1 minute

.com .com .co m .


a24 a24 2 4 24
The EM 241 Modem Module replaces the function of an
o o
external modem connected to the communications port
o a o a
ngh n gh
of the CPU. With an EM 241 installed in your S7-200
o o n gh on g h
Tud Tu d u d
system, all you need to communicate with your CPU
from a remote location is a personal computer with an T
external modem and STEP 7–Micro/WIN.
See Chapter 7, Communicating over a Network, for A
.c o m
information on configuring. See Chapter 10, Creating a
. c o m . c o m .
a24 24 24 24
Program for the Modem Module for programming and

o hoa hoa oa
advanced features of the module.

ngh d on g
d on g o n gh
T u T u Tud
Country Code Switch

Figure A-26 EM 241 Modem Module Terminal Block

4 .c om .com
Diagram
. com 4.
2 24 a2 4 2
ng hoa gh oa
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 385
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
oS7-200 .c om Modules . c om
a 2 4 CPUs that Support
a 2 4
Intelligent
a 2 4 a 2 4.
o gho is an intelligent expansion moduleodesigned
ghoto work with the S7-200 CPUs ongho
ngh The EM 241 Modem module
shown in Table o
d n d n
Tud
A-45.
TuEM
Table A-45 TuCPUs
241 Modem Module Compatibility with S7-200
CPU Description
CPU 222 Rel. 1.10 or greater CPU 222 DC/DC/DC and CPU 222 AC/DC/Relay

. co m CPU 224 Rel. 1.10 or greater

.c m
CPU 224 DC/DC/DC and CPU 224 AC/DC/Relay
o . c o m
24
CPU 226 Rel. 1.00 or greater
24
CPU 226 DC/DC/DC and CPU 226 AC/DC/Relay

a24 2 4.
hoa hoa ho ho a
CPU 226XM Rel. 1.00 or greater CPU 226XM DC/DC/DC and CPU 226XM AC/DC/Relay

ng don
g
do n g
d ong
Tu
Installing the EM 241
Follow these steps to install the EM 241:
Tu
Table A-46 Country Codes Supported by the
Tu
EM 241
1. Snap the EM 241 on the DIN rail and plug Code Country Telecom Standard

4 .c om in the ribbon cable.


4 .c om 01 Austria
4 . c o
CTR21 m .
2 2 connect a2 CTR21 24
hoa aand a
2. Connect 24 VDC from the CPU sensor 02 Belgium
h o
supply or external source, the
h o h o
ng g g g
05 Canada IC CS03
o n
ground terminal to your system earth
o n on
Tud dDenmark d
08 CTR21
ground.
09 T u Finland CTR21 T u
3. Plug the phone line into the RJ11 jack. 10 France CTR21
11 Germany CTR21
4. Set the country code switches according to
om om om
Table A-46. You must set the switches 12 Greece CTR21

2 4 .c 4 . c
before power is applied to the CPU for the 16 Ireland
4 . c
CTR21
4.
hoa oa2
correct country code to be read.
gh
18 Italy
ho a2 CTR21 hoa 2
ng o n
5. Power the CPU. The green MG (Module
d
22
o n g
Luxembourg

dNetherlands
CTR21
o ng
u Tu Tud
Good) light should come on. 25 CTR21
T
Your EM 241 is now ready to communicate.
27 Norway CTR21
30 Portugal CTR21
34 Spain CTR21

4 . c om 4 .c om 35 Sweden

4 .c om
CTR21
.
2 2 36 Switzerland
2 CTR21
24
ng hoa g hoa 38 U.K.
g hoa CTR21
g h o a
ud on 39

u d on
U.S.A. FCC Part 68

u d on
T T T
RJ11 Jack Pin Description
A Figure A-27 shows the details of the RJ11 Jack. 1 234 56
3
4
Ring
Tip

.c o mYou can use adaptors to other standard m


c o
telephone connectors. Refer to your.adaptor . c o m .
a2 4 4
a2 information. 4 connection is allowed.
2Reverse 24
hoa a
connector documentation for more
ho h o gh o
ng d o ng d o g of RJ11 Jack
nView o n
Tu Tu Tud
Figure A-27

Caution
Lightning surges or other unexpected high voltages on the telephone line can damage your EM 241

.co m Modem Module.


.co m . com
a2 4 a 2 4 a2 4
Use a commercially available telephone line surge protector, such as are commonly sold for protection
a2 4.
o gho ho
of personal computer modems. Surge protectors can be damaged as they protect your EM 241 Modem
ho
ng h d o n d o n g
Module. Choose a surge protector with a positive indicator that shows it is functional.
d ong
Tu
Check your
protected.
surge protector regularly to ensure that
Tu
your EM 241 Modem Module continues to be
Tu

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
386
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
Technical Specifications Appendix A

4 .c om 4 .c om 4. c om .
o a2 EM 253 Position
a2
Module
o
Specifications
o a2 o a 24
ng h h
ng Module Order Number ng h g h
Table A-47
o
EM 253 Position
d d o d on
Tu Order Number
Tu Expansion Model EM Inputs EM Outputs
T u
Removable
Connector
6ES7 253–1AA22–0XA0 EM 253 Position Module – 81 Yes

. co
1
m o m
Eight Q outputs are used as logical controls of the motion function and do not directly control any external signals.

.c . c o m
24 24 a24 2 4.
ng hoa Table A-48
g h
EM 253 Position
n
oa General Specifications
Module
n gho ng ho a
o o o
Tud
Order Number
Tud
Module Name and Description
Dimensions (mm)
(W x H x D)
Weight Dissipation
+5 VDC Tu
+24 VDC
d
VDC Requirements

6ES7 253–1AA22–0XA0 EM 253 Position Module 71.2 x 80 x 62 0.190 kg 2.5 W 190 mA See below

4 .c om
Table A-49 EM 253 Position Module Specifications

4 .co m
4 .co m .
2 General
2 2
6ES7 253–1AA22–0XA0
24
ng hoa Input Features
n gh o a
n gh o a
g h o a
Number of inputs
d o 5 points
d o d on
Input type Tu Tu
Sink/Source (IEC Type 1 sink, except ZP) T u
Input Voltage
Maximum Continuous permissible
STP, RPS, LMT+, LMT– 30 VDC

4 .c om ZP

4 .co m
30 VDC at 20 mA, maximum

4 .co m
4.
2 Surge (all inputs)
2 35 VDC for 0.5 sec.
2 2
ng hoa Rated Value
STP, RPS, LMT+, LMT–
ngh oa 24 VDC at 4 mA, nominal
n gh o a
ng hoa
do d o o
Tud
ZP 24 VDC at 15 mA, nominal

Tu
Logic “1” signal (minimum)
STP, RPS, LMT+, LMT– Tu
15 VDC at 2.5 mA, minimum
ZP 3 VDC at 8.0 mA, minimum
Logic “0” signal (maximum)
STP, RPS, LMT+, LMT– 5 VDC at 1 mA, maximum

.com .co m .co m


ZP 1 VDC at 1 mA, maximum
.
a24 2 4 2 4 24
Isolation (field to logic)

o o a o a o a
ngh gh gh h
Optical Isolation (Galvanic) 500 VAC for 1 minute

o n
Isolation groups of
o
1 point for STP, RPS, and ZP
n on g
Tud Tu d u d
2 points for LMT+ and LMT–
Input Delay Times T
STP, RPS, LMT+, LMT– 0.2 ms to 12.8 ms, user selectable
ZP (countable pulse width) 2 µsec minimum A
.c o m Connection of 2 Wire Proximity Sensor (Bero)
Permissible leakage current
. c o m 1 mA, maximum
. c o m .
o a24 Cable Length
hoa
24
hoa
24 oa 24
ngh Unshielded

d on g
d on g o n gh
Tud
STP, RPS, LMT+, LMT– 30 meters
ZP
Shielded T u Not recommended
T u
STP, RPS, LMT+, LMT– 100 meters
ZP 10 meters

om m om
Number of inputs on simultaneously

2 4 .c 55 Degrees C

2 4 .co 5
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 n gh n gho 387
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
oA-49 .co m . c om .
a2 4 Table
2 4
EM 253 Position Module Specifications, continued
a a2 4 a 24
o o o o
ngh gh gh g h
General 6ES7 253–1AA22–0XA0

on on on
Output Features
T
Number of integrated outputs
ud 6 points (4 signals) T ud T u d
Output type
P0+, P0–, P1+, P1– RS422/485 driver
P0, P1, DIS, CLR Open drain

. co m
Output voltage
.c o m . c o m
24 P0, P1, RS–422 drivers, differential output voltage
24 a24 2 4.
hoa hoa ho ho a
Open circuit 3.5 V typical

ng don
g
Into optocoupler diode with 200Ω series resistance 2.8 V minimum

do n g
d ong
Tu Tu Tu
100Ω load 1.5 V minimum
54Ω load 1.0 V minimum
P0, P1, DIS, CLR open drain
recommended voltage, open circuit 5 VDC, available from module
permissible voltage, open circuit 30 VDC1

.co m
Sink current
.co m
50 mA maximum
.co m .
a 2 4 On state resistance
a 2 4 15Ω maximum
a 2 4 a 24
o o 10 µA maximum
o o
ngh gh gh h
Off state leakage current, 30 VDC

n
Internal Pull up resistor, output drain to T1
o
3.3K Ω2
o n on g
Output current
Tu
Number of output groups
d 1 Tu d T u d
Number of outputs ON (maximum) 6
Leakage current per point
P0, P1, DIS, CLR 10 µA maximum

4 .c om Overload Protection
4 .co No m
4 .co m
4.
2 2 2 2
hoa oa a a
Isolation (field to logic)

gh gh o ho
ng g
Optical Isolation (Galvanic) 500 VAC for 1 minute

do n d o n o n
Tud
Output delay

Tu
DIS, CLR: Off to On / On to Off
Pulse Distortion
30 µs, maximum
Tu
P0, P1, outputs, RS–422 drivers, 100 Ω external 75 ns maximum
load

4 . c omP0, P1 outputs, open drain, 5 V / 470 Ω external

4 .co m
300 ns maximum

4 .co m .
24
load
2 2 2
ng hoa Switching frequency

n gh o a
n gh o a
g h o a
on
P0+, P0–, P1+, P1–, P0 and P1 200 kHz
o o
Cable length
Unshielded Tud Not recommended Tu d T u d
Shielded 10 meters
A Power Supply

.c o mL+ supply voltage


. c o m
11 to 30 VDC
. c o m .
a24 24 24 24
Logic supply output +5 VDC +/– 10%, 200 mA maximum

ngh
o L+ supply current vs. 5 VDC load
g hoa g hoa gh oa
Load current
d on 12 VDC Input
d on 24 VDC Input
o n
u u Tud
0 mA (no load)
200 mA (rated load) T 120 mA
300 mA T 70 mA
130 mA
Isolation
L+ power to logic 500 VAC for 1 minute
L+ power to inputs 500 VAC for 1 minute

.co m
L+ power to outputs
.co
None m . com
a2 4 Reverse Polarity
a 2 4 a2 4
L+ input and +5V output are diode-protected. Placing a positive voltage on any M terminal
a2 4.
o gho o
with respect to output point connections can result in potentially damaging current flow.
ho
ng h don d o n gh
d ong
Tu Tu Tu
1 Operation of open drain outputs above 5 VDC may increase radio frequency emissions above permissible limits. Radio frequency containment measures may be required
for your system or wiring.
2 Depending on your pulse receiver and cable, an additional external pull up resistor may improve pulse signal quality and noise immunity.

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
388
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
Technical Specifications Appendix A

4 .c om S7-200 CPUs that Support 4 .c m


oIntelligent 4. c om 4.
o a 2 a 2 Modules
a 2 a 2
ngh homodule is an intelligent expansion module
gA-50.
The EM 253 Position
n n g o to work with the S7-200 CPUs gho
hdesigned
shown in o
u d Table
u d o u d on
T A-50 EM 253 Position Module Compatibility with
Table T S7-200 CPUs T
CPU Description
CPU 222 Rel. 1.10 or greater CPU 222 DC/DC/DC and CPU 222 AC/DC/Relay

. co m CPU 224 Rel. 1.10 or greater

.c o m
CPU 224 DC/DC/DC and CPU 224 AC/DC/Relay

. c o m
24
CPU 226 Rel. 1.00 or greater
24
CPU 226 DC/DC/DC and CPU 226 AC/DC/Relay

a24 2 4.
hoa hoa ho ho a
CPU 226XM Rel. 1.00 or greater CPU 226XM DC/DC/DC and CPU 226XM AC/DC/Relay

ng don
g
do n g
d ong
Tu
EM 253 Position Module Status LEDs Tu
The Status LEDs for the Position Modules are shown in Table A-51.
Tu

om m m
Table A-51 Position Module Status LEDs

2 4 .c Local I/O LED


2 4 .co
Color Function Description
2 4 .co 24 .
hoa a a a
– MF Red Illuminated when module detects a fatal error

gh o gh o h o
ng g
– MG Green Illuminated when there is no module fault, and flashes at 1 Hz rate when a configuration error is

d o n detected
d o n d on
Tu

Input
PWR
STP
Green
Green Tu
Illuminated when 24 VDC is supplied on the L+ and M terminals of the module
Illuminated when the stop input is on T u
Input RPS Green Illuminated when the reference point switch input is on
Input ZP Green Illuminated when the zero pulse input is on

4 .c om Input
Input
LMT–
LMT +
Green
Green
4 . c om
Illuminated when the negative limit input is on
Illuminated when the positive limit input is on
4 .co m
4.
2 2 2 2
hoa oa o a hoa
Output P0 Green Illuminated when the P0 output is pulsing

ng g h gh g
don n n
Output P1 Green Illuminated when the P1 output is pulsing or when this output indicates positive motion

d o o
Tu Tu Tud
Output DIS Green Illuminated when the DIS output is active
Output CLR Green Illuminated when the clear deviation counter output is active

.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
A
.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

4 .c om Figure A-28 EM 253 Position Module

4 .co m
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 389
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
oWiring .c om . c om .
a2 4 Diagrams
a2 4 2 4
aA-28 a 24
h o h o h o h o
ng arrangement. ong
In the following schematic
g
figures, the terminals are not in order. See Figure
o n for terminal
on g
Tud Tud T u d
+5VDC
L+

. co m .c o m T1

. c o m
4.
P/S 3.3K

24 2 4 P0

a24 2
hoa hoa a
M

ng g 5.6K
gho ng ho
don n
STOP

do d o
3.3K

Tu 1M
1K
Tu P1
Tu
5.6K
RPS
3.3K
DIS
1K

.co m 2M

.co m .co m .
a 2 4 a 2 4
ZP 3.3K

a 2 4 a 24
o o o o
ngh gh gh h
CLR

o n 3M
o n on g
Tu d LMT+
5.6K
Tu d P0+

T u d
P0–
1K
P1+

om om m
5.6K
LMT– P1–

2 4 .c 4 . c M
4 .co 4.
oa2 2 2
1K

hoa a a
M

ho ho
4M

ng n g h n g ng
o Schematic for the Inputs and Outputs of theuEM o253 Position Module o
Tud T d Tud
Figure A-29 Internal

4 . c om +24V EM253 Motion Module

4 .c om +5VDC
+24V FM Step Drive

4 .co m .
24
L+

2 2 2
hoa hoa a a
T1
P/S 3.3K

gh
GATE_N
o h o
ng 24V_RTN

d o ngM
P0

d o n d on g
Tu Tu u
24V_RTN GND
STOP
3.3K
P1
T
A 1M
ENABLE

m m m
RPS
3.3K

.c o . c o DIS ENABLE_N
. c o .
a24 24 24 24
Terminals are not in order.

hoa hoa a
2M See Figure A-28 for terminal
o o
ngh gh
arrangement.
ZP
g 3.3K
g
don on o n
CLR

Tu 3M
P0+ T u d PULSE Tud
LMT+
P0– PULSE_N

P1+ DIR

.co m LMT– 5.6K

.co m . com 4.
P1– DIR_N

a2 4 a 2 4 M GND
a2 4 a2
o gho o ho
1K

ng h gh
M GND

ng
4M

don
TuConnecting an EM 253 Position Module to a SIMATIC
Figure A-30
Tu FM Step Drive d o n
Tu d o

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
390
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
Technical Specifications Appendix A

4 .c om 4 .co m
4. c om .
oa2
+24V

o a 2
EM253 Motion Module
+5VDC
o a2
Industrial Devices Corp. (Next Step)

o a 24
ngh gh gh h
L+

on T1

on on g
ud ud d
P/S 3.3K

T 24V_RTN M
P0
T T u
STOP
3.3K
P1

. co m 1M

.c o m +

. c o m
4.
Terminals are not in order.

24 24 a24
RPS
3.3K SD See Figure A-28 for terminal
2
hoa hoa ho ho a
DIS arrangement.

ng don
g 2M

do n g
d ong
Tu Tu Tu
ZP 3.3K
CLR

3M
P0+ +
LMT+
STP

om om m
P0–

2 4 .c 2 4 .c P1+ +

2 4 .co 24 .
hoa hoa a a
DIR
LMT– P1–

gh o h o
ng don
g M

d o n d on g
Tu Tu u
M
4M

T
Figure A-31 Connecting an EM 253 Position Module to a Industrial Devices Corp. (Next Step)

4 .c om 4 .co m
4 .co m
4.
o a2 oa 2 o a 2
hoa 2
ngh gh gh g
+24V EM253 Motion Module Oriental Motor UPK Standard

do n d o n o n
Tud
L+ +5VDC

Tu Tu
+
T1
P/S 3.3K Pulse
24V_RTN M P0 –
+
STOP

4 . c om 4 .c om
3.3K CW/CCW

4 .co m .
24
P1 –

2 2 2
hoa hoa a a
1M

gh
+
o h o
ng ng g
RPS

d o
3.3K
DIS
SD

d o n –
d on
Tu 2M
Tu T u
Terminals are not in order.
See Figure A-28 for terminal
ZP 3.3K arrangement.
CLR
A
.c o m 3M

. c o m P0+
. c o m .
a24 24 24 24
LMT+

o hoa hoa oa
P0–

ngh g g gh
P1+

Tu don
LMT–
P1–
T u d on
Tud
o n
M
4M M

4 .c om Figure A-32

4 .co m
Connecting an EM 253 Position Module to an Oriental Motor UPK Standard

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 391
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 .co m
4. c om .
o a2 +24V
a 2
EM253 Motion Module
o a2
Parker/Compumotor OEM 750
o o a 24
ngh gh gh g h
+5VDC

n n on
L+

ud o T1

ud o u d
24V_RTNT M
P/S 3.3K
P0 T T
STOP
3.3K DIR

.com .com m
P1
1M
. c o 4.
o a 24 o a 24 a24 a2
ho ho
RPS
3.3K

ng h g h g Terminals are not in order.


ng
don n
DIS

do o
See Figure A-28 for terminal

Tu
2M

ZP 3.3K Tu
arrangement.
Tu d
CLR

3M
P0+

4 .c om LMT+

4 .co m Step

4 .co m .
24
P0–

2 2 2
hoa o a o a o a
P1+

ng LMT–
o n gh P1–
o n gh on g h
Tu d M
M Tu d T u d
4M

Figure A-33 Connecting an EM 253 Position Module to a Parker/Compumotor OEM 750

4 .c om 4 .co m
4 .co m
4.
2 2 2 2
ng hoa ngh oa
n gh o a
ng hoa
do d o o
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
A
.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
392
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
Technical Specifications Appendix A

4 .c om 4 . c om 4. c om .
o a2 AS–Interface (CP
o a2
243–2) Module Specifications
o a2 o a 24
ng h h
ng(CP 243–2) Module Order Number dong h g h
Table A-52
o
AS-Interface
d d on
Tu
Order Number
Tu
Expansion Model EM Inputs EM Outputs
T u
Removable
Connector
6GK7 243–2AX01–0XA0 AS–Interface (CP 243–2) Module 8 Digital and 8 Digital and Yes
8 Analog 8 Analog

. co m . c o m . c o m
24 Table A-53 AS-Interface (CP 243–2)2 4 General Specifications 24 2 4.
hoa a a a
Module

gh o gh o ho
ng o n o n
Dimensions (mm) ng
VDC Requirements
o
Tud Tud d
Order Number Module Name and Description Weight Dissipation +5 VDC
Tu
From
(W x H x D)
AS–Interface
6GK7 243–2AX01–0XA0 AS–Interface (CP 243–2) Module 71 x 80 x 62 approx. 3.7 W 220 mA 100 mA
250 g

.co m
Table A-54
.co m
AS-Interface (CP 243–2) Module Specifications
.co m .
a 2 4 General
a 2 4 a 2 4
6GK7 243–2AX01–0XA0
a 24
o o o o
ngh gh gh g h
5 ms with 31 slaves
Cycle time

d o n d o n
10 ms with 62 AS–I slaves using the extended addressing mode
d on
Configuration
Tu Tu T u
Set button on the front panel, or use the total configuration command (refer to the
description of the AS–I commands in the CP 243–2 AS–I Interface Master manual)
AS–I master profiles supported M1e
Attachment to the AS–I cable Via an S7-200 terminal block. Permitted current loading from terminal 1 to 3 or from
terminal 2 to 4 maximum 3 A.

4 .c om Address range
4 .co m .co m
One digital module with 8 digital inputs and 8 digital outputs, and
4 4.
a2 2 2 2
One analog module with 8 analog inputs and 8 analog outputs

o oa ho a hoa
ngh Features n g
doperate
h n g
o up to two AS–Interface modules onudtheoS7-200 at the same time, significantly increasingdo n g
Youu u
T can
T T
the number of available digital and analog inputs/outputs (maximum 124 digital input/124 digital output on
AS–Interface per CP). Setup times are reduced because of the ability to configure at the touch of a button.
LEDs reduce downtime in the event of an error by displaying status of the CP and of all connected slaves,

.co m and by monitoring AS–Interface main voltage.


.co m .co m .
a 2 4 2 4
The AS–Interface Module has the following features:
a a 2 4 a 24
o ho ho o
ngh -
d n g
Supports analog modules
o all master functions and allows connections
-uSupports d o n g
d o ng h
T- LEDs in the front plate display operating T u for up to 62 AS–Interface slaves
Tu
status and availability of connected slaves.
- LEDs in the front plate display errors (including AS–Interface voltage error, configuration error) A
.c o m -
c o m
Two terminals allow direct connection of the AS–Interface cable.
. . c o m
a24 a
- Two buttons display 2 4 status information of the slaves, switchaoperating
the 2 4 mode, and adopt the a 2 4.
o ho as the SET configuration. ngho ho
ngh g g
existing configuration
o n o o n
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 393
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 omOperation 4 .co m
4. c om .
o a2 o a 2 o a2 o a 24
ngh gh gh h
In the process image of the S7-200, the AS–Interface Module occupies a digital input byte (status byte), a
on on
digital output byte (control byte), 8 analog input and 8 analog output words. The AS–Interface Module
on g
ud ud
uses two logical module positions. You can use the status and the control byte to set the mode of the
T T T
AS–Interface Module using a user program. Depending on its mode, the AS–Interface stores either the I/O
u d
data of the AS–Interface slave, diagnostics values, or enables master calls (for example, changing a slave
address) in the analog address area of the S7-200.

. co mAllthetheCPconnected AS–Interface slaves can m


.c o be configured at the touch of a button. Furtherm
. c o configuration of

a 2 4 is not necessary.
a 2 4 a 2 4 a2 4.
o ho ho ho
ngh Caution
n g n g n g
When you use
If analog
udotheisAS–Interface
Tfiltering Tpoint
not disabled in the CPU, the digital
o filtering in the CPU.
Module, you must disabledanalog
u data Tud
will be destroyed, and error conditions
o
will not be returned as bit values in the analog word.
Ensure that analog filtering in the CPU is disabled.

.co m .co m .co m .


a 2 4 Functions
a 2 4 a 2 4 a 24
o o o o
ngh gh gh g h
The CP 243–2 is the AS–Interface master for the M1e master class, which means that it supports all the

d o n d o n
specified functions. This makes it possible to operate up to 31 digital slaves on the AS–Interface by
d on
Tu Tu
means of double address assignment (A–B). The CP 243–2 can be set to two different modes:
T u
- Standard mode: access to the I/O data of
the AS–Interface slave

om - Extended mode: master calls (for


.co m .co m
24.c 4.
example, write parameters) or diagnostic
24 2 4 2
hoa oa a a
value request
gh gh o ho
ng Connections
o n o n o ng
Tud Tu d Tud
The AS–Interface Module has the following
connections:

- Two connections to the AS–Interface


Functional Ground
Module cable (bridged internally)

.co m- .co
One connection for functional ground m .co
+ – m .
a 2 4 a 2 4 a 2
+ – 4 a 24
o o ho the As–Interface Module Cable ng o
ngh gh h
The terminals are located under the cover of the AS–I Cables

o n
front panel as shown in Figure A-34.
o n g o
Tud Tud Tud
Figure A-34
Connecting

Caution

A The load capacity of the AS–Interface Module contacts is a maximum of 3 A. If this value is exceeded
on the AS–Interface Module cable, the AS–Interface must not be looped into the AS–I cable, but must

.c o m . c o m . c o m
be connected by a separate cable (in this case, only one pair of terminals of the AS–Interface Module is
.
a24 24 24 24
used). The AS–Interface must be connected to the grounding conductor via the ground terminal.

ngh
o g hoa ghoa gh oa
Tip
d on d on o n
u u
The AS–Interface Module has a connection for functional ground. This connector should be connected
T T
to the PE conductor with as little resistance as possible. Tud
Additional Information

4 .c omFor 4 . c
more information about the CP 243–2 m
oAS–Interface c omCP 243–2
Master, refer to the SIMATIC NET
4 . 4.
o a2 AS-Interface Master manual.
a 2 a 2 a2
ng h n g ho n g ho n g ho
o o o
Tud Tud Tud

4 . com 4. c om 4 . com .
o a2 o a2 a2 a 24
ngh
394
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
Technical Specifications Appendix A

4 .c om 4 .c om 4. c om .
o a2 Optional Cartridges
o a2 o a2 o a 24
ng h ng h n gh g h
d o ud o d on
Tu u
Cartridge Description Order Number
Memory cartridge T
Memory cartridge storage: Program, Data, and Configuration T
6ES7 291–8GE20–0XA0
Real-Time Clock with battery Clock cartridge accuracy: 6ES7 297–1AA20–0XA0
2 minutes/month at 25°C,

. co m .c m
7 minutes/month at 0°C to 55°C
o . c o m
24
Battery cartridge
24 a24
Battery cartridge (data retention time): 200 days, typical 6ES7 291–8BA20–0XA0
2 4.
ng hoa g hoa General Features
gho Dimensions
ng ho a
Tu
Battery
Size
don Tu
3 V, 30 mA hour, Renata CR 1025
9.9 mm x 2.5 mm
do n
Tu d o
Type Lithium < 0.6 g 18 mm

om om om
10 mm

2 4 .c 2 4 .c 2 4 . c 18 mm
24 .
ng hoa g hoa g hoa g h o a
u on
CPU 224, CPU 226 and CPU 226XM).
u d on
The Memory cartridge stores the complete program and data block for all CPUs (CPU 221, CPU 222,
d u d on
T T T
I/O Expansion Cable

4 .c om 4 .co m
General Features (6ES7 290–6AA20–0XA0)
4 .co m
4.
o a2 Cable length
oa 2 0.8 m
o a 2
hoa 2
ngh Weight
do ngh
d o n gh
25 g
o ng
Tu
Connector type
Tu 10 pin ribbon
Tud

.com .co m .co m .


a 2 4 a 2 4 Female Connector
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
Male Connector A
.c o m . c o m . c o m .
o a24 o a 24of the I/O Expansion Cable
Figure A-35 Typical Installation
o a 24 oa 24
ngh o n gh o n gh o n gh
Tud
Tip Tud Tud
Only one expansion cable is allowed in a CPU/expansion module chain.

.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 395
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 .co m
4. c om .
o a2 PC/PPI Cable
o a 2 o a2 o a 24
ngh on gh on gh on g h
ud
PC/PPI Cable (6ES7 901–3BF21–0XA0)
T
General Characteristics T ud T u d
Supply voltage 14.4 to 28.8 VDC

Supply current at 24 V nominal supply 50 mA RMS max.

24 .com .com
Direction change delay: RS–232 start bit edge received to RS–485

24
1.2 µS max.
. c o m
4.
a24 2
start bit edge transmitted

h o a h o a ho ho a
ng g g ng
Direction change delay: RS–232 stop bit edge received to RS–485 1.4 character times max.

don do n o
transmission disabled (1.4 x 11/baud) = 1.6 ms at 9600 baud

Propagation delay
Tu Tu
4 µS max., RS–485 to RS–232,
Tu d
1.2 µS max., RS–232 to RS–485

Isolation (RS–485 to RS–232) 500 VDC

.co m
RS–485 Side Electrical Characteristics

.co m .co m .
a 2 4 Common mode voltage range

a 2 4 a 2 4
–7 V to +12 V, 1 second, 3 V RMS continuous

a 24
o o o o
ngh gh gh h
Receiver input impedance 5.4K Ω min., including termination

o n o n on g
Termination/bias

Tu d Tu d
10K Ω to +5V on B, PROFIBUS pin 3
10K Ω to GND on A, PROFIBUS pin 8
T u d
Receiver threshold/sensitivity +/– 0.2 V, 60 mV typical hysteresis

Transmitter differential output voltage 2 V min. at RL = 100 Ω, 1.5 V min. at RL = 54 Ω

4 .c om
RS–232 Side Electrical Characteristics

4 .co m
4 .co m
4.
2 2 3K Ω min., minimum
2 2
hoa oa a a
Receiver input impedance

gh gh o ho
ng Receiver threshold/sensitivity

do n n
0.8 V min. low, 2.4 V max. high,

d o o ng
Tud
0.5 V typical hysteresis

Tu
Transmitter output voltage Tu
+/– 5 V min. at RL = 3K Ω

.co m .co m 0.1 m


.co m .
a 2 4 a
0.3 m 2 4 a 2 4
4.6 m
a 24
o o o o
ngh o n gh o n gh on g h
Tud 40 mm
Tu d T u d
RS-232 COMM RS-485 COMM
A Isolated

.c o m . c o m PC/PPI Cable
. c o m .
4 4 4 4 24
PPI

2 2 2
PC

hoa hoa hoa a


Dipswitch # 123 1= 10 BIT
115.2–38.4K 000 0= 11 BIT
gh o
ng d on g 19.2
d on 001 g 5 1= DTE
o n
Tud
1

T u 0 1 2 3 4 5 6
9.6K
2.4K T u 010
100 6
0= DCE
1= RTS for XMT
1.2K 101 0= RTS Always

.co mFigure A-36 .co m . com 4.


PC/PPI Cable Dimensions

a2 4 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
396
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
Technical Specifications Appendix A

4 .c om 4 .co m
4. c om .
oa2
Table A-55
o a 2
Switch Selections on the PC/PPI Cable
o a2 o a 24
ngh gh gh g h
Baud Rate Switches 1,2,3* Modem Operation Switch 4* DCE/DTE Selection Switch 5* RTS Selection for DTE Switch 6*

on on on
ud ud d
115200 – 38400 000 11-bit modem 0 DCE 0 RTS always active 0
19200 T 001 10-bit modem 1 T DTE 1 T u
RTS active when PLC transmits 1
9600 010
4800 011

. co m 2400 100
.c o m . c o m
24 1200 101
24 a24 2 4.
ng hoa 600 110
g hoa gho ng ho a
don
* Switch : 1 = Up; 0 = Down
u
TPin-outs Tu do n
Tu d o
Table A-56 for the RS–485 to RS–232 DCE Connector
RS-485 Connector Pin-out RS-232 DCE Connector Pin-out

4 .c om Pin Number

4 .c om
Signal Description Pin Number

4 . c om
Signal Description

.
24
1 Ground (RS-485 logic ground) 1 Data Carrier Detect (DCD) (not used)
2 2 2
ng hoa 2
hoa
24 V Return (RS-485 logic ground)
g
2
g hoa
Receive Data (RD) (output from PC/PPI cable)
g h o a
3

u d on
Signal B (RxD/TxD+)

u d on 3 Transmit Data (TD) (input to PC/PPI cable)

u d on
4
5
T RTS (TTL level)
Ground (RS-485 logic ground)
T 4
5
Data Terminal Ready (DTR)(not used)
Ground (RS-232 logic ground)
T
6 No connect 6 Data Set Ready (DSR) (not used)

4 .c om 7
8
24 V Supply
Signal A (RxD/TxD–)
4 . c om 7
8
4
m
Request To Send (RTS) (not used)

.co
Clear To Send (CTS) (not used)
4.
2 oa2 2 2
ng hoa 9

ng h
Protocol select

n g ho 9 a
Ring Indicator (RI) (not used)

ng hoa
o o o
Tud for RS–485 to RS–232 DTE Connector Tud
Table A-57 Pin-outs
RS-485 Connector Pin-out RS-232 DTE Connector Pin-out1
Tud
Pin Number Signal Description Pin Number Signal Description

.com 1 Ground (RS-485 logic ground)

.co m 1
m
Data Carrier Detect (DCD) (not used)

.co .
a 2 4 2

a 2 4
24 V Return (RS-485 logic ground) 2
4
Receive Data (RD) (input to PC/PPI cable)

a 2 a 24
o 3
o
Signal B (RxD/TxD+) 3
o
Transmit Data (TD) (output from PC/PPI cable)
o
ngh 4
o n gh
RTS (TTL level)
o n gh
4 Data Terminal Ready (DTR) (not used)
on g h
5
6
Tud Ground (RS-485 logic ground)
No connect
Tu d 5
6
Ground (RS-232 logic ground)
Data Set Ready (DSR) (not used)
T u d
7 24 V Supply 7 Request To Send (RTS)
(output from PC/PPI cable) (switch selectable) A
.c o m 8 Signal A (RxD/TxD–)
. c o m 8
c o m
Clear To Send (CTS) (not used)
. .
o a24 9

hoa
Protocol select
24 9

hoa
24
Ring Indicator (RI) (not used)
oa 24
ngh g g gh
1 A conversion from female to male, and a conversion from 9-pin to 25-pin is required for modems

d on 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 397
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 Input Simulators
o a2 o a2 o a 24
ng h ng h n gh g h
d o ud o d on
Tu Order Number
8 Position Simulator
6ES7 274–1XF00–0XA0
T 14 Position Simulator
6ES7 274–1XH00–0XA0
T u
24 Position Simulator
6ES7 274–1XK00–0XA0
Size (L x W x D) 61 x 36 x 22 mm 91 x 36 x 22 mm 147 x 36 x 25 mm

. co m
Weight 0.02 Kg

.c o m 0.03 Kg

. c o m
0.04 Kg

24
Points 8
24
14

a24
24
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 DC 24V
INPUTS
1M 0.0 0.1
Tu
0.2 0.3 2M 0.4 0.5 0.6 0.7 M L
+
DC SENSOR
SUPPLY
T u
1
23 mm 0

4 .c om 4 . c om 4 .co m
4.
o a2 o a2Simulator o a 2
hoa 2
ngh h gh
Figure A-37 Installation of the Input

d o ng d o n o ng
Tu
Caution Tu Tud
These input simulators are not approved for use in Class I DIV 2 or Class I Zone 2 hazardous locations. The switches
present a potential spark hazard.

4 . c om 4 .co m
Do not use input simulators in Class I DIV 2 or Class I Zone 2 hazardous locations.

4 .co m .
2 2 2 24
ng hoa n gh o a
n gh o a
g h o a
o o on
Tud Tu d T u d
A
.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
398
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 .
o a2 Calculating o aa2 Power Budget o a2 o a 24
ng h ng h ng h g h
d o d o d on
Tu Tu T u
The S7-200 CPU has an internal power supply that provides power for the CPU itself, for any expansion
modules, and for other 24 VDC user power requirements. Use the following information as a guide for

. co m o m o m
determining how much power (or current) the S7-200 CPU can provide for your configuration.
.c . c
24 24 a24 2 4.
ng hoa n g ho
Power Requirements a
n g ho n g ho a
do
Each S7-200
T-uEach
CPU supplies both 5 VDC and 24
T
VDC
u do
power:
T u do
CPU has a 24 VDC sensor supply that can supply 24 VDC for local input points or for relay
coils on the expansion modules. If the power requirement for 24 VDC exceeds the power budget of
the CPU, you can add an external 24 VDC power supply to provide 24 VDC to the expansion

.co m .co m .co m


modules. You must manually connect the 24 VDC supply to the input points or relay coils.
.
a 2 4 -
a 2 4 a 2 4
The CPU also provides 5 VDC power for the expansion modules when an expansion module is
a 24
o ho ho
connected. If the 5 VDC power requirements for expansion modules exceeds the power budget of
o
ngh Theu
n g n g n
the CPU, you must remove expansion modules until the requirement is within the power budget.
d o d o d o g h
T specifications
requirements Tu about the power budgets of the CPUs andTuthe power
in Appendix A provide information
of the expansion modules.

Warning

4 .c om . om . om
Connecting an external 24 VDC power supply in parallel with the S7-200 DC Sensor Supply can result
c c
in a conflict between the two supplies as each seeks to establish its own preferred output voltage level.
4 4 4.
o a2 o a 2
The result of this conflict
ho a 2
can be shortened lifetime or immediate failure of one or both power supplies,
hoa 2
ngh n g
with consequent
death oro
d serious
hunpredictable operation of the PLC system.gUnpredictable
injury to personnel, and/or damage too n
d equipment.
operation could result in
do ng
TuS7-200
The DC Sensor Supply and any external Tupower Tupoints.
supply should provide power to different
A single connection of the commons is allowed.

.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 399
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
oCalculating .c om . c om
a 2 4 a Sample 2
Power
a 4 Requirement
a 2 4 a 2 4.
o hocalculation of the power requirementsnforganhS7-200
o that includes the following: gho
ngh d
g
Table B-1 shows a sample
n
o 224 AC/DC/Relay d o d on
- S7-200
T u CPU
T u T u
- 3 each EM 223 8 DC In/8 Relay Out

- 1 each EM 221 8 DC In

. co mThis installation has a total of 46 inputs.cand


o m34 outputs.
. c o m
a 2 4 The S7-200 CPU in this example a 2 4 sufficient 5 VDC current for the expansion
provides a 2 4 modules, but does a2 4.
o ocurrent from the sensor supply for all ofgthehoinputs and expansion relay coils. ho
ngh The I/O requireso n
400gmAhand
not provide enough 24 VDC
n
do all the included 24 VDC inputs andTudo
d of at least 120 mA at 24 VDC powerTtouoperate
the S7-200 CPU provides only 280 mA. This installation requires an n g
additional u
outputs.T source

.c o mTable B-1 Power Budget Calculations


. c m
for a Sample Configuration
o . c om .
a2 4 CPU Power Budget
a 4
2 5 VDC a 2
24 VDC 4 a 24
ho h o h o h o
ng CPU 224 AC/DC/Relayg
d o n 660 mA
d o ng 280 mA d on g
Tu minus
Tu T u
System Requirements 5 VDC 24 VDC
CPU 224, 14 inputs 14 * 4 mA = 56 mA

4 .c om 3 EM 223, 5 V power required 4.3c* 80omA


m= 240 mA
.com 4.
o a2 1 EM 221, 5V power required a2 1 * 30 mA = a 24 a 2
ho o ho
30 mA

ng h n g g h g
docoils each
3 EM 223, 8 inputs each
d on 3 * 8 * 4 mA = 96 mA
o n
3 EM 223, u
T 8 relay T u 3 * 8 * 9 mA = 216 mA
Tud
1 EM 221, 8 inputs each 8 * 4 mA = 32 mA
Total Requirements 270 mA 400 mA

.co m .co mequals .co m .


a 2 4 2 4
a 5 VDC 24 a
2 4 a 24
o o gho o
ngh gh h
Current Balance VDC

o n on on g
Tud d d
Current Balance Total 390 mA [120 mA]
T u T u

.c o m . c o m . c o m .
B a24 24 24 24
ngh
o g hoa ghoa gh oa
d on 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
400
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
Calculating a Power Budget Appendix B

4 .c om Calculating Your Power4.Requirementc om 4 . c om 4.


o a 2 a 2 a 2 a 2
ngh g hototo Appendix
Use the table below
n determine how much power (or current) h
n g theoS7-200 CPU can provide for your
n g ho
o o o
Tudexpansion modules. Tud Tud
configuration. Refer A for the power budgets of your CPU model and the power requirements
of your

Power Budget 5 VDC 24 VDC

24 .com 24 .com . c o m
4.
h o a h o a minus
ho a24 ho a2
ng d o ng
System Requirements
do n g
d ong
Tu
5 VDC
Tu
24 VDC
Tu

.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 Total Requirements
4 .co m
4 .co m
4.
2 2 2 2
hoa oa a a
equals

gh gh o ho
ng o n
Current Balance
d 5 VDC
d o n 24 VDC
o ng
Tu Balance Total
Current 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
a24 24 24 B 2 4.
ngh
o g hoa g hoa gho
a
d on 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 401
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 .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

You might also like