SIMATIC S7-300和S7-400编程的梯形图(LAD)

西门子plc
西门子plc
西门子plc
1976
文章
127
评论
2018年10月21日15:09:14 评论 581 阅读

前言

用途

本手册是您以语句表编程语言梯形图创建用户程序的指南。

本手册还包含了对梯形图语言元素的语法和函数进行描述的参考部分。

所需要的基础知识

本手册供S7程序员、操作员以及维护/维修人员使用。

要了解本手册,需要具有自动化技术的常规知识。

除此之外,还需要具有计算机应用能力和其它类似于PC (例如,编程设备)的、使用MS Windows XP、MS Windows Server 2003或MS Windows 7 版操作系统的工作设备的知识。

手册应用范围

本手册适用于STEP 7编程软件包5.6版本。

符合的标准

STL符合国际电工技术委员会IEC 1131-3标准所定义的"梯形图"语言,但在操作方面有很大的不同。欲知更多详细资料,请参见STEP 7文件NORM_TBL.RTF中的标准表。

在线帮助

集成于软件中的在线帮助是对本手册的补充。提供在线帮助的目的是,在使用软件时提供详细的支持。

该帮助系统通过一些界面集成于软件中:

•上下文相关帮助提供关于当前语境(例如,打开的对话框或激活的窗口)的信息。可以通过通过菜单命令帮助 > 上下文相关的帮助,或按下F1键或通过使用工具栏上的问号符来打开上下文相关的帮助。

•可以通过使用菜单命令帮助 > 目录,或在上下文相关的帮助窗口中按"STEP 7帮助"按钮来调用STEP 7中的常规帮助。

•可以通过按"词汇表"按钮,调用所有STEP7应用程序的词汇表。
本手册是"语句表帮助"的摘录。由于手册和在线帮助具有完全相同的结构,因此非常容易在手册和在线帮助之间切换。

前言 ................................................................................................................................................................ 3
目录 ................................................................................................................................................................ 7
1 位逻辑指令 ............................................................................................................................................. 13
1.1 位逻辑指令概述 ............................................................................................................................ 13
1.2 ---| |--- 常开触点(地址) ................................................................................................................ 14
1.3 ---| / |--- 常闭触点(地址) ................................................................................................................ 15
1.4 XOR 逻辑"异或" .......................................................................................................................... 15
1.5 --|NOT|-- 能流取反 ....................................................................................................................... 16
1.6 ---( ) 输出线圈 ............................................................................................................................. 17
1.7 ---( # )--- 中线输出 ....................................................................................................................... 18
1.8 ---( R ) 复位线圈 ........................................................................................................................... 19
1.9 ---( S ) 置位线圈 ........................................................................................................................... 21
1.10 RS置位优先型RS双稳态触发器 ................................................................................................. 22
1.11 SR复位优先型SR双稳态触发器 ................................................................................................. 23
1.12 ---( N )--- RLO负跳沿检测............................................................................................................ 24
1.13 ---( P )--- RLO正跳沿检测 ............................................................................................................ 25
1.14 ---(SAVE) 将RLO保存到BR存储器中 ...................................................................................... 26
1.15 NEG 地址下降沿检测 .................................................................................................................. 27
1.16 POS 地址上升沿检测 .................................................................................................................. 28
1.17 立即读取 ....................................................................................................................................... 29
1.18 立即写入 ....................................................................................................................................... 30
2 比较指令 ................................................................................................................................................ 33
2.1 比较指令概述 ................................................................................................................................ 33
2.2 CMP ? I 整数比较 ........................................................................................................................ 34
2.3 CMP ? D 长整数比较 .................................................................................................................. 35
2.4 CMP ? R 实数比较 ...................................................................................................................... 37
3 转换指令 ................................................................................................................................................ 39
3.1 转换指令概述 ................................................................................................................................ 39
3.2 BCD_I BCD码转换为整型........................................................................................................... 40
3.3 I_BCD 整型转换为BCD码 .......................................................................................................... 41
3.4 I_DINT 整型转换为长整型 ........................................................................................................... 42 S7-300 和 S7-400 编程的梯形图(LAD)
参考手册, 05/2017, A5E41524852-AA 7
目录
3.5 BCD_DI BCD码转换为长整型 .................................................................................................... 43
3.6 DI_BCD 长整型转换为BCD码 ................................................................................................... 44
3.7 DI_REAL 长整型转换为浮点型 .................................................................................................... 45
3.8 INV_I 对整数求反码 ..................................................................................................................... 46
3.9 INV_DI 二进制反码双精度整数 .................................................................................................... 47
3.10 NEG_I 对整数求补码 ................................................................................................................... 48
3.11 NEG_DI 二进制补码双精度整数 .................................................................................................. 49
3.12 NEG_R 浮点数取反 ..................................................................................................................... 50
3.13 ROUND 取整到最接近的双精度整数........................................................................................... 51
3.14 TRUNC 截取双精度整数部分 ...................................................................................................... 52
3.15 CEIL 向上取整 ............................................................................................................................. 53
3.16 FLOOR 向下取整 ........................................................................................................................ 54
4 计数器指令 ............................................................................................................................................. 55
4.1 计数器指令概述 ............................................................................................................................ 55
4.2 S_CUD 双向计数器 ..................................................................................................................... 57
4.3 S_CU 升值计数器 ........................................................................................................................ 59
4.4 S_CD 降值计数器 ........................................................................................................................ 61
4.5 ---( SC ) 设置计数器值 ................................................................................................................. 63
4.6 ---( CU ) 升值计数器线圈 ........................................................................................................ 64
4.7 ---( CD ) 降值计数器线圈 ........................................................................................................ 65
5 数据块指令 ............................................................................................................................................. 67
5.1 ---(OPN)打开数据块:DB或DI .................................................................................................... 67
6 逻辑控制指令 ......................................................................................................................................... 69
6.1 逻辑控制指令概述 ........................................................................................................................ 69
6.2 ---(JMP)--- 无条件跳转 ................................................................................................................. 70
6.3 ---(JMP)--- 条件跳转 .................................................................................................................... 71
6.4 ---(JMPN) 若非则跳转 ................................................................................................................. 72
6.5 LABEL标号 .................................................................................................................................. 73
7 整型数学运算指令 .................................................................................................................................. 75
7.1 整数算术指令概述 ........................................................................................................................ 75
7.2 使用整数算术指令时得出状态字的位数值 .................................................................................... 76
7.3 ADD_I 加上整数 .......................................................................................................................... 77
7.4 SUB_I 减去整数........................................................................................................................... 78
7.5 MUL_I 乘以整数 .......................................................................................................................... 79
7.6 DIV_I 除以整数 ............................................................................................................................ 80 S7-300 和 S7-400 编程的梯形图(LAD)
8 参考手册, 05/2017, A5E41524852-AA
目录
7.7 ADD_DI 加上双精度整数 ............................................................................................................. 81
7.8 SUB_DI 减去双精度整数 ............................................................................................................. 82
7.9 MUL_DI 乘以双精度整数 ............................................................................................................. 83
7.10 DIV_DI 除以双精度整数 .............................................................................................................. 84
7.11 MOD_DI 返回双精度除法的余数 ................................................................................................. 85
8 浮点型数学运算指令 ............................................................................................................................... 87
8.1 浮点运算指令概述 ........................................................................................................................ 87
8.2 使用浮点运算指令时得出状态字的位数值 .................................................................................... 88
8.3 基本指令 ....................................................................................................................................... 89
8.3.1 ADD_R 加上实数 ......................................................................................................................... 89
8.3.2 SUB_R 减去实数 ......................................................................................................................... 91
8.3.3 MUL_R 乘以实数 ......................................................................................................................... 92
8.3.4 DIV_R 除以实数 .......................................................................................................................... 93
8.3.5 ABS 求浮点数的绝对值 ............................................................................................................... 94
8.4 扩充指令 ....................................................................................................................................... 95
8.4.1 SQR 求平方 ................................................................................................................................. 95
8.4.2 SQRT 求平方根 ........................................................................................................................... 96
8.4.3 EXP 求指数值 .............................................................................................................................. 97
8.4.4 LN 求自然对数............................................................................................................................. 98
8.4.5 SIN 求正弦值 ............................................................................................................................... 99
8.4.6 COS 求余弦值 ........................................................................................................................... 100
8.4.7 TAN 求正切值 ............................................................................................................................ 101
8.4.8 ASIN 求反正弦值 ....................................................................................................................... 102
8.4.9 ACOS 求反余弦值 ..................................................................................................................... 103
8.4.10 ATAN 求反正切值...................................................................................................................... 104
9 传送指令 .............................................................................................................................................. 105
9.1 MOVE分配值 ............................................................................................................................. 105
10 程序控制指令 ....................................................................................................................................... 107
10.1 程序控制指令总览 ...................................................................................................................... 107
10.2 ---(Call) 调用来自线圈的FC SFC (不带参数) ............................................................................ 108
10.3 CALL_FB 调用来自框的FB ...................................................................................................... 110
10.4 CALL_FC 调用来自框的FC ...................................................................................................... 112
10.5 CALL_SFB 调用来自框的系统FB ............................................................................................. 114
10.6 CALL_SFC 调用来自框的系统FC ............................................................................................ 116
10.7 调用多重背景 .............................................................................................................................. 118
10.8 调用来自库的块 .......................................................................................................................... 118
10.9 关于使用MCR功能的重要注意事项 .......................................................................................... 119
10.10 ---(MCR<) 主控制继电器打开 .................................................................................................... 120
10.11 ---(MCR>) 主控制继电器关闭 .................................................................................................... 122 S7-300 和 S7-400 编程的梯形图(LAD)
参考手册, 05/2017, A5E41524852-AA 9
目录
10.12 ---(MCRA) 主控制继电器激活 .................................................................................................... 124
10.13 ---(MCRD) 主控制继电器取消激活 ............................................................................................ 125
10.14 ---(RET) 返回 ............................................................................................................................. 126
11 移位和循环指令 .................................................................................................................................... 127
11.1 移位指令 ..................................................................................................................................... 127
11.1.1 移位指令概述 .............................................................................................................................. 127
11.1.2 SHR_I 向右移位整数 ................................................................................................................. 128
11.1.3 SHR_DI 向右移位双精度整数 .................................................................................................... 130
11.1.4 SHL_W 字左移 .......................................................................................................................... 131
11.1.5 SHR_W 字右移.......................................................................................................................... 133
11.1.6 SHL_DW 双字左移 .................................................................................................................... 134
11.1.7 SHR_DW 双字右移 ................................................................................................................... 135
11.2 循环移位指令 .............................................................................................................................. 137
11.2.1 循环移位指令概述 ...................................................................................................................... 137
11.2.2 ROL_DW 双字循环左移Word0 ................................................................................................. 137
11.2.3 ROR_DW 双字循环右移 ............................................................................................................ 139
12 状态位指令 ........................................................................................................................................... 141
12.1 状态位指指令概述 ...................................................................................................................... 141
12.2 OV ---| |--- 异常位溢出 ............................................................................................................. 142
12.3 OS ---| |--- 存储的异常位溢出 .................................................................................................. 143
12.4 UO ---| |--- 无序异常位 ............................................................................................................. 145
12.5 BR ---| |--- 异常位二进制结果 .................................................................................................. 146
12.6 ==0 ---| |--- 结果位等于0 ......................................................................................................... 147
12.7 <>0 ---| |--- 结果位不等于0 ..................................................................................................... 148
12.8 >0 ---| |--- 结果位大于0 ........................................................................................................... 149
12.9 <0 ---| |--- 结果位小于0 ........................................................................................................... 150
12.10 >=0 ---| |--- 结果位大于等于0 ................................................................................................... 151
12.11 <=0 ---| |--- 结果位小于等于0 .................................................................................................. 152
13 定时器指令 ........................................................................................................................................... 153
13.1 定时器指令总览 .......................................................................................................................... 153
13.2 定时器在存储器中的位置与定时器组件 ...................................................................................... 154
13.3 S_PULSE脉冲S5定时器 .......................................................................................................... 157
13.4 S_PEXT扩展脉冲S5定时器 ..................................................................................................... 159
13.5 S_ODT接通延时S5定时器 ....................................................................................................... 161
13.6 S_ODTS保持接通延时S5定时器 ............................................................................................. 163
13.7 S_OFFDT断开延时S5定时器 .................................................................................................. 165
13.8 ---( SP ) 脉冲定时器线圈 .................................................................................................... 167
13.9 ---( SE )扩展脉冲定时器线圈 ...................................................................................................... 169 S7-300 和 S7-400 编程的梯形图(LAD)
10 参考手册, 05/2017, A5E41524852-AA
目录
13.10 ---( SD ) 接通延时定时器线圈 ............................................................................................. 171
13.11 ---( SS ) 带保持的接通延迟定时器线圈 ..................................................................................... 173
13.12 ---( SF )断开延时定时器线圈 ...................................................................................................... 175
14 字逻辑指令 ........................................................................................................................................... 177
14.1 字逻辑指令概述 .......................................................................................................................... 177
14.2 WAND_W (字)单字与运算 ......................................................................................................... 178
14.3 WOR_W (字)单字或运算 ........................................................................................................... 179
14.4 WAND_DW (字)双字与运算 ...................................................................................................... 180
14.5 WOR_DW (字)双字或运算 ........................................................................................................ 181
14.6 WXOR_W (字)单字异或运算 ..................................................................................................... 182
14.7 WXOR_DW (字)双字异或运算 .................................................................................................. 183
A 所有LAD指令总览 ............................................................................................................................... 185
A.1 按英语助记符(国际)排序的LAD指令 ......................................................................................... 185
A.2 按德语助记符(SIMATIC)排序的LAD指令 ................................................................................. 189
B 编程实例 .............................................................................................................................................. 193
B.1 编程实例总览 .............................................................................................................................. 193
B.2 实例:位逻辑指令 ...................................................................................................................... 194
B.3 实例:定时器指令 ...................................................................................................................... 198
B.4 实例:计数器和比较指令 ........................................................................................................... 202
B.5 实例:整型数学运算指令 ........................................................................................................... 205
B.6 实例:字逻辑指令 ...................................................................................................................... 206
C 使用梯形图 ........................................................................................................................................... 209
C.1 块类型 ........................................................................................................................................ 209
C.2 EN/ENO机制 ............................................................................................................................. 210
C.2.1 连接了EN和ENO的加法器 ...................................................................................................... 211
C.2.2 连接EN但未连接ENO的加法器 ............................................................................................... 212
C.2.3 连接EN但未连接ENO的加法器 ............................................................................................... 212
C.2.4 没有连接EN和ENO的加法器 .................................................................................................. 213
C.3 参数传送 ..................................................................................................................................... 214
索引 ............................................................................................................................................................ 215

下载链接:https://www.siemensplc.com/xuanxingshouce/10458.html

继续阅读
weinxin
plc入门知识问答
所有PLC工程师都会关注的微信公众账号,只需输入您的问题,就会有答案
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: