+(86)0752-5103606 E-mail:info@hytech-cn.com

What is the perfect PLC program

Last Updated on 2021-01-09 Hits:2359

Today, share an article to let you know more about what a perfect PLC program looks like, as well as PLC programming specifications and suggestions in actual work.
1. Design requirements to be met by a perfect PLC program
A complete PLC program is not only so simple to make the system run, it also requires complete annotations, sophisticated architecture, good scalability, complete alarm protection system, and simulation system before operation.
1. Simplicity
Make the PLC program as simple as possible. The simple meaning is to use a standardized program framework as much as possible, and use simple instructions as much as possible.
In order to make the program simple, the program structure should be optimized from a large point of view, the program should be simplified with flow control instructions, and from a small point of view, powerful instructions should be used to replace single-function instructions, and attention should be paid to the order of instructions.
2. Readability
The readability of the designed program is required. This not only facilitates programmers to deepen their understanding of the program, and facilitates debugging, but also facilitates others to read your program and facilitate user maintenance. If necessary, the program can also be promoted.
To make the program readable, the designed program must be as clear as possible. Attention should be paid to the level and the realization of modularity, so as to design with an object-oriented method. Use more standard designs.
If language programming is used in special circumstances, in most cases please use ladder diagram programming for easy reading.
Then there must be regular I/O allocation to facilitate memory and understanding. If necessary, some annotation work should be done. The use of internal devices should also be regular, don't just use them casually.
Readability should be paid attention to at the beginning of program design. This is not easy to do completely. Because in the process of program debugging, the increase and decrease of instructions and the use of internal devices may make the original clearer program a little messy. Therefore, when designing, leave a certain amount of room for debugging increase and decrease, and then do some sorting after debugging, so that the designed program has a higher quality.
The comments of the program should at least have the following aspects:
A. System notes: the copyright company of the entire program and the purpose of this program;

B. Program block comment: the main purpose and author of this program block;

C. Section comment: the purpose of this section of code;

D. Variable comments: The importance does not need to be said, 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 block, rather than the cleverness of reducing comments.

3. 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 is not possible, the others are 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. For this reason, the meaning of instructions and conditions of use must be clarified. If necessary, you can write some small programs to test some unclear instructions.
For the same instruction, due to the different factory batches of the PLC or the different series models of the PLC, the details of some instructions may be different, so please refer to the programming manual carefully.
The correct use of internal devices is also important. If some PLCs have power failure protection, some PLCs do not. The power-down protection device must be used to achieve the power-down protection, otherwise it cannot be used.
In a word, it is the most fundamental requirement for PLC program to use the instructions accurately and use the internal devices correctly to make the programmed program operate correctly.
For a simple example, Siemens' rising and falling edges need to use variables with storage functions as intermediate variables, such as M point or DB point. If you use FC's temp variable, problems will occur.
4. Reliability
The procedure must not only be correct, but also reliable. Reliability reflects the stability of PLC program, which is also the basic requirement for PLC program.
Some PLC programs can work correctly under normal working conditions or legal operations, but abnormal working conditions (such as a temporary power failure and quickly re-energizing) or illegal operations (such as pressing some buttons out of order, or After pressing several buttons at the same time), the program will not work properly. This kind of program is not very reliable or unstable, which is a bad program.
A good PLC program can recognize the occurrence of abnormal working conditions and connect it with normal conditions, so that the program can be adapted to many situations. A good PLC program can reject illegal operations without leaving "tracks". Only accept legal operations.
Interlocking is a common means to refuse illegal operations. This method is commonly used in relay circuits, and PLC can also inherit this method.
5. Easy to modify
To make the program easy to modify, that is, easy to modify. One of the characteristics of PLC is its convenience, which can be flexibly applied to various situations. The solution is to modify or redesign the program.
The redesign of the program is used to change the use requirements of the PLC process, not only the program is reprogrammed, but also the I/O must be redistributed. In most cases, there is no need to reprogram, just make some modifications. This requires the program to be easy to modify.
Easy to change is flexibility, requiring only a few changes to achieve the purpose of changing parameters or modifying actions.
6. Scalability
Many programs may have been compiled before entering the site, but when you arrive at the site, you may need to add additional programs. In order to avoid disrupting the structure of the entire system, you need to reserve a certain space in each functional area as a backup.
Leave enough margin on the hardware. When writing the software, consider manual, automatic, and semi-automatic, and set aside positions.
7. Complete alarm system
PLC systems are often used in industrial environments. Every accident will cause large or small losses. In order to achieve accident pretreatment or minimize losses in accidents, the alarm and protection of PLC must be paid attention to. Take it out as an important part of the system.
8. Program simulation
In order to ensure the progress of on-site debugging or to show to customers, it is often necessary to perform a fully automatic simulation of one's own program before entering the site. For this reason, it is necessary to add a simulation program part to the program, which is disconnected after normal on-site operation. In order to make the program have a simulation function, you need to do the following:

(1) Convert the actual PLC I/O points into PLC intermediate variables or data block variables;

(2) Compile simulation programs of each equipment according to process requirements;

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

2. PLC program design specification

1. Select the appropriate PLC model and I/O points, and select special function modules when special functions are required.

2. Familiar with the selected PLC programming instructions and compiling software.

3. Carry out software component planning, including internal relays, holding relays, data registers, timers, counters, etc.

4. Carry out program planning, generally in the order of fault extraction, fault processing, manual processing, automatic processing, and output processing. Larger projects or equipment are processed in sections and blocks according to functional units. For example, if an automated production line has hoists, shifters, jacking-up rotating devices, etc., it should be programmed in blocks according to the above-mentioned units.

5. A short section comment should be added before the program written in sections and blocks to explain the function of this section of the program, and the corresponding process flow can be indicated if necessary. The block or segment program and the overall program position sequence should basically be arranged in the order of the process flow to facilitate the readability of the program.

6. Before program design, the equipment should be abstracted, and common factors such as stop, emergency stop, overload, overrun, overtime, safety light curtain, touch stop, door switch, etc. should be extracted and placed in the start loop or start main control, Chain loop, as the major premise of the entire program structure, on this basis, the program is divided into two major functional areas, automatic and manual.

7. Extract the common factors of the manual function area of the program structure, such as manual, endangering the personal safety of the equipment and other factors, and place them in the manual main control and interlock loop to protect, shield and alarm the manual control.

8. Extract the common factors of the automatic function area of the program structure, such as automatic, overrun, overtime and other factors, and place them in the automatic main control and interlocking loops to protect, shield and alarm the equipment under automatic control. A general principle is to strictly restrict the entry of equipment and loosely restrict the exit of equipment under the premise of ensuring safety.

9. The overall reset function of the program should be designed in the program design, so that the user can easily restore the normal operation of the equipment as soon as possible when the equipment fails. The overall reset should fully consider the safety of equipment and personnel during the reset process.

10. When the automatic mode is switched to manual mode, the program should clear the output and intermediate state in automatic mode. Especially when the SET command is used in the automatic mode, it must be cleared by the RESET command in the manual mode.

11. It is strictly forbidden to use dual outputs in programming, that is, the same output sentence or the same output coil appears twice or more in the program. Under different mode conditions, the output of the same output point is relayed by using an intermediate relay, and finally gathered together and paralleled to the output point.

12. When using the touch screen, the control area and status area shared by the touch screen and PLC shall not be used for programming of other functions.

13. For special modules of PLC, before using, check whether the control area and status area occupies work words. If they are occupied, these work words must not be programmed in other aspects.

14. The input, output, intermediate relay, timer, counter, data register, etc. of PLC must be added with Chinese comments. Input and output also have component names and tag numbers. Corresponding input points, in general, the peripheral switch is connected to NO contact by default, and the NC contact needs to be connected to it must be marked in the comment. All comments should be clear and concise, not easy to misunderstand, and use general references as little as possible.

15. After the project debugging is completed, the system must retain the final software program, and the saved file name should include the project number/author/date information/version number, etc.

16. About program encryption: The password of the encrypted program must be saved in a special file, and the corresponding user name + password + authority must be indicated, and distributed to at least two people to understand the password to prevent the loss of the password and the situation that the program cannot be opened .

Three, programming suggestions

1. When PLC and host computer (or touch screen) form a monitoring system, there are many control modes such as "manual" and "automatic" on the screen (usually there are only one when there are multiple). The "MOV" instruction can be used in the program. For example, when selecting “manual”, the constant 1 MOV is transferred to a register VB10, and when “automatic” is selected, 2 MOV is transferred to the same register VB10. As long as you judge the data in the register, you know what kind of control the system is. The advantage of this idea is that it is easy to understand and does not require troublesome programs such as interlocking.

2. When the program has analog control, if the read analog is basically without error, time filtering can be used to delay for a period of time. If the error of the read data is large, other filtering methods are needed, such as calculating the average value. You can consult relevant information.

3. In the process of program debugging (especially when the equipment is modified, your program is added to the program of the original equipment), when the condition is met in the program statement and the output coil is not connected, you can check your section Whether the program is between such statements, such as JUMPgo to statements. Another possibility is that after the program is interrupted, the condition is met but the output is not turned on. Generally, this section of the program is not scanned.

4. In the sequence control program, that is, after one action is completed, enter the next action, and other similar sequence control, using +10+10 control mode, I think it is very convenient. The idea is: preset a register, the value is 0 at initialization, when the system is started, to it +10, at this time the register is 10, when the register is equal to 10, you can do the first action; after the first action is completed, Then the register +10, at this time the register is equal to 20, you can do the second action, after the second action is completed, +10, at this time the register is equal to 30, so as long as you judge the data in the register, you know which action to complete . When jumping action is needed, you can no longer +10, you can add +20+30..., depending on actual needs.

Why add 10 instead of adding 1, because after adding 10, if you insert a paragraph, just choose a position in these 10 free places.

5. When designing the program, when there is a technological failure (not controlled by the control system), it is best to maintain the failure phenomenon and have a light and sound alarm. Until the operator reset, let him know that the system has malfunctioned. Otherwise, it will stop, and others will think that your program has a problem. Generally, you should pay attention to these when designing a new system.

6. For frequently called subprograms, it can be made into submodules and called frequently.

7. Since each step movement of the production machine in the work cycle takes a certain amount of time to execute, and these times have certain limits, these times can be used as a reference, and at the same time the step movement to be detected is started, Start a timer, the time setting of the timer is 20% to 30% longer than the duration of the action under normal conditions, and the output signal of the timer can be used for alarm or automatic shutdown device. When the operation time of a certain step of the production machinery exceeds the specified time and reaches the corresponding preset time of the timer, the timer sends out a fault signal when it has not transferred to the next step. This signal stops the normal working cycle program, starts an alarm or stops Program, this is what we often call super beat protection.

8. Some safety detection switches (such as emergency stop buttons, safety light curtains, limit switches, etc.) are practically closed (NC) inputs.

9. For the sake of safety and energy saving, try to design the output to act only when it needs to be actuated, and stop the output once it is in place, instead of designing it to always output, and only let the output disconnect when it needs to stop.

10. The principle of action of the actuator should be rather not move, and don't move!

11. Single device control: a single device must have soft hand operation/automatic switching and start/stop function during soft hand operation. When switching from automatic to soft hand operation, the equipment cannot be stopped; when switching from soft hand operation to automatic operation , The equipment start/stop depends on the automatic program.

12. Single equipment (pumps, fans and other large-scale equipment) must be rotated after 24 hours of operation, and must have an accumulated running time. If the start/stop sequence is set by the host computer, the operator shall set it by himself.

友情链接: 广州到上海物流 集运系统 情趣家具 猎酷网 物流网站 展会运输 淘宝集运