Abstract: This paper proposes the concept of an open CNC system based on IEC 61131-3 by comparing it with the traditional open CNC system concept. Then, based on a comprehensive analysis of foreign technologies, its hardware and software systems are analyzed and summarized. Finally, the development direction of open CNC systems is discussed. Keywords: Open CNC system, IEC 61131-3, OMAC, PLCopen 0 Introduction From the market situation in recent years, especially in the European market, due to the widespread application of the IEC 61131 standard, open CNC systems based on IEC 61131-3 have gradually become the mainstream of open CNC systems and are expected to become the standard for future open CNC systems. The hardware system, according to the concept of the American OMAC Packaging Workgroup (OPW), is divided into three types. It implements CNC standard functions such as motion control, interpolation calculation, and G-code control by running user software written in the IEC 61131-3 language on the software or hardware PLC, while simultaneously realizing PLC logic control functions. Given that the technological breakthrough of this open CNC system is mainly reflected in the use of IEC61131-3 language programming to realize CNC functions, it is called an open CNC system based on IEC61131-3. 1. Hardware System OPW is a working group under the OMAC Users Group in the United States, dedicated to promoting motion control solutions in the packaging machinery industry. Its "Guidelines for Automation of Packaging Machinery" established a complete concept of digital motion control systems. Based on the integration and expansion of existing hardware system architectures, OPW established the concepts of three hardware system architectures: Controller-Based System Architecture, PC-Based System Architecture, and Drive-Based System Architecture. Although OMAC is located in the United States, it receives widespread support from European control system suppliers. Many European manufacturers, such as Siemens and Schneider Electric, are members of the organization. Siemens, in particular, strictly followed the OPW concept to launch the Simotion series of motion control products, including Simotion C, Simotion P, and Simotion D, corresponding to the three OPW platforms mentioned above. 1.1 Controller Platform System [align=center] Figure 1: Logic Connection Diagram of Controller Platform System[/align] According to the OPW concept, the controller shown in Figure 1 is the core of the control system and is an independent hardware entity that can realize logic control and motion control functions. The HMI is optional; even if a PC is used as the hardware for the HMI, it can only realize the HMI software functions. Distributed I/O and drivers with digital setting interfaces are connected to the controller via fieldbus. Although OPW does not explicitly specify what kind of controller it is, the controller here is actually a PLC with extended motion control functions, mainly because: it uses a hardware clock consistent with the PLC to realize scan cycles and interrupts; its logic control and motion control functions are both implemented using the PLC standard programming language IEC61131-3. Although Siemens does not call the Simotion C motion control system a PLC, this product is actually based on the SIMATIC S7 series PLC with extended motion control functions, and can directly use the I/O templates and function templates of the SIMATIC S7 series PLC. This is even more evident in Schneider Electric's products. Their initial motion control products involved plugging motion control modules onto the Modicon Premium series PLC baseboard, directly expanding motion control functionality on a standard PLC. In practical applications, PLC hardware has two structural forms: a traditional PLC hardware system where all components are mounted on a separate rack, and a slot-type PLC hardware system that plugs into a PC motherboard. Siemens Simotion C belongs to the former, while Schneider Electric's Modicon Premium series includes the Atrium slot-type PLC, where the PLC's CPU and bus module are integrated onto a PC board, plugged into the PC's PCI bus slot, and then communicating with motion control modules and I/O modules on an external rack via the bus. Atrium slot-type PLCs operate completely independently of a PC: the standard PC's "restart" command has no effect on the slot-type PLC's operating mode; turning the PC off and on again will cause a warm restart of the program managed by the slot-type PLC, but the application content will not be lost; the 24V power supply that can be plugged into the PC slot allows the slot-type PLC to operate independently of the PC's power supply. OPW recommends two fieldbuses for connecting controllers to distributed I/O modules and drivers with digital setting interfaces: SERCOS and PROFIBUS. In practical applications, many products use other methods: other fieldbuses can be used, such as Schneider Electric's CANopen bus; for traditional PLC systems, distributed I/O can be omitted, and traditional ±10V analog signals can be used to connect to drivers with analog setting interfaces. Due to the development of IEC61131-3 language programming tools, control software has hardware independence, portability, and other open characteristics, giving emerging control system suppliers and even machine tool manufacturers the opportunity to break the market monopoly of traditional control system suppliers. In the European market, emerging control system suppliers and even machine tool manufacturers, much like PC assemblers, purchase hardware components such as chips, independently configure controller systems, and buy IEC61131-3 language programming tools and software modules from professional software companies. They can also develop their own software modules, thus breaking the monopoly of traditional control system suppliers such as Siemens. 1.2 PC Platform System [align=center] Figure 2: Logical Connection Diagram of PC Platform System[/align] According to the OPW concept, the PC shown in Figure 2 is the core of the control system. By running HMI (optional), logic control, motion control and other functional software, it can realize HMI, logic control and motion control functions. The HMI hardware is optional and is generally a PC monitor. Distributed I/O modules and drivers with digital setting interfaces are connected to the PC through a fieldbus. The PC communicates with the distributed I/O and drivers with digital setting interfaces on the machine tool through a bus card inserted into the PC slot. To realize I/O and other control functions on the PC platform, the PLC hardware must first be simulated in the PC using IEC61131-3 language programming tools, that is, various control functions are implemented in the form of a software PLC. The PC platform system architecture is the most open hardware platform because the application software runs on MS Windows operating systems and general-purpose industrial PCs with extended real-time performance. Control system providers only need to focus on developing control software such as development tools and software modules. The competitiveness of PC platform system products mainly comes from software, which gives emerging small professional software companies the opportunity to break the market monopoly of traditional control system suppliers. This is also the advantage of open control systems. 1.3 Drive Platform System According to the OPW concept, the core of the control system is the multiple sets of drives that integrate logic control and motion control software and hardware functions, as shown in Figure 3. In addition to the drive's own axis control function, it can realize logic control and motion control functions; HMI software and hardware and independent PLC are optional; distributed I/O modules are connected to the drives through fieldbus. [align=center] Figure 3: Logic Connection Diagram of Drive Platform System Structure[/align] This is a distributed motion control system. The drive is actually an intelligent drive that integrates a compact controller and can independently complete logic control and motion control functions. According to the information currently available, there is only one drive platform motion control product on the market: Siemens Simotion D. 2. Software System The openness of the IEC61131-3-based open CNC system is mainly reflected in its software. The software system can be divided into system software and application software. System software includes real-time operating systems, communication systems, device drivers, etc. Application software includes development tools, user programs, etc. 2.1 System Software The real-time performance of the operating system is a prominent issue for PC platform systems because the MS Windows series of general-purpose operating systems running on PCs were originally designed for commercial applications, not industrial real-time control. Control system suppliers such as Siemens have tested the real-time characteristics of Windows, confirming that it suffers from problems such as "crashes" and interrupt delays, and does not possess hard real-time characteristics. Controller platform and driver platform systems do not require the operating system necessary for PCs; instead, they strictly follow the hardware clock to call instructions in a loop, thus eliminating the real-time performance issue of the operating system. Currently, the most widely used method to solve the real-time performance problem of the operating system is to extend the real-time capabilities of Windows. Ardence (formerly VenturCom)'s RTX (Real-time Extension for Windows) is a real-time operating system built into Windows. When the RTX thread runs, Windows interrupts are masked, but Windows cannot mask interrupts managed by RTX. Windows becomes an RTX-managed task with the lowest priority. RTX guarantees a worst-case response time of 50µs for any thread. The German company 3S (Smart Software Solution) uses CoDeSys SP RTE (Real Time Extension), also a real-time operating system built into Windows. It is periodically invoked by the hardware clock on the PC motherboard, and then the RTE generates two hardware interrupts every millisecond: one for executing the CoDeSys task and the other for executing the Windows task. One millisecond is the default clock cycle, which can be changed, with a minimum of 50µs. The time ratio for the two interrupts can also be set. In other words, the RTE uses a clock cycle in a time-sharing manner for the CoDeSys task and the Windows task, without interference. Currently, the interpolation cycle of general CNC systems is typically 1ms or less. Both of these Windows real-time extensions guarantee the real-time characteristics of Windows when applied to CNC systems. 2.2 Application Software Application software includes development tools and user programs. In a PC platform system, the PC can run both development tools and user programs. The controller platform and driver platform systems themselves can run user programs and can be connected to a separate PC to run development tools. 2.2.1 Development Tools With the promotion of the IEC 61131 standard, many development tools conforming to this standard have emerged, such as CoDeSyS from 3S and OpenPCS from Infoteam. IEC 61131 is an international PLC standard issued by the International Electrotechnical Commission, specifying two main categories of programming languages: text-based programming languages and graphical programming languages. The former includes Instruction Listing Language (IL) and Structured Text Language (ST), while the latter includes Ladder Diagram Language (LD), Function Block Diagram Language (FBD), and Sequential Function Chart (SFC). These languages were initially used for writing PLC logic control programs, but thanks to the efforts of the PLCopen international organization and specialized software companies, they can also be used to write motion control and interpolation calculation programs. The IEC 61131 programming language is an industrial control programming language. Compared with high-level programming languages such as C, it is similar in data structure, program structure, and instructions (mainly referring to ST language), but it is significantly simplified and easier for automation engineers to master. This allows users to write their own motion control and interpolation calculation programs and define their own CNC code, thus possessing a high degree of openness. Because it adopts the international standard language IEC 61131-3, which is adapted to the requirements of automatic control, open CNC systems based on IEC 61131-3 have a high degree of openness and strong vitality. 2.2.2 User Programs User programs refer to PLC programs written in the IEC 61131-3 language that implement logic control, motion control, and interpolation calculation functions. They can interpret and execute CNC machining programs written in G-code. For structured user programs, the most important element is the software module. Due to the openness of the IEC 61131-3-based control system, the software module can be written by the control system supplier or by the user, and its use is open to the user. For open systems, the requirements of interchangeability, portability, and hardware independence are primarily reflected in the interchangeability, portability, and hardware independence of software modules, thus creating a need for software module standardization. The PLCopen international organization is dedicated to promoting the application of the IEC 61131-3 language. Its members include major global control system suppliers, such as Siemens, Schneider Electric, 3S, and Infoteam mentioned above. As an international organization, PLCopen, along with its members Siemens and Schneider Electric, is also a member of the American Organization for Automation (OMAC), playing a crucial role in developing the "Guidelines for Automation of Packaging Machinery." In fact, because PLCopen focuses on promoting the IEC 61131-3 language, primarily emphasizing software aspects, its ideas regarding hardware platforms and mechanical structures are reflected in the OPW's "Guidelines for Automation of Packaging Machinery." The PLCopen international organization has developed a complete set of standard motion control function blocks in its technical specification, "Motion Control Function Blocks." To achieve standardization, PLCopen defines seven machine tool states. The machine tool's motion axes are always in one of these defined states. Motion commands cause the axes to transition between these states, and motion commands for a single axis are always executed sequentially. The specific states, state transitions, and function block definitions are shown in Figure 4. The seven states defined by PLCopen are: 1) Stand still; 2) Homing; 3) Discrete motion; 4) Continuous motion; 5) Synchronized motion (which involves multi-axis motion); 6) Stopping; 7) Error stop. Among these, 3), 4), and 5) are motion states. [align=center] Figure 4: Function Block State Behavior Note: This figure shows the definitions in PLCopen's technical specification "Motion Control Function Blocks" Version 1.0. The transitions between states define the functions of the function blocks. There are 10 single-axis motion control function blocks, such as MC_MoveAbsolute; 5 multi-axis motion control function blocks, such as CamIn; and 10 information transmission function blocks, such as MC_ReadStatus. By calling these 25 limited function modules for programming, the motion control of the machine tool can be achieved. Machine tool manufacturers can purchase development tools and motion control function blocks from professional software companies such as 3S and Infoteam, choose a control system hardware platform, and write PLC programs according to the working principle of the equipment. They can define G-code and write code programs themselves, and implement CNC control by calling the code program using multiple selection statements CASE...OF... This is common in the European machine tool industry. PLCopen has a dedicated section for interpolation calculations in its technical specification "Motion Control Function Blocks," but this section is still under construction and no standard documents have been published to date. In addition, PLCopen has not introduced G-code into its technical specifications; if G-code control is required, users still need to define and write it themselves. However, some members of PLCopen, such as the German companies 3S and Beckhoff, have made progress in implementing interpolation calculations and standard G-code control using the IEC 61131-3 language and have launched corresponding products. This article briefly introduces CoDeSys Version 2.3.7.2 from the German company 3S (Smart Software Solution). CoDeSys has an optional component, Softmotion, for implementing standard G-code control. Except for drivers for hardware such as buses and drives, all components are programmed in the IEC 61131-3 language, suitable for PC platform system architectures. Currently, it can achieve 9-axis control, including the spindle, with two axes used for non-linear interpolation and the others for linear interpolation. G-code programs can be written in both graphical and text formats in the CNC program editor, and the programming language follows the DIN 66025 standard. To achieve standard CNC code control, multiple functional modules are required, among which the interpolation module, conversion module, and direct setpoint input module are crucial for understanding the implementation process of CNC code control. The interpolation module processes the G-code program, transforming the continuous trajectory described by the G-code into discrete path position points. Then, the conversion module decomposes these position points into coordinate points on each axis. Finally, the direct setpoint input module controls the driver of each axis to achieve the target trajectory. There are two interpolation modules: SMC_Interpolator and SMC_Interpolator2D. The latter can perform interpolation operations in both forward and reverse directions; the two have the same function. Currently, there are six conversion modules, classified according to machine tool kinematics principles: Portal Systems, Portal Systems with Tool Offset, H-Portal Systems with Stationary Drives, 2-Jointed Scara-Systems, 3-Jointed Scara-Systems, and Parallel Kinematics. Each type is further divided into forward and reverse conversion modules. The direct setpoint input module communicates with the driver program provided by the driver manufacturer to control the driver. Based on different control principles, it can be divided into three types: position control, speed control, and torque control. 3. Conclusion In summary, because the open CNC system based on IEC61131-3 adopts the PLC standard programming language IEC61131-3, it has a high degree of openness, especially in terms of hardware systems and motion control function blocks, making its application prospects bright. However, in terms of interpolation calculation, no standard has yet been formed, which will be a problem to be solved in future development. China's CNC industry can learn from the experience of foreign counterparts in developing new products. The development direction of open CNC systems lies in software. Currently, it is possible to start with the controller platform, purchasing hardware such as chips to configure the controller, using development tools provided by specialized software companies; then, based on these development tools, secondary development can be carried out, ultimately developing its own open CNC system development tools based on IEC61131-3. In fact, some well-known foreign control system suppliers are doing this. For example, Schneider Electric's latest motion control product, Lexium PAC, launched in 2007, has a hardware structure based on a controller platform and uses 3S's CoDeSys as its development tool. Siemens' Simotion series of motion products uses Scout, a development tool that is a secondary development based on Infoteam's OpenPCS. References: [1] OMAC. Guidelines for Packaging Machinery Automation, Version 3.1 [M], 2006. "Used with permission of the OMAC Packaging Workgroup; www.omac.org". [2] PLCopen. Technical Specification PLCopen-Technical Committee 2-Task Force Function blocks for motion control, Version 1.0 [M], 2001. [3] Siemes AG. Simotion Motion Control System Catalog PM10. 2005 [M], 2005. [4] 3S-Smart Software Solutions GmbH. Softmotion in CoDeSys 2.3 User Manual, Version 2.8 [M], 2006. [5] Schneider Electric. Modicon Premium Automation Platform and Unity Software Catalog [M], 2005. [6] Li Xia, Wang Yongzhang, Zheng Jiaxin, Liang Hongbin. Research and Implementation of Key Technologies for Open Soft CNC System [J]. Modular Machine Tools & Automated Machining Technology, No. 10, 2003.