How to write a perfect PLC program

Publisher:数字之舞Latest update time:2022-04-02 Source: elecfansKeywords:plc Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The best evaluation standard for PLC programs is practice. See whether the program can achieve the expected purpose. But this is not enough. Because there are good and bad programs that can achieve the purpose. What kind of program is considered a good program? Generally speaking, there are the following aspects:

1. Brevity

Making the PLC program as short as possible is also a goal that should be pursued.

How to write a perfect PLC program

Short programs save user storage area; in most cases, they also save execution time, increase the response speed to input, and improve the readability of the program.

Whether a program is short or not can generally be measured by the number of instructions used by the program. The fewer instructions used, the shorter the program will naturally be.

To make the program shorter, from a broad perspective, we need to optimize the program structure and use flow control instructions to simplify the program. From a detailed perspective, we also need to replace single-function instructions with more powerful instructions and pay attention to the order in which the instructions are arranged.


2. Time saving

A short program can save program running time, but short and time saving are not exactly the same thing. Because the program running time is related to the number of instructions in the program, but also to the instructions used. Different PLC instructions have different execution times. Moreover, some instructions have different execution times when the logic condition is ON and when it is OFF. In addition, due to the use of process control instructions, not all instructions in the program need to be executed. Therefore, the calculation of the program running time is more complicated. However, it is necessary to require that the average time is short and the maximum time is not too long. This can improve the response speed of the PLC.

The key to saving time is to use the process control instructions well. According to the situation, determine some instructions that must be executed as necessary parts, and the rest can be carried out according to the program, executed selectively, or some time-sharing work design can be made to avoid the maximum time being too long.


3. Readability

The designed program should be readable. This will not only help the programmer to deepen his understanding of the program and debug it, but also make it easier for others to understand your program and for users to maintain it. If necessary, the program can also be promoted.

To make the program readable, the program should be designed as clearly as possible. Pay attention to the hierarchy, implement modularization, and use object-oriented methods for design. Use more standard designs.


Readability should be taken into consideration at the beginning of program design. This is not easy to achieve completely. Because during the process of program debugging, the increase or decrease of instructions and the change of the use of internal devices may make the original clear program become a little messy. Therefore, when designing, leave some room for debugging increase or decrease, and then do some sorting after debugging is completed, so that the designed program has higher quality.


4. Correctness

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 the PLC program. If this cannot be achieved, no matter how good the other programs are, they will be useless.


To make the program correct, you must use the instructions accurately and use the internal devices correctly. Accurate use of instructions is related to accurate understanding of instructions, so the meaning of instructions and usage conditions must be made clear. If necessary, you can write some small programs to test some unclear instructions.


For the same instruction, some instruction details may be different due to different PLC factory batches or different PLC series models. Please refer to the programming manual carefully.


It is also important to use the internal components correctly. For example, some PLCs have power-off protection, (information source: http://www.dqjsw.com.cn) some PLCs do not. It is important to use the components that have power-off protection, otherwise it cannot be used.

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.


5. Reliability

The program 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.


Some PLC programs can work correctly under normal working conditions or legal operations, but they cannot work properly when abnormal working conditions (such as temporary power failure and quick power-on) or illegal operations (such as pressing some buttons out of sequence or pressing several buttons at the same time) occur. Such programs are not very reliable, or unstable, and are bad programs.


A good PLC program can identify abnormal working conditions and link them with normal conditions, so that the program can adapt to a variety of situations. A good PLC program can reject illegal operations without leaving any "traces". Only legal operations are accepted.


Interlocking is a commonly used means to prevent illegal operations. Relay circuits often use this method, and PLCs can also inherit this method.


6. Easy to modify

To make the program easy to change, it should be easy to modify.

One of the characteristics of PLC is its convenience and flexibility in adapting to various situations by modifying or redesigning the program.


Redesigning the program is used to change the use requirements of the PLC process. Not only the program needs to be rewritten, but the I/O needs to be reallocated. In most cases, rewriting the program is not necessary, and some modifications are sufficient. This requires the program to be easy to modify.


Easy to modify means flexibility, which requires only a few changes to achieve the purpose of changing parameters or modifying actions.

In the process of designing PLC programs, a program that can meet the above 6 requirements can be called a good program.


Keywords:plc Reference address:How to write a perfect PLC program

Previous article:Method of using PLC to judge the fault of switch signal
Next article:Basic Design Steps of PLC Control System

Recommended ReadingLatest update time:2024-11-16 11:43

What are the five languages ​​that support PLC programming?
Compared with general computer languages, the software programming language of PLC has obvious characteristics. It is different from high-level languages ​​and general assembly languages, and must meet the requirements of easy writing and debugging. Early PLCs only supported ladder diagram programming languages ​​an
[Embedded]
What are the five languages ​​that support PLC programming?
Basic knowledge points of PLC programming
Calculation of switch quantity Switching quantity, also known as logic quantity, has only two values, 0 or 1, ON or OFF. It is the most commonly used control. Controlling it is the advantage of PLC and also the most basic application of PLC. The purpose of switch quantity control is to make the PLC g
[Embedded]
Basic knowledge points of PLC programming
What are the main sources of electromagnetic interference in PLC control systems?
1. Overview With the development of science and technology, PLC is increasingly used in industrial control. The reliability of PLC control systems directly affects the safe production and economic operation of industrial enterprises, and the anti-interference ability of the system is the key to the reliable ope
[Embedded]
Siemens PLC example explanation: circuit diagram, design steps
1. Design Ideas PART 01 1. Use PLC to control the one-dimensional motion platform to realize the automatic forward and reverse operation and manual forward and reverse operation of the motor; 2. There is a travel switch at each end of the one-dimensional motion platform, which is defined as positive limit
[Embedded]
Siemens PLC example explanation: circuit diagram, design steps
PLC Case: How to set up MRP in TIA environment?
Highlight Sync Domain MRP Domain Settings MRP Domain Management Diagnostic interrupt Configure the topology view to quickly view the fault point when a port error or device failure occurs. Topology View Setting MRP parameters Select the PLC
[Embedded]
PLC Case: How to set up MRP in TIA environment?
PLC motor forward and reverse control circuit diagram ladder diagram program
When learning PLC, the application of edge instructions is indispensable, which brings us a lot of convenience in programming. Today, we will introduce a case to directly and reliably switch the motor forward and reverse program. We know that the most important issue in the motor forward and reverse contr
[Embedded]
PLC motor forward and reverse control circuit diagram ladder diagram program
Function and application examples of PLC data transmission instructions
Data transfer instructions can realize the transfer and copy of data between storage units. Mitsubishi PLC (FX2N for example) has about 6 transfer instructions for users to use, and Siemens PLC (S7-1200 for example) has about 4 (mainly depends on whether they are strictly distinguished). This article uses examples t
[Embedded]
Function and application examples of PLC data transmission instructions
Common causes and solutions for PLC failures
PART1: Failure of peripheral circuit components This type of failure often occurs after the PLC has been working for a certain period of time. If a component failure occurs in the PLC control loop, the PLC control system will automatically stop working immediately. The input circuit is the port throu
[Embedded]
Common causes and solutions for PLC failures
Latest Embedded Articles
Change More Related Popular Components
Guess you like

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号