通常一套好的PLC程序需要具备以下几个特征:简单性、可读性、正确性、可靠性、易改性、扩展性、完整的报警系统和方便程序模拟。对于不同的行业和工艺,尽管这些特征表现形式多样,但其核心思想是一样的。今天我们就展开讲讲PLC编程规范!
Usually a good PLC program needs to have the following characteristics: simplicity, readability, correctness, reliability, easy modification, expansibility, complete alarm system and convenient program simulation. Although these characteristics take different forms for different industries and processes, the core idea is the same. Today we will start talking about PLC programming specifications!
使PLC程序尽可能简单。简单的含义就是尽可能的使用标准化的程序框架,尽可能使用简单的指令。
Make PLC programs as simple as possible. The simple meaning is to use standardized program frameworks and simple instructions as much as possible.
要想程序简单,从大的方面讲,要优化程序结构,用流程控制指令简化程序,从小的方面讲还要用功能强的指令取代功能单一的指令,以及注意指令的安排顺序等。
If you want a program to be simple, from a large perspective, you must optimize the program structure and use flow control instructions to simplify the program. From a small perspective, you must replace instructions with single functions with powerful instructions, and pay attention to the order of arrangement of instructions.
要求所设计的程序可读性要好。这不仅便于程序设计者加深对程序的理解,便于调试,而且,还要便于别人读懂你的程序,便于使用者维护。必要时,也可使程序推广。
It is required that the designed program be readable. This not only makes it easier for programmers to deepen their understanding of the program and facilitate debugging, but also makes it easier for others to understand your program and user maintenance. If necessary, the program can also be promoted.
要使程序可读性好,所设计的程序就要尽可能清晰。要注意层次,实现模块化,以至于用面向对象的方法进行设计。要多用一些标准的设计。
To make a program readable, the program must be designed as clear as possible. Pay attention to hierarchy, implement modularity, and even use object-oriented methods to design. Use more standard designs.
如遇特殊情况下采用语言编程,多数情况下请使用梯形图编程,方便阅读。
If language programming is used under special circumstances, in most cases please use ladder diagram programming for easier reading.
再就是I/O分配要有规律性,便于记忆与理解。必要时,还要做一些注释工作。内部器件的使用也要讲规律性,不要随便地拿来就用。
Furthermore, the I/O allocation must be regular to facilitate memory and understanding. If necessary, do some annotation work. The use of internal components must also be regular, and do not use them casually.
可读性在程序设计开始时就要注意。这不易完全做到。因为在程序调试的过程中,指令的增减,内部器件的使用变化,可能使原较清晰的程序,变的有些乱。所以在设计时就对调试增减留有一定的余地,然后调试完毕后再做一下整理,这样所设计的程序具有更高的质量。
Readability should be paid attention to at the beginning of programming. This is not easy to do completely. Because during the process of program debugging, the addition and deletion of instructions and the changes in the use of internal devices may make the originally clear program a little confusing. Therefore, there is a certain amount of room for debugging additions and deletions during design, and then some sorting is done after debugging is completed, so that the designed program has higher quality.
A、系统注释:整套程序的版权公司和此套程序用途 A. System notes: The copyright company of the entire program and the purpose of this program
B、程序块注释:此程序块的主要用途和作者 B. Program block comments: the main purpose and author of this program block
C、段注释:此段代码的用途 C. Section comment: the purpose of this code
D、变量注释:重要性无需多言,包含I/O注释、中间变量注释
D. Variable comments: Needless to say the importance, including I/O comments and intermediate variable comments
而至于保密性的考虑,我觉得应该在程序的加密算法或者块的加密上考虑,而不应该用减少注释这种小聪明来实现。
As for the consideration of confidentiality, I think it should be considered in the encryption algorithm of the program or the encryption of the blocks, and should not be implemented by such clever tricks as reducing comments.
PLC的程序一定要正确,并要经过实际工作验证,证明其能够正确工作。这是对PLC程序的最根本的要求,若这一点做不到,其它的再好也没有用。
The PLC program must be correct and must be verified by actual work to prove that it can work correctly. This is the most fundamental requirement for PLC programs. If this cannot be done, everything else will be useless no matter how good it is.
要使程序正确,一定要准确的使用指令,正确的使用内部器件。准确的使用指令与准确理解指令相联系,为此对指令含义和使用条件一定要弄清楚。必要时,可编些小程序对一些不清楚的指令作些测试。
To make the program correct, you must use instructions accurately and use internal devices correctly. Accurate use of instructions is related to accurate understanding of instructions. For this reason, the meaning and usage conditions of the instructions must be clear. If necessary, you can write some small programs to test some unclear instructions.
同一指令,由于PLC的出厂批次不同或是PLC的系列型号的不同,一些指令细节有可能不一样,应仔细查阅编程手册。
For the same instruction, due to different PLC factory batches or different PLC series models, some instruction details may be different, so you should carefully check the programming manual.
内部器件正确使用也是重要的。如有的PLC有掉电保护,有的PLC没有。一定要做到该掉电保护的一定要用掉电保护的器件,反之则不能用。
Correct use of internal components is also important. For example, some PLCs have power-off protection, and some PLCs do not. It is necessary to use power-down protection devices for power-down protection, and vice versa.
总之,要准确的使用指令,正确使用内部器件,使所编的程序能正确要作,这是对PLC程序最根本的要求。
In short, it is necessary to use instructions accurately and use internal devices correctly so that the compiled program can be executed correctly. This is the most fundamental requirement for PLC programs.
举个简单的例子,西门子的上升沿和下降沿需要使用带存储功能的变量作为中间变量,比如M点或者DB点,如果使用FC的temp变量就会出问题的。
To give a simple example, Siemens’ rising and falling edges need to use variables with storage functions as intermediate variables, such as point M or point DB. If you use the temp variable of FC, there will be problems.
程序不仅要正确,还要可靠。可靠反映着PLC程序的稳定性,这也是对PLC程序的基本要求。
The procedure must not only be correct, but also reliable. Reliability reflects the stability of the PLC program, which is also the basic requirement for the PLC program.
有的PLC程序,在正常的工作条件下或合法操作时能正确工作,而出现非正常工作条件(如临时停电,又很快再通电)或进行非法操作(如一些按钮不按顺序按,或同时按若干按钮)后,程序就不能正常工作了。这种程序,就不大可靠,或说不稳定,就是不好的程序。
Some PLC programs can work correctly under normal working conditions or legal operations, but abnormal working conditions occur (such as a temporary power outage and then power on again soon) or illegal operations (such as pressing some buttons out of sequence, or After pressing several buttons at the same time), the program does not work properly. This kind of program is not very reliable, or unstable, and it is a bad program.
好的PLC程序对非正常工作条件出现,能予以识别,并能使其与正常条件衔接,可使程序适应于多种情况。好的PLC程序对非法操作能予以拒绝,且不留下“痕迹”。只接受合法操作。
A good PLC program can identify abnormal working conditions and connect them with normal conditions, allowing the program to adapt to a variety of situations. A good PLC program can reject illegal operations without leaving “trace”. Only legal operations will be accepted.
联锁是拒绝非法操作常用的手段,继电电路常用这个方法,PLC也可继承这个方法。
Interlocking is a common method to reject illegal operations. This method is commonly used in relay circuits, and PLC can also inherit this method.
要使程序易改,也就是要便于修改。 To make a program changeable, that is, it must be easy to modify.
PLC的特点之一就是方便,可灵活地适用于各种情况。其办法就是靠修改或重新设计程序。
One of the characteristics of PLC is its convenience and its flexibility to be applied to various situations. The solution is to modify or redesign the program.
重新设计程序用于改变PLC工艺的用途要求的情况,不仅程序重编,而且I/O也要重新分配。多数情况下不需要重编程序,作一些修改就可以了。这就要求程序具有易性,便于修改。
When the program is redesigned to change the application requirements of the PLC process, not only the program must be rewritten, but the I/O must also be reallocated. In most cases, there is no need to reprogram, just make some modifications. This requires the program to be easy to modify.
易改也就是弹性,要求只要作很少的改动,即可达到改变参数或理改动作的目的。
Ease of change means flexibility, which requires only a few changes to achieve the purpose of changing parameters or modifying actions.
许多程序可能在进现场之前都已经编好,但是到了现场,可能还需要添加另外的程序,为了避免打乱整套系统的结构,需要在每个功能区预留一定的空间作为备用。
Many programs may have been programmed before entering the site, but upon arrival, additional programs may need to be added. In order to avoid disrupting the structure of the entire system, a certain amount of space needs to be reserved in each functional area as a backup.
硬件上留出足够的余量,软件在编写的时候把手动,自动,半自动考虑好,位置留出来。
Leave enough margin on the hardware. When writin
g the software, consider manual, automatic, and semi-automatic functions, and leave space for them.
PLC系统往往用于工业环境中,每一次的事故都会造成或大或小的损失,为了做到事故预处理或者在事故中将损失降到最小,必须重视PLC的报警和保护,在此将其摘出来作为系统的一个重要组成部分。
PLC systems are often used in industrial environments. Every accident will cause large or small losses. In order to pre-process the accident or minimize the losses during the accident, we must pay attention to the alarm and protection of the PLC. Here, we will Take it out as an important part of the system.
为了保证现场的调试进度或者给客户展示,往往在进现场之前,要对自己的程序进行全自动的模拟。为此需要在程序中加入模拟程序部分,模拟程序部分在正常现场运行之后断开。为了使程序具备模拟功能,需要做以下工作:
In order to ensure on-site debugging progress or to demonstrate to customers, it is often necessary to conduct a fully automatic simulation of one’s own program before entering the site. To do this, a simulation program part needs to be added to the program, and the simulation program part is disconnected after normal field operation. In order for the program to have simulation capabilities, the following work needs to be done:
(1)将实际的PLC的I/O点转换为PLC的中间变量或者数据块变量;
(1) Convert actual PLC I/O points into PLC intermediate variables or data block variables;
(2)根据工艺要求编写各个设备的模拟程序。 (2) Write simulation programs for each equipment according to process requirements.
在设计PLC程序的过程中,能够满足以上几个方面的要求的就能称的上是一个好程序了。
In the process of designing a PLC program, a program that can meet the above requirements can be called a good program.
在了解了PLC编程规范之后,该如何运用到实操中呢?下面就引用几个大型企业的编程规范,供大家学习参考!
After understanding the PLC programming specifications, how to apply them in practical operations? Here are some programming specifications from large enterprises for your reference!
免责声明:本文转自网络,版权归原作者所有,如涉及作品版权问题,请及时与我们联系删除,谢谢!
Disclaimer: This article is reproduced from the Internet, and the copyright belongs to the original author. If there is any copyright issue with the work, please contact us in time to delete it. Thank you!