Research on PLC Control in Multi-point Positioning and Reciprocating Systems
2026-04-06 05:57:53··#1
Abstract: In reciprocating transmission control systems, multi-point positioning is often involved. This requires initiating different mechanical actions at different positioning points. However, due to mechanical inertia, positioning errors often occur. This system takes the mechanical transmission of a gantry planer as an example, using a PLC as the controller, adjusting the speed through a frequency converter, and utilizing a photoelectric encoder and a high-speed counter from the PLC for positioning control, thereby achieving precise positioning. Keywords: Frequency converter; PLC; High-speed counter; Photoelectric encoder 1 Mechanical Transmission Control Requirements of a Gantry Planer [align=center] Figure 1 Schematic diagram of reciprocating mechanical transmission[/align] Figure 1 shows a schematic diagram of the mechanical transmission of a gantry planer. The transmission system starts from the origin, travels at medium speed to 1000mm, then begins high-speed travel, travels at high speed to 3000mm, then begins low-speed crawling, and stops at the endpoint (3200mm). It pauses for 2 seconds. It then travels in the opposite direction at high speed, and begins low-speed crawling 200mm from the origin. It stops at the origin, pauses for 2 seconds, and then resumes the reciprocating motion. The purpose of slow crawling at the origin and destination is to avoid positioning errors caused by system inertia, and to achieve precise positioning and stopping at the origin and destination. 2 Hardware Design of PLC Control System for Gantry Planer Mechanical Transmission 2.1 System Control Requirements for Frequency Converter The forward and reverse rotation of the frequency converter is controlled by relays K1 and K2, and speed switching is completed by relays K3 and K4. The frequency converter fault alarm output contacts (30A, 30C contacts) are used to immediately stop the high-speed counter operation, and are indicated by indicator light HR. The frequency converter has a multi-stage speed setting function. When both relay contacts K3 and K4 are open, high-speed travel (first speed); when K3 is closed and K4 is open, medium-speed travel (second speed); when K3 is open and K4 is closed, low-speed travel (third speed); when both K3 and K4 are closed, manual adjustment of travel (fourth speed). Knob SF is used for manual/automatic switching, and indicator light HG1 indicates the automatic state. In manual mode, the position of the transmission system can be manually adjusted by buttons SA1 (motor forward rotation) and SA2 (motor reverse rotation). Button SA is used for start/stop control of the transmission system in automatic mode. Start/stop control is achieved using a "one-button start/stop" method, with indicator light HG2 indicating the start status. Limit switch SQ is used to determine the transmission system's origin position during automatic start and to ensure the transmission system returns to the origin during automatic stop. Limit switches SQ1 and SQ2 are used to limit the transmission system at both ends, ensuring the transmission system cannot disengage from the equipment. 2.2 PLC System Hardware Structure and Connection To achieve precise positioning of the gantry planer's mechanical transmission, this system uses a PLC as the controller, a frequency converter for speed regulation, and a photoelectric encoder and a high-speed counter from the PLC for positioning control. Based on the mechanical transmission control requirements of the gantry planer, the system has 8 digital input points, 7 digital output points, and one A-phase input from the photoelectric encoder. Therefore, a SIEMENS CPU224 is selected as the controller, and its I/O point allocation and system wiring are shown in Figure 2. [align=center]Figure 2 Wiring diagram of PLC control system for gantry planer[/align] 3 Design of PLC ladder diagram program The design of PLC ladder diagram program includes main program (used to call manual subroutine SBR_0 and automatic subroutine SBR_1 in real time), subroutine SBR_0 (used to realize manual control of the system) and SBR_1 (used to realize automatic control of the system) and interrupt handler INT_0 program (used to handle the processing of the current value of the high-speed counter reaching different preset values). Due to space limitations, the following will take the interrupt handler INT_0 program as an example to illustrate the speed control and adjustment of the frequency converter. Its ladder diagram is as follows. 4 Several key issues to pay attention to in ladder diagram design 4.1 Achieving multi-point positioning by changing the interrupt and preset value of the high-speed counter multiple times The key to achieving multi-point positioning control includes two points. The first point is to set the high-speed counter interrupt event 12 (counter current value = counter preset value), and the other point is to change the high-speed counter preset value in the interrupt handler. Positioning control requires measuring the distance between the positioning point and the origin, then converting the unit distance (mm) into pulse quantities. Changes in these pulse quantities are recorded by a photoelectric encoder and a high-speed counter in the PLC. In this system, the mechanical shaft of the photoelectric encoder is coaxial with the motor. The transmission ratio is 10, the diameter of the transmission roller used to drive the equipment is 100mm, and the number of pulses per revolution of the photoelectric encoder is 600. The number of pulses per millimeter can be calculated as: 600 ÷ (10 × 100 × 3.14) ≈ 0.19108 pulses/mm. Comparison between the fixed position and the preset value must use a high-speed counter interrupt method, not a general comparison instruction, because general comparison instructions cannot capture rapidly changing events. Therefore, the high-speed counter interrupt event number 12 (counter current value = counter preset value) must be connected to the interrupt handler INT_0 via the ATCH and ENI instructions. In the interrupt handler INT_0, when the preset value is reached, the next preset value is reloaded, and the relay output required by the process is executed to handle the inverter's operating speed. In the automatic subroutine SBR_1, the high-speed counter HC0 is set to a single-phase counting input with no external control function. By changing the counting direction at the origin and end points, the interrupt handler INT_0 can determine the inverter's operating direction. 4.2 The equal-or-less comparison instruction cannot be used in the interrupt handler INT_0 because multiple preset values are processed in one interrupt handler INT_0. A comparison instruction and the counting direction are needed to determine which stage the high-speed counter is currently counting at, and to decide which instruction to execute based on the determination. However, the equal-or-less comparison instruction cannot be used; a greater than or less than instruction should be used instead. Although the PLC immediately interrupts the current main program and subroutines and executes the instructions in the interrupt handler INT_0 when an interrupt event (current counter value = counter preset value) occurs, the PLC still executes the interrupt handler INT_0 according to a line-by-line scanning mechanism. The rapidly changing counter value cannot be synchronized with the execution of the interrupt handler. If an equality comparison instruction is used, the PLC may miss the equal value during interrupt handler execution, making it impossible for the PLC to determine the current stage of the device's operation. 4.3 During automatic operation, writing to the initial value register of the high-speed counter must be prohibited. Because multi-point positioning requires multiple loading of the preset value, writing the preset value must be done using the HSC instruction. Executing the HSC write instruction not only writes the preset value, but also, if not restricted in the control byte, writes the value in the initial value register SMD38. Since SMD38 = 0, this will set the current value of the high-speed counter to 0. Therefore, during automatic operation, the seventh bit SM37.6 of the control byte SMB37 must be set to 0, and writing the initial value must be prohibited when loading the preset value. However, during the initial setup of the high-speed counter and its return to the origin to restart operation, the initial value must be written to set it to 0 to avoid errors caused by mechanical reasons. Therefore, the control byte must be modified multiple times. The principle followed is: after allowing the writing of the initial value and executing the HSC instruction, the control byte must be modified immediately to prohibit the writing of the initial value, and the HSC instruction must be executed again. No other instructions can exist in between. 4.4 For multi-point positioning, the output coil should use immediate instructions as much as possible. High-speed counters are used for multi-point positioning mainly for accurate positioning. Positioning accuracy depends on both the measurement of the high-speed counter and the execution speed of the actuator. If ordinary output instructions are used, only the output image memory is changed during the program execution phase of a scan cycle. The PLC's output points are not refreshed immediately. Only after the program execution is completed can the PLC's output image memory refresh the output points and execute the output. To increase positioning accuracy, immediate output instructions should be used as much as possible. Immediate output instructions are not limited by the PLC scan cycle phase and refresh the PLC output points immediately while changing the output image memory. 4.5 Automatic/Manual Programs Implemented Using For-Next Loop Instructions and Subroutine Instructions The automatic/manual functions in this system are implemented using For-Next instructions and subroutine instructions. The automatic and manual programs are essentially loop bodies of two loop instructions. Each loop instruction performs a single loop scan refresh. The manual subroutine SBR_0 and automatic subroutine SBR_1 are used to segment the entire program, facilitating understanding and increasing readability. The For-Next loop instruction allows the output coil to be reused, simplifying the program. Interrupt Handling Program: INT_0 When the inverter is running in the forward direction (determined by SM36.5, incrementing the counter indicates forward operation, SM36.5=1), and the current value of the high-speed counter equals 19108 (1000mm), relays K3 (Q0.2) and K4 (Q0.3) are disconnected, and the inverter speed is set to high-speed forward travel (first speed). Simultaneously, the high-speed counter preset value is changed to 57325 (3000mm). When the inverter is running in the forward direction, and the current value of the high-speed counter equals 59325 (3000mm), relays K3 (Q0.2) disconnect and K4 (Q0.3) connect, setting the inverter speed to low-speed forward crawling (third speed). Simultaneously, the high-speed counter preset value is changed to 61146 (3200mm). When the inverter is running in the forward direction, and the current value of the high-speed counter equals 61146 (3200mm), indicating the endpoint has been reached, relays K1 (Q0.0), K2 (Q0.1), K3 (Q0.2), and K4 (Q0.3) are all reset and disconnected, and the inverter immediately stops running. At the same time, an endpoint arrival signal M0.1 is sent, causing subroutine SBR_1 to pause for 2 seconds and then handle the reverse running settings. When the inverter runs in reverse (determined by SM36.5; when the countdown indicates reverse operation, SM36.5=0), and the current value of the high-speed counter equals 3822 (200mm), relays K3 (Q0.2) disconnect and K4 (Q0.3) connect, setting the inverter speed to low-speed reverse crawling (third speed). Simultaneously, the high-speed counter preset value is changed to 0. When the inverter runs in reverse (judged by SM36.5, countdown indicates reverse operation, SM36.5=0), and the current value of the high-speed counter is equal to 0, it indicates that the inverter has returned to the origin. Relays K1 (Q0.0), K2 (Q0.1), K3 (Q0.2), and K4 (Q0.3) are all reset and disconnected, and the inverter stops running immediately. At the same time, the origin arrival signal M0.0 is issued, causing the subroutine SBR_1 to pause for 2 seconds, and then SBR_1 processes the forward re-run setting. Innovation of this paper: Multi-point positioning of reciprocating drive control system is a difficult problem to solve. This system uses PLC as controller, and through frequency conversion speed regulation, it uses photoelectric encoder and PLC high-speed counter for positioning control, which overcomes the positioning error caused by mechanical inertia in the reciprocating drive control system, thus realizing accurate positioning. References: [1] SIMATIC S7-200 Programmable Controller System Manual and User Manual. 1999. [2] Fang Chengyuan, Factory Electrical Control Technology [M]. Beijing: Machinery Industry Press, 1992.7. [3] Hu Xingming, Dai Yiping. Retrofitting of Combined Machine Tools Based on PLC Technology [J]. Microcomputer Information, 2006, 7-1: 32-38