s
SIMATIC
Ladder Logic (LAD) for S7-300 and
S7-400 Programming
Reference Manual
04/2017
A5E41524738-AA
Preface
Bit Logic Instructions
1
Comparison Instructions
2
Conversion Instructions
3
Counter Instructions
4
Data Block Instructions
5
Logic Control Instructions
6
Integer Math Instructions
7
Floating Point Math
Instructions
8
Move Instructions
9
Program Control Instructions
10
Shift and Rotate Instructions
11
Status Bit Instructions
12
Timer Instructions
13
Word Logic Instructions
14
Overview of All LAD
Instructions
A
Programming Examples
B
Working with Ladder Logic
C
Siemens AG
Division Digital Factory
Postfach 48 48
90026 NÜRNBERG
GERMANY
A5E41524738-AA
Ⓟ 03/2017 Subject to change
Copyright © 2017.
All rights reserved
Legal information
Warning notice system
This manual contains notices you have to observe in order to ensure your personal safety, as well as to
prevent damage to property. The notices referring to your personal safety are highlighted in the manual by a
safety alert symbol, notices referring only to property damage have no safety alert symbol. These notices
shown below are graded according to the degree of danger.
DANGER
indicates that death or severe personal injury will result if proper precautions are not taken.
WARNING
indicates that death or severe personal injury may result if proper precautions are not taken.
CAUTION
indicates that minor personal injury can result if proper precautions are not taken.
NOTICE
indicates that property damage can result if proper precautions are not taken.
If more than one degree of danger is present, the warning notice representing the highest degree of danger
will be used. A notice warning of injury to persons with a safety alert symbol may also include a warning
relating to property damage.
Qualified Personnel
The product/system described in this documentation may be operated only by personnel qualified for the
specific task in accordance with the relevant documentation, in particular its warning notices and safety
instructions. Qualified personnel are those who, based on their training and experience, are capable of
identifying risks and avoiding potential hazards when working with these products/systems.
Proper use of Siemens products
Note the following:
WARNING
Siemens products may only be used for the applications described in the catalog and in the relevant technical
documentation. If products and components from other manufacturers are used, these must be recommended
or approved by Siemens. Proper transport, storage, installation, assembly, commissioning, operation and
maintenance are required to ensure that the products operate safely and without any problems. The permissible
ambient conditions must be complied with. The information in the relevant documentation must be observed.
Trademarks
All names identified by ® are registered trademarks of Siemens AG. The remaining trademarks in this
publication may be trademarks whose use by third parties for their own purposes could violate the rights of the
owner.
Disclaimer of Liability
We have reviewed the contents of this publication to ensure consistency with the hardware and software
described. Since variance cannot be precluded entirely, we cannot guarantee full consistency. However, the
information in this publication is reviewed regularly and any necessary corrections are included in subsequent
editions.
Ladder Logic (LAD) for S7-300 and S7-400 Programming
Reference Manual, 04/2017, A5E41524738-AA
3
Preface
Purpose
This manual is your guide to creating user programs in the Statement List programming language
Ladder Logic.
The manual also includes a reference section that describes the syntax and functions of the
language elements of Ladder Logic.
Basic Knowledge Required
The manual is intended for S7 programmers, operators, and maintenance/service personnel.
In order to understand this manual, general knowledge of automation technology is required.
In addition to, computer literacy and the knowledge of other working equipment similar to the PC
(e.g. programming devices) under the operating systems MS Windows XP, MS Windows Server
2003 or MS Windows 7 are required.
Scope of the Manual
This manual is valid for release 5.6 of the STEP 7 programming software package.
Compliance with Standards
LAD corresponds to the "Ladder Logic" language defined in the International Electrotechnical
Commission's standard IEC 1131-3, although there are substantial differences with regard to the
operations. For further details, refer to the table of standards in the STEP 7 file NORM_TBL.RTF.
Online Help
The manual is complemented by an online help which is integrated in the software. This online help
is intended to provide you with detailed support when using the software.
The help system is integrated in the software via a number of interfaces:
•
The context-sensitive help offers information on the current context, for example, an open
dialog box or an active window. You can open the context-sensitive help via the menu
command Help > Context-Sensitive Help, by pressing F1 or by using the question mark symbol
in the toolbar.
•
You can call the general Help on STEP 7 using the menu command Help > Contents or the
"Help on STEP 7" button in the context-sensitive help window.
•
You can call the glossary for all STEP 7 applications via the "Glossary" button.
This manual is an extract from the "Help on Statement List". As the manual and the online help
share an identical structure, it is easy to switch between the manual and the online help.
Preface
Ladder Logic (LAD) for S7-300 and S7-400 Programming
4
Reference Manual, 04/2017, A5E41524738-AA
Further Support
If you have any technical questions, please get in touch with your Siemens representative or
responsible agent.
You will find your contact person at:
http://www.siemens.com/automation/partner
You will find a guide to the technical documentation offered for the individual SIMATIC Products
and
Systems at:
http://www.siemens.com/simatic-tech-doku-portal
The online catalog and order system is found under:
http://mall.automation.siemens.com/
Training Centers
Siemens offers a number of training courses to familiarize you with the SIMATIC S7 automation
system. Please contact your regional training center or our central training center in D 90026
Nuremberg, Germany for details:
Internet:
http://sitrain.automation.siemens.com/sitrainworld/
Technical Support
You can reach the Technical Support for all Industry Automation and Drive Technology products
•
Via the Web formula for the Support Request
http://www.siemens.com/automation/support-request
Additional information about our Technical Support can be found on the Internet pages
http://www.siemens.com/automation/service
Service & Support on the Internet
In addition to our documentation, we offer our Know-how online on the internet at:
http://www.siemens.com/automation/service&support
where you will find the following:
•
The newsletter, which constantly provides you with up-to-date information on your products.
•
The right documents via our Search function in Service & Support.
•
A forum, where users and experts from all over the world exchange their experiences.
•
Your local representative for Industry Automation and Drive Technology.
•
Information on field service, repairs, spare parts and consulting.
Preface
Ladder Logic (LAD) for S7-300 and S7-400 Programming
Reference Manual, 04/2017, A5E41524738-AA
5
Security Information:
Siemens provides products and solutions with industrial security functions that support the secure
operation of plants, systems, machines and networks.
In order to protect plants, systems, machines and networks against cyber threats, it is necessary to
implement - and continuously maintain - a holistic, state-of-the-art industrial security concept.
Siemens' products and solutions only form one element of such a concept.
Customer is responsible to prevent unauthorized access to its plants, systems, machines and
networks. Systems, machines and components should only be connected to the enterprise network
or the internet if and to the extent necessary and with appropriate security measures (e.g. use of
firewalls and network segmentation) in place.
Additionally, Siemens' guidance on appropriate security measures should be taken into account.
For more information about industrial security, please visit
http://www.siemens.com/industrialsecurity
.
Siemens' products and solutions undergo continuous development to make them more secure.
Siemens strongly recommends to apply product updates as soon as available and to always use
the latest product versions. Use of product versions that are no longer supported, and failure to
apply latest updates may increase customer's exposure to cyber threats.
To stay informed about product updates, subscribe to the Siemens Industrial Security RSS Feed
under
http://www.siemens.com/industrialsecurity
.
Preface
Ladder Logic (LAD) for S7-300 and S7-400 Programming
6
Reference Manual, 04/2017, A5E41524738-AA
Ladder Logic (LAD) for S7-300 and S7-400 Programming
Reference Manual, 04/2017, A5E41524738-AA
7
Table of Contents
Preface .................................................................................................................................................................... 3
Table of Contents .................................................................................................................................................. 7
1
Bit Logic Instructions ............................................................................................................................... 13
1.1
Overview of Bit Logic Instructions ................................................................................................ 13
1.2
---| |--- Normally Open Contact (Address) ................................................................................. 14
1.3
---| / |--- Normally Closed Contact (Address) .............................................................................. 15
1.4
XOR Bit Exclusive OR ................................................................................................................ 15
1.5
--|NOT|-- Invert Power Flow ......................................................................................................... 16
1.6
---( ) Output Coil ........................................................................................................................ 17
1.7
---( # )--- Midline Output .............................................................................................................. 18
1.8
---( R ) Reset Coil ........................................................................................................................ 19
1.9
---( S ) Set Coil ............................................................................................................................ 21
1.10
RS Reset-Set Flip Flop ............................................................................................................... 22
1.11
SR Set-Reset Flip Flop ............................................................................................................... 23
1.12
---( N )--- Negative RLO Edge Detection .................................................................................... 24
1.13
---( P )--- Positive RLO Edge Detection ...................................................................................... 25
1.14
---(SAVE) Save RLO into BR Memory ........................................................................................ 26
1.15
NEG Address Negative Edge Detection ..................................................................................... 27
1.16
POS Address Positive Edge Detection ....................................................................................... 28
1.17
Immediate Read ........................................................................................................................... 29
1.18
Immediate Write ........................................................................................................................... 30
2
Comparison Instructions .......................................................................................................................... 33
2.1
Overview of Comparison Instructions .......................................................................................... 33
2.2
CMP ? I Compare Integer ........................................................................................................... 34
2.3
CMP ? D Compare Double Integer ............................................................................................. 35
2.4
CMP ? R Compare Real ............................................................................................................. 37
Table of Contents
Ladder Logic (LAD) for S7-300 and S7-400 Programming
8
Reference Manual, 04/2017, A5E41524738-AA
3
Conversion Instructions ........................................................................................................................... 39
3.1
Overview of Conversion Instructions ........................................................................................... 39
3.2
BCD_I BCD to Integer ................................................................................................................. 40
3.3
I_BCD Integer to BCD ................................................................................................................. 41
3.4
I_DINT Integer to Double Integer ................................................................................................ 42
3.5
BCD_DI BCD to Double Integer .................................................................................................. 43
3.6
DI_BCD Double Integer to BCD .................................................................................................. 44
3.7
DI_REAL Double Integer to Floating-Point ................................................................................. 45
3.8
INV_I Ones Complement Integer ................................................................................................ 46
3.9
INV_DI Ones Complement Double Integer ................................................................................. 47
3.10
NEG_I Twos Complement Integer .............................................................................................. 48
3.11
NEG_DI Twos Complement Double Integer ............................................................................... 49
3.12
NEG_R Negate Floating-Point Number ...................................................................................... 50
3.13
ROUND Round to Double Integer ............................................................................................... 51
3.14
TRUNC Truncate Double Integer Part ........................................................................................ 52
3.15
CEIL Ceiling ................................................................................................................................ 53
3.16
FLOOR Floor ............................................................................................................................... 54
4
Counter Instructions ................................................................................................................................. 55
4.1
Overview of Counter Instructions ................................................................................................. 55
4.2
S_CUD Up-Down Counter .......................................................................................................... 57
4.3
S_CU Up Counter ....................................................................................................................... 59
4.4
S_CD Down Counter ................................................................................................................... 61
4.5
---( SC ) Set Counter Value ......................................................................................................... 63
4.6
---( CU ) Up Counter Coil ............................................................................................................ 64
4.7
---( CD ) Down Counter Coil ........................................................................................................ 65
5
Data Block Instructions ............................................................................................................................ 67
5.1
---(OPN) Open Data Block: DB or DI .......................................................................................... 67
6
Logic Control Instructions ....................................................................................................................... 69
6.1
Overview of Logic Control Instructions ........................................................................................ 69
6.2
---(JMP)--- Unconditional Jump ................................................................................................... 70
6.3
---(JMP)--- Conditional Jump ...................................................................................................... 71
6.4
---( JMPN ) Jump-If-Not .............................................................................................................. 72
6.5
LABEL Label ............................................................................................................................... 73
Table of Contents
Ladder Logic (LAD) for S7-300 and S7-400 Programming
Reference Manual, 04/2017, A5E41524738-AA
9
7
Integer Math Instructions ......................................................................................................................... 75
7.1
Overview of Integer Math Instructions ......................................................................................... 75
7.2
Evaluating the Bits of the Status Word with Integer Math Instructions ........................................ 76
7.3
ADD_I Add Integer ...................................................................................................................... 77
7.4
SUB_I Subtract Integer ............................................................................................................... 78
7.5
MUL_I Multiply Integer ................................................................................................................ 79
7.6
DIV_I Divide Integer .................................................................................................................... 80
7.7
ADD_DI Add Double Integer ....................................................................................................... 81
7.8
SUB_DI Subtract Double Integer ................................................................................................ 82
7.9
MUL_DI Multiply Double Integer ................................................................................................. 83
7.10
DIV_DI Divide Double Integer ..................................................................................................... 84
7.11
MOD_DI Return Fraction Double Integer .................................................................................... 85
8
Floating Point Math Instructions ............................................................................................................. 87
8.1
Overview of Floating-Point Math Instruction ................................................................................ 87
8.2
Evaluating the Bits of the Status Word with Floating-Point Math Instructions ............................. 88
8.3
Basic Instructions ......................................................................................................................... 89
8.3.1
ADD_R Add Real ........................................................................................................................ 89
8.3.2
SUB_R Subtract Real ................................................................................................................. 91
8.3.3
MUL_R Multiply Real .................................................................................................................. 92
8.3.4
DIV_R Divide Real ...................................................................................................................... 93
8.3.5
ABS Establish the Absolute Value of a Floating-Point Number .................................................. 94
8.4
Extended Instructions .................................................................................................................. 95
8.4.1
SQR Establish the Square .......................................................................................................... 95
8.4.2
SQRT Establish the Square Root ............................................................................................... 96
8.4.3
EXP Establish the Exponential Value ......................................................................................... 97
8.4.4
LN Establish the Natural Logarithm ............................................................................................ 98
8.4.5
SIN Establish the Sine Value ...................................................................................................... 99
8.4.6
COS Establish the Cosine Value .............................................................................................. 100
8.4.7
TAN Establish the Tangent Value ............................................................................................. 101
8.4.8
ASIN Establish the Arc Sine Value ........................................................................................... 102
8.4.9
ACOS Establish the Arc Cosine Value ..................................................................................... 103
8.4.10
ATAN Establish the Arc Tangent Value .................................................................................... 104
Dostları ilə paylaş: |