In automated production, processing, and control processes, accurate positioning control of workpiece dimensions or mechanical equipment movement distances is frequently required. This positioning control simply requires the controlled object to enter a designated position according to instructions, without special requirements on the speed of movement. Examples include point-to-point control in production processes (typically tool positioning before cutting on horizontal boring machines, coordinate boring machines, and CNC machine tools), conveyor belt positioning control in warehousing systems, and axis positioning control of robotic arms. Servo motors, such as AC asynchronous motors or stepper motors, are commonly used as drive or control elements in positioning control systems. The key to achieving positioning control lies in controlling the servo motor. Since programmable logic controllers (PLCs) are industrial control computers specifically designed for industrial applications, they possess significant advantages such as strong anti-interference capabilities, extremely high reliability, and small size, making them ideal control devices for achieving mechatronics integration. This paper aims to explain the method of using a PLC to control a servo motor for accurate positioning, introduces several issues that need to be recognized and solved in the design and implementation of the control system, and provides a reference scheme and design ideas for the hardware and software structure of the control system. It has high practical and reference value for the implementation of positioning control in industrial production.
1. Accurate positioning achieved by controlling a three-phase AC asynchronous motor using a PLC's high-speed counter instruction and rotary encoder.
1.1 System Working Principle
The combined use of high-speed counter instructions and encoders in PLCs enables precise positioning and length measurement in modern industrial automation. Currently, most PLCs have high-speed counter functionality; for example, the Siemens S7-200 series CPU226 PLC has six high-speed counters. These high-speed counters can accurately count high-speed pulses with pulse widths shorter than the PLC's scan cycle, handling pulse signals with frequencies up to tens or hundreds of kHz without requiring additional special function units. Rotary encoders, on the other hand, convert angular displacement on the motor shaft into pulse values.
The accurate positioning control system, which utilizes the high-speed counter instructions of a PLC and the encoder to control a three-phase AC asynchronous motor, works by converting the angular displacement of the motor into pulse values through a photoelectric rotary encoder coaxially connected to the motor. The high-speed counter of the PLC then counts the number of pulses emitted by the encoder, thereby achieving positioning control.
1.2 Design and Implementation
The following example illustrates the design of a conveyor belt positioning control system. A conveyor belt is needed to transport goods, with a distance of 10cm from the starting point to the designated location (end point). The requirement is that the conveyor belt motor stops running after the goods have traveled 10cm. The system hardware primarily includes a Siemens S7-200CPU226 PLC, a conveyor belt motor (three-phase AC asynchronous motor), an OMRON E6A2-CW5W photoelectric rotary encoder, and a Panasonic VFO series BFV00042GK frequency converter. The system works by coaxially connecting the mechanical shaft of the photoelectric encoder and the transmission roller (driven by the three-phase AC asynchronous motor). The transmission roller drives the mechanical shaft of the photoelectric encoder to rotate, outputting pulse signals. The PLC's high-speed counter counts the number of pulses (using A-phase pulses). When the current value of the high-speed counter equals a preset value, an interrupt is generated, and the frequency converter controls the motor to stop running, thus achieving accurate positioning control of the conveyor belt's running distance. Clearly, the key to achieving accurate positioning control in this system is setting the preset value of the PLC's high-speed counter. This preset value is the number of pulses generated by the photoelectric encoder when the conveyor belt travels 10cm. This pulse value is related to parameters such as the conveyor belt's travel distance, the number of pulses per revolution of the photoelectric encoder, and the diameter of the drive roller. This pulse number can be obtained through experimental measurement or calculation. The calculated pulse number corresponding to 10cm of conveyor belt travel is:
Pulse count = [(drive roller diameter (mm) × π ÷ (pulse count/revolution)] × conveyor belt running distance (mm)
The system calculates that the number of pulses is 100, so the preset value of the high-speed counter is 100.
In the subroutine, the high-speed counter HSC0 is set to mode 1, i.e., an increment/decrement counter with single-channel pulse input internal direction control. There is no start input; a reset input is used. When the system starts running, the subroutine HSC_INIT is called to initialize HSC0, setting its control byte SMB37 to 16#F8, writing the current and preset values to the high-speed counter, and simultaneously connecting interrupt event 12 (i.e., the high-speed counter's current value equals the preset value interrupt) and the interrupt service routine COUNT_EQ via the interrupt connection instruction ATCH, and executing the ENI instruction to enable global interrupts. When the high-speed counter's current value equals the preset value, the interrupt service routine is executed, clearing the value of SMD42 to zero, and then executing the HSC instruction again to rewrite the current and preset values to the high-speed counter, while simultaneously setting M0.0 and stopping the motor.
2. Accurate positioning is achieved by controlling a stepper motor using high-speed pulse commands from a PLC.
2.1 System Working Principle
Stepper motors have become a primary actuator in industrial control due to their advantages such as simple structure, convenient control, low moment of inertia, high positioning accuracy, no cumulative error, and low cost, especially in precision positioning applications. In industrial production, stepper motors are connected to production machinery in many ways. A common method is to connect the stepper motor to a lead screw, converting the rotational motion of the stepper motor into the linear motion of a worktable. When positioning control of the worktable's movement distance is required, only the stepper motor's speed and angular displacement need to be controlled. Under non-overload conditions, the stepper motor's speed and angular displacement depend only on the frequency and number of pulse signals. Its output angular displacement is proportional to the number of input pulses, and its speed is proportional to the pulse frequency. Changing the phase sequence of the winding energization can reverse the stepper motor.
Currently, most major PLC manufacturers worldwide produce PLCs with dedicated high-speed pulse output instructions, which can be easily integrated with stepper motors to form motion positioning control systems. The essence of using PLC high-speed pulse instructions to control a stepper motor for accurate positioning is that the PLC outputs high-speed pulse signals via PTO/PWM instructions, which are then controlled by the stepper motor's pulse microstepping driver, thus moving the worktable to the designated position and achieving accurate positioning. The relationship between the distance the worktable moves and the number of PLC pulses is as follows:
In the formula: N is the number of control pulses issued by the PLC; n is the pulse microstepping number of the stepper motor driver (if the stepper motor driver has pulse microstepping drive); θ is the stepper motor's feed angle, that is, the angle through which the shaft rotates for each pulse change received by the stepper motor; d is the thread pitch of the lead screw, which determines the distance the worktable moves forward for each revolution of the lead screw; δ is the pulse equivalent (positioning accuracy); i is the transmission speed ratio; L is the distance the worktable moves.
Clearly, the key to achieving accurate positioning using a PLC-controlled stepper motor lies in setting the number of pulses generated by the PLC. The number of pulses is related to factors such as pulse equivalent, transmission speed ratio, stepper motor driver microstepping, and pulse frequency.
2.2 Design and Implementation
This paper takes the positioning control design of a linear guide in a cargo storage system as an example. In the storage system, a stepper motor is required to drive a linear guide to deliver materials to a designated warehouse entrance. Assuming the transport distance from the starting point to the destination is 100mm, the stepper motor is required to drive the guide in a linear motion with a positioning distance of 100mm. To achieve accurate positioning, the system uses a Siemens S7-200 series CPU226 PLC, a Sitong 57BYG250C hybrid stepper motor, and a Senchuang SH-20403 stepper motor driver. The CPU226 PLC has two pulse generators, Q0.0 and Q0.1 terminals. Both terminals can output PTO/PWM high-speed pulse signals with a pulse frequency up to 20kHz. According to the control requirements, the system will use a high-speed pulse train output PTO function, which can output a square wave signal with a certain number of pulses and a duty cycle of 50%. The period of the output pulses is incremented in μs or ms. The PTO (Pulse Train Toggle) function allows multiple pulse trains to be output in sequence, thus forming a pipeline. There are two types of pipelines: single-stage pipelines and multi-stage pipelines.
To eliminate low-frequency oscillations in the motor and improve resolution, a stepper motor microstepping driver is used, with a step angle of 0.9°/1.8° and a pulse microstepping count of 4. To ensure speed and positioning accuracy requirements, the stepper motor operation generally involves three processes: acceleration, constant speed operation, and deceleration when approaching the positioning point. To maintain the stepper motor and drive equipment, the drive pulse frequency also needs to be linearly increased. Therefore, this positioning control system employs multi-pipeline operation to control the motor's operation. Assume the linear guide rail starts at point A, and the desired position is to move it from point A to point D, where AD = 100mm. Positioning accuracy is only related to the stepper motor pulse equivalent; taking a pulse equivalent of 0.11mm/pulse, 900 pulses are needed to complete the positioning. During the stepper motor's operation, it accelerates from point A to point B and then maintains a constant speed, then decelerates from point C to point D to complete the positioning process. This requires 200 pulses for frequency increase acceleration, 500 pulses for constant speed operation, and 200 pulses for frequency decrease deceleration.
Therefore, the PTO is determined to be a 3-segment pulse pipeline (AB, BC, CD). Assuming the maximum pulse frequency is 1kHz, write 16#A0 to the control byte SMB67 to allow multiple PTO pulse outputs. The time base is in the μs range. Establish the envelope table for the 3 pulse segments and set the parameters for each segment separately. The period increment for a given segment is calculated using the following formula:
The period increment of a given segment = (period value at the end of the segment - period value at the beginning of the segment) / number of pulses in the segment.
This control method is an open-loop control of the stepper motor, and its advantages include simple structure, low cost, accurate positioning, and ease of implementation.
2.3 Precautions during the design and implementation of control systems
(1) Selection of PLC type. First, the PLC must be a transistor output type capable of outputting high-speed pulses. Second, the maximum pulse frequency of the PLC output must meet the control requirements.
(2) Selection and parameter setting of stepper motor pulse microstepping driver.
(3) Stepper Motor Selection. The first consideration is the type of stepper motor, followed by the specific model. Based on system requirements, determine the stepper motor's voltage and current values, as well as whether it has a positioning torque and whether a bolt-operated positioning device is used. This will determine the number of phases and steps of the stepper motor. When selecting the specific model of stepper motor, consider the speed ratio i, axial force F, load torque Ti, rated torque TN, and operating frequency fy to determine the specific specifications and control device of the stepper motor.
(4) Calculation of pulse equivalent.
3. Accurate positioning achieved using other methods of PLC
3.1 Achieving accurate positioning using PLC PID instructions and software/hardware coordination
For example, in a cylinder precision positioning control system, a closed-loop control system is composed of a PLC, solenoid valves, an optical encoder, and a cylinder. The PLC acts as the control and calculation center, while the optical encoder acts as a detection device to measure the piston movement of the cylinder. The detection result is fed back to the PLC via its analog input terminals, compared with a set value, and subjected to PID control. The PID calculation result drives an AC or DC solenoid valve through the PLC's relay output interface. The switching of the solenoid valve changes the flow rate of the cylinder piston, causing the cylinder to move accurately to the target position, thus achieving precise positioning.
3.2 Accurate positioning achieved using the EM253 module of the PLC
The EM253 position control module is a special function module for the S7-200 series PLC. It generates pulse trains for open-loop speed and position control of stepper and servo motors. It communicates with the S7-200 series PLC via an extended I/O bus. Featuring eight digital outputs, it functions as an intelligent module in the I/O configuration, providing the functionality and performance required for single-axis, open-loop motion control. It offers high-speed control, ranging from 12 to 200,000 pulses/s. STEP7-Micro/WIN provides a position control wizard for configuring and programming the position control module, generating configuration/envelope tables and position control instructions, and configuring the EM253's motion parameters, motion trajectory envelope, etc.
4 Conclusion
Practice has proven that the accurate positioning control system proposed in this paper, composed of PLC, rotary encoder, servo motor, etc., has advantages such as simple structure, high cost performance, and ease of implementation, and can be widely used in industrial production and military fields. It has practical and reference value in applications such as precise length cutting of sheet metal, military radar positioning systems, screen printing machine stop control, and positioning control using asynchronous motors or stepper motors in CNC machine tools, material metering, and film feeding packaging.