TwinCAT PLC 编程手册

[复制链接]
查看8 | 回复0 | 2020-8-22 20:46:04 | 显示全部楼层 |阅读模式
TwinCAT PLC 编程手册(2011 更新版).pdf (13.86 MB, 售价: 3 工控币)
目 录
1 TwinCAT PLC Control 简介 ........................................................................ 1
1.1 引言.......................................................................................................... 1
1.2 项目组件.................................................................................................. 3
1.3 编程语言................................................................................................ 10
1.3.1 编程语言 .........................................................................................................10
1.3.2 指令表(IL).........................................................................................................12
1.3.3 结构化文本(ST)................................................................................................13
概述....................................................................................................................................14
FOR循环..............................................................................................................................14
REPEAT 循环.......................................................................................................................15
WHILE 循环 ........................................................................................................................15
IF 指令 ...............................................................................................................................16
CASE 指令...........................................................................................................................16
RETURN(返回)指令 .....................................................................................................17
EXIT 指令 ...........................................................................................................................17
1.3.4 顺序功能图(SFC) .......................................................................................17
1.3.5 功能块图(FBD)...........................................................................................21
1.3.6 连续功能图编辑器(CFC)...........................................................................21
1.3.7 梯形图(LD)..................................................................................................22
1.4 调试,联机功能................................................................................... 24
1.5 IEC 61131-3............................................................................................. 26
2 例程 ......................................................................................................... 27
2.1 样例程序................................................................................................ 27
3 分类介绍 ............................................................................................36
3.1 主窗口.................................................................................................... 36
3.2 选项........................................................................................................ 38
3.3 项目管理 ............................................................................................... 62
3.4 对象........................................................................................................ 84
.................
........
3.5 编辑功能................................................................................................ 97
3.6 联机功能 ..............................................................................................102
3.7 窗口 ......................................................................................................111
3.8 帮助系统...............................................................................................111
3.9 日志.......................................................................................................112
4 编辑器 .......................................................................................... 114
4.1 概述.......................................................................................................114
4.2 声明编辑器 ..........................................................................................116
4.3 文本编辑器 ..........................................................................................128
4.4 指令表编辑器 ......................................................................................132
4.5 结构化文本编辑器 .............................................................................134
4.6 图形编辑器 .........................................................................................135
4.7 功能块图编辑器 .................................................................................137
4.8 梯形图编辑器 .....................................................................................142
4.9 连续功能图编辑器(CFC) .....................................................................147
4.10 顺序功能图编辑器 .............................................................................159
5 资源....... .......................................................................................... 168
5.1 概述.......................................................................................................168
5.2 全局变量...............................................................................................169
5.3 报警配置...............................................................................................173
5.3.1 概述................................................................................................................173
5.3.2 报警系统........................................................................................................173
5.3.3 报警类............................................................................................................174
5.3.4 报警组............................................................................................................178
5.3.5 报警保荐 .......................................................................................................179
5.3.6 'Extras'菜单:Settings....................................................................................180
5.4 PLC 配置 ...............................................................................................182
5.5 任务配置...............................................................................................183
5.6 抽样跟踪...............................................................................................186
5.7 Watch and Receipt Manager(监视和接收管理器).........................191
...........
................
6 库管理 ..............................................................................................194
6.1 库管理器...............................................................................................194
7 工程接口(ENI)...........................................................................................196
7.1 概述.......................................................................................................196
8 可视化 .......................................................................................... 199
8.1 简介.......................................................................................................199
8.2 可视化编辑 ..........................................................................................201
8.2.1 概述................................................................................................................201
8.2.2 创建一个新的可视化...................................................................................202
8.2.3 插入可视化单元 ...........................................................................................202
8.2.4 可视化单元布局 ...........................................................................................206
8.2.5 配置可视化....................................................................................................209
8.2.5.1 概述................................................................................................................... 209
8.2.5.2 配置可视化单元...................................................................................................209
8.2.5.3 配置表格 ..............................................................................................................228
8.2.5.4 报警表配置 ..........................................................................................................238
8.2.5.5 运行时的各种特殊输入.......................................................................................249
8.2.5.6 配置可视化对象...................................................................................................251
8.3 语言转换 ..............................................................................................255
8.3.1 可视化界面中的语言转换...........................................................................255
8.3.2 静态 ...............................................................................................................256
8.3.2.1 静态语言转换 ................................................................................................. 256
8.3.3 动态................................................................................................................257
8.3.3.1 动态语言的转换 ............................................................................................. 257
8.3.3.2 配置.................................................................................................................. 258
8.3.3.3 用于动态文本的XML文件.............................................................................. 259
8.3.4 通过可视化单元调用在线语言帮助..........................................................261
8.4 占位符概念 .........................................................................................263
8.4.1 概述 ..................................................................................................................... 263
..............
...........
8.5 联机模式...............................................................................................265
8.5.1 概述 ..................................................................................................................... 265
8.6 库 ........................................................................................................266
8.6.1 概述 ..................................................................................................................... 266
8.7 TwinCAT PLC HMI Visualization .............................................................267
8.7.1 概述 ..................................................................................................................... 267
8.7.2 安装、启动和操作 ............................................................................................ 267
8.8 目标可视化 ..........................................................................................269
8.8.1 概述 ..................................................................................................................... 269
8.8.2 有关TwinCAT可视化的特征概述 ...................................................................... 269
8.8.3 要求 ..................................................................................................................... 271
8.8.4 创建目标可视化................................................................................................. 271
8.8.5 启动目标可视化................................................................................................. 274
8.8.6 查询鼠标点击和动态文本................................................................................ 275
8.8.7 限制 ..................................................................................................................... 276
8.9 系统变量...............................................................................................278
8.9.1 概述 ..................................................................................................................... 278
9 附录 .......................................................................................... 279
9.1 使用键盘...............................................................................................279
9.2 编译错误...............................................................................................283
9.3 命令行/命令文件命令.........................................................................305
9.4 数据类型...............................................................................................310
9.4.1 概述 .................................................................................................................... 310
9.4.2 标准数据类型 .................................................................................................... 311
BOOL................................................................................................................................................311
BYTE ...............................................................................................................................................312
WORD .............................................................................................................................................312
DWORD ...........................................................................................................................................312
SINT ................................................................................................................................................312
USINT ..............................................................................................................................................312
INT ..................................................................................................................................................312
...........
UINT ................................................................................................................................................313
DINT ................................................................................................................................................313
UDINT .............................................................................................................................................313
REAL ...............................................................................................................................................313
LREAL ..............................................................................................................................................313
STRING ............................................................................................................................................313
TIME ...............................................................................................................................................314
TIME_OF_DAY ................................................................................................................................314
DATE ...............................................................................................................................................314
DATE_AND_TIME ............................................................................................................................314
9.4.3 用户数据类型 ....................................................................................................................315
数组 .............................................................................................................................................315
指针 .............................................................................................................................................316
枚举(ENUM)..............................................................................................................................316
结构(STRUCT) ..........................................................................................................................317
参考类型(别名) ......................................................................................................................319
子范围类型 ...................................................................................................................................319
9.5 操作符...................................................................................................321
9.5.1 概述 .................................................................................................................... 321
9.5.2 IEC 操作符概述 .................................................................................................. 321
9.5.3 数值运算符......................................................................................................... 324
ABS ..................................................................................................................................................324
ACOS................................................................................................................................................325
ASIN.................................................................................................................................................325
ATAN................................................................................................................................................325
COS..................................................................................................................................................325
EXP ..................................................................................................................................................325
EXPT ................................................................................................................................................325
LN ....................................................................................................................................................326
LOG..................................................................................................................................................326
SIN...................................................................................................................................................326
SQRT ................................................................................................................................................326
TAN..................................................................................................................................................326
9.5.4 算术运算符......................................................................................................... 327
ADD .................................................................................................................................................327
MUL ................................................................................................................................................327
SUB..................................................................................................................................................327
DIV ..................................................................................................................................................328
MOD ...............................................................................................................................................328
9.5.5 位运算符............................................................................................................. 330
AND ................................................................................................................................................330
OR ...................................................................................................................................................330
XOR .................................................................................................................................................330
NOT .................................................................................................................................................331
9.5.6 位移操作符 .........................................................................................................................331
SHL ..................................................................................................................................................331
SHR .................................................................................................................................................332
ROL .................................................................................................................................................333
ROR .................................................................................................................................................334
9.5.7 选择运算符 .........................................................................................................................335
SEL ..................................................................................................................................................335
MAX ................................................................................................................................................336
MIN .................................................................................................................................................336
LIMIT ...............................................................................................................................................337
MUX ................................................................................................................................................337
9.5.8 比较运算符 .........................................................................................................................337
GT ...................................................................................................................................................337
LT ....................................................................................................................................................338
LE ....................................................................................................................................................338
GE....................................................................................................................................................339
EQ ...................................................................................................................................................339
NE ...................................................................................................................................................340
9.5.9 地址操作符 .........................................................................................................................340
INDEXOF .........................................................................................................................................340
SIZEOF .............................................................................................................................................340
ADR (地址操作符) ........................................................................................................................341
Attention: ........................................................................................................................................341
ADRINST(程序地址操作符) ..........................................................................................................341
^ (内容操作符)..............................................................................................................................341
CAL (调用操作符) .........................................................................................................................341
BITADR ............................................................................................................................................341
9.5.10 类型转换操作符................................................................................................................342
BOOL_TO 转换 ..............................................................................................................................342
TO_BOOL 转换 ...............................................................................................................................342
STRING_TO 转换.............................................................................................................................342
TO_STRING 转换.............................................................................................................................343
TIME_TO 转换 ...............................................................................................................................343
DATE_TO 转换 ................................................................................................................................343
TOD_TO 转换..................................................................................................................................343
DT_TO 转换.....................................................................................................................................344
REAL_TO-/LREAL_TO 转换..............................................................................................................344
整型数类型之间的转换 ..............................................................................................................344
TRUNC .............................................................................................................................................345
9.6 操作数 ........................................................................................................346
9.6.1 常数.....................................................................................................................................346
BOOL 常数......................................................................................................................................346
TIME 常数 ......................................................................................................................................346
DATE 常数.......................................................................................................................................346
TIME_OF_DAY 常数 .......................................................................................................................346
DATE_AND_TIME 常数 ...................................................................................................................347
数值常数 .......................................................................................................................................347
REAL/LREAL常数 ............................................................................................................................347
STRING 常数 ..................................................................................................................................347
类型符 ...........................................................................................................................................348
9.6.2 变量.....................................................................................................................................348
概述 ...............................................................................................................................................348
地址 ...............................................................................................................................................349
内存定位 .......................................................................................................................................349
存取数组、结构和 POU 变量......................................................................................................350
变量的位寻址 ...............................................................................................................................350
Functions(功能).........................................................................................................................350
9.6.2.1系统标志.....................................................................................................351
概述 ......................................................................................................................................................... 351
SYSTEMINFO ............................................................................................................................................ 351
SYSTEMTASKINFOARR............................................................................................................................... 351
9.7 系统功能 ........................................................................................................352
CheckBounds 功能 .....................................................................................................................................352
CheckDivByte 功能 ....................................................................................................................................353
CheckDivReal 功能 ....................................................................................................................................353
CheckDivWord 功能 ..................................................................................................................................354
CheckDivDWord 功能 ................................................................................................................................355
CheckRangeSigned 功能 ...........................................................................................................................355
CheckRangeUnsigned 功能 .......................................................................................................................357
什么是 TwinCAT PLC Control?
TwinCAT PLC Control 是为 PLC 设计的一种完整的开发环境。TwinCAT PLC Control 为 PLC 编程提供了一种简便的方法,可以自由地处理功能强大的IEC 语言。编辑器和调试功能的使用则基于先进编程语言和已验证的程序开发环境。
TwinCAT PLC Control 概述
一个项目是如何构成的?
一个项目置于一个在项目后期命名的文件内。首先打开一个默认的“Task Configuration(任务配置)”。任务的名字是“Standard(标准)”。在一个新项目中建立的第一个 POU(程序组织单元)将自动地命名为“MAIN(主程序)”。你可以在任务配置中重新命名这个 POU。TwinCAT PLC Control 能够区分一个项目中不同类型的对象:POU,数据类型和资源。对象管理器(Object Organizer)包括一个表,该表列出了项目中所有的对象。
怎样建立项目?
首先,你应该选择目标系统。然后配置任务。你可以建立解决你的问题所需要的 POU。现在你可以应用所期望的编程语言对你所需要的 POU 进行编程。一旦编程完成,你就可以编译该项目,并修改可能存在的任何错误。
如何测试项目?
一旦已经修改完成所有的错误, 联机 PLC 并将你的项目 “下载” 到 PLC 内。 现在, TwinCAT PLC Control 处于“联机”模式。测试你的项目是否为正确顺序。为此,手动设置输入变量并观察输出是否为期望值。你还可以观察 POU 中本地变量的数值顺序。在“Watch and Receipt Manager(监视和接收管理器)”中,你可以配置你想要检查的数据记录。
当程序出现错误时,你可以设置断点。如果程序在该断点处停止,你可以及时在该断点处检查项目所有的变量值。并按照顺序操作(单步),检查程序的逻辑正确性。TwinCAT PLC Control 还有另外一种调试功能:你可以设置程序变量以及输入和输出为某些值。你可以使用流控制来检查哪些程序行已经运行。使用“Sampling Trace(抽样跟踪)”,可以在扩展的时间范围内跟踪和显示变量的实际变化过程。“Log(日志)”则按时间顺序记录在联机对话期间的操作、用户采取的动作和各种内部过程。整个项目可随时进行文档化或输出到一个文本文件。
其它功能
整个项目可随时进行文档化或输出到一个文本文件。也可将它翻译成其它语言。
ENI:通过 ENI 接口(“工程接口”),可以将编程系统连接到一个外部数据库。在那里可以存储创建一个自动化项目过程中所需要的各种数据。外部数据库的使用保证了数据的一致性,这些数据以后可以被多个用户、项目和程序所共享。

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则