The direct control of stepper motors by programmable logic controllers (PLCs) can significantly reduce the cost of the control system for automated production lines of modular machine tools. This article introduces the method of using a PLC to control a CNC slide driven by a stepper motor, including servo control, drive and interface, and the software logic of PLC control of stepper motors. 1 Overview In automated production lines of modular machine tools, three types of slides are generally set according to different machining accuracy requirements: (1) hydraulic slides, used in roughing operations with large cutting volume and low machining accuracy requirements; (2) mechanical slides, used in semi-finishing operations with medium cutting volume and certain machining accuracy requirements; (3) CNC slides, used in finishing operations with small cutting volume and high machining accuracy requirements. Programmable logic controllers (PLCs) are widely used in industrial automatic control due to their advantages such as strong versatility, high reliability, simple instruction system, easy programming and learning, easy mastery, small size, less maintenance work, and convenient on-site interface installation. In particular, they have shown excellent performance in the control of automated production lines of modular machine tools and the S, T, M function control of CNC machine tools. PLC-controlled open-loop servo mechanisms for stepper motors are used in the control of CNC slides on automated production lines for modular machine tools. This eliminates the need for a separate CNC system in the unit, reducing control system costs by 70-90%, and even requiring only 3-5 I/O interfaces and <1KB of memory from the PLC control unit. This is particularly significant for large automated lines, leading to a substantial reduction in control system costs. 2. PLC-Controlled CNC Slide Structure Generally, CNC slides in automated production lines for modular machine tools employ open-loop servo mechanisms driven by stepper motors. A PLC-controlled CNC slide consists of a programmable logic controller (PLC), a loop pulse distributor, a stepper motor driver, a stepper motor, and a servo drive mechanism, as shown in Figure 1. [align=center][img=425,106]http://www.mcu99.com/Article/UploadFile/200612/20061203125054880.GIF[/img] Figure 1 [/align] Gears Z1 and Z2 in the servo transmission mechanism should be designed with backlash elimination measures to avoid generating reverse dead zones or reducing machining accuracy; while the ball screw transmission pair should be selected based on the machining accuracy requirements of the unit to determine whether to use a ball screw pair. Using a ball screw pair has the advantages of high transmission efficiency, good system rigidity, high transmission accuracy, and long service life, but it is more expensive and cannot self-lock. 3 PLC Control Method for CNC Slide Tables The control factors of CNC slide tables are mainly three: 3.1 Stroke Control Generally, the stroke control of hydraulic and mechanical slide tables is achieved using position or pressure sensors (limit switches/dead stops); while the stroke of CNC slide tables is achieved using digital control. From the structure of the CNC slide table, it can be seen that the stroke of the slide table is proportional to the total rotation angle of the stepper motor. Therefore, it is only necessary to control the total rotation angle of the stepper motor. From the working principle and characteristics of the stepper motor, it can be seen that the total rotation angle of the stepper motor is proportional to the number of input control pulses. Therefore, the number of pulses output by the PLC can be determined according to the displacement of the servo mechanism: n = DL/d (1) Where DL is the displacement of the servo mechanism (mm), and d is the pulse equivalent of the servo mechanism (mm/pulse). 3.2 Feed speed control The feed speed of the servo mechanism depends on the speed of the stepper motor, and the speed of the stepper motor depends on the input pulse frequency. Therefore, the pulse frequency output by the PLC can be determined according to the feed speed required by the process: f = Vf/60d (Hz) (2) Where Vf is the feed speed of the servo mechanism (mm/min). 3.3 Feed direction control Feed direction control is the direction control of the stepper motor. The direction of rotation of a stepper motor can be changed by altering the energizing sequence of its windings. For example, a three-phase stepper motor rotates forward when energized in the sequence A-AB-B-BC-C-CA-A…; it rotates in reverse when energized in the sequence A-AC-C-CB-B-BA-A… Therefore, this can be achieved by changing the output sequence of the hardware ring distributor using the direction control signal output from the PLC, or by programming to change the energizing sequence of the stepper motor windings. 4. PLC Software Control Logic As seen from the PLC control method for the slide table, the total number of input pulses and the pulse frequency of the stepper motor should be controlled accordingly. Therefore, a pulse signal generator with controllable total pulse count and pulse frequency is set up in the control software. For lower frequency control pulses, a timer in the PLC can be used, as shown in Figure 2. The pulse frequency can be controlled by the timer's timing constant to control the pulse period, while the total number of pulses can be controlled by setting a pulse counter C10. When the pulse count reaches the set value, the counter C10 activates, cutting off the pulse generator circuit and stopping its operation. When there is no pulse input, the stepper motor of the servo mechanism stops operating, and the servo actuator positions itself. When the displacement speed requirement of the servo actuator is high, a high-speed pulse generator in the PLC can be used. Different PLCs can have high-speed pulse frequencies of 4000-6000Hz. For general servo mechanisms on automatic lines, the speed requirement can be fully met. [align=center][img=244,279]http://www.mcu99.com/Article/UploadFile/200612/20061203125054638.GIF[/img] Figure 2[/align] 5 Servo Control, Drive and Interface5.1 Composition of Stepper Motor Control System The stepper motor control system consists of a programmable controller, a loop pulse distributor and a stepper motor power driver, as shown in Figure 1. In the control system, the PLC is used to generate control pulses. A certain number of square wave pulses are output through PLC programming to control the rotation angle of the stepper motor, thereby controlling the feed rate of the servo mechanism. Simultaneously, the pulse frequency—the feed speed of the servo mechanism—is controlled by programming. A loop pulse distributor distributes the control pulses output by the programmable controller to the corresponding windings according to the stepper motor's energizing sequence. The PLC-controlled stepper motor can use a software loop distributor or a hardware loop distributor as shown in Figure 1. Using a software loop distributor consumes more PLC resources, especially when the number of phases in the stepper motor windings M>4; this should be carefully considered for large production lines. While the hardware loop distributor has a slightly more complex hardware structure, it saves on the number of PLC I/O ports, and various dedicated chips are available on the market. The stepper motor power driver amplifies the control pulses output by the PLC to a driving capability of tens to hundreds of volts and several to tens of amps. Generally, the output interface of a PLC has a certain driving capability, while the load capacity of a typical transistor DC output interface is only tens to tens of volts and tens to hundreds of milliamps. However, power stepper motors require a drive capability of tens to hundreds of volts and several to tens of amps, therefore a driver should be used to amplify the output pulses. 5.2 Programmable Controller Interface If the servo mechanism uses a hardware loop distributor, the number of I/O ports occupied by the PLC is less than 5, generally only 3. One I/O port is used as the start control signal; two I/O ports are used: one as the PLC's pulse output interface, connected to the clock pulse input terminal of the servo system's hard loop, and the other as the stepper motor direction control signal, connected to the phase sequence distribution control terminal of the hard loop, as shown in Figure 3. When the servo system uses a software loop distributor, its interface is shown in Figure 4. [img=477,135]http://www.mcu99.com/Article/UploadFile/200612/20061203125055850.GIF[/img]6. Application Examples and Conclusions An open-loop servo mechanism controlled by a PLC was used in the CNC slides of a large production line. Each slide only occupies 4 I/O interfaces, saving the CNC control system space. Its pulse equivalent is 0.01~0.05mm, and the feed speed is Vf=3~15m/min, which fully meets the process requirements and machining accuracy requirements.