For position control of rotating objects driven by servo motors, a common approach is to use a shaft-mounted electromagnetic rotary transformer with complex processing circuitry to encode angles, which are then used for closed-loop position control. This type of position control is primarily used in applications requiring high angular accuracy, resulting in complex equipment and high costs. In some practical applications, simpler position positioning is needed. For example, a servo motor-driven mechanical mechanism may require positioning at four or more positions within a 360° rotation range. Practical applications such as controlling valve sizes in the construction industry to regulate water, cement, and sand flow, or military engineering control, where high precision is not required, make the aforementioned method uneconomical and prohibitively expensive.
PLCs (Programmable Logic Controllers) are widely used in industrial control. Their high reliability, high stability, user-friendly programming environment, and touch-screen human-machine interface make various industrial controls more convenient, intuitive, economical, and reliable. This paper mainly describes a position control method based on an S7-200 PLC.
1 System Hardware Design
This system is a position control system with a PLC controller at its core, including servo motors, photoelectric encoders, operators and displays, a host computer, servo motor control circuits, and status return circuits. Its overall hardware structure diagram is shown in Figure 1.
1.1S7-200PLC
The core component of this system is a Siemens S7-200 series PLC. This series of PLCs is feature-rich, with multiple functional modules, allowing for convenient operation and monitoring of the equipment via a human-machine interface (HMI). Higher version PLCs have two communication ports, enabling remote control and monitoring of the equipment via RS-485 interface and logic operations and status management with a computer, in addition to HMI operation. A key function of the S7-200 PLC used in this system is high-speed reversible counting. A photoelectric encoder and a servo motor are coaxially connected. The servo motor's rotation drives the photoelectric encoder to generate a continuous pulse train. The PLC reads these pulses from the encoder through input points, achieving high-speed reversible counting. For example, three water flow levels (high, medium, and low) can be set and controlled. During the commissioning phase, the servo motor should be driven to calibrate the three water flow levels; that is, each of the three levels corresponds to a unique pulse count. It should be noted that because an incremental photoelectric encoder is used, the current pulse count is not saved when the encoder is powered off. Therefore, two limit switches are also installed on the rotating mechanism. Firstly, to protect the mechanical structure; secondly, to set the reverse limit switch to the zero position. Thus, the number of pulses read from the photoelectric encoder relative to this zero position for the high, medium, and low water supply levels indicates the position of these three levels. These three positions can be controlled via PLC programming. Figure 2 shows the timing diagram of the S7-200 PLC high-speed reversible counter.
1.2 Photoelectric Encoder
An optical encoder is a sensor that converts the mechanical geometric displacement of an output shaft into pulses or digital signals through photoelectric conversion. It is currently the most widely used sensor. An optical encoder consists of a grating disk and a photoelectric detection device. The grating disk has several rectangular holes evenly spaced on a circular plate of a certain diameter. Since the optical encoder disk is coaxial with the motor, it rotates at the same speed as the motor. The detection device, composed of LEDs and other electronic components, detects and outputs several pulse signals. Furthermore, to determine the direction of rotation, the encoder disk can also provide two pulse signals with a 90° phase difference. Figure 3 shows the timing diagram of an optical encoder used in an actual project. It can be seen from the figure that the phase judgment angle of this optical encoder is 90°±45°. Additionally, the CW (clockwise) and CCW (counterclockwise) symbols marked in the figure can be defined in the PLC program according to the actual application. Figure 4 shows the internal circuit and external wiring diagram of an optical encoder used in an actual project.
2 System Software Design
2.1 Design Considerations
The key points of this system software design are: 1) Accurate configuration of the high-speed counter; 2) Tolerance design of the position controller. The tolerance should be as small as possible to improve the control accuracy of the servo system. While meeting the system's positioning accuracy requirements, the tolerance design also needs to consider the resolution of the mechanical structure's positioning to avoid insufficient mechanical control due to excessively small settings, causing repeated rotation and adjustment of the drive motor, often requiring on-site calibration; 3) Precise calibration of the initial position. It is important to note that manual control should be used when initially calibrating each position, and the status of the mechanical limit switches should be connected to the PLC. Since an incremental photoelectric encoder is used, the current counter value must be stored in the PLC's power-off storable register MDL4.
2.2 Programming
The program first needs to configure the high-speed counter as A/B phase quadrature input, 4x counting rate, incrementing count, and enabling the high-speed counter. Then, the calibrated positions of each gear are filled into the corresponding addresses, and the tolerance is set to two pulses. That is, the pulse count for each gear plus or minus 2 indicates the corresponding position. The clearance of the servo system's transmission device is diverse and affects the performance of servo control. Setting the tolerance aims to eliminate system instability caused by servo transmission clearance, thereby ensuring accurate positioning. The flowchart of the position positioning program is shown in Figure 5.
In program design, besides the clockwise and counterclockwise limit switches and the interlocking programs for clockwise and counterclockwise rotation, the focus is on how to use a PLC to achieve multi-point repetitive positioning. The main program design is as follows:
3. Engineering Application
This design method was used in a 4-position positioning system controlled by an attenuator in a military radar project. The system requires the driven mechanical components to reciprocate between four positions within a 0° to 360° range, with a positioning accuracy of 0.1°. In the specific design, a 55TYD02 AC motor was selected as the drive motor, and an OMRONE6B2 relative photoelectric encoder was used as the encoding mechanism. The 360° position travel range corresponds to 8400 pulses. Therefore, the position resolution read by the S7-200 PLC high-speed counter is 360°/8400 = 0.043°. Based on the actual calibration position tolerance value of the mechanical structure, it is set to 2 pulses. The control accuracy of this positioning system can reach 0.86°, meeting the system positioning accuracy requirement of 0.1°. The motor can complete the forward or reverse rotation in one go, quickly and accurately.
4. Conclusion
PLCs are suitable for harsh industrial environments. Through their communication ports, they communicate with a host computer, allowing operators to remotely control the equipment in a safe environment. Photoelectric encoders have a simple construction principle, a mechanical lifespan of tens of thousands of hours, and strong anti-interference capabilities. The hardware circuit based on these two components implements a position control method suitable for mechanical rotary control equipment with multiple setpoints for repetitive positioning, fully meeting general industrial control requirements. This design has a clear principle, well-defined hardware requirements, is easy to implement, and convenient for debugging and maintenance, demonstrating excellent practicality and applicability. The aforementioned position control method has been applied to attenuator control in a military radar project, achieving a control accuracy of 0.86°, meeting the system's positioning accuracy requirement of 0.1°. The equipment operates stably and reliably, with excellent results.