-
基于
Codesys
的
PLC
自动控制及
IEC
相关标准
p>
1.
概念
IEC(International
Electrotechnical
Commission,
国际电工委员会
)
它是世界
上成立最早的国际性电工标准化机构,负责有关电气工程和电子工程领域中
的国际标准化工作。
PLC(Programmable
Logic
Controller,
可编程逻辑控制器
)
是种专门为在工业
环境下应用而设计的数字运算操作电子系统。它采用一种可编程的存储器,
在其内部存储
执行逻辑运算、顺序控制、定时、计数和算术运算等操作的指
令,
通过数字式或模拟式的输入输出来控制各种类型的机械设备或生产过程。
Codesys(Controlled Developement System)
是可编程逻辑控制器
PLC
的完
整开发环境,在
PLC
程序员编程时,
Codesys
为强大的
IEC
语言提供了一个
p>
简单的方法,系统的编辑器和调试器的功能是建立在高级编程语言的基础上
< br>(如
Visual
C++
)
。
2.
相关标准
IEC61131
包括:
?
Part 1:
General Overview
?
Part 2
Hardware
?
Part 3
Programming Languages
?
Part 4
User Guidelines
?
Part 5
Communication
?
Part 7
Fuzzy Logic
?
Part 8
Application Guidelines
IEC 61131-3
是
IEC
61131
的第三章,介绍了五种编程语言:
–
Instruction
List (IL)
–
Ladder Diagram (LD)
–
Funktion Block
Diagram (FBD)
–
Sequential Function Chart (SFC)
–
Structured Text
(ST)
(
IEC61131-3
包
含梯形图、功能块图、顺序功能图(
LD/FBD/SFC
)三
种图形语言,及两
种文本语言
:
指令表
、结构文本(
IL/ST
)
。按照工程
师的技能和适用用途能选择最适合的
语言。
)
< br>
#
相关资料网址:
?
John,
Tiegel
kamp: “IEC 61131
-3:
Programming
Industrial Automation
Systems“
(/controle_automati
co/cursos/IEC61131-3_Programming
_Indust
rial_Automation_)
?
Peter
Rohner: “PLC
- automation with
programmable logic
controllers”
?
Webb, Reis: “
Programmable
logic controllers:
principles and
applications”
Web:
/pages/tc1_standards/
2.1
编程语言简介
2.1.1
.
梯形图(
LD
)
Ladder
Diagram
从程序电路图演变而来
,
和电气工程师的图形语言很相似
:
图
1
LD
(梯形图编程语言)
LD
使用着与程序电路同等的逻辑图形,
适合<
/p>
I/O
的互锁处理、
位控等的处理,
p>
不过,对于大规模且复杂系统功能要求而言,整体编程就变得很难,需要拆分。
2.1.2
功能块图(
FBD
)
Function
Block Diagram
适合
DCS(Distributed Control Sy
stem)
工程师的图形语言,
被使用在以测试设备
领域为中心的场合。
由于控制适用范围的不断扩大,
程序的可读性也在提高,
所
以目前也常被使用在
PLC
编程中。
像图
p>
2
那样,
FBD
语
言通过连接电子元件(被称作功能块)间的那些线路,
同电路图一样描述程序,
很明了。
功能块左侧需要输入变量参数,
作为演
算结果
的右侧需要变量输出参数。
图
2
FBD
(功能块图编程语言)
2.1.3
顺序功能图(
SFC
)
Sequential
Function Chart
适合生产线等的状态变迁的图形语言。
SFC
不具有演算功能与输入输出功能
之间严密「要素
」规定
,
不过从整体来看,这种没有语言要素的形式,也被当作
编程语言。
图
3
SFC
(顺序功能图编程语言)
2.1.4
指令表(
IL
)
Instruction List
类似于汇编语言程序,就像单片机编程的文本语言一样。
p>
应对小型化和保养场合编程非常有效,不过受限于程序设计的生产效率低。
< br>
图
4
IL
(指令表编程语言)
2.1.5
结构文本(
ST
)
Structured Text
用在基于被设计
p>
PASCAL
的可构造性文本语言,适合习惯电脑的高级语言开
p>
发者和接受过
C
,
C++
等教育的工程师。由于四则运算表达式和数据处理等,在
梯形图环境下编程繁琐。
即如果梯形图打算处理多项式或者带括号的计算式,
开
始需为二个项式一一进行内容分解,
其次在计算
分解的结果,
最后再得到总体处
理结果。这样很显然势必会影响
程序的可读性。
图
5
ST
(结构文本编程语言)
----
--------------------------------------------------
---------------------------------------
2.2 IEC 61131-3 Program Organization
Units (POUs)?
?
Function (FUN). POU that can be
assigned parameters, but has no static
variables (without memory), which, when
invoked with the same input
parameters,
always yields the same result as its function
value (output).
?
Function block (FB). POU that can be
assigned parameters and has static
variables (with memory). An FB (for
example a counter or timer block), when
invoked with the same input parameters,
will yield values which also depend
on
the state of its internal (VAR) and external
(VAR_EXTERNAL) variables,
which are
retained from one execution of the function block
to the next.
?
Program (PROG). This type of POU
represents the “main program”. All
variables of the whole program, that
are assigned to physical addresses (for
example PLC inputs and outputs) must be
declared in this POU or above it
(Resource, Configuration). In all other
respects it behaves like an FB.
2.3
Variables(
变量
)
Variables are only assigned to explicit
hardware addresses(e.g. input and outputs)
in configurations, resources or
programs. In this way a high level of hardware
independency is created, supporting the
reusability of the scopes of the
variables are normally limited to the
organization unit in which they are declared, e.g.
means that their names can be reused
in other parts without any conflict,
eliminating another source of errors.
-
-
-
-
-
-
-
-
-
上一篇:数字示波器的使用方法
下一篇:超声波代码