没有合适的资源?快使用搜索试试~ 我知道了~
ShbSW_EN_03 Programming.pdf
需积分: 9 0 下载量 187 浏览量
2019-06-04
09:34:43
上传
评论
收藏 3.39MB PDF 举报
温馨提示
With the IEC 61131 standard, an internationally recognized document has been created which will form the basis for all future new developments in automation. The scope of the standard was deliberately made very broad, in order also to encompass future approaches with industrial computers and combinations of various application areas, such as control engineering with drive engineering.
资源推荐
资源详情
资源评论
MAS Programming Table of contents
18.03.2013, 43930126 System Manual
MAS Software, page 3.1
MAS Programming
3. 18.03.2013
Table of contents
1. IEC 61131 ................................................................................................................ 10
1.1 Why a standard? ............................................................................................................. 10
1.1.1 Existing problems .............................................................................................. 10
1.1.2 Objectives of IEC 61131-3 ................................................................................. 10
1.2 Introduction to IEC 61131................................................................................................ 11
–............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 11
1.3 Programming languages ................................................................................................. 12
1.3.1 Textual languages.............................................................................................. 12
1.3.1.1 IL - Instruction List ................................................................................ 12
1.3.1.2 ST - Structured Text ............................................................................. 13
1.3.1.3 ANSI-C ................................................................................................. 13
1.3.2 Graphical languages .......................................................................................... 14
1.3.2.1 FBD – Function Block Diagram ............................................................ 14
1.3.2.2 LD – Ladder Diagram ........................................................................... 15
1.3.2.3 SFC – Sequential Function Chart ......................................................... 16
–............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 17
1.4 Software model acc. to IEC 61131-3 ............................................................................... 18
1.4.1 Configuration elements ...................................................................................... 19
1.4.1.1 Configuration ........................................................................................ 19
1.4.1.2 Resources ............................................................................................ 20
1.4.1.3 Task ..................................................................................................... 20
1.4.1.4 Global variables ................................................................................... 20
1.4.1.5 Access path ......................................................................................... 20
–............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 20
1.4.2 POUs – Program Organization Units ................................................................. 21
1.4.2.1 PRG: Program ...................................................................................... 21
1.4.2.2 FB: Function Block ............................................................................... 21
1.4.2.3 FUN: Function ...................................................................................... 22
–............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 22
1.4.3 Data types.......................................................................................................... 22
1.4.3.1 Variables .............................................................................................. 23
1.4.3.2 Absolute (directly represented) variables ............................................. 23
1.4.3.3 Symbolic programming......................................................................... 24
1.4.3.4 Variable classes ................................................................................... 24
1.4.3.5 Global and local variables .................................................................... 25
1.5 Literature and references concerning IEC 61131 ............................................................ 25
–............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 25
2. Theory of programming ............................................................................................. 26
2.1 Working method of the CPU ............................................................................................ 26
2.1.1 Scanner task ...................................................................................................... 26
2.1.2 Cyclical program processing .............................................................................. 27
2.1.3 Time-controlled program processing .................................................................. 28
2.1.4 Internal synchronization (I/O phase) .................................................................. 29
2.1.4.1 Process image ..................................................................................... 29
–............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 29
MAS Programming Table of contents
18.03.2013, 43930126 System Manual
MAS Software, page 3.2
2.2 System behaviour ........................................................................................................... 30
2.2.1 Operating states and start-up behaviour ............................................................ 30
2.2.1.1 Initializing the system ........................................................................... 30
2.2.1.2 Start-up behaviour................................................................................ 30
2.2.2 FTP access ........................................................................................................ 31
- ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 31
2.3 Variable types and address ranges ................................................................................. 32
2.3.1 Simple standard data types ............................................................................... 32
2.3.1.1 Absolute (direct) and symbolic representation ..................................... 32
2.3.1.2 ANY_BIT data types ............................................................................. 32
2.3.1.3 ANY_INT data types ............................................................................ 33
2.3.1.4 ANY_REAL data types ......................................................................... 33
2.3.1.5 TIME data type ..................................................................................... 33
2.3.1.6 DATE_AND_TIME data type ................................................................ 33
2.3.1.7 STRING data type ................................................................................ 34
–............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 34
2.3.2 Multi element variables ...................................................................................... 34
2.3.2.1 Array .................................................................................................... 35
2.3.2.2 Structure (Struct) .................................................................................. 35
2.3.3 Using variables .................................................................................................. 35
2.3.4 Initial values of variables .................................................................................... 36
2.3.4.1 When does which initial value apply? ................................................... 36
- ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 36
2.4 Address ranges of variables and flags ............................................................................ 36
2.4.1.1 Inputs and output variables .................................................................. 37
2.4.1.2 System and user flags .......................................................................... 39
2.4.1.3 System flag area .................................................................................. 40
- ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 40
2.5 Variable types ................................................................................................................. 41
2.5.1 RETAIN variables .............................................................................................. 42
2.5.1.1 Retain concept ..................................................................................... 42
2.5.2 Global and local variables .................................................................................. 42
2.5.3 Validity of variables ............................................................................................ 43
2.5.4 Declaring and inserting variables in IEC headers .............................................. 43
2.5.4.1 Local variables ..................................................................................... 43
2.5.4.2 Hardware I/O ........................................................................................ 44
2.5.4.3 Global Variable List (GVL) ................................................................... 46
2.5.4.4 Data Unit Type (DUT) .......................................................................... 48
2.5.4.5 Function Blocks (FB) ............................................................................ 48
- ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 48
2.6 Programming recommendations ..................................................................................... 49
2.6.1 Naming .............................................................................................................. 49
2.6.2 Variable names .................................................................................................. 49
2.6.3 Program Organization Units (POU) .................................................................... 50
2.6.3.1 Program (PRG) .................................................................................... 50
2.6.3.2 Function Block (FB) .............................................................................. 50
2.6.3.3 Function (FUN)..................................................................................... 51
–............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 51
2.6.4 SFC ................................................................................................................... 51
2.6.4.1 Steps .................................................................................................... 51
2.6.4.2 Transitions ........................................................................................... 51
2.6.4.3 Actions ................................................................................................. 51
2.6.4.4 Jumps .................................................................................................. 52
–............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 52
MAS Programming Table of contents
18.03.2013, 43930126 System Manual
MAS Software, page 3.3
2.6.5 Program structure .............................................................................................. 52
2.6.5.1 General principles ................................................................................ 52
2.6.5.2 Example of a possible program structure ............................................. 53
2.6.6 Remarks ............................................................................................................ 54
- ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 54
2.7 Compiling, downloading and monitoring programs .......................................................... 54
2.7.1 Compiling ........................................................................................................... 55
2.7.1.1 Compiling the entire project ................................................................. 55
2.7.1.2 Partial compilation ................................................................................ 55
2.7.1.3 Compiler messages ............................................................................. 56
2.7.2 Download ........................................................................................................... 57
2.7.2.1 Access to the CPU ............................................................................... 59
2.7.2.2 Remote operation ................................................................................. 60
2.7.3 Online change .................................................................................................... 61
2.7.3.1 What does "online change" mean? ...................................................... 61
2.7.4 Online monitoring ............................................................................................... 62
2.7.4.1 Monitoring a body................................................................................. 63
2.7.4.2 Monitoring a header ............................................................................. 66
2.7.4.3 Entry Data Monitor ............................................................................... 66
2.7.4.4 Select data format ................................................................................ 67
2.7.4.5 Trend display ....................................................................................... 68
2.7.5 Backup/restore ................................................................................................... 70
- ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 70
3. Hardware-specific ..................................................................................................... 71
3.1 Introduction ..................................................................................................................... 71
3.2 Program processing ........................................................................................................ 71
3.2.1 Scanner task ...................................................................................................... 72
3.2.2 Cyclical program processing .............................................................................. 73
3.2.3 Time-controlled program processing .................................................................. 74
–............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 74
3.3 Internal synchronization (I/O phase)................................................................................ 75
3.3.1 Process image ................................................................................................... 75
3.3.2 Synch and event mode ...................................................................................... 76
3.3.2.1 Event mode (default) ............................................................................ 77
3.3.2.2 Synch mode ......................................................................................... 77
–............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 77
3.4 Operating statuses and startup behaviour ....................................................................... 78
3.4.1 Status diagram ................................................................................................... 78
3.4.1.1 Initializing the system ........................................................................... 79
3.4.2 Startup behaviour and service functions ............................................................ 80
3.4.2.1 CPU 83x-Tx ......................................................................................... 81
3.4.2.2 CPU 73x-Tx and CPU 854-T ................................................................ 81
3.4.2.3 CPU 72x-Tx ......................................................................................... 81
3.4.2.4 Flash cassette FMC 701-T ................................................................... 81
3.4.3 Memory map ...................................................................................................... 83
3.4.4 Retain variables CPU 854-T .............................................................................. 83
3.4.5 Address ranges .................................................................................................. 83
3.4.5.1 Variables and markers ......................................................................... 83
3.4.5.2 Absolute addressing ............................................................................. 84
3.4.5.3 User marker range ............................................................................... 84
3.4.5.4 System marker range ........................................................................... 85
- ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 85
3.5 Initialization and file system of the CPU 854-T ................................................................ 85
3.5.1 Initializing the system ......................................................................................... 85
3.5.2 Image of the compact flash (C:\) ........................................................................ 86
- ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 86
MAS Programming Table of contents
18.03.2013, 43930126 System Manual
MAS Software, page 3.4
4. Programming ............................................................................................................ 87
4.1 Introduction ..................................................................................................................... 87
4.1.1 The accumulator ................................................................................................ 87
4.1.1.1 Loading and saving .............................................................................. 87
4.2 Standard operators & logic operations ............................................................................ 88
4.2.1 Programming example for logic operations ........................................................ 89
4.2.1.1 Teaching objectives ............................................................................. 89
4.2.1.2 Task ..................................................................................................... 89
4.2.1.3 Solutions .............................................................................................. 89
4.2.2 Arithmetic operators ........................................................................................... 91
4.2.2.1 Arithmetic programming example ......................................................... 92
4.2.3 Comparisons ...................................................................................................... 93
–............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 94
4.3 Function calls .................................................................................................................. 94
4.3.1 Call in Instruction List [IL] ................................................................................... 95
4.3.2 Call in Function Block Diagram [FBD] and Ladder Diagram [LD] ....................... 95
4.3.3 Call in Structured Text [ST] ................................................................................ 95
–............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 95
4.4 Standard functions .......................................................................................................... 96
4.4.1 Functions for type conversion ............................................................................ 96
4.4.2 Numerical functions ........................................................................................... 97
4.4.2.1 Functions for numerical operations ...................................................... 97
4.4.2.2 Trigonometric functions ........................................................................ 97
4.4.3 Bit manipulation functions .................................................................................. 98
4.4.4 Selection functions ............................................................................................. 98
4.4.5 String functions .................................................................................................. 99
4.4.6 Sample program: Type conversion and selection ............................................ 100
4.4.6.1 Task ................................................................................................... 100
4.4.6.2 Solutions ............................................................................................ 100
–.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 101
4.5 Creating a function ........................................................................................................ 102
4.5.1 Sample program: Temperature conversion ...................................................... 102
4.6 Function block calls ....................................................................................................... 106
4.6.1 Call in Instruction List [IL] ................................................................................. 107
4.6.2 Call in Function Block Diagram [FBD] and Ladder Diagram [LD] ..................... 108
4.6.3 Call in Structured Text [ST] .............................................................................. 108
–.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 108
4.7 Standard Function Blocks ............................................................................................. 109
4.7.1 Function Blocks for bi-stable elements (flip-flops) ............................................ 109
4.7.1.1 Examples: Setting and resetting Boolean variables ........................... 109
4.7.2 Sample program: Bi-stable elements ............................................................... 111
4.7.2.1 Teaching objectives ........................................................................... 111
4.7.2.2 Task ................................................................................................... 111
4.7.2.3 Solutions ............................................................................................ 111
4.7.3 Function blocks for edge detection .................................................................. 112
4.7.3.1 SELE–Trigger..................................................................................... 112
4.7.3.2 Edge detection according to IEC 61131-3 .......................................... 113
4.7.4 Function blocks for counters ............................................................................ 114
4.7.4.1 Counter with arithmetical functions .................................................... 114
4.7.4.2 Counters with function blocks ............................................................. 114
4.7.5 Function blocks for timers ................................................................................ 115
–.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 117
MAS Programming Table of contents
18.03.2013, 43930126 System Manual
MAS Software, page 3.5
4.8 Type conversion ............................................................................................................ 118
4.8.1 Function blocks for type conversion ................................................................. 118
4.8.2 Sample program: Type conversion and RTC ................................................... 120
4.8.2.1 Teaching objective ............................................................................. 120
4.8.2.2 Task ................................................................................................... 120
4.8.2.3 Solutions ............................................................................................ 121
4.8.3 Applying the arithmetical operators to time types ............................................. 122
–.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 122
4.9 Creating a function block ............................................................................................... 123
4.9.1 Sample program: Analog value processing ...................................................... 123
–.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 127
4.10 Jumps and jump flags ................................................................................................... 127
4.10.1 Returns ............................................................................................................ 128
4.10.2 Sample program: Jumps, timers and trigonometric instructions ....................... 128
4.10.2.1 Teaching objective ............................................................................. 128
4.10.2.2 Task ................................................................................................... 128
4.10.2.3 Solutions ............................................................................................ 128
4.10.3 Sample program: Car park ............................................................................... 130
4.10.3.1 Teaching objectives ........................................................................... 130
4.10.3.2 Task ................................................................................................... 130
4.10.4 Solutions with SELE-Trigger ............................................................................ 131
4.10.5 Solution with trigger according to IEC 61131-3 ................................................ 132
–.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 133
4.11 Selection in Structured Text [ST] ................................................................................... 134
4.11.1 Selection with 'IF' ............................................................................................. 134
4.11.1.1 Statements ......................................................................................... 134
4.11.2 Selection with 'CASE OF' ................................................................................. 135
4.11.3 Loops ............................................................................................................... 136
4.11.3.1 Loop with 'WHILE DO' ........................................................................ 136
4.11.3.2 Statements ......................................................................................... 136
4.11.3.3 Loop with 'REPEAT' ........................................................................... 137
4.11.3.4 Statements ......................................................................................... 137
4.11.3.5 FOR-loop ........................................................................................... 138
4.11.3.6 Cancel with 'EXIT' .............................................................................. 138
4.11.3.7 Statements ......................................................................................... 138
–.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 138
4.12 Creating a user library ................................................................................................... 139
4.13 Real time clock RTC ..................................................................................................... 143
4.14 Serial port RS-232 ......................................................................................................... 144
4.14.1 Configuration ................................................................................................... 144
–.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 146
4.15 Programming in SFC ..................................................................................................... 147
4.15.1 Elements of Sequential Function Chart ............................................................ 148
4.15.1.1 Step ................................................................................................... 148
4.15.1.2 Transition ........................................................................................... 149
4.15.1.3 Alternative branching ......................................................................... 150
4.15.1.4 Parallel branching .............................................................................. 150
4.15.1.5 Jumps ................................................................................................ 151
4.15.1.6 Action ................................................................................................. 151
4.15.1.7 Action assignment .............................................................................. 152
- .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 152
剩余157页未读,继续阅读
资源评论
ferrari550c
- 粉丝: 0
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功