PLC梯形图转化为指令表算法及实现.pdf
文本预览下载声明
控 制 工 程
Control Engineering of China
Mov . 2 0 0 6
Vol. 13, No. 6
2006年11月
第13卷第6期
文章编号: 1671-7848( 2006) 06-0573-04
收稿日期: 2005-09-15; 收修定稿日期: 2005-11- 29
作者简介: 莫易敏( 1960-) ,男,湖南桃源人,教授,博士生导师,主要从事机电一体化等方面的教学与科研工作。
PLC梯形图转化为指令表算法及实现
莫易敏, 章德平, 周 哲
(武汉理工大学 机电工程学院, 湖北武汉 430070)
摘 要: 针对目前 PLC 梯形图编辑软件的缺陷和不足, 基于面向对象的设计思想, 提出
了一种全新的将梯形图转化为指令表的优化算法。介绍了语法检查、构造逻辑树结构和遍历
树结构得到相应指令集三个具体过程的解决方案。结合灵活的类管理机制, 将该算法应用于
编辑软件, 成功地解决了图形语言向文本语言的转化。由于指令程序比较接近于机器语言,
将梯形图转换成指令表以后, 通过指令解释器对指令表的解释得出程序的逻辑, 可以在 PC 机
上执行程序。使用该算法开发出来的 PLC 编辑软件, 作为一个编写 PLC 程序的通用开发平台,
它功能强大、操作简单、使用方便。
关 键 词: 梯形图; 指令表; 树; 扫描; 编译
中图分类号: TP 311 文献标识码: A
Algorithm and Realization of Transformation
from PLC Ladder Diagram to Instruction Table
MO Yi-min, ZHANG De-ping, ZHOU Zhe
( College of Mechanical and Electronical Engineering, Wuhan University of Technology, Wuhan 430070, China)
Abstract: Aiming at the limitation and lack of the current editing software for PLC ladder diagram, based on the idea of or iented-object , an
optimal algorithm to convert ladder diagram to instruction table is presented. A concrete solution of grammar checking, constructing logic tree
and traversal of the tree to come up with instruction table are introduced. With flexible mechanism of class management, the algorithm is suc-
cessfully applied to the editing software to realize the transformation from graph language to text language. As procedure is fairly close to the b-i
nary code, PLC ladder diagram is transformed to the instruction table, then the logic of procedure is educed through the explanation to the in-
struction table of interpreter, so that the procedure can be run on PC. The software based on this algorithm is powerful and simple to operate,
and convenient to use.
Key words: ladder diagram; instruction table; tree; scanning; compile
1 引 言
软PLC是一种基于工业控制计算机或嵌入式
PC的逻辑控制软件,主要用于工业控制领域。它是
随着工业自动化控制领域的最新国际标准的颁布而
发展起来的,此编程标准
[ 1]
包括 5种 PLC 编程语言:
顺序功能图、功能块图、梯形图、指令表及结构文本。
其中梯形图和指令表简单易用, 使用最为广泛
[ 2]
。
梯形图形象、直观,对于熟悉继电器表示方式的人
显示全部