An USB-based software CNC system

An USB-based software CNC system

Journal of Materials Processing Technology 139 (2003) 286–290 An USB-based software CNC system Chengrui Zhang∗ , Heng Wang, Jingkun Wang Department o...

166KB Sizes 65 Downloads 216 Views

Journal of Materials Processing Technology 139 (2003) 286–290

An USB-based software CNC system Chengrui Zhang∗ , Heng Wang, Jingkun Wang Department of Mechanical Engineering, Shandong University, Jinan, Shandong 250061, PR China

Abstract This paper presents an open architecture software-based CNC, and analyzes the hardware and software platform of the CNC system. In the hardware structure, Universal Serial Bus (USB), as the interface and protocol of the communication, is mainly emphasized. In the software structure, the paper first discusses the operating system in the control applications, then Linux and RT-Linux are selected, and finally the functions of the CNC system begin elaborated according to the module’s hierarchy. © 2003 Published by Elsevier Science B.V. Keywords: CNC; USB; Real-time

1. Introduction Over the last decade, the CNC system has involved a gradual migration from a closed architecture and proprietary system to an open system. The recent trend in the area of open architecture control is described in detail in the report [1]. Open architecture control is a popular topic in industry with the progress and completion of several research projects, which include the following: (i) The ESPRIT III project OSACA (open system architecture for controls within automation systems) lasted from 1992 to 1996, in which almost all of the standardization matters including networking, application software as well as hardware, were considered [2]. (ii) The enhanced machine controller (EMC) is a project by National Institute of Standards and Technology (NIST), the US, to develop and validate a specification for interfaces to open architecture controllers [3]. (iii) General motors powertrain group has developed open modular architecture controllers (OMAC) for application in the automotive industry [4]. (iv) Six companies in Japan founded the working group named OSE (open system environment for controller) to define an open architecture and an interface specification of the production system and promote an international standard of FA control equipment [5]. In the academic world, a common definition about an open architecture control system still has not been reached. This ∗ Corresponding author. E-mail address: [email protected] (C. Zhang).

0924-0136/03/$ – see front matter © 2003 Published by Elsevier Science B.V. doi:10.1016/S0924-0136(03)00237-1

leaves a squirming room for a control vendor to claim their system as open. The basic features of “open” are no proprietary hardware elements, access of data in the controller and freedom to reconfigure the control system. There are several solutions for an open system with a different level of openness. PC front end: This is a traditional CNC black box with a personal computer added on, such as FANUC Series 150/160/180/210. It requires dual operating systems, such as MS Windows and proprietary NC operating system. The personal computer is exploited to improve the operators interface. Motion control card with PC: This system is configured by rigging an NC function board in a commercially available PC. The added on card, usually DSP-based, performs the time-critical NC kernel tasks and the PC is for non-real-time function. The two CPUs communicate each other by PC-bus or dual port RAM. This scheme improves the interface and offers flexibility to the machine tool builder and end user. Software-based solution: This is an ideal open system, based on vendor-neutral PC hardware and dedicated designed CNC software. It should be necessary in this solution to adopt a real-time kernel such as QNX, RT-Linux, Vxworks and VenturCOM’s RTX for Windows NT, etc. The system benefits from great flexibility and openness. At present, the solution to the open controller mostly is based on Host PC/DSP motion control card architecture [6–8]. This architecture is more flexible than a traditional proprietary NC system, but strictly speaking, it is not open, because it still contains the “special” proprietary motion control card and is just a type of proprietary technology to substitute for another.

C. Zhang et al. / Journal of Materials Processing Technology 139 (2003) 286–290

With the drastic advancement of PC hardware and software technology, the time-critical NC kernel task can be implemented by software via the support of a real-time operating system (RTOS). Cheng et al. [9] addressed real-time computing in an open system for manufacturing. The software-based CNC system is a solution to meet the real “open” requirement. The software CNC control is built on an open architecture that integrates off-the-shelf hardware and software technologies to achieve flexibility and agility. Unlike proprietary CNC or HOST/DSP open architecture controls, software-based control requires no proprietary hardware or motion control cards, combining a soft CNC and soft PLC in a single application. Software-based CNC lowers control and life-cycle costs, increases machine tool uptime and productivity, incrementally upgrades control systems with technology advances, and provides a simple and common approach to communication and networking.

2. Hardware platform In the soft CNC system, the whole system is built on off-the-shelf PC hardware. One can utilize a single processor or symmetrical multiple processors to complete all the tasks in CNC. Furthermore, one can plug an audio card and video capture card into the PC to combine multimedia technology with the CNC system. There are several kinds of fieldbus used in the CNC system such as Profibus/DP, CAN and SERCOS, etc. All the above fieldbuses need a master card plugged into the PC to communicate with the slave devices. The authors propose a USB (Universal Serial Bus) based soft CNC controller, the system structure of hardware being shown in Fig. 1. The USB is strictly hierarchical and controlled by one host. The host uses a master/slave protocol to communicate with attached USB devices, such as servo-drivers and

Fig. 1. The software-based CNC hardware configuration.

287

PLC-I/O. This means that every kind of communication is initiated by the host and devices cannot establish any direct connection to other devices. This seems to be a drawback in comparison to other bus architectures but it is not because the USB was designed as a compromise of costs and performance. The master/slave protocol solves implicitly problems like collision avoidance or distributed bus arbitration. The current implementation of the USB theoretically allows 127 devices to be connected at the same time and the communication bandwidth is limited to 12 Mbit/s [10]. Because there is no USB-interfaced motor driver commercially available, the authors designed an USB board to interface the controller and the motor driver for step motors and servomotors. The interface is implemented with 89c52 micro-controller, USBN9604 and other ICs. Normally the physical ports of the host controller are handled by a virtual root hub. This hub is simulated by the host controllers device driver and helps to unify the bus topology. So every port can be handled in the same way by the USB subsystem’s hub driver. The messages which are transmitted between host controller and devices include: (1) (2) (3) (4) (5) (6)

the commanded values of position, velocity and torque; the actual values of position, velocity and torque; the parameters of drivers and motors; the servo’s status and alarming; the selection of the servo’s mode; PLC-I/O signals.

The scheduling of these messages is ensured by the deterministic RTOS timer.

3. Software platform 3.1. The selection of the operating system The operating system plays the most important role in the soft CNC system, and RTOS is a key nucleus in control-oriented applications. CNC kernel tasks, like interpolating and servo-control, etc., need hard real-time OS to support for time-stringent response. There are several choices for RTOS such as QNX, Vxworks, LynxOs, VenturCOM’s RTX and RT-Linux, etc. The real-time control applications require RTOS to have properties of real-time determinism and low latency. Moreover, they now also routinely require access to TCP/IP, graphical display and windowing systems, file and database systems, and other services that are neither primitive nor simple. One solution is to add these non-real-time services to the basic real-time kernel, as has been done for the venerable Vxworks and, in a different way, for the QNX micro-kernel. A second solution is to modify a standard kernel to make it completely pre-emptable. This is the approach taken by the developers of RT-IX (Modcomp). RT-Linux is based on a third path in which a simple real-time executive runs

288

C. Zhang et al. / Journal of Materials Processing Technology 139 (2003) 286–290

a non-real-time kernel as its lowest priority task, using a virtual machine layer to make the standard kernel fully pre-emptable. Also, like RT-Linux, VenturCOM’s RTX technology enables Windows NT and 2000 to address the RTOS’s performance and determinism. The authors chose Linux and RT-Linux as CNC platform because of its free availability, open source code, full support to network protocol, small kernel of the system, stability and low latency of RT-Linux (maximal 15 us). 3.2. The software hierarchy and functions Although the CNC systems for various machining purposes have different requirements in function and human– machine interface (HMI), almost CNC systems are based on the similar principles and functions. The software CNC system can be divided into several fundamental modules, based on the summarizing and analysis of general CNC functions and user requirements, shown in Fig. 2. On the whole, the modules are grouped into the real-time tasks and non-real-time tasks according to the time-bounded requirement of task. 3.2.1. Real-time tasks The real-time modules require correct not only in computing results but also in time response. These modules are programmed in RT-Linux and implemented by the multi-thread technology. Every module occupies a thread, and they have different priority. When the timing of the thread is reached, the system is transferred to the corresponding interrupt handler to deal with the real-time task. The thread with higher priority will pre-emptable. The

communication between the controller and device drivers by USB is most time-critical task among the real-time ones. USB device driver programmed in Linux can be called by communication module in RT-Linux to assure the synchronous motion of axis. The main real-time modules are: (1) NC code interpreter: This module partly belongs to a real-time task. It is designed for checking syntax error and code grammar of part program, interpreting and translating part program into proper data structure and status for the sequential modules. (2) Path planning: This produces the tool path according to the part program, tool and system information. For precision verification of tool path, a calculation of surface normal machining error is essential but time consuming. (3) Trajectory planning: The trajectory planning, also called interpolator, coordinates the motion of the individual machine axes to achieve a desired spatial trajectory with required precision, including backlash compensation and pitch error compensation and the process of acceleration and deceleration. The interpolator operates at 10 ms intervals, during which the next interpolation step calculation is performed and a new position command is sent to the servo-control loops. (4) Servo-controlling: The servo-control loops operate at fixed time intervals. Each loop compares the command received from the interpolator with its position feedback, and sends the commands to the motor to drive the corresponding machine axis by USB communication. (5) Soft PLC: The programmable logic control is performed by scanning method. There are two levels of PLC programs available.

Fig. 2. Open architecture CNC software system.

C. Zhang et al. / Journal of Materials Processing Technology 139 (2003) 286–290

• Basic level: Instructions entered at this level are executed sequentially in the form of infinite loop. The duration of the PLC scan time is determined by the size and structure of the basic level program. • High speed level. Programs entered at high speed level are executed in a fixed time frame from the beginning to the end. It is the programmer’s responsibility to keep the high speed level program short enough to allow for acceptable PLC scan time. The PLC maintains following five data tables: (i) NC–PLC signals; (ii) PLC–NC signals; (iii) machine– PLC signals; (iv) PLC–machine signals; (v) PLC internal signals. (6) Device drivers: In order to ensure the deterministic and real-time communication between CNC and machine tools, the device drivers for the servo-drivers and the PLC-I/O, which are considered as the USB devices, are programmed in Linux layer. There exists a subsystem called “the USB Core” with a specific API to support USB devices and host controllers [11]. Its purpose is to abstract all hardware or device dependent parts by defining a set of data structures, macros and functions. These functions can be grouped into an upper and a lower API layer, as shown in Fig. 2. The authors concentrate on the servo- and PLC device driver layer, because the operating system has already provided host controller drivers. We developed the common interfaces for the different vendors’ servo-drivers. A C language application programming interface (API) between the soft PLC and the external world is provided so that specific hardware can be integrated into the CNC system without modifying any of the core control code. Programmers must implement these API functions for each board. 3.2.2. Non-real-time tasks The non-real-time tasks are programmed by the standard API. Their functions include user’s interface, database, network and configure system.

289

Fig. 3. HMI for automatic mode.

(3) Configuration system: When users first use the CNC system, they will configure the system with files according to their requirements. Then the CNC system will read the setup file with the same syntax as Microsoft Windows INI files to configure at the startup. The INI file contains all the machine parameters such as servo-gains, scale factors, cycle times, units, and also includes the tool information such as which pocket contains which tool, and the length and diameter for each tool. The syntax format is the following: [SECTION] ;COMMENT SYMBOL = VALUE The users can edit the values for each keyword in any text editor or the configure GUI. The changes will not take effect until the next time the controller is run.

4. Conclusions (1) GUI: The system combines the traditional CNC functions with feature of multimedia and network technology to improve the operation interface and data management. Taking advantages of X-window GUI functions, the friendly HMI is designed with the conformity style. The system provides the rich multimedia help information on the use of NC system and machine, operation instructions, online training course, fault treatment and maintenance. The HMI for automatic mode is shown in Fig. 3. (2) Database system: The manufacturing process parameters (e.g., the types of materials, the corresponding cutting parameters) and all of the multimedia help messages are stored in the database system. The end users can add, delete and modify the contents of these messages according to their demands and the style of CNC system.

This paper discusses the hardware and software architecture of soft CNC system. An integrated environment has been developed for building an open CNC system with off-the-shelf PC hardware. This CNC system utilizes the open source Linux and RT-Linux as the system platform, and makes full use of USB to communicate between the CNC system and the machine tools. It also reaches the open architecture to a certain extent.

Acknowledgements The authors would like to acknowledge the support of funding by the National Natural Science Foundation (NSFC) of China (No. 59975055).

290

C. Zhang et al. / Journal of Materials Processing Technology 139 (2003) 286–290

References [1] R. Katz, B.K. Min, Z. Pasek, Open architecture control technology trends, ERC/RMS Report No. 35, 2000. [2] W. Sperling, P. Lutz, Designing applications for an OSACA control, in: Proceedings of the International Mechanical Engineering Congress and Exposition, The ASME Winter Annual Meeting, Dalles, USA, 1997, pp. 16–21. [3] F.M. Proctor, J. Michaloski, Enhanced machine controller architecture overview, NIST Internal Report No. 5331, December 1993. [4] J. Yen, C. Bailo, Requirements of Open, Modular Architecture Controllers for Applications in the Automotive Industry (OMAC), Version 1.1, 1994.

[5] S. Fujita, OSE: open system environment for controller, in: Proceedings of the Seventh IMEC Conference, 1996, pp. 234–244. [6] Y. Altintas, W.K. Munasinghe, A hierarchical open-architecture CNC system for machine tools, CIRP Ann. 42 (1) (1994) 349–354. [7] PMAC User’s Manual, Delta Tau Data Systems, Inc., 1998. [8] Y. Koren, Z.J. Pasek, A.G. Ulsoy, U. Benchetrit, Real-time control architecture and system performance, CIRP Ann. 45 (1) (1996) 377– 380. [9] H.H. Cheng, F. Proctor, J.L. Michaloski, W.P. Shackleford, Real-time computing in open systems for manufacturing, J. Comput. Inform. Sci. Eng. 1 (2001) 1–7. [10] Universal Serial Bus Specification Compaq, Revision 1.1, Intel, Microsoft, NEC, 1998. [11] A. Rubini, Linux Device Drivers, 1st ed., 1998.