Designing a complete PLC application system generally involves several steps, including project analysis, PLC hardware selection, program design, and debugging.
I. Project Analysis
Project analysis requires a comprehensive analysis of the project's production processes, working environment, hardware requirements, and control requirements. This work forms the foundation of the entire system design. Inadequate preliminary project analysis will lead to inaccurate hardware selection later, resulting in project delays.
1. Project Analysis
Engineering technicians must first analyze the project, that is, the control process of the project and the control type of each process, and make predictions about the problems that may occur in the whole project.
(1) Analyze the control flow. When analyzing the control flow, it is recommended to draw a relevant control flow diagram, clearly marking the content of each step and the conditions for moving to the next step.
(2) Analyze the control type and estimate the parameters required for PLC selection. Generally, PLCs are suitable for four types of control: sequential control, process control, motion (or position) control, and network communication. After analyzing the control requirements, engineers classify the control type of each control process according to the drawn control flowchart, and then combine the control types according to the complexity of the project. Therefore, accurately analyzing the control type of each step in the early stage will help to ensure accurate selection and problem prediction.
While analyzing the project's control type, engineers also need to estimate the important parameter values required for PLC selection. For example, the number of I/O points in sequential control; if an encoder is used, the frequency of its output pulses must be calculated based on the encoder's parameters, and then converted into the pulse frequency for the PLC's high-speed counting. Other parameters include the number and accuracy of analog signals in process control, the PLC's response speed to servo drive feedback signals and the number of high-speed pulse outputs in motion control, and whether the selected PLC supports the corresponding network type in network communication.
2. Anticipate potential problems
Anticipating potential problems is one of the more challenging aspects of engineering analysis. This requires not only that engineering technicians have a good grasp of the on-site working environment and the overall project control difficulties, but also that they have the ability to anticipate potential emergencies and hazards.
(1) Understanding the working environment of the equipment. Engineers need to have a comprehensive understanding of the production environment. For example, the working environment of textile machinery has high humidity and large vibration, so anti-vibration measures should be taken when designing the PLC system. Another example is that the ambient temperature in building material processing plants is relatively high, and there is a lot of dust and strong static electricity. Therefore, engineers should take further measures to prevent dust and eliminate static electricity while ensuring good ventilation of the electrical control cabinet.
Understanding the equipment's operating environment goes beyond the physical environment. With the increasing application of PLCs, human factors must also be considered. For example, if the operators have low skill levels, a simpler operating interface needs to be developed.
(2) Anticipation of Project Challenges. Anticipating project challenges essentially involves understanding the core issues of the project. For example, the core control of an air-jet loom is how to quickly and orderly control the solenoid valves, using the friction of compressed air to pull the weft yarn through the shuttle and complete the weft insertion process. This requires the PLC to have a very fast response speed. After identifying the project challenges, engineering technicians can select the appropriate PLC based on these challenges. From the perspective of the entire project, the challenges are the characteristics of the system design and also the direction for PLC selection.
(3) Preliminary assessment of project hazards. In the early stages of project design, engineering and technical personnel need to predict potential hazards in the project. For example, protection against malfunctions when debugging equipment in sequential control or motion control; in process control, whether there are high pressure, high temperature, or toxic and harmful substances during testing, and related protective measures. Preliminary assessment of hazards in the early stages of project design helps to enhance the safety awareness of engineering and technical personnel.
II. PLC Hardware Selection
The selection of a PLC is based on the preliminary project analysis and anticipated project challenges by engineering and technical personnel. The main principles are as follows.
1. The principle of applying the specific to the general
Based on engineering experience, the factors that restrict the selection of PLC in most engineering projects are mainly concentrated on a few key points, so the principle of selecting PLC should be followed first for specific cases and then for general cases.
The term "special" refers to the specific control requirements of the project, with different control types having different primary constraints. For example, in sequential control, the CPU's program capacity and I/O point expansion capabilities are the main factors for PLC selection. In process control, the selection is based on the number and accuracy of the controlled analog signals. In relatively simple motion control, the PLC needs to receive position signals from field encoders and correspondingly send pulses of a certain frequency to control the servo motor; therefore, the PLC's data processing speed, its ability to receive high-speed pulses at the input, and its ability to send high-speed pulses at the output become the primary factors for PLC selection. In large-scale complex projects, different PLCs need to be networked; therefore, the network type supported by the PLC becomes the primary factor for PLC selection.
Engineering technicians should arrange the different control requirements in order from specific to general according to the core needs of the project. This will make the selection process more efficient and reduce the overall difficulty of the project.
2. Bottom-up principle
The bottom-up approach aims to maximize the cost-effectiveness of PLC selection. Currently, most manufacturers divide their PLC products into multiple series. When engineers select a PLC, they should follow the first step of selection from specific to general, starting with the lowest-end model and comparing its performance parameters one by one. If a model doesn't meet the requirements, consider a higher-end product. Continue this process until all PLC models that meet the requirements are selected. Selecting from the top down would result in wasted PLC functions, creating an overkill situation.
3. Selection of PLC digital input/output units
The PLC's digital input points are used to receive level signals from field sensors, while the output points, when switched, drive external loads based on internal control signals.
(1) Selection of digital input terminals. Currently, most PLC input points on the market are transistor inputs, and users only need to select them according to the estimated number of input points. However, it should be noted that due to different PLC terminal wiring types, there are two input methods: NPN and PNP. The meaning is whether the input terminal is active low or active high. Once the wiring type of the input terminal is determined, the same type of sensor must be selected. That is, NPN and PNP type sensors cannot share a PLC input terminal.
Most PLC input terminals on the market now use a DC 24V input voltage. If you need to connect a sensor with a different voltage rating to the PLC, you need to use a relay for appropriate isolation to ensure that the signal connected to the PLC input terminal is a DC 24V voltage.
(2) Selection of digital output terminals. The main types of PLC digital output points are relay output and transistor output.
1) Relay output type. Relays have good output load capacity and can withstand high overvoltage and overcurrent for short periods of time, and have strong isolation properties. However, because relays have mechanical contacts inside, their operating life is limited, so they can only be used in applications where the operating frequency is low and high-speed pulse output is not required.
2) Transistor output type. Transistor output type controls the on/off state of the output terminal by controlling the conduction of its internal transistor. Since it does not have an internal mechanical contact structure, compared with relay output contacts, transistor output contacts have a longer lifespan, higher operating frequency, and are less prone to damage. The disadvantage is that the load capacity is relatively poor.
3) Considerations for selecting digital output terminals
① Similar to the input terminals, transistor output terminals are also divided into NPN and PNP types. Once the model is determined, the load can only be connected using the same wiring method.
② In practical applications, it is recommended that engineers choose transistor-output PLCs and connect them to external loads using relays at the output terminals to create electrical isolation for downstream load devices. This combination leverages the advantages of long transistor lifespan and high relay load capacity. If an electrical fault occurs on-site, the PLC output terminals will be protected from damage by the isolation relays, and only the damaged relays need to be replaced. However, once a relay-output PLC terminal is damaged, the damaged terminal cannot be repaired.
4. Principle of building internal components first, then expanding them
With the continuous upgrading of PLCs, especially the increasing functionality of mini PLCs, standalone PLCs now have many built-in expansion module functions, such as analog signal processing and communication functions. Therefore, when selecting a PLC, it is advisable to choose one with as many built-in functions as possible, which reduces costs, saves control cabinet space, and simplifies setup and programming.
5. Determining the Redundancy of PLC Selection
Due to the needs of initial estimation, on-site construction modifications, and subsequent maintenance and upgrades, PLC selection must consider a certain degree of redundancy. The main consideration is the number of I/O points; for smaller projects, redundancy should be controlled within a 20% range; for larger projects, it should be controlled within 5% to 10%. Other redundancy issues, such as analog signals, communication, and bus functions, need to be flexibly determined by engineering technicians based on the on-site hardware configuration. If all control functions are built into the PLC, a higher-level standalone PLC needs to be replaced; if the control functions are implemented through expansion modules, then when considering redundancy, only the corresponding modules need to be updated.
III. Key Points of PLC Programming
(1) Allocate program segments according to the control flow diagram.
Based on the initial control flowchart, the control program is broken down into different program segments. This makes the overall program structure clear and facilitates later debugging. If the project is complex, segmenting the program allows several programmers to program and debug simultaneously, thus improving overall programming efficiency.
(2) Compile I/O tables and memory tables
Creating an I/O table involves assigning addresses to each input/output point and adding comments to prevent I/O point confusion during programming. Creating a memory table involves allocating PLC memory addresses to intermediate variables in the program and adding comments for easy referencing during programming.
(3) Simplify programming
Programmers who are familiar with the PLC instruction system and proficient in using advanced instructions can greatly reduce programming workload, save PLC memory space, and better utilize PLC functions.
(4) Clear annotations
To facilitate later program debugging, each relevant point should be clearly commented in the program, including the purpose of any special instructions used. Good program readability lays the foundation for future project maintenance and upgrades.
IV. PLC Program Debugging Methods
The debugging of PLC applications can be divided into two steps: simulation debugging and online debugging.
1. Simulation debugging
Analog debugging refers to debugging based on the display status of the corresponding LEDs on each bit of the digital I/O unit without output devices.
After designing the control program, simulation debugging is usually performed first. Some PLC manufacturers provide simulation software that runs on a computer and can be used to debug programs, replacing the PLC hardware. For example, Omron's CX-Simulator simulation software, which is used in conjunction with the CX-Programmer programming software, can be used. During simulation, certain input element bits are forced to ON or OFF according to the system's functional requirements, or the data in certain elements is rewritten, to monitor whether the system functions correctly.
When connecting to the PLC hardware for program debugging, small switches and buttons connected to the input terminals can be used to simulate the actual input signals of the PLC. For example, they can be used to issue operation commands or simulate actual feedback signals, such as the opening and closing of limit switch contacts. The output signals can be observed to see if they meet the design requirements by checking the LEDs corresponding to each output point on the digital output unit.
The main task of debugging the sequence control program is to check whether the program's operation conforms to the requirements of the sequence control diagram. Specifically, this involves checking whether the active step state changes correctly during a transition, whether all preceding steps become inactive, all subsequent steps become active, and whether the loads driven by each step change accordingly. During debugging, all possible scenarios should be fully considered. Every possible operating mode of the system, every branch in the sequence control diagram, and every possible progression path should be checked one by one without omission. If problems are found, the program should be modified promptly until the relationship between input and output signals perfectly meets the requirements under all possible conditions. If the set values of certain timers or counters in the program are too large, they can be reduced during debugging to shorten the debugging time, and then their actual set values can be written back after the simulation debugging is completed.
In summary, simulation debugging is a crucial part of the entire programming process, serving as a preliminary check of the program's actual performance. Simulation debugging and program writing are inseparable; many program functions are continuously modified and gradually improved during debugging. Simulation debugging can be conducted in a laboratory or on-site. If on-site simulation debugging is performed, the PLC system should be isolated from field signals, and the external power supply to the I/O units should be disconnected to avoid unnecessary losses.
2. Online debugging
Online debugging refers to the process of installing the PLC in the control cabinet, connecting the input components and output loads, and running the control program for overall debugging.
While simulating and debugging the program, the control cabinet can be designed and manufactured, and the installation and wiring of other hardware besides the PLC can also be carried out simultaneously. After completing the internal wiring of the control cabinet, the wiring should be tested. Simulate external switch input signals to the PLC on the control cabinet terminals, or operate the buttons and command switches on the control cabinet panel to observe whether the state changes of the corresponding PLC input points are correct. Use a programmer or programming software to force-set or reset the PLC output points, and observe whether the corresponding PLC loads (such as external relays, contactors, etc.) operate normally, or whether the state changes of the output signals on the corresponding control cabinet terminals are correct.
For systems with analog inputs, a standard input signal can be provided to the transmitter. By adjusting the potentiometer on the unit or the parameters in the program, the relationship between the analog input signal and the converted digital quantity can be made to meet the requirements.
After installing the control cabinet on site and completing the wiring test inside the cabinet, connect the external input components and actuators to the PLC, put the PLC into running mode, run the control program, and check whether the control system can meet the requirements.
During the debugging process, potential hardware problems and ladder diagram design issues in the PLC system will be exposed. These problems will be resolved on-site until they fully meet the requirements. After all debugging is completed, a trial run will be conducted for a period of time to verify the system's reliability.