Abstract: This paper utilizes the I/O ports of an 8051 microcontroller to control a five-phase stepper motor. An internal program distributes the microcontroller's output signals to drive the stepper motor, thus controlling the direction, speed, and position of the CNC lathe's feed system. Variable frequency technology, widely used in industrial automation, is employed to achieve stepless speed regulation of the CNC lathe spindle, with the five-phase stepper motor serving as the actuator. Since the angular displacement of the stepper motor is proportional to the number of command pulses, and the rotation direction is related to the energizing phase sequence, controlling the number and frequency of command pulses and the energizing phase sequence of the motor windings allows control of the machine tool's feed system's displacement, speed, and direction of movement. This automatic control of the CNC lathe spindle and feed system effectively saves energy, improves equipment automation, and increases product output and quality, resulting in significant economic benefits. Microcontrollers are widely used in modern industrial automation systems, and mastering microcontroller technology is an important skill for those engaged in industrial control.
1 Introduction
CNC machine tools are a general term for numerically controlled machine tools. They are advanced mechatronic products that integrate the latest achievements in modern precision mechanical design and manufacturing technology, computer technology, communication technology, automatic control technology, testing technology, power electronics and microelectronics technology, motor and new materials technology, hydraulic and pneumatic technology, and optoelectronic technology. As machine tools in the processing and manufacturing industry, they are modern equipment that combines high precision, high flexibility, high efficiency, and high automation. CNC machine tools are important basic equipment in national defense and the national economy. Their applications are widespread in all sectors of the social economy. They are pillar industries in machinery, electronics, automobiles, petrochemicals, and construction, and also important tools for the modernization of basic industries such as energy, transportation, materials, and communications.
In today's technological landscape, automation control technology is one of the most widely used, fastest-growing, and most economically beneficial technologies. Single-chip microcomputers are specifically designed for industrial applications, and many organizations in my country currently use them to implement low-end, economical CNC systems. The 8051 series of single-chip microcomputers has become the most widely used type. Besides being used in low-end, economical CNC machine tools, single-chip microcomputers are also commonly used in full-function CNC systems with multiprocessors to implement functions such as servo drives.
The operating performance of a stepper motor is related to the characteristics of the motor itself, the load, and the driving power supply used with it. The operating performance of a stepper motor is a comprehensive result of the stepper motor and the driving power supply. Therefore, selecting a high-performance driving power supply is very important for maximizing the performance of the stepper motor.
Speed control of AC asynchronous motors has always been a difficult problem to solve. It wasn't until the 1970s, with the advent of computers and the emergence of new, fast power electronic components in the last two decades, that speed control of AC asynchronous motors became possible and rapidly gained widespread adoption. According to electrical machinery theory, the speed of an AC asynchronous motor can be determined by the formula n=60fp(1-s). It is known that changing the power supply frequency is the most effective method for speed control of AC asynchronous motors; this is known as variable frequency speed control.
In the early 1980s, with the development of computer software and hardware technology, CNC devices capable of interactive automatic programming emerged. These devices became increasingly miniaturized and could be directly installed on machine tools. The automation level of CNC machine tools further improved, featuring functions such as automatic monitoring of tool breakage and automatic workpiece inspection. After decades of development, current CNC machine tools are computer-controlled and widely used in industry, particularly in the mold manufacturing sector. Various categories of CNC machine tools have been developed to meet the needs of metal cutting processes such as turning, milling, grinding, drilling, and planing, as well as special processing processes such as electrical discharge machining and laser processing.
2. Mechanical Structure of CNC Machine Tools
2.1 Overview of CNC Lathes
CNC lathes, also known as Computer Numerical (CNC) lathes, are lathes controlled by computer numerical control. Horizontal lathes rely on manual operation to perform various cutting operations, while CNC lathes input a pre-programmed machining program into a CNC system. The CNC system then controls the sequence of movements, amount of travel, and feed rate of the lathe's feed motion components via servo motors on the X and Z axes. Combined with the spindle speed and direction of rotation, this allows for the machining of various shapes of shafts or disc-shaped rotating parts. Therefore, CNC lathes are currently the most widely used CNC machine tools.
2.2 Main Drive System of CNC Lathe
The main motion transmission system is driven by an 11/15KW AC servo motor, which drives the spindle to rotate via a 1:1 belt drive, enabling stepless speed regulation of the spindle within the speed range of 35-3500r/min. The gear transmission mechanism inside the spindle box is eliminated. This reduces the impact of the original gears on the spindle and facilitates maintenance.
2.3 Spindle Box Structure
The spindle employs a two-support structure. The front support consists of a double-row cylindrical roller bearing 11 and a pair of angular contact ball bearings 10. Bearing 11 supports radial loads. One large opening of the two angular contact ball bearings faces the front end of the spindle, and the other large opening faces the rear end, to withstand bidirectional axial and radial loads. The clearance of the front support bearings is adjusted using nuts 1 and 6. Screws 17 and 13 serve as anti-loosening devices. The spindle support is front-end positioned, and the spindle extends rearward due to thermal expansion. The double-row cylindrical roller bearings used in both the front and rear supports provide good support rigidity and a high permissible limiting speed. The angular contact ball bearings can withstand larger axial loads and also have a high permissible limiting speed. This support structure meets the needs of high-load cutting.
2.4 Feed transmission system and transmission device
The X-axis and Z-axis feeds are driven by stepper motors. A simplified diagram of the X-axis feed transmission device is shown. Stepper motor 15 drives ball screw 6 to rotate via synchronous pulleys 14 and 10 and synchronous belt 12. Nut 7 on the ball screw drives tool post 21 to move along the guide rail of slide plate 1, realizing the X-axis feed motion. The front support 3 of the ball screw consists of three angular contact ball bearings, one with its large end facing forward and two with their large ends facing backward, bearing axial loads in both directions. The front support is preloaded by nut 2. The rear support 9 of the ball screw is a pair of angular contact ball bearings, with their large ends facing away from each other, and is preloaded by nut 11. This type of support with fixed ends on the screw has a more complex structure and manufacturing process, but it can ensure and improve the axial stiffness of the screw. The Z-axis feed transmission device: Stepper motor 14 drives ball screw 5 via synchronous pulleys 12 and 2 and synchronous belt 11. Nut 4 drives slide plate and tool post to move along the rectangular guide rail of bed 13, realizing the Z-axis feed motion. The motor shaft and the synchronous pulley 12 are connected without a key by a tapered ring, where 19 and 20 are inner and outer tapered rings with interlocking tapered surfaces. When the screw 17 is tightened, the end face of the flange 18 presses the outer tapered ring 20 to expand outward, while the inner tapered ring 19 contracts towards the motor shaft under force, thereby connecting the motor shaft and the synchronous pulley together.
3. Machine tool spindle frequency conversion speed regulation
3.1 Variable Frequency Speed Control Principle
The most commonly used variable frequency drive (VFD) is the voltage-type VFD, which consists of three parts: a rectifier, a filter system, and an inverter. In operation, the three-phase AC power is first rectified into pulsating DC power by a bridge rectifier. This pulsating DC voltage is then smoothed and filtered, and under the control of a microprocessor, the inverter converts the DC power back into a three-phase AC power supply with adjustable voltage and frequency, which is then output to the motor requiring speed regulation. As electrical principles show, the motor speed is directly proportional to the power supply frequency. By using a VFD, the power supply output frequency can be arbitrarily changed, thereby arbitrarily adjusting the motor speed and achieving smooth, stepless speed regulation.
3.2 Variable frequency speed control of lathe spindle
The lathe spindle is driven by an 11kW three-phase asynchronous motor. After comparison, a Mitsubishi series frequency converter was selected to achieve variable frequency speed control of the spindle, ensuring it always operates at its optimal state. Additionally, an encoder is installed at the rear end of the spindle to achieve speed control. Figure 1 shows a schematic diagram of the variable frequency speed control structure, utilizing the output of an 8051 microcontroller to achieve forward and reverse rotation and speed control of the spindle motor.
3.3 Anti-interference technology of frequency converters
3.3.1 External Interference
Inverters utilize high-performance microprocessors and other integrated circuits, making them highly sensitive to external electromagnetic interference. Errors caused by electromagnetic interference can severely impact operation. External interference often intrudes through the inverter's control cable; therefore, adequate anti-interference measures must be implemented when laying the control cable.
3.3.2 Interference generated by the frequency converter
The input and output current waveforms of frequency converters are not standard sine waves, but contain many high-order harmonic components. These harmonics will propagate their energy through air radiation and line propagation, interfering with the operation of surrounding electronic, communication, and wireless equipment. Therefore, when installing frequency converters, various anti-interference measures should be considered to weaken the strength of interference signals.
4. Stepper motor control system for the feed device
The open-loop feed servo system of this CNC machine tool does not have a position detection feedback device, and the command signals issued by the CNC unit are unidirectional. The system uses a power stepper motor as the driving element to realize the feed motion. When a certain axis needs to move by one unit length, a pulse is output to the servo circuit of that axis, which is then distributed and amplified in a loop to drive the stepper motor to rotate one step, and the lead screw rotates to move the moving parts of the machine tool by one unit length. Figure 2 is a schematic diagram of the open-loop system using a power stepper motor.
Stepper motors, as actuators, are key products in mechatronics and are widely used in various automated control systems. With the development of microelectronics and computer technology, the demand for stepper motors is increasing daily, and they are used in various sectors of the national economy. A stepper motor is an electromagnetic device that converts electrical pulse signals into angular displacement. The angular displacement of a stepper motor is proportional to the number of input pulses and is synchronized with the input pulses in time. Its rotation is a step-by-step movement at fixed angles. Therefore, by controlling the number and frequency of input pulses and the energizing sequence of the motor windings, the desired speed and direction of rotation can be obtained. When there is no pulse input, under the excitation of the winding power supply, the air gap magnetic field can keep the rotor in its original position and in a self-locking state. Stepper motors can also be used as special motors for control, taking advantage of their characteristic of no accumulated error (100% accuracy), and are widely used in various open-loop control systems.
Commonly used stepper motors include variable reluctance (VR) stepper motors, permanent magnet (PM) stepper motors, hybrid stepper motors (HB) stepper motors, and single-phase stepper motors. Permanent magnet stepper motors are generally two-phase, with smaller torque and size, and a step angle typically of 7.5 or 15 degrees. Variable reluctance stepper motors are generally three-phase, capable of high torque output, with a step angle typically of 1.5 degrees, but they are much noisier and vibrate more. The rotor winding of a variable reluctance stepper motor is made of soft magnetic material, and the stator has multi-phase excitation windings, generating torque through changes in magnetic permeability. Hybrid stepper motors combine the advantages of permanent magnet and variable reluctance motors. They are further divided into two-phase and five-phase: two-phase typically has a step angle of 1.8 degrees, while five-phase typically has a step angle of 0.72 degrees. This type of stepper motor is the most widely used and is the stepper motor selected for this segmented drive scheme.
Microcomputer control principle of 5 stepper motors
Traditional stepper controllers are complex and costly. When controlling stepper motors with a microcontroller, the microcontroller hardware and software can replace the aforementioned stepper controller. This not only simplifies the circuit and reduces costs, but also greatly improves reliability and allows for flexible changes to the stepper motor control scheme according to system needs, making it more convenient to use. The stepper motor drive circuit operates based on control signals. In microcontroller control of stepper motors, the control signals are generated by the microcontroller. Its basic control functions are as follows.
5.1 Controlling the commutation sequence
The commutation sequence of a stepper motor strictly follows its operating mode. This commutation process is typically referred to as pulse distribution. Taking a five-phase stepper motor operating in a 2-3 phase energization mode (ten pulses), the energization sequence is: AB-ABC-BC-BCD-CD-CDE-DE-DEA-EA-EAB. First, the AB winding is connected, then the ABC windings are connected, then the A winding is disconnected, allowing the BC winding to connect; then the BCD windings are simultaneously connected, and so on. The five stator windings require ten switching cycles to complete one cycle.
5.2 Controlling the direction of the stepper motor
As we know from the stepper motor principle explained earlier, if the commutation sequence is followed in the correct order, the stepper motor will rotate forward; if the commutation sequence is reversed, the motor will rotate in reverse. A five-phase, ten-beat stepper motor operating in 2-3 phase mode rotates forward with the commutation sequence AB-ABC-BC-BCD-CD-CDE-DE-DEA-EA-EAB. If the commutation sequence is reversed, the motor will rotate in reverse.
5.3 Controlling the speed of the stepper motor
Sending a control pulse to a stepper motor causes it to rotate one step; sending another pulse causes it to rotate another step. The shorter the interval between two pulses, the faster the stepper motor rotates. Therefore, the pulse frequency determines the stepper motor's speed. By adjusting the frequency of the pulses emitted by the microcontroller, the speed of the stepper motor can be adjusted. Stepper motor speed control is achieved by controlling the frequency of the stepping pulses emitted by the microcontroller. Speed adjustment can be achieved by adjusting the time interval between two control words. This can be done by using a software delay method; changing the delay time can change the frequency of the output pulses. However, this method causes the CPU to wait for a long time, consuming a significant amount of machine time.
5.4 Stepper motors can be controlled by microcomputers in two ways: serial and parallel.
5.4.1 Serial Control
This method minimizes the wiring between the microcontroller system and the stepper motor drive power supply. The microcontroller sends signals to the ring distributor of the stepper motor drive power supply through the I/O interface. Therefore, in this system, the drive power supply must contain a ring distributor.
5.4.2 Parallel Control
The method of directly controlling the phase drive circuits of a stepper motor using several port lines of a microcomputer system is called parallel control. The motor drive power supply does not include a ring distributor, whose function must be implemented by the microcomputer system. There are two methods to implement the ring distributor function using a computer system: one is a pure software method, where phase sequence allocation is entirely implemented in software, directly outputting the on or off signals for each phase, mainly using register shifting and lookup table methods; the second is a combination of software and hardware. This paper implements pulse distribution through software, sending control pulses to the drive circuit through the microcontroller's I/O ports according to the given power-on sequence, as shown in Figure 3.
6 Conclusions
This article focuses on how to use a microcontroller to control a stepper motor, thereby controlling the X and Z axes of a lathe. Mechanically, this system not only ensures the machine tool's precision and stability and achieves reliable machining quality, but also significantly reduces the need for gear transmission mechanisms.