Share this

Research on Real-time Data Acquisition of CNC Machine Tools Based on PMAC

2026-04-06 08:00:37 · · #1
Abstract: This paper analyzes the characteristics and problems encountered in data acquisition using a multimedia timer. A real-time data acquisition method combining PMAC's dual-port RAM technology with a multimedia timer is proposed. Experiments were conducted on a CNC camshaft grinding machine, achieving satisfactory results. Compared with multi-threaded data acquisition methods, this method is simpler and more secure. Keywords : PMAC; Real-time Data Acquisition; Dual-Port RAM; Multimedia Timer; Multi-threaded Technique; Multimedia timers are widely used in data acquisition due to their high timing accuracy. Using a multimedia timer to acquire motion parameters of a PMAC-based CNC machine tool can lead to memory read errors and even system crashes if the data acquisition is large and the time intervals are short, causing the machining program to be interrupted. If unexecuted machining data in the buffer is not cleared in time, an open-loop "runaway" will occur upon the next startup, which is extremely dangerous. However, using the dual-port RAM of the PMAC for data reading not only effectively avoids this problem but also greatly simplifies the data acquisition process. Satisfactory results have been achieved in data acquisition applications on CNC camshaft grinding machines. This method has significant advantages compared to using multi-threaded technology for data acquisition. 1. Introduction to PMAC Card The PMAC (Programmable Multi-Axis Controller) is an open multi-axis motion controller based on a PC platform, launched by Delta Tau in the 1990s. It uses Motorola's DSP56 series high-performance digital signal processor as its CPU and is one of the most powerful motion controllers in the world. One PMAC can control 1 to 8 axes simultaneously, and multiple PMACs cascaded can control up to 128 axes, enabling precise positioning. It is widely used in packaging, assembly, pharmaceutical, and machine tool industries. 2 Multimedia Timer Technology 2.1 Comparison of Multimedia Timers and Ordinary Timers Ordinary timers are set using the function SetTimer, in milliseconds. However, due to the influence of message queue processing speed and system clock frequency, the sampling period is at least 54.925ms. That is to say, the sampling period of SetTimer(1,1,NULL) and SetTimer(1,50,NULL) is about 55ms. However, by using Windows multimedia timers instead of conventional timers, a sampling interval of 1ms or less and a resolution of 1µm can be obtained through programming. The timing accuracy is very high and the stability is particularly good [1]. 2.3 How to Use Multimedia Timers Before using multimedia timers, it is necessary to determine the resolution range of the multimedia timers of the operating system. The resolution range of the multimedia timers of this computer can be obtained by using the function timeGetDevCaps. The main steps of using multimedia timers are as follows: 1) Set the multimedia timer using the timeSetEvent function. This function can initialize the multimedia timer, determine the sampling time interval, and set a timing callback event. 2) Define a callback function using the function TimeProc. Code can be added to this function to implement various operations. 3) Call the `timeKillEvent` function to end the multimedia timer. 3. Real-time Data Acquisition Methods Based on Dual-Port RAM Technology 3.1 PMAC Data Reading Methods Currently, two common PMAC data reading methods are used: one method is to determine the acquisition source and acquisition period by setting the `I` variable and obtaining the acquired data from the buffer. This method can acquire data from any valid PMAC address, but it is relatively complex; the other method is to directly acquire data from I/O and motion registers by setting the `M` variable to correspond to the address of the motion parameter in the register and reading the value of the `M` variable to acquire data. This method is relatively simpler. This paper adopts another PMAC data reading method: starting the dual-port RAM and using the functions provided by the dual-port RAM for data acquisition. This method is more convenient. The functions of the dual-port RAM encapsulate the PMAC data reading process. Users only need to call the relevant functions to directly read motion parameters from the dual-port RAM without setting the acquisition source and data address. The dual-port RAM provides many motion parameter acquisition functions, which can be used to acquire the status, position, speed, following error, etc. of each motor. For example, the function `Double PmacDPRPosition(DWORD dwDevice, int motor, double units)` returns the actual position of the specified motor. The parameter `dwDevice` is the PMAC card number, `motor` refers to the motor number, and `units` represents the units. By using appropriate unit conversion, the motor's motion parameters can be converted into the motion parameters of the corresponding axis. If the functions provided by PMAC's dual-port RAM still cannot meet the needs, register acquisition can also be used; dual-port RAM also supports register reading. 3.2 Dual-Port RAM Technology PMAC's Option 2 provides an 8K×16-bit RAM, allowing PMAC and PC to share a fast memory for rapid data transfer. During machine tool processing, it is necessary to download large amounts of data quickly in real-time, while simultaneously repeatedly and quickly reading the status information of each motor from PMAC. The motor status information data can be continuously updated and automatically written into the dual-port RAM by the PLC program or PMAC. If dual-port RAM is not used, this data must be accessed via the PC bus using PAMC's online commands. Since dual-port RAM access does not require sending commands through the communication port and waiting for response time, it is much faster [2]. The following are some of the main dual-port RAM background fixed-point data reporting function functions [3]: · The function PmacDPRRealTime is used to enable or disable the PMAC card dual-port RAM and specify the servo update cycle. · The function PmacDPRSetMotors is used to set the PMAC card and copy the relevant data of the motor to the dual-port RAM. · The function PmacDPRSetHostBusyBit is used to notify the PMAC card that the client is about to "read" the data in the dual-port RAM. · The function PmacDPRGetHostBusyBit is used to check whether a "write" operation is being performed on the dual-port RAM. The above four functions can be used together to complete the initialization of the dual-port RAM and the preparation of data acquisition. 4. Application Example 4.1 Introduction to the CNC Camshaft Grinding Machine Experimental System The CNC camshaft grinding machine experimental device generates the cam profile through a two-axis linkage: horizontal reciprocating movement of the X-axis grinding wheel head and rotation of the C-axis workpiece spindle. Its main hardware includes an industrial computer, PMAC card, Panasonic servo motor, Renishaw grating, CBN grinding wheel, and electric spindle. The linear grating mounted on the X-axis has a resolution of 1µm, and the circular grating mounted on the C-axis has a resolution of 20µm. The CNC system uses the linear grating to collect X-axis displacement as feedback and the circular grating to collect C-axis rotation angle as feedback, forming a fully closed-loop control, as shown in Figure 1. PMAC supports multiple high-level languages ​​such as C++, VB, VC, and Delphi, and provides dynamic link library functions for secondary development. This experimental device uses Visual C++ 6.0 as a tool to develop a software CNC system. A data acquisition and display module was developed based on the original CNC system. [align=center] Figure 1 Control principle diagram of CNC system[/align] 4.2 Determine timing accuracy and acquisition time interval After testing, it was found that the timing range of the multimedia timer of the operating system of the software CNC system is 1ms-1000000ms. Since the sampling period is >=1.28ms, various position and speed curves can be accurately analyzed[5]. Therefore, the timing accuracy is set to 1ms and the acquisition time interval is set to 2ms. 4.3 Programming idea First, initialization is required: turn on the dual-port RAM, set the servo update period to 2ms, copy the data of the motor to be acquired to the dual-port RAM, and open the file to prepare to write data. When the acquisition starts, first notify PMAC to "read" the data in the dual-port RAM, and then check whether the dual-port RAM is performing a "write" operation. If no "write" operation is performed, start the multimedia timer and call the callback function to complete the data acquisition and display. After the acquisition is completed, delete the multimedia timer, turn off the dual-port RAM, and close the data save file. The program flowchart is shown in Figure 2. [align=center] Figure 2 Data Acquisition Module Program Flow[/align] The core source code of the callback function is: XAPosition=PmacDPRPosition(0,0,1000); //Acquire the actual position of the X-axis sprintf(buf1,"%10.3lf",XAPosition); //Convert the acquisition result from double type to character type ::SetDlgItemText(hWnd,IDC_EDIT1, buf1); //Display the data fprintf(fGather,"%s\n",buf1); //Write the acquired data to a file for saving... This article only gives the acquisition code for the X-axis position. If you want to acquire other data, you can call the corresponding function in the dual-port RAM. It should be noted that the motor parameter in PmacDPRPosition should be the current axis number minus 1; The unit in the PmacDPRPosition function is different from the register reading method introduced in reference [2]. If you want to use mm as the unit, the meaning of the unit here should be how many pulses the encoder sends to move the X-axis 1mm. Since the encoder moves the X-axis by 1µm for every pulse, it moves the X-axis by 1mm for every 1000 pulses. Therefore, the unit here is 1000. 4.4 Acquisition Results The acquisition interface is shown in Figure 3. [align=center] Figure 3 Acquisition Interface[/align] Below are some data acquired during the processing: 4.5 Application Result Analysis After testing, it was found that if multimedia timers and register reading methods are used for data acquisition, the system will crash when acquiring four motion parameters at an acquisition interval of 10ms and a timing accuracy of 2ms. However, by using the dual-port RAM reading method, the system still works normally when acquiring four motion parameters at an acquisition interval of 2ms and a timing accuracy of 1ms, solving the memory shortage problem. This not only improves the acquisition accuracy but also enhances security, fully leveraging the technical advantages of multimedia timers and dual-port RAM. 5 Comparison with Multi-threaded Acquisition Methods Multi-threading technology is also a commonly used method in real-time data acquisition. The Windows operating system supports multi-task scheduling and processing, allowing each process to execute multiple threads simultaneously. This means that a program can complete multiple tasks concurrently. Multithreading technology can also be combined with PMAC's dual-port RAM technology, allowing each motion parameter or axis motion parameter to be read and written separately as a thread, achieving rapid real-time acquisition and display. However, it should be noted that multithreading is a relatively difficult technology because the parallelism of concurrent threads increases the additional complexity of the code, making the writing and debugging of multithreaded applications challenging. During the acquisition process, data must be written to files for storage in each thread, and since each thread is relatively independent, accurately obtaining data "at the same moment" is extremely difficult. Moreover, when many threads are involved and functions are called frequently, fatal errors can easily occur, which is very dangerous. Multimedia timers, on the other hand, perform data acquisition, data processing, and data storage all within callback functions, enabling the acquisition of various motion parameters "at the same moment," facilitating parameter comparison, and offering good security. 6 Conclusion Applying multimedia timers and PMAC's dual-port RAM technology for data acquisition in PMAC-based systems offers high timing accuracy, short acquisition intervals, and the ability to acquire various motion parameters "at the same moment," facilitating parameter comparison, simplifying the data acquisition process, and providing good security. It is an effective method for data acquisition in PMAC-based systems. References: [1] Hou Ming, Wang Dongxing. Research on high-precision timing method of WINDOWS system [J]. Microcomputer Information (Control Integration). 2006 (3): 262-264. [2] Beijing Yuanmaoxing Control Equipment Technology Co., Ltd. PMAC User Manual [M]. 1999: 216-217. [3] DELTA TAU Data System Inc. PMAC USER'S MANUAL [M]. USA:DELTA TAU Data System Inc, 1999: 60-64. [4] Shen Yu, Ma Boyuan, Zhang Jinlou. High-speed data acquisition based on PMAC card [J]. Electromechanical Engineering Technology, 2006 (4): 96-97.
Read next

CATDOLL Dudu Soft Silicone Head

You can choose the skin tone, eye color, and wig, or upgrade to implanted hair. Soft silicone heads come with a functio...

Articles 2026-02-22
CATDOLL Diana Soft Silicone Head

CATDOLL Diana Soft Silicone Head

Articles
2026-02-22
CATDOLL 115CM Kiki TPE

CATDOLL 115CM Kiki TPE

Articles
2026-02-22