Everyone has their own ideas when programming PLC, even if the same control logic is written by different engineers, they will get different results. Even the same engineer has different ideas at different times. So when writing a program, two different programs can achieve the same function.
Since different programs can be used to achieve the same function, there are good and bad programs. How to evaluate the pros and cons of a set of procedures?
Here are a few programming principles I summarized:
1. Safety. There will be automatic operation part when using PLC control. This part should be foolproof, rather than doing it, and don’t let the controlled object be out of control. Manual part of the program should also chain limit, or add time limit. Many machinery and equipment have their own safety mechanisms in their organizations. You’d better forget this and ensure that personnel and machines are absolutely safe in terms of procedures.
2. The function is complete, under the premise of ensuring safety, as far as possible to achieve the customer’s functional requirements. This time is the time to reflect your professionalism. Don’t wait until the equipment is delivered, so that the sales staff can’t make the job. For parts that cannot be realized due to hardware or other reasons, communicate with customers as soon as possible.
3. The logic is meticulous, our program not only needs to complete each action smoothly when all parts are normal. When some signals are lost, they must still be in the installed state and have safety tips.
My experience for so many years is that it is easy to implement functions and difficult to handle exceptions. Human thinking is misunderstood, especially when you are racking your brains in order to achieve certain functions, it is really difficult to be careful and have no loopholes in your thinking. It is best to disassemble the functions during programming and work together by different engineers. It is also necessary when the staff is insufficient. Find a colleague who understands the process and let him be responsible for the verification procedure. Repeated experiments, step by step modification, until it can cope with various working conditions.
4. The program is simplified, and we need to be logical and careful in terms of function, so that our thinking has no loopholes. But when programming, it is necessary to use the simplest sentences to complete as many functions as possible. Make the program easy to modify, easy to debug, and easy to upgrade. The general flow of the program is: clarify the process requirements, program design, debug, find problems, add (modify) functions, continue programming, debug again, continue a new round of modification, and so on. Therefore, your program should be easy to modify from the beginning. Don’t make it “touch the whole body” and make yourself more difficult.
5. Easy to read. In addition to completing the specified functions, the programs we write must also be easy to read and use. Many projects can’t be completed by one person. If your program is easy to understand, people in the team can cooperate better. Are you still in the mood to debug when you get a shit-like program at a site where the environment itself is bad?
In addition, the variable names and comments must be clearly marked in the program and correspond to the drawings. Make the information in the program easy to retrieve and find.
The scientific programming steps are actually very simple, but most engineers often think that they are simple and ignore many details. Ignoring details will inevitably cause problems in the future. If you want to avoid future problems, you can only obey the rules, and there is no rule.
PLC programming has its own rules.
Step 1: Read the product manual
The first step looks simple enough, but many engineers can’t do it. Think that this step is a waste of time, and even only learn about the equipment from the supplier’s training.
Reading the manual carefully is the first step in programming. First, you must read the safety rules. Know which actuators may cause personal injury, which organizations are most likely to collide, and how to solve them when danger occurs. These most deadly problems are in safety. Why don’t you read the code?
In addition, the characteristics, usage, and debugging methods of each component of the device are also in the manual. Don’t read it. Even if the program is correct, if the components are not properly debugged, the device will not work. In addition, all the circuit diagrams, pneumatic hydraulic circuit diagrams, and assembly diagrams are also in the manual. How can I know what kind of modification can be made without reading it?
Step 2: According to the manual, check I/O, check I/O, commonly known as “doing”.
There are many ways to check I/O, but be sure to check sequentially according to the address provided in the manual, and check under absolutely safe conditions.
When checking the input point, the general input signal is nothing more than various sensors, such as capacitance, inductance, photoelectric, piezoresistive, ultrasonic, magnetic induction and travel switch sensors. It is relatively simple to check these components. Put the workpiece on the work station according to the component description, or move the actuator to check whether the sensor has a signal. Of course, different devices may have different detection methods, depending on the specific situation.
But be extra careful when checking the output signal. If it is an electric drive product, it must be under safe conditions, especially under the premise of ensuring that the equipment will not collide, so that the actuator of the actuator is energized, and check whether the actuator can move. If it is a hydraulic or pneumatic actuator, it is also safe to manually energize the reversing valve to control the actuator. When checking the output signal, no matter what the driving method of the actuator is, it must be based on the component manual. First of all, the equipment and personal safety must be ensured. Note that not all the actuators of the equipment can be energized and tested, so sometimes individual output signals It may not be possible to test manually.
Whether it is an input or output device, when the sensor has a signal or the actuator’s drive device is energized, you must also check whether the I/O module indicator on the PLC is also on. In many devices, the input and output signals are connected to the PLC through wiring terminals. Sometimes the indicator lights of the wiring terminals have signals, but it cannot be guaranteed that the corresponding address on the PLC is not connected because of the internal open circuit of the connecting wires. Pay special attention to this point.
After measuring the input and output signals, record the measured address at the same time to ensure that the signal address is consistent with the specification. If there is a difference, measure the device address again, and the multiple measurements are still inconsistent. Please contact the device manufacturer first, because there is no guarantee that the address provided by the manufacturer is correct.
Step 3: Open the programming software, configure the hardware, and write the I/O address in the symbol table
Different PLCs use different programming software. But for any kind of software, the first step before programming is to carry out the hardware configuration, and establish the hardware configuration and corresponding communication configuration according to the actual PLC type. After the hardware configuration is completed, write the I/O address recorded on the paper in the symbol table of the software. Due to different software, the definition of the symbol table may be different, but general software has this function, this step is very important. When writing the symbol table, not only must the absolute address of the input and output of the device be written correctly, it is best to name each address and add comments, which will be very convenient for subsequent programming. There is no need to query the absolute address every time during programming, just fill in the named name. Of course, this also depends on whether the software has this function.
Step 4: Write out the program flow chart
Before programming, be sure to write the flow chart of the program on the draft. A complete program should include the main program, stop program, emergency stop program, reset program and other parts. If the software allows, each program should be written in the form of “blocks”, that is, a program is a block, and finally each block Just call it as needed.
What PLC is best at is processing sequence control. In sequence control, the main process is the core. It is necessary to ensure that the established process is correct and carefully check on the draft. If there is a problem with the main process, after the program is executed by the PLC, it is likely to cause an impact, which may damage the equipment or cause danger to the human body.
Step 5: Write a program in the software
After ensuring that there is no problem with the main process, you can write the program in the software. In addition, pay attention to the correctness of the stop, emergency stop and reset procedures, especially the stop and emergency stop procedures, which are the most important procedures related to personal safety and equipment safety and must not be underestimated. It must be ensured that the equipment will never cause personal injury as long as the stop or emergency stop procedure is executed under any circumstances.
Step 6: Debug the program
In this step of debugging the program, it can be divided into two aspects.
1. If conditions permit, or your logic ability is super strong, you can use the software’s simulation function to test first, but many tedious programs are difficult to use software simulation to see whether the program is correct.
2. Download the program to the PLC for online debugging. If the device does not move or there is an abnormal situation during operation, do not modify the program first, it is likely that the sensor has not been debugged in place, if you ensure that the sensor is correct, then modify the program.
Step 7: After debugging, edit the program again
In the last step of debugging, because the program has been modified, it is necessary to check or edit the program as a whole again, and then download the final program to the PLC.
Step 8: Save the program
In this step, we should pay attention to a question, that is, where should the program be stored? PC hard drive? Flash device? Mobile hard drive? Of course none of these are possible. All these storage devices may be infected with viruses. Therefore, it is necessary and only to burn the program to the CD. And there is another question, which is the firing procedure? We have downloaded the final debugged and modified program to the PLC before. If the PLC is completely correct when executing the program, upload the program to the PC and burn the program to the CD. Everything above is for safety.
Step 9: Fill out the report
After completing the programming, you should fill in the final debugging report, and record the problems encountered and some difficult problems of the program one by one. Because after a long time, I will forget some of the skills of the program, and it is also convenient for other colleagues to understand the program you have written.