6ES7 272-0AA30-0YA0 SIEMENS, 6ES7 272-0AA30-0YA0 Datasheet

TEXT DISPLAY, TD200

6ES7 272-0AA30-0YA0

Manufacturer Part Number
6ES7 272-0AA30-0YA0
Description
TEXT DISPLAY, TD200
Manufacturer
SIEMENS
Datasheet

Specifications of 6ES7 272-0AA30-0YA0

Accessory Type
Display
Length
76mm
External Width
148mm
External Depth
27mm
For Use With
S7-200 CPU
SIMATIC
S7-200 Programmable Controller
System Manual
6ES7 298- - 8FA22- - 8BH0
Release 3
Preface, Contents
Product Overview
Getting Started
Installing the S7-200
PLC Concepts
Programming Concepts,
Conventions and Features
S7-200 Instruction Set
Communicating over a Network
Hardware Troubleshooting Guide
and Software Debugging Tools
Creating a Program for the
Position Module
Creating a Program for the
Modem Module
Using the USS Protocol Library to
Control a MicroMaster Drive
Using the Modbus Protocol
Library
Technical Specifications
Calculating a Power Budget
Error Codes
Special Memory (SM) Bits
S7-200 Order Numbers
Execution Times for STL
Instructions
S7-200 Quick Reference
Information
Index
10
11
12
G
A
B
C
D
E
1
2
3
4
5
6
7
8
9
F

Related parts for 6ES7 272-0AA30-0YA0

6ES7 272-0AA30-0YA0 Summary of contents

Page 1

SIMATIC S7-200 Programmable Controller System Manual 6ES7 298- - 8FA22- - 8BH0 Release 3 Preface, Contents Product Overview Getting Started Installing the S7-200 PLC Concepts Programming Concepts, Conventions and Features S7-200 Instruction Set Communicating over a Network Hardware Troubleshooting Guide ...

Page 2

... This device and its components may only be used for the applications described in the catalog or the technical descriptions, and only in connection with devices or components from other manufacturers which have been approved or recommended by Siemens. This product can only function correctly and safely transported, stored, set up, and installed correctly, and operated and maintained as recommended ...

Page 3

Preface The S7-200 series is a line of micro-programmable logic controllers (Micro PLCs) that can control a variety of automation applications. Compact design, low cost, and a powerful instruction set make the S7-200 a perfect solution for controlling small applications. ...

Page 4

... S7-200 Programmable Controller System Manual Maritime Approvals At the time this manual was printed, the SIMATIC S7-200 series met the maritime agencies identifed below. For the latest product approvals, contact your local Siemens distributor or sales office. Agency Lloyds Register of Shipping (LRS) American Bureau of Shipping (ABS) ...

Page 5

... For additional information about Siemens products and services, technical support, frequently asked questions (FAQs), product updates, or application tips, refer to the following Internet addresses: www.ad.siemens.de This 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 ...

Page 6

... 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. ...

Page 7

Contents 1 Product Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...

Page 8

S7-200 Programmable Controller System Manual 6 S7-200 Instruction Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...

Page 9

Shift and Rotate Instructions Shift Right and Shift Left Instructions Rotate Right and Rotate Left Instructions Shift Register Bit Instruction Swap Bytes Instruction String Instructions . . . . . . . . . . . . . . . ...

Page 10

S7-200 Programmable Controller System Manual 10 Creating a Program for the Modem Module Features of the Modem Module Using the Modem Expansion Wizard to Configure the Modem Module Overview of Modem Instructions and Restrictions Instructions for the Modem Module Sample ...

Page 11

C Error Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...

Page 12

xii ...

Page 13

Product Overview The S7-200 series of micro-programmable logic controllers (Micro PLCs) can control a wide variety of devices to support your automation needs. The S7-200 monitors inputs and changes outputs as controlled by the user program, which can include Boolean ...

Page 14

... Figure 1-1 S7-200 Micro PLC Siemens provides different S7-200 CPU models with a diversity of features and capabilities that help you 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. ...

Page 15

... 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. Computer Requirements STEP 7--Micro/WIN runs on either a personal computer or a Siemens programming device, such 760. Your computer or programming device should meet the following minimum requirements: Operating system: ...

Page 16

... To install STEP 7--Micro/WIN on a Windows NT or Windows 2000 operating system, you must log in with Administrator privileges. Communications Options Siemens provides two programming options for connecting your computer to your S7-200: a direct connection with a PC/PPI cable Communications Processor (CP) card with an MPI cable for MPI and PROFIBUS--DP networks. ...

Page 17

Getting Started STEP 7--Micro/WIN makes it easy for you to program your S7-200. In just a few short steps using a simple example, you can learn how to connect, program, and run your S7-200. All you need for this example ...

Page 18

S7-200 Programmable Controller System Manual Connecting the S7-200 CPU Connecting your S7-200 is easy. For this example, you only need to connect power to your S7-200 CPU and then connect the communications cable between your programming device and the S7-200 ...

Page 19

Starting STEP 7- - Micro/WIN Click on the STEP 7--Micro/WIN icon to open a new project. Figure 2-3 shows a new project. Notice the navigation bar. You can use the icons on the navigation bar to open elements of the ...

Page 20

S7-200 Programmable Controller System Manual Creating a Sample Program Entering this example of a control program will help you understand how easy use STEP 7--Micro/WIN. This program uses six instructions in three networks to create a very ...

Page 21

Opening the Program Editor Click on the Program Block icon to open the program editor. See Figure 2-6. Notice the instruction tree and the program editor. You use the instruction tree to insert the LAD instructions into the networks of ...

Page 22

S7-200 Programmable Controller System Manual Entering Network 2: Turning the Output On When the timer value for T33 is greater than or equal to 40 (40 times 10 milliseconds, or 0.4 seconds), the contact provides power flow to turn on ...

Page 23

Saving the Sample Project After entering the three networks of instructions, you have finished entering the program. When you save the program, you create a project that includes the S7-200 CPU type and other parameters. To save the project: 1. ...

Page 24

S7-200 Programmable Controller System Manual 2 12 ...

Page 25

Installing the S7-200 The S7-200 equipment is designed to be easy to install. You can use the mounting holes to attach the modules to a panel, or you can use the built-in clips to mount the modules onto a standard ...

Page 26

S7-200 Programmable Controller System Manual Guidelines for Installing S7-200 Devices You can install an S7-200 either on a panel standard rail, and you can orient the S7-200 either horizontally or vertically. Separate the S7-200 Devices from Heat, ...

Page 27

Power Budget All S7-200 CPUs have an internal power supply that provides power for the CPU, the expansion modules, and other 24 VDC user power requirements. The S7-200 CPU provides the 5 VDC logic power needed for any expansion in ...

Page 28

S7-200 Programmable Controller System Manual Mounting Dimensions The S7-200 CPUs and expansion modules include mounting holes to facilitate installation on panels. Refer to Table 3-1 for the mounting dimensions. Table 3-1 Mounting Dimensions ...

Page 29

Tip Using DIN rail stops could be helpful if your S7-200 environment with high vibration potential or if the S7-200 has been installed vertically. If your system high-vibration environment, then panel-mounting the S7-200 will ...

Page 30

S7-200 Programmable Controller System Manual Guidelines for Grounding and Wiring Proper grounding and wiring of all electrical equipment is important to help ensure the optimum operation of your system and to provide additional electrical noise protection for your application and ...

Page 31

Guidelines for Grounding the S7-200 The best way to ground your application is to ensure that all the common connections of your S7-200 and related equipment are grounded to a single point. This single point should be connected directly to ...

Page 32

S7-200 Programmable Controller System Manual Guidelines for Suppression Circuits You should equip inductive loads with suppression circuits to limit voltage rise when the control output turns off. Suppression circuits protect your outputs from premature failure due to high inductive switching ...

Page 33

PLC Concepts The basic function of the S7-200 is to monitor field inputs and, based on your control logic, turn on or off field output devices. This chapter explains the concepts used to execute your program, the various types of ...

Page 34

S7-200 Programmable Controller System Manual Understanding How the S7-200 Executes Your Control Logic The S7-200 continuously cycles through the control logic in your program, reading and writing data. The S7-200 Relates Your Program to the Physical Inputs and Outputs The ...

Page 35

Reading the Inputs Digital inputs: Each scan cycle begins by reading the current value of the digital inputs and then writing these values to the process-image input register. Analog inputs: The S7-200 does not update analog inputs as part of ...

Page 36

S7-200 Programmable Controller System Manual Accessing the Data of the S7-200 The S7-200 stores information in different memory locations that have unique addresses. You can explicitly identify the memory address that you want to access. This allows your program to ...

Page 37

V B 100 Byte address Access to a byte size Area identifier MSB 7 VB100 VB100 Most significant byte MSB VW100 15 VB100 Most significant byte MSB 31 VD100 VB100 Figure 4-4 Comparing Byte, Word, and Double-Word Access to the ...

Page 38

S7-200 Programmable Controller System Manual Timer Memory Area: T The S7-200 provides timers that count increments of time in resolutions (time-base increments ms, 10 ms, or 100 ms. Two variables are associated with a timer: Current value: this ...

Page 39

High-Speed Counters: HC The high-speed counters count high-speed events independent of the CPU scan. High-speed counters have a signed, 32-bit integer counting value (or current value). To access the count value for the high-speed counter, you specify the address of ...

Page 40

S7-200 Programmable Controller System Manual Special Memory: SM The SM bits provide a means for communicating information between the CPU and your program. You can use these bits to select and control some of the special functions of the S7-200 ...

Page 41

Analog Inputs: AI The S7-200 converts an analog value (such as temperature or voltage) into a word-length (16-bit) digital value. You access these values by the area identifier (AI), size of the data (W), and the starting byte address. Since ...

Page 42

S7-200 Programmable Controller System Manual Format for Strings A string is a sequence of characters, with each character being stored as a byte. The first byte of the string defines the length of the string, which is the number of ...

Page 43

Addressing the Local and Expansion I/O The local I/O provided by the CPU provides a fixed set of I/O addresses. You can add I/O points to the S7-200 CPU by connecting expansion I/O modules to the right side of the ...

Page 44

S7-200 Programmable Controller System Manual Using Pointers for Indirect Addressing of the S7-200 Memory Areas Indirect addressing uses a pointer to access the data in memory. Pointers are double word memory locations that contain the address of another memory location. ...

Page 45

Sample Program for Using an Offset to Access Data in V Memory This example uses LD10 as a pointer to the address VB0. You then increment the pointer by an offset stored in VD1004. LD10 then points to another address ...

Page 46

S7-200 Programmable Controller System Manual Understanding How the S7-200 Saves and Restores Data The S7-200 provides a variety of safeguards to ensure that your program, the program data, and the configuration data for your S7-200 are properly retained. The S7-200 ...

Page 47

Saving the Retentive M Memory Area on Power Loss If you configured the first 14 bytes of bit memory (MB0 to MB13 retentive, these bytes are permanently saved to the EEPROM in the event that the S7-200 loses ...

Page 48

S7-200 Programmable Controller System Manual Storing Your Program on a Memory Cartridge The S7-200 supports an optional memory cartridge that provides a portable EEPROM storage for your program. The S7-200 stores the following elements on the memory cartridge: the program ...

Page 49

As shown in Figure 4-19, the S7-200 performs the following tasks after you cycle power with the memory cartridge installed the contents of the memory cartridge differ from the contents of the EEPROM, the S7-200 clears the RAM. ...

Page 50

S7-200 Programmable Controller System Manual Using Your Program to Save V Memory to the EEPROM You can save a value (byte, word, or double word) stored in any location of the V memory area to the EEPROM. A Save-to-EEPROM operation ...

Page 51

Features of the S7-200 The S7-200 provides several special features that allow you to customize how the S7-200 functions to better fit your application. The S7-200 Allows Your Program to Immediately Read or Write the I/O The S7-200 instruction set ...

Page 52

S7-200 Programmable Controller System Manual The S7-200 Allows You to Allocate Processing Time for Communications Tasks You can configure a percentage of the scan cycle to be dedicated for processing the communications requests that are associated with a RUN mode ...

Page 53

The S7-200 Allows You to Define Memory to Be Retained on Loss of Power You can define up to six retentive ranges to select the areas of memory you want to retain through power cycles. You can define ranges of ...

Page 54

S7-200 Programmable Controller System Manual The S7-200 Allows You to Filter the Analog Inputs The S7-200 allows you to select software filtering on individual analog inputs. The filtered value is the average value of a preselected number of samples of ...

Page 55

Figure 4-27 shows the basic operation of the S7-200 with and without pulse catch enabled. Scan cycle Input update Physical Input Output from pulse catch Disabled Enabled Figure 4-27 Operation of the S7-200 with the Pulse Catch Feature Enabled and ...

Page 56

S7-200 Programmable Controller System Manual The S7-200 Provides Password Protection All models of the S7-200 provide password protection for restricting access to specific functions. A password authorizes access to the functions and memory: without a password, the S7-200 provides unrestricted ...

Page 57

Recovering from a Lost Password If you forget the password, you must clear the memory of the S7-200 and reload your program. Clearing the memory puts the S7-200 in STOP mode and resets the S7-200 to the factory-set defaults, except ...

Page 58

S7-200 Programmable Controller System Manual The S7-200 Provides High-speed I/O High-Speed Counters The S7-200 provides integrated high-speed counter functions that count high speed external events without degrading the performance of the S7-200. See Appendix A for the rates supported by ...

Page 59

Programming Concepts, Conventions, and Features The S7-200 continuously executes your program to control a task or process. You use STEP 7--Micro/WIN to create this program and download it to the S7-200. STEP 7--Micro/WIN provides a variety of tools and features ...

Page 60

S7-200 Programmable Controller System Manual Guidelines for Designing a Micro PLC System There are many methods for designing a Micro PLC system. The following general guidelines can apply to many design projects. Of course, you must follow the directives of ...

Page 61

Create the Configuration Drawings Based on the requirements of the functional specification, create configuration drawings of the control equipment. Include the following items: Overview showing the location of each S7-200 in relation to the process or machine Mechanical layout of ...

Page 62

S7-200 Programmable Controller System Manual Main Program The main body of the program contains the instructions that control your application. The S7-200 executes these instructions sequentially, once per scan cycle. The main program is also referred to as OB1. Subroutines ...

Page 63

Using STEP 7- -Micro/WIN to Create Your Programs To open STEP 7--Micro/WIN, double-click on the STEP 7--Micro/WIN icon, or select the Start > SIMATIC > STEP 7 MicroWIN 3.2 menu command. As shown in Figure 5-1, the STEP 7--Micro/WIN project ...

Page 64

S7-200 Programmable Controller System Manual Features of the LAD Editor The LAD editor displays the program as a graphical representation similar to electrical wiring diagrams. Ladder programs allow the program to emulate the flow of electric current from a power ...

Page 65

Choosing Between the SIMATIC and IEC 1131- -3 Instruction Sets Most PLCs offer similar basic instructions, but there are usually small differences from vendor to vendor in appearance, operation, and so forth. Over the last several years, the International Electrotechnical ...

Page 66

S7-200 Programmable Controller System Manual Understanding the Conventions Used by the Program Editors STEP 7--Micro/WIN uses the following conventions in all of the program editors front of a symbol name (#var1) indicates that the symbol is of ...

Page 67

General Conventions of Programming for an S7-200 EN/ENO Definition EN (Enable IN Boolean input for boxes in LAD and FBD. Power flow must be present at this input for the box instruction to be executed. In STL, the ...

Page 68

S7-200 Programmable Controller System Manual Using Wizards To Help You Create Your Control Program STEP 7--Micro/WIN provides wizards to make aspects of your programming easier and more automatic. In Chapter 6, instructions that have an associated wizard are identified by ...

Page 69

I/O errors At startup, the S7-200 reads the I/O configuration from each module. During normal operation, the S7-200 periodically checks the status of each module and compares it against the configuration obtained during startup. If the S7-200 detects a difference, ...

Page 70

S7-200 Programmable Controller System Manual Assigning Addresses and Initial Values in the Data Block Editor The data block editor allows you to make initial data assignments to V memory (variable memory) only. You can make assignments to bytes, words, or ...

Page 71

Using Local Variables You can use the local variable table of the program editor to assign variables that are unique to an individual subroutine or interrupt routine. See Figure 5-9. Local variables can be used as parameters that are passed ...

Page 72

S7-200 Programmable Controller System Manual Creating an Instruction Library STEP 7--Micro/WIN allows you either to create a custom library of instructions use a library created by someone else. See Figure 5-11. To create a library of instructions, you ...

Page 73

S7-200 Instruction Set This chapter describes the SIMATIC and IEC 1131 instruction set for the S7-200 Micro PLCs. In This Chapter Conventions Used to Describe the Instructions S7-200 Memory Ranges and Features Bit Logic Instructions . . . . . ...

Page 74

S7-200 Programmable Controller System Manual Program Control Instructions Conditional End Stop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...

Page 75

Conventions Used to Describe the Instructions Figure 6-1 shows a typical description for an instruction and points to the different areas used to describe the instruction and its operation. The illustration of the instruction shows the format in LAD, FBD, ...

Page 76

S7-200 Programmable Controller System Manual S7-200 Memory Ranges and Features Table 6-1 Memory Ranges and Features for the S7-200 CPUs Description User program size User data size Process-image input register Process-image output register Analog inputs (read only) Analog outputs (write ...

Page 77

Table 6-2 Operand Ranges for the S7-200 CPUs Access Method CPU 221 Bit access (byte.bit) I 0.0 to 15.7 Q 0.0 to 15.7 V 0.0 to 2047.7 M 0.0 to 31.7 SM 0.0 to 179.7 S 0.0 to 31.7 T ...

Page 78

S7-200 Programmable Controller System Manual Bit Logic Instructions Contacts Standard Contacts The Normally Open contact instructions (LD, A, and O) and Normally Closed contact instructions (LDN, AN, ON) obtain the referenced value from the memory or from the process-image register. ...

Page 79

Tip Because the Positive Transition and Negative Transition instructions require an on-to-off or an off-to-on transition, you cannot detect an edge-up or edge-down transition on the first scan. During the first scan, the S7-200 sets the state of the bit ...

Page 80

S7-200 Programmable Controller System Manual Coils Output The Output instruction (=) writes the new value for the output bit to the process-image register. When the Output instruction is executed, the S7-200 turns the output bit in the process-image register on ...

Page 81

Example: Coil Instructions Network Network Network Network 4 LD LPS A S LPP A R Network Timing Diagram Network 1 I0.0 Q0.0, Q0.1, V0.0 Networks 2 ...

Page 82

S7-200 Programmable Controller System Manual Logic Stack Instructions AND Load The AND Load instruction (ALD) combines the values in the first and second levels of the stack using a logical AND operation. The result is loaded in the top of ...

Page 83

As shown in Figure 6-2, the S7-200 uses a logic stack to resolve the control logic. In these examples, “iv0” to “iv7” identify the initial values of the logic stack, “nv” identifies a new value provided by the instruction, and ...

Page 84

S7-200 Programmable Controller System Manual Set and Reset Dominant Bistable Instructions The Set Dominant Bistable is a latch where the set dominates. If the set (S1) and reset (R) signals are both true, the output (OUT) is true. The Reset ...

Page 85

Clock Instructions Read Real-Time Clock and Set Real-Time Clock The Read Real-Time Clock (TODR) instruction reads the current time and date from the hardware clock and loads 8-byte Time buffer starting at address T. The Set Real-Time ...

Page 86

S7-200 Programmable Controller System Manual Communications Instructions Network Read and Network Write Instructions The Network Read instruction (NETR) initiates a communications operation to gather data from a remote device through the specified port (PORT), as defined by the table (TBL). ...

Page 87

Figure 6-4 describes the table that is referenced by the TBL parameter, and Table 6-10 lists the error codes. D Done (function has been completed): Byte Offset Active (function has been queued): E Error (function returned an ...

Page 88

S7-200 Programmable Controller System Manual Case Packer #1 Station 2 VB100 Control VW101 Status VB100 f e VB101 VB102 t Out of butter tubs to pack; t=1, out of butter tubs 6 b Box supply is low; b=1, must add ...

Page 89

Example: Network Read and Network Write Instructions S7-200 Instruction Set Network 1 //On the first scan, enable the PPI master mode /and clear all receive and transmit buffers. LD SM0.1 MOVB 2, SMB30 FILL +0, VW200, 68 Network 2 //When ...

Page 90

S7-200 Programmable Controller System Manual Example: Network Read and Network Write Instructions , continued 6 78 Network 4 //If not the first scan and there are no errors: //1. Load the station address of case packer #1. //2. Load a ...

Page 91

Transmit and Receive Instructions (Freeport) The Transmit instruction (XMT) is used in Freeport mode to transmit data by means of the communications port(s). The Receive instruction (RCV) initiates or terminates the receive message function. You must specify a start and ...

Page 92

S7-200 Programmable Controller System Manual Changing PPI Communications to Freeport Mode SMB30 and SMB130 configure the communications ports, 0 and 1 respectively, for Freeport operation and provide selection of baud rate, parity, and number of data bits. Figure 6-7 describes ...

Page 93

As shown in Table 6-12, the Receive instruction allows you to select the message start and message end conditions, using SMB86 through SMB94 for port 0 and SMB186 through SMB194 for port 1. Tip The receive message function is automatically ...

Page 94

S7-200 Programmable Controller System Manual Start and End Conditions for the Receive Instruction The Receive instruction uses the bits of the receive message control byte (SMB87 or SMB187) to define the message start and end conditions. Tip If there is ...

Page 95

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 function searches for an idle line condition. ...

Page 96

S7-200 Programmable Controller System Manual The Receive instruction supports several ways to terminate a message. The message can be terminated on one or a combination of the following: 1. End character detection: The end character is any character which is ...

Page 97

Characters Start of the message: Starts the message timer Figure 6-12 Using the Message Timer to Terminate the Receive Instruction 4. Maximum character count: The Receive instruction must be told the maximum number of characters to receive (SMB94 or SMB194). ...

Page 98

S7-200 Programmable Controller System Manual Example: Transmit and Receive Instructions Network 1 //This program receives a string of characters until //a line feed character is received. //The message is then transmitted back to the ...

Page 99

Example: Transmit and Receive Instructions, continued S7-200 Instruction Set Network 1 //Receive complete interrupt routine: //1. If receive status shows receive of end character, // then attach a ...

Page 100

S7-200 Programmable Controller System Manual Get Port Address and Set Port Address Instructions The Get Port Address instruction (GPA) reads the station address of the S7-200 CPU port specified in PORT and places the value in the address specified in ...

Page 101

Compare Instructions Comparing Numerical Values The compare instructions are used to compare two values: IN1 = IN2 IN1 >= IN2 IN1 <= IN2 IN1 > IN2 IN1 < IN2 IN1 <> IN2 Compare Byte operations are unsigned. Compare Integer operations ...

Page 102

S7-200 Programmable Controller System Manual Example: Compare Instructions 6 90 Network 1 //Turn analog adjustment potentiometer 0 to vary //the SMB28 byte value. //Q0.0 is active when the SMB28 value is less than //or equal to 50. //Q0.1 is active ...

Page 103

Compare String The Compare String instruction compares two strings of ASCII characters: IN1 = IN2 IN1 <> IN2 When the comparison is true, the Compare instruction turns the contact (LAD) or output (FBD) on, or the compare instruction Loads, ANDs ...

Page 104

S7-200 Programmable Controller System Manual Conversion Instructions Standard Conversion Instructions Numerical Conversions The Byte to Integer (BTI), Integer to Byte (ITB), Integer to Double Integer (ITD), Double Integer to Integer (DTI), Double Integer to Real (DTR), BCD to Integer (BCDI) ...

Page 105

Operation of the BCD to Integer and Integer to BCD Instructions The BCD to Integer instruction (BCDI) converts the binary-coded decimal value integer value and loads the result into the variable specified by OUT. The valid range ...

Page 106

S7-200 Programmable Controller System Manual Operation of the Round and Truncate Instructions The Round instruction (ROUND) converts the real-number value double integer value and places the result into the variable specified by OUT. If the fraction portion ...

Page 107

Operation of the Segment Instruction To illuminate the segments of a seven-segment display, the Segment instruction (SEG) converts the character (byte) specified generate a bit pattern (byte) at the location specified by OUT. The illuminated segments represent ...

Page 108

S7-200 Programmable Controller System Manual ASCII Conversion Instructions Valid ASCII characters are the hexadecimal values 30 to 39, and 41 to 46. Converting between ASCII and Hexadecimal Values The ASCII to Hexadecimal instruction (ATH) converts a number LEN of ASCII ...

Page 109

Figure 6-14 shows examples of values that are formatted using a decimal point (c=0) with three digits to the right of the decimal point (nnn=011). The output buffer is formatted according to the following rules: Positive values are written to ...

Page 110

S7-200 Programmable Controller System Manual Operation of the Real to ASCII Instruction The Real to ASCII instruction (RTA) converts a real-number value IN to ASCII characters. The format FMT specifies the conversion precision to the right of the decimal, whether ...

Page 111

Example: ASCII to Hexadecimal Instruction ‘3’ ‘E’ ‘A’ ATH VB30 VB40 Example: Integer to ASCII Instruction ‘ ’ ‘ ’ ‘1’ 12345 ITA VW2 VB10 VB11 ... Example: Real to ASCII Instruction ‘ ...

Page 112

S7-200 Programmable Controller System Manual String Conversion Instructions Converting Numerical Values to String The Integer to String (ITS), Double Integer to String (DTS), and Real to String (RTS) instructions convert integers, double integers, or real number values (IN ...

Page 113

FMT MSB LSB comma (1) or decimal point (0) nnn = digits to right of decimal point Figure 6-17 FMT Operand for ...

Page 114

S7-200 Programmable Controller System Manual Operation of the Real to String The Real to String instruction (RTS) converts a real value ASCII string. The format (FMT) specifies the conversion precision to the right of the decimal, whether ...

Page 115

Converting Substrings to Numerical Values The Substring to Integer (STI), Substring to Double Integer (STD), and Substring to Real (STR) instructions convert a string value IN, starting at the offset INDX integer, double integer or real number value ...

Page 116

S7-200 Programmable Controller System Manual Valid Input Strings for Integer and Double Integer Input String ‘123’ ‘- -00456’ ‘123.45’ ‘+2345’ ‘000000123ABCD’ Figure 6-20 Examples of Valid and Invalid Input Strings Example: String Conversion: Substring to Integer, Double Integer and Real ...

Page 117

Encode and Decode Instructions Encode The Encode instruction (ENCO) writes the bit number of the least significant bit set of the input word IN into the least significant “nibble” (4 bits) of the output byte OUT. Decode The Decode instruction ...

Page 118

S7-200 Programmable Controller System Manual Counter Instructions SIMATIC Counter Instructions Count Up Counter The Count Up instruction (CTU) counts up from the current value each time the count up (CU) input makes the transition from off to on. When the ...

Page 119

Tip Since there is one current value for each counter, do not assign the same number to more than one counter. (Up Counters, Up/Down Counters, and Down counters with the same number access the same current value.) When you reset ...

Page 120

S7-200 Programmable Controller System Manual Example: SIMATIC Count Up/Down Counter Instruction 6 Timing Diagram 108 Network 1 //I0.0 counts up //I0.1 counts down //I0.2 resets current value I0.0 LD I0.1 LD I0.2 CTUD C48, +4 Network 2 ...

Page 121

IEC Counter Instructions Up Counter The Count Up instruction (CTU) counts up from the current value to the preset value (PV) on the rising edges of the Count Up (CU) input. When the current value (CV) is greater than or ...

Page 122

S7-200 Programmable Controller System Manual Example: IEC Counter Instructions 6 110 Timing Diagram I4 I3 Down I2 Reset I1 Load 4 4 VW0 ...

Page 123

High-Speed Counter Instructions High-Speed Counter Definition The High-Speed Counter Definition instruction (HDEF) selects the operating mode of a specific high-speed counter (HSCx). The mode selection defines the clock, direction, start, and reset functions of the high-speed counter. You use one ...

Page 124

S7-200 Programmable Controller System Manual Typically, a high-speed counter is used as the drive for a drum timer, where a shaft rotating at a constant speed is fitted with an incremental shaft encoder. The shaft encoder provides a specified number ...

Page 125

Defining Counter Modes and Inputs Use the High-Speed Counter Definition instruction to define the counter modes and inputs. Table 6-25 shows the inputs used for the clock, direction control, reset, and start functions associated with the high-speed counters. The same ...

Page 126

S7-200 Programmable Controller System Manual Examples of HSC Modes The timing diagrams in Figure 6-21 through Figure 6-25 show how each counter functions according to mode. Clock Internal Direction Control (1 = Up) Counter 6 Current Value Figure 6-21 Operation ...

Page 127

When you use counting modes and rising edges on both the up clock and down clock inputs occur within 0.3 microseconds of each other, the high-speed counter could see these events as happening simultaneously. If this ...

Page 128

S7-200 Programmable Controller System Manual Phase A Clock Phase B Clock 6 Counter Current Value Figure 6-25 Operation Example of Modes 9, 10 (Quadrature 4x Mode) Reset and Start Operation The operation of the reset and start inputs ...

Page 129

Four counters have three control bits that are used to configure the active state of the reset and start inputs and to select counting modes (quadrature counters only). These bits are located in the control byte for ...

Page 130

S7-200 Programmable Controller System Manual Setting the Control Byte After you define the counter and the counter mode, you can program the dynamic parameters of the counter. Each high-speed counter has a control byte that allows the following actions: Enabling ...

Page 131

Addressing the High-Speed Counters (HC) To access the count value for the high-speed counter, specify the address of the high-speed counter, using the memory type (HC) and the counter number (such as HC0). The current value of the high-speed counter ...

Page 132

S7-200 Programmable Controller System Manual Sample Initialization Sequences for the High-Speed Counters HSC1 is used as the model counter in the following descriptions of the initialization and operation sequences. The initialization descriptions assume that the S7-200 has just been placed ...

Page 133

Initialization Modes The following steps describe how to initialize HSC1 for Single Phase Up/Down Counter with External Direction (Modes 5): 1. Use the first scan memory bit to call a subroutine in which ...

Page 134

S7-200 Programmable Controller System Manual 7. In order to capture direction changes, program an interrupt by attaching the direction changed interrupt event (event 14 interrupt routine order to capture an external reset event, program an interrupt ...

Page 135

Change Direction in Modes The following steps describe how to configure HSC1 for Change Direction for Single Phase Counter with Internal Direction (Modes 2): 1. Load SMB47 to write the desired direction: SMB47 ...

Page 136

S7-200 Programmable Controller System Manual Example: High-Speed Counter Instruction 124 Network 1 //On the first scan, call SBR_0. LD SM0.1 CALL SBR_0 Network 1 //On the first ...

Page 137

Pulse Output Instruction The Pulse Output instruction (PLS) is used to control the Pulse Train Output (PTO) and Pulse Width Modulation (PWM) functions available on the high-speed outputs (Q0.0 and Q0.1).You can use Position the Position Control wizard to configure ...

Page 138

S7-200 Programmable Controller System Manual Pulse Train Operation (PTO) PTO provides a square wave (50% duty cycle) output for a specified number of pulses and a specified cycle time. (See Figure 6-28.) PTO can produce either a single train of ...

Page 139

Table 6-32 Profile Table Format for Multiple-Segment PTO Operation Byte Offset Segment Description of Table Entries 0 Number of segments 255 1 #1 Initial cycle time (2 to 65,535 units of the time base) 3 Cycle time delta ...

Page 140

S7-200 Programmable Controller System Manual Tip The PWM Update Method bit (SM67.4 or SM77.4) in the control byte specifies the update type used when the PLS instruction is executed to invoke changes. If the time base is changed, an asynchronous ...

Page 141

Table 6-34 SM Locations of the PTO / PWM Control Registers Q0.0 Q0.1 Status Bits SM66.4 SM76.4 PTO profile aborted (delta calculation error): SM66.5 SM76.5 PTO profile aborted due to user command: SM66.6 SM76.6 PTO pipeline overflow/underflow: SM66.7 SM76.7 PTO ...

Page 142

S7-200 Programmable Controller System Manual Calculating Profile Table Values The multiple-segment pipelining capability of the PTO/PWM generators can be useful in many applications, particularly in stepper motor control. For example, you can use PTO with a pulse profile to control ...

Page 143

In order to determine if the transitions between waveform segments are acceptable, you need to determine the cycle time of the last pulse in a segment. Unless the delta cycle time is 0, you must calculate the cycle time of ...

Page 144

S7-200 Programmable Controller System Manual Sample Operation of a PWM Output Tip The following description of the PWM initialization and operation sequences recommends using the First Scan bit (SM0.1) to initialize the pulse output. Using the First Scan bit to ...

Page 145

Example: Pulse Width Modulation (PWM Timing Diagram Q0.1 10% duty cycle Cycle time = 10,000 ms S7-200 Instruction Set Network 1 //On the first scan, //set the image ...

Page 146

S7-200 Programmable Controller System Manual Sample Operation of a PTO Output Tip The following description of the PTO initialization and operation sequences recommends using the First Scan memory bit (SM0.1) to initialize the pulse output. Using the First Scan bit ...

Page 147

Changing the PTO Pulse Count (Single-Segment Operation) For a single-segment PTO operation, you can use an interrupt routine or a subroutine to change the pulse count. To change the PTO pulse count in an interrupt routine or a subroutine when ...

Page 148

S7-200 Programmable Controller System Manual Example: Single-Segment Pulse Train Operation (PTO 136 Network 1 //On the first scan, //set the image register bit low and call subroutine 0. LD SM0.1 R ...

Page 149

Example: Single-Segment Pulse Train Operation (PTO), continued Timing Diagram 1 cycle 500 ms Q0.0 4 cycles or 4 pulses S7-200 Instruction Set Network 1 //If current cycle time is 500 ms: //Set the cycle time to ...

Page 150

S7-200 Programmable Controller System Manual Example: Multiple-Segment Pulse Train Operation (PTO 138 Network 1 //On the first scan, //set the image register bit low and call subroutine 0 LD SM0.1 R ...

Page 151

Example: Multiple-Segment Pulse Train Operation (PTO) , continued S7-200 Instruction Set Network 2 //1. Set up the control byte Select ...

Page 152

S7-200 Programmable Controller System Manual Math Instructions Add, Subtract, Multiply, and Divide Instructions Add IN1 + IN2 = OUT IN1 + OUT = OUT The Add Integer (+I) or Subtract Integer (--I) instructions add or subtract two 16-bit integers to ...

Page 153

Example: Integer Math Instructions Add 100 AC1 AC0 AC0 Example: Real Math Instructions Add 4000.0 + 6000.0 = 10000.0 AC1 AC0 AC0 S7-200 Instruction Set Network 1 LD I0.0 +I AC1, AC0 *I AC1, VW100 /I ...

Page 154

S7-200 Programmable Controller System Manual Multiply Integer to Double Integer and Divide Integer with Remainder Multiply Integer to Double Integer IN1 * IN2 = OUT IN1 * OUT = OUT The Multiply Integer to Double Integer instruction (MUL) multiplies two ...

Page 155

Numeric Functions Instructions Sine, Cosine, and Tangent The Sine (SIN), Cosine (COS), and Tangent (TAN) instructions evaluate the trigonometric function of the angle value IN and place the result in OUT. The input angle value is in radians. SIN (IN) ...

Page 156

S7-200 Programmable Controller System Manual Increment and Decrement Instructions Increment OUT OUT + 1 = OUT Decrement OUT OUT -- 1 = OUT The Increment and Decrement instructions add or subtract 1 ...

Page 157

Proportional/Integral/Derivative (PID) Loop Instruction The PID Loop instruction (PID) executes a PID loop calculation on the referenced LOOP based on the input and configuration information in Table (TBL). Error conditions that set ENO = 0: SM1.1 (overflow) 0006 (indirect address) ...

Page 158

S7-200 Programmable Controller System Manual Understanding the PID Algorithm In steady state operation, a PID controller regulates the value of the output drive the error (e) to zero. A measure of the error is given by the ...

Page 159

The S7-200 uses a modified form of the above simplified equation when calculating the loop output value. This modified equation is output = proportional term + where the calculated value of the ...

Page 160

S7-200 Programmable Controller System Manual Understanding the Differential Term of the PID Equation The differential term MD is proportional to the change in the error. The S7-200 uses the following equation for the differential term ...

Page 161

Converting and Normalizing the Loop Inputs A loop has two input variables, the setpoint and the process variable. The setpoint is generally a fixed value such as the speed setting on the cruise control in your automobile. The process variable ...

Page 162

S7-200 Programmable Controller System Manual Converting the Loop Output to a Scaled Integer Value The loop output is the control variable, such as the throttle setting of the cruise control on an automobile. The loop output is a normalized, real ...

Page 163

By adjusting the bias as described, an improvement in system responsiveness is achieved once the calculated output comes back into the proper range. The calculated bias is also clamped between 0.0 and 1.0 and then is written to the bias ...

Page 164

S7-200 Programmable Controller System Manual Loop Table The loop table is 36 bytes long and has the format shown in Table 6-42. Table 6-42 Loop Table Offset Field 0 Process variable ( Setpoint ( ...

Page 165

Example: PID Loop Instruction S7-200 Instruction Set Network 1 //On the first scan, //Call the initialization subroutine LD SM0.1 CALL SBR_0 Network 1 //Load PID parameters and //attach the PID interrupt routine: ...

Page 166

S7-200 Programmable Controller System Manual Example: PID Loop Instruction, continued 154 Network 1 //Scale the normalized real number: //1. Convert the integer value to a double integer. //2. Convert the double integer ...

Page 167

Interrupt Instructions Enable Interrupt and Disable Interrupt The Enable Interrupt instruction (ENI) globally enables processing of all attached interrupt events. The Disable Interrupt instruction (DISI) globally disables processing of all interrupt events. When you make the transition to RUN mode, ...

Page 168

S7-200 Programmable Controller System Manual You can disable individual interrupt events by breaking the association between the interrupt event and the interrupt routine with the Detach Interrupt instruction. The Detach Interrupt instruction returns the interrupt to an inactive or ignored ...

Page 169

Understanding How the S7-200 Processes Interrupt Routines The interrupt routine is executed in response to an associated internal or external event. Once the last instruction of the interrupt routine has been executed, control is returned to the main program. You ...

Page 170

S7-200 Programmable Controller System Manual Calling Subroutines from Interrupt Routines You can call one nesting level of subroutines from an interrupt routine. The accumulators and the logic stack are shared between an interrupt routine and a subroutine that is called. ...

Page 171

After being enabled, the timed interrupt runs continuously, executing the attached interrupt routine on each expiration of the specified time interval. If you exit RUN mode or detach the timed interrupt, the timed interrupt is disabled. If the global disable ...

Page 172

S7-200 Programmable Controller System Manual Table 6-48 Priority Order for Interrupt Events Event Description 8 Port 0 9 Port 0 23 Port 0 24 Port 1 25 Port 1 26 Port 1 19 PLS0 20 PLS1 0 I0.0 2 I0.1 ...

Page 173

Example: Interrupt Instructions M Network ATCH ENI Network 2 LD DTCH Network 3 LD DISI I Network CRETI Example: Timed Interrupt for Reading the Value of an Analog Input M ...

Page 174

S7-200 Programmable Controller System Manual Logical Operations Instructions Invert Instructions Invert Byte, Word, and Double Word The Invert Byte (INVB), Invert Word (INVW), and Invert Double Word (INVD) instructions form the one’s complement of the input IN and load the ...

Page 175

AND, OR, and Exclusive OR Instructions AND Byte, AND Word, and AND Double Word The AND Byte (ANDB), AND Word (ANDW), and AND Double Word (ANDD) instructions AND the corresponding bits of two input values IN1 and IN2 and load ...

Page 176

S7-200 Programmable Controller System Manual Example: AND, OR, and Exclusive OR Instructions 6 164 Network 1 LD I4.0 ANDW AC1, AC0 ORW AC1, VW100 XORW AC1, AC0 AND Word OR Word AC1 0001 1111 0110 1101 AND AC0 1101 0011 ...

Page 177

Move Instructions Move Byte, Word, Double Word, or Real The Move Byte (MOVB), Move Word (MOVW), Move Double Word (MOVD), and Move Real (MOVR) instructions move a value from a memory location new memory location OUT without ...

Page 178

S7-200 Programmable Controller System Manual Move Byte Immediate (Read and Write) The Move Byte Immediate instructions allow you to immediately move a byte between the physical I/O and a memory location. The Move Byte Immediate Read (BIR) instruction reads physical ...

Page 179

Block Move Instructions Block Move Byte, Word, or Double Word The Block Move Byte (BMB), Block Move Word (BMW), and Block Move Double Word (BMD) instructions move a specified amount of data to a new memory location by moving the ...

Page 180

S7-200 Programmable Controller System Manual Program Control Instructions Conditional End The Conditional End instruction (END) terminates the current scan based upon the condition of the preceding logic. You can use the Conditional End instruction in the main program, but you ...

Page 181

Example: Stop, End, and Watchdog Reset Instructions Network 1 LD STOP Network 2 LD WDR BIW Network 3 LD END S7-200 Instruction Set //When an I/O error is detected: //Force the transition to STOP mode. SM5.0 //When M5.6 is on, ...

Page 182

S7-200 Programmable Controller System Manual For- - Next Loop Instructions Use the For (FOR) and Next (NEXT) instructions to delineate a loop that is repeated for the specified count. Each For instruction requires a Next instruction. You can nest For--Next ...

Page 183

Example: For- - Next Loop Instructions 2 S7-200 Instruction Set Network 1 //When I2.0 comes on, the outside loop //(arrow 1) is executed 100 times 1 LD I2.0 FOR VW100, +1, +100 Network 2 //The inside loop (arrow 2) is ...

Page 184

S7-200 Programmable Controller System Manual Jump Instructions The Jump to Label instruction (JMP) performs a branch to the specified label N within the program. The Label instruction (LBL) marks the location of the jump destination N. You can use the ...

Page 185

Sequence Control Relay (SCR) Instructions SCR instructions provide you with a simple yet powerful state control programming technique that fits naturally into a LAD, FBD, or STL program. Whenever your application consists of a sequence of operations that must be ...

Page 186

S7-200 Programmable Controller System Manual Figure 6-31 shows the S stack and the logic stack and the effect of executing the Load SCR instruction. The following is true of Sequence Control Relay instructions: The Load SCR instruction (LSCR) marks the ...

Page 187

Example: Sequence Control Relay Instruction Network Network 2 LSCR Network TON Network 4 LD SCRT Network 5 SCRE Network 6 LSCR Network TON Network 8 LD SCRT Network 9 SCRE ...

Page 188

S7-200 Programmable Controller System Manual Divergence Control In many applications, a single stream of sequential states must be split into two or more different streams. When a control stream diverges into multiple streams, all outgoing streams must be activated simultaneously. ...

Page 189

State L Figure 6-33 Convergence of a Control Stream Example: Convergence of Control Streams S7-200 Instruction Set State M Transition Condition State N Network 1 //Beginning of State L control region LSCR S3.4 Network 2 //Transition to State L’ LD ...

Page 190

S7-200 Programmable Controller System Manual In other situations, a control stream might be directed into one of several possible control streams, depending upon which transition condition comes true first. Such a situation is depicted in Figure 6-34, which shows an ...

Page 191

Shift and Rotate Instructions Shift Right and Shift Left Instructions The Shift instructions shift the input value IN right or left by the shift count N and load the result in the output OUT. The Shift instructions fill with zeros ...

Page 192

S7-200 Programmable Controller System Manual Example: Shift and Rotate Instructions Rotate Before rotate AC0 0100 0000 0000 0001 6 After first rotate AC0 1010 0000 0000 0000 After second rotate AC0 0101 0000 0000 0000 Zero Memory Bit (SM1.0) Overflow ...

Page 193

Shift Register Bit Instruction The Shift Register Bit instruction shifts a value into the Shift Register. This instruction provides an easy method for sequencing and controlling product flow or data. Use this instruction to shift the entire register one bit, ...

Page 194

S7-200 Programmable Controller System Manual Example: Shift Register Bit Instruction Timing Diagram I0.2 Positive transition (P) I0.3 6 First shift 182 Network 1 LD I0.2 EU SHRB I0.3, V100. (MSB) Before first shift V100 Overflow (SM1.1) After first ...

Page 195

Swap Bytes Instruction The Swap Bytes instruction exchanges the most significant byte with the least significant byte of the word IN. Error conditions that set ENO = 0 0006 (indirect address) Table 6-60 Valid Operands for the Swap Bytes Instruction ...

Page 196

S7-200 Programmable Controller System Manual String Instructions String Length The String Length instruction (SLEN) returns the length of the string specified by IN. Copy String The Copy String instruction (SCPY) copies the string specified the string specified ...

Page 197

Example: Concatenate String, Copy String, and String Length Instructions Before executing the program VB0 VB6 6 ’H’ ’E’ ’L’ ’L’ ’O’ ’ ’ After executing the program VB0 11 ’H’ ’E’ ’L’ ’L’ ’O’ ’ ’ VB100 11 ’H’ ’E’ ...

Page 198

S7-200 Programmable Controller System Manual Copy Substring from String The Copy Substring from String instruction (SSCPY) copies the specified number of characters N from the string specified by IN, starting at the index INDX new string specified by ...

Page 199

Find String Within String The Find String Within String instruction (SFND) searches for the first occurrence of the string IN2 within the string IN1. The search begins at the starting position specified by OUT sequence of characters is ...

Page 200

S7-200 Programmable Controller System Manual Example: Find String Within String Instruction The following example uses a string stored at VB0 as a command for turning a pump on or off. A string ’On’ is stored at VB20, and a string ...

Related keywords