CNC lathe spindle frequency conversion speed regulation
2026-04-06 05:51:14··#1
Zhou Hong and Zhou Wenjun of Hunan Railway Vocational and Technical College, combining the design of the CK0625 CNC system, studied the application of variable frequency speed regulation technology in the spindle drive system. Under the Windows 2000 platform, using the MSComm control and event-driven communication, they developed communication software between the industrial computer and the frequency converter using VC++ 6.0, solving the communication problem between the industrial computer and the frequency converter and realizing stepless speed regulation of the spindle. 1 Introduction The main motion of a CNC lathe is the rotational motion of the spindle driving the workpiece. The rotational accuracy of the spindle determines the machining accuracy of the part. To ensure the selection of reasonable cutting parameters during machining, thereby obtaining high production efficiency, machining accuracy, and surface quality, CNC lathes require the spindle speed to be continuously adjustable within a wide range. AC variable frequency speed regulation technology is one of the most effective means to achieve stepless speed regulation of the CNC lathe spindle. The hardware of the CK0625 machine tool consists of a motion controller, an industrial computer, an AC servo motor and its driver, an AC asynchronous motor, and a frequency converter. It belongs to the NC embedded PC type open numerical control system. Its control software is developed using Visual C++ 6.0 under the Windows 2000 development platform. This article will introduce the communication between the industrial computer and the frequency converter and the specific implementation of the stepless speed change of the spindle in conjunction with the software design of CK0625. 2 Frequency conversion speed regulation of AC asynchronous motor According to the basic principle of motor, the speed of the asynchronous motor is: (1) Where: f1 is the power supply frequency; p is the number of stator winding pole pairs; s is the slip. CK0625 uses a three-phase AC asynchronous motor with model number JW7134. Its power is 750W, rated voltage is 380V, rated current is 2.05A, rated frequency is 50Hz, maximum speed is 1400r/min, and number of pole pairs is 2. The rotational speed of the asynchronous motor magnetic field (i.e., synchronous speed) n0. The following formula can be used to express: (2) Substituting the rated frequency of 50Hz and the number of magnetic pole pairs of 2 into formula (2), we get that the maximum speed of motor JW7134 is 1400r/min, that is, n=1400r/min. The formula for calculating the slip s is as follows: (3) Substituting n0=1500 and n=1400 into formula (3), we get s=0.067. The main motion of CK0625 adopts variable frequency speed regulation technology, that is, the speed regulation method of smoothly changing the speed by smoothly changing f1. Substituting the slip s=0.067 into formula (1), the relationship between the spindle speed and frequency of CK0625 is as follows: According to the speed regulation range of the CK0625 lathe spindle, the power of the AC asynchronous motor and the installation size of the electrical cabinet, this CNC system selects a 0.75kW Delta general-purpose frequency converter with model VFD007M21A. 3. Communication between the Industrial PC and the Spindle Inverter The VFD007M21A inverter has a microprocessor and communication capabilities, eliminating the need for a dedicated communication interface. Currently, inverters with communication functions mainly use RS-485 or RS-232C communication interface standards. This inverter uses RS-485 communication, connecting to the industrial PC via an RS-232CRS-485 converter. It employs a two-wire twisted-pair transmission method, i.e., data D+ and data D-. This differential data transmission method effectively eliminates interference, and the maximum baud rate can reach 19200 bit/s. The communication between the industrial PC and the inverter is mainly divided into two parts: The first part is mainly used to set communication parameters, such as setting the baud rate, start bit, data bits, parity bit, stop bit, and selecting the communication port. The specific values depend on the inverter's communication protocol and the industrial PC's configuration. The second part is mainly used to implement communication between the industrial PC and the inverter. During normal production operation, it may be necessary to set the function parameters or operating characteristics of the frequency converter via an industrial control computer. Simultaneously, it is also necessary to read, analyze, and dynamically display relevant information fed back from the frequency converter (such as frequency converter function parameter values, operating characteristics, actual frequency values, motor speed values, etc.), and control the lathe's operation based on this information. The VFD007M21A frequency converter uses the USS protocol (universal serial protocol 1). This protocol achieves access and control of the equipment through a master-slave structure and serial communication. In this system, the frequency converter is connected to the industrial control computer via twisted-pair cable, and communication control is performed through the industrial control computer. Each communication message between the industrial control computer and the frequency converter consists of 14 bytes, each byte using the standard Universal Asynchronous Receiver/Transmitter (UART) format: 1 start bit, 8 data bits, 1 parity bit, and 1 stop bit. 4. Software Design for Communication between Industrial Control Computer and Frequency Converter In serial communication of computers, there are three common communication methods: direct serial port reading and writing, using Windows API functions to read and write the serial port, and using the MSComm serial communication control to operate the serial port. Direct serial port reading and writing involves calling the -inp() and -out() functions to directly read and write the serial port; using Windows API functions involves calling API functions such as CreateFile(), ReadFile(), and WriteFile() to operate the serial port. Programming using these two methods is relatively complex and not intuitive. However, by introducing the ActiveX control MSComm, the serial communication requirements of different users can be easily met in the Windows environment by simply changing the MSComm control's property settings and writing the corresponding initialization program, thus achieving the purpose of remote control. Therefore, this system uses the MSComm control to implement serial communication. The MSComm control provides applications with a simple method for sending and receiving data through a serial interface, and it provides two methods for handling communication problems: event-driven method and polling method. In this system, the status information returned by the frequency converter is 14 bytes per frame, and the system is required to respond promptly and have high reliability. Therefore, an event-driven communication method is adopted in the programming. The GetCommEvent() function can be used to obtain the code of the onComm event or error. According to the USS protocol, the information message returned by the frequency converter to the industrial control computer is a 14-byte sixteen-bit word. The system needs to read the ADR and HIW fields to obtain the operating status of the frequency converter. After calculation by the mathematical model, the speed of the spindle motor can be obtained and displayed. The software for communication between the industrial control computer and the frequency converter should have three functions: setting and reading frequency converter function parameters, reading frequency converter operating characteristics, and reading the frequency value sent and the frequency value during frequency converter operation. The latter two functions are implemented using VC++ 6.0 on the Windows 2000 platform. The process of using the MSComm control for serial port programming is as follows: (1) Inserting the MSComm control In the VC++6.0 development environment, select the MSComm control to insert the program. The system will automatically define a CM-SComm class for the inserted control, and the related files are saved in mscomm.h and mscomm.cpp files. After confirming the above menu selection, the MSComm control has been embedded into the project file. Use Class Wizard to add a variable m_MSComm to it. All operations on the serial port in the program are implemented through this variable. The program is as follows: Add the following declaration statement in MainOperPanlView.h: protected: CMSComm m_MSComm; Add the statement to create the control in the CMainOperPanlView.cpp::OnCreate() function: m_MSComm. Create(NULL, 0, CRect(0, 0, 0, 0), this, IDC_MSCOMMl); (2) Initialize and open the serial port. In the program design, the serial port of the industrial control computer is initialized in the OnCreate(LPCREATESTRUCT lpCreateStruct) function in the main framework class CmainFrm. Generally speaking, the serial port initialization requires setting five settings: setting the communication port number (CommPort), setting the communication protocol (Hand-Shaking), setting the transmission rate and other parameters (Setting), setting other parameters, and opening the communication port (PortOpen). The code is as follows: { m_MSComm.SetCommPort(2); // Select COM2 m_MSComm.SetlnBufferSize(1024); // Receive buffer, set the size of the input buffer, Bytes m_MSComm.SetOutBufferSize(1024); // Send buffer, set the size of the output buffer, Bytes m_MSComm.SetlnputLen(0) ; // Set the current receiving area data length to 0, indicating that all data is read m_MSComm.SetlnputMode(1) ; // Read and write data in binary mode m_MSComm.SetRThreshold(1) ; // When there is 1 or more characters in the receiving buffer, the OnComm event for receiving data will be triggered m_MSComm.SetSettings("9600, n, 7, 2") ; // Baud rate 9600, no parity bit, 7 data bits, 2 stop bits... } (3) Capture serial port events The MSComm control uses an event-driven method to obtain data from the port, that is, when an event (such as receiving data) occurs, it notifies the program, and the program needs to capture and process the corresponding event. The program is as follows: Add the following to MainOperPanlView.h: protected: afx_msg void OnCommMscomm(); DECLARE_EVENTSINK_MAP() In CMainOperPanlView.h Add event mapping in cpp: BEGIN_EVENTSINK_MAP(CMainOperPanlView, CFormView) //{{AFX_EVENTSINK_MAP(CMainOperPanlView) ON_VENT(CMainOperPanlView, IDC MSCOMMl, 1/*OnComm*/, OnComm, VTS_NONE) //Map MSComm control events //} 1AFX_EVENTSINK_MAP END_EVENTSINK_MAP() (4) Serial port read and write The function prototypes of the serial port read and write functions Getlnput() and SetOutput() are VARIANT Getlnput(); void SetOutput(const VARIANT& new Value); Both must use the VARIANT type. The parameters of the frequency converter controlled by the PC are implemented through the constructor of the ColeVariant class. ColeVariant can receive various types of data (such as strings, integers, floating-point numbers, etc.) and automatically convert them into data that meets the requirements of VARIANT. The program code is as follows: void CMainOperPanlView::OnComm() { VARIANT variant_inp; COleSafeArray safearray_inp; LONG len, k; BYTErxdata[2048] ;//Set the BYTE array… { varlant_mp MSComm.Getlnput() ;//Read the buffer sdearray_inp: variant_inp;//Convert the VARIANT type variable to a ColeSafeArray type variable len: safearray_inp•GetOneDimSize() ;//Get the effective data length for (k=0;k 5. Conclusion In CNC lathe spindle drive systems, variable frequency speed control technology is used to adjust the spindle speed, offering advantages such as high efficiency, wide speed range, and high precision. This system utilizes VC++ 6.0 developed under the Windows 2000 platform to develop communication software between the industrial computer and the frequency converter, resolving the communication issues between them. Practice has proven that this software effectively achieves stepless speed regulation of the CNC lathe spindle. (Proceedings of the 2nd Servo and Motion Control Forum; Proceedings of the 3rd Servo and Motion Control Forum)