Mechatronics, Electrical Power, and Vehicular Technology 05 (2014) 37-44 Mechatronics, Electrical Power, and Vehicular Technology e-ISSN:2088-6985 p-ISSN: 2087-3379 Accreditation Number: 432/Akred-LIPI/P2MI-LIPI/04/2012 www.mevjournal.com © 2014 RCEPM - LIPI All rights reserved doi: 10.14203/j.mev.2014.v5.37-44 DISTRIBUTED CONTROL SYSTEM DESIGN FOR PORTABLE PC BASED CNC MACHINE Roni Permana Saputra a,b, *, Tinton Dwi Atmaja a , Budi Prawara a a Research Centre for Electrical Power and Mechatronics, Indonesian Institute of Sciences Komp LIPI Jl. Sangkuriang, Gd. 20, Lt 2, Bandung, West Java, 40135 Indonesia b School of Mechanical and Manufacturing Engineering, The University of New South Wales Library Rd, Kensington NSW 2033 Australia Received 28 March 2013; received in revised form 05 June 2014; accepted 06 June 2014 Published online 23 July 2014 Abstract The demand on automated machining has been increased and emerges improvement research to achieve many goals such as portability, low cost manufacturability, interoperability, and simplicity in machine usage. These improvements are conducted without ignoring the performance analysis and usability evaluation. This research has designed a distributed control system in purpose to control a portable CNC machine. The design consists of main processing unit, secondary processing unit, motor control, and motor driver. A preliminary simulation has been conducted for performance analysis including linear accuracy and circular accuracy. The results achieved in the simulation provide linear accuracy up to 2 μm with total cost for the whole processing unit is up to 5 million IDR. Keywords: distributed control, portable CNC machine, linear interpolation, circular interpolation. I. INTRODUCTION Recently, the demand on automated machining has increased remarkably in the industrial world. At present decade, some fields such as the electronic, automotive, and medical have incorporated applications requiring microproducts [1]. This research purpose is to solve this current status based on other current research which focused on research and development of micro-machines and low cost PC based CNC system. Research and development of micro- machines for different applications is widely available, mainly at academic and experimental level [2]. A general discussion on micro- machining with emphasis in the selection of the cutting parameters and the vibrations can be found. It is emphasized that for micro-turning, diamond tools, as well as micro-tools shaped through the focused ion beam (FIB) sputtering technique are the usual choice, thus achieving results ranging from 15 to 100 microns and edge radii of 40 nanometers. In [2] we can find the development of a CNC micro-lathe for bone micro implants. Micro turning with the CNC micro-lathe has been proved as a method for the fabrication of bone micro implants with controlled geometries. Other research on CNC System was conducted by Yamanaka et al. [3], Weidong et al. [4], Atmaja et al. [5], [6], and Permana et al. [7]. Research in the PC-based CNC is so much. In James et al [8], the authors developed PC-based low-cost CNC automation of plasma profile cutting of pipe. They developed CNC pipe profile cutting machine which has the capability of producing high precision parts by simultaneous control of only two axes. In Surya et al. [9], a discussion on PC-based open architecture servo controller for CNC machining can be found. This system is modular with greater flexibility with the choice of its components. In Zhiming et al. [10], it can be found the development of PC- based adaptive CNC control system. The new concept of integrating CNC control systems with adaptive feedback control for intelligent material processing has been explored. In Onwubolu et al. * Corresponding Author. Tel: +62-22-2503055 E-mail: permana.saputra@yahoo.co.id http://dx.doi.org/10.14203/j.mev.2014.v5.37-44 R. P. Saputra et al. / Mechatronics, Electrical Power, and Vehicular Technology 05 (2014) 37-44 38 [11], development of a PC-based computer numerical control drilling machine can be found. On the other hand, distributed architecture development for control system started to emerge many advantages e.g. open architecture, dynamic ability, fast mobility, and high flexibility. Moreover, distributed system provides simplicity on the extension and configuration by adding and removing certain module [12]. The distributed system contains of structured devices having respective function which can exchange their function with each other. One of the important advantages on this distributed system is that the exchange method between structured devices is done via communication appliance [13]. The examples of popular distributed control system implementation are on the complex manufacturing production control and the centralized factory control system [14]. II. METHODS Methodology used in this research involved three steps. Firstly, literature studies concerning CNC machine. Secondly, machine elements selection and integration to realize a portable CNC machine having a distributed control system. Thirdly is development of control algorithm through computer simulation. The CNC machine is controlled by an operator by means of a portable computer using designated user interface. In order to disseminate the resulted technology to small and medium enterprises, special consideration has been put to emerge a low cost system. The CNC machine has two axis motors and one spindle motor. It is equipped with one working table for holding the work piece. Stepper motors of the type of 4-phase unipolar were used for axis motors. The maximum rotation speed attainable is 300 rpm and the detent torque is 3.5 nm. The displacement of the XY table is produced by a helical rack and pinion mechanism in each axis. Thus the rotational motion applied to the pinion by a reduction system and the stepper motor will cause the rack to move to the side, up to the limit of its travel. The pitch diameter in these pinions varies depending on the axis, for the X-axis the pitch diameter of the pinion is 13.5 mm and for the Y-axis is 6.5 mm. For the purpose of this research the displacement resolution per step was 1μm in each axis. This research focuses on design and analyzing of a control system for portable CNC machine based on PC using distributed control method. III. DISTRIBUTED CONTROL SYSTEM DESIGN The distributed control system block diagram proposed in this research is shown in Figure 1. It consists of a primary processing unit, secondary processing unit, motor controllers, motor drivers and feedback sensors. Secondary Processing Unit / Supervisory Control Unit Using Microcontroller Motor Control Unit (Speed & Position Control) Motor Control Unit (Speed & Position Control) Motor Control Unit (Speed & Position Control) Driver Motor Unit Driver Motor Unit Driver Motor Unit Motor Actuator 1 Motor Actuator 2 Motor Actuator 3 S e ri a l C o m m u n ic a ti o n Using USB to Serial Device Portable Computer for User Interface and Main Processing Unit Feed Back Sensor Feed Back Sensor Feed Back Sensor F e e d B a c k S ig n a l F e e d B a c k S ig n a l F e e d B a c k S ig n a l Figure 1. Distributed control system design R.P. Saputra et al. / Mechatronics, Electrical Power, and Vehicular Technology 05 (2014) 37-44 39 The primary processing unit was designed to receive, process, and interpret the input geometry data. The input was given to the software in the form of machine G-code according to the ISO841 standard. In this research, not all functionalities of the G-code were used, and only the very basic features were implemented. Interpolation was processed in a software application, which receives the geometric information input in the form of machine G-code and then converts it into 8-bit words that will be interpreted by the microcontroller. These words contain information such as motor to be actuated, sense of motion, or stepping sequence. The secondary processing unit was designed to facilitate the microprocessor embedded to the system. For the purpose of this research, motion control of the machine tool was done following a CNC-like approach. Therefore, the use of a microcontroller unit was required to interpret the software output and convert it into registries that will actuate the stepper motors. The basic functions of the microcontroller in this project can be summarized as receive input data, write random access memory (RAM), read RAM, interpret instruction and actuate motors. A. Main Processing Unit The overall of the main processing unit is in the form of a portable computer. It is used to facilitate portability of the control module and simplify the dimension of the control system. This unit processes the data inputted by the operator via the designated user interface. Input data is in the form of G-Code and M-Code including a value data representing the geometric coordinate for the end effectors geometric movement. Mainly, there are two kinds of geometric movement i.e. linear and circular movement. Coordinate calculation for linear trajectory is called linear interpolation while the coordinate calculation for circular trajectory is called circular interpolation. Article [7] shows the calculation method for linear interpolation and circular interpolation. This paper proposes a design of main processing unit algorithm which consists of a distributed control system algorithm and a user interface for the operator whose flowcharts are shown in Figure 2 and Figure 3, respectively. B. Secondary Processing Unit This unit is the second part of the distributed control system. It translates the geometrical data sent from the main processing unit into control algorithm producing control signal for the mechanical servo. This unit consists of supervisory control module and motor control module. The supervisory control module is to process the reference data from the main processing unit and to produce reference data for each motor control module. The motor control module is to control each motor actuator over servo mechanism. 1. Supervisory Control Module The supervisory control module in this system was designed to communicate with the main processing unit using serial communication port. It reads reference data sent by the computer. The received data is in the form of velocity data and position data for all motor actuators. The data Begin Input G-Code Data by Operator Save Data In Acumulator Read 1 Row Data from Accumulator Interpretation Data : 1. Function (G-Code / M-Code) 2. Value (geometrical value) Linear Interpolation Circular Interpolation Other Functions Send Data to Secondary Processing Unit (Start/Stop; Run/Brake; ω 1-n; θ 1-n) End Figure 2. Flowchart of the software for the main processing unit Figure 3. User interface design for the main processing unit R. P. Saputra et al. / Mechatronics, Electrical Power, and Vehicular Technology 05 (2014) 37-44 40 is then distributed to all control motor sequentially from control motor 1 until control motor n. This data will be used as the main reference by unit control motor. This unit contains software and hardware. The hardware usually microcontroller system equipped with embedded software. Microcontroller ATMega128 was used because it has many I/O port so it can distribute many data to many control unit module [15]. I/O port in this microcontroller system is divided into several parts i.e. port common speed data reference, common position data reference, header control identifier, verification data identifier, external data input unit, and external control unit. Figure 4 shows the system schematic of ATMega128 as the supervisory control module. To execute its function, it was equipped with embedded software using flowchart shown in Figure 5. 2. Motor Controller Module The motor controller module in this system serves as the motor actuator movement controller either for the axis motor actuator or for the spindle motor actuator. This unit controls velocity and angle of motor rotation. This unit consists of hardware in the form of a microcontroller chip with embedded software. This system use ATMega16 as the main component of the module. ATMega16 microcontroller module was selected because it has 32 I/O ports with the process speed up to 1 µs per working cycle [16]. Moreover, economical aspect and availability in the domestic market are included in the main consideration [17]. I/O port in this module was divided into several parts i.e. position data reference, speed data reference, SPV communication, motor control digital signal, and feedback control signal. Figure 6 shows schematic system design of the motor control module. As in the supervisory control module, the motor control module has also been equipped with embedded software. This module receives data distribution from the supervisory control module in the form of velocity reference and position reference. After receiving the data, this module will send back a feedback signal to the supervisory control module. The received data will be used as the reference on controlling the motor actuator. This module produces digital Figure 4. System schematic of the supervisory control module using ATMega128 Begin Read Refference Data from Supervisory Control Unit (ω 1~n ; θ 1~n) Transmit Data to Motor Control Unit 1 - n Save Actual Data in Accumulator Yes No Has data transmit from main processing unit? Innitial Data End Figure 5. Flowchart of the software for the secondary processing unit R.P. Saputra et al. / Mechatronics, Electrical Power, and Vehicular Technology 05 (2014) 37-44 41 signal to the motor driver to drive the motor to designated trajectory with designated velocity according to the received reference. Furthermore, this module observes the actual condition corresponds to the feedback signal from the sensor. The received feedback signal will be compensated back to the calculation of the motor control module. Flowchart of the software for the motor controller module is shown in Figure 7. C. Servo Mechanism Unit The servo mechanism unit is the physical part of the CNC machine which actuates all the orders received from the control system and also generates the status of the machine [7]. This part consists of motor actuator with motor driver and feedback sensor giving the actual information of position and velocity of the end effectors. The designated motor actuator can be DC motor, stepper motor, brushless DC motor, AC motor, etc. This motor must be equipped with a driver unit suitable with the motor type. Figure 8 shows the example of the motor driver actuator equipped with a driver [18]. Feedback sensor used in this system was a rotary encoder which acts as position and velocity sensor. Rotary encoder was used to measure rotary position. The number of the pulse sent by the rotary encoder can be counted as the number of the steps taken by the motor actuator so the position and the direction can be controlled. Figure 9 shows incremental type and absolute type of rotary encoder which can be used as feedback sensor [19] [20]. IV. RESULT AND DISCUSSION The technical prototype of this distributed control system is shown in Figure 10. Figure 10(a) shows user interface used in main processing unit while Figure 10(b) shows the secondary processing unit and Figure 10(c) shows complete integrated prototype of the distributed control system on CNC lathe machine. Figure 6. System schematic design of the motor control module using ATMega16 microcontroller Begin Read Refference Data from Supervisory Control Unit (ω ; θ) Refference = Actual Read Actual Data from Feedback Sensor Send Signal to Driver Unit to Running Motor Actuator Save Actual Data in Accumulator Save Actual Data in Accumulator End Yes No Figure 7. Flowchart of the software for the motor controller module Figure 8. Motor driver actuator Figure 9. Incremental type and absolute type of rotary encoder [19] [20] R. P. Saputra et al. / Mechatronics, Electrical Power, and Vehicular Technology 05 (2014) 37-44 42 Some preliminary tests were conducted to observe the performance of each component of the designated distributed control system, including main processing unit, secondary processing unit and the communication between each other. The testing was done by inputting one G-Code instruction set to the user interface in main processing unit and then generate numerical path for the instruction set. The testing analysis consists of three interpolation processes. First is performance calculation for linear interpolation, second is calculation for circular interpolation using G-02 instruction with clockwise characteristic, and the third is calculation for circular interpolation using G-03 instruction with counterclockwise characteristic. Further calculation will consider the combination of them. The interpolation result from the main processing unit was then simulated using numerical programming software to generate the actual curve and the planned curve. This simulation was performed on 1 μm movement resolution for X Axis and Y axis. Figure 11 shows the simulation of linear interpolation from the main processing unit which was designed using quasi continuous movement with the calculation explained in [7].The set instruction for Figure 11 was: G01 X0000 Y0000 G01 X1000 Y2000 where the unit is at μm. The same method was used for circular interpolation simulation shown in Figure 12 at clockwise direction and Figure 13 at counterclockwise direction. The set instruction (a) (b) (c) Figure 10. Processing unit as the control system of the prototype; (a) main processing unit; (b) secondary processing unit; (c) complete prototype of the distributed control system on CNC lathe machine (a) (b) Figure 11. Simulation of G-Code interpretation process by the main processing unit for linear interpolation; (a) simulation result on 100 μm scale (0.1 mm); (b) simulation result on 2 μm scale (a) (b) Figure 12. Simulation of G-Code interpretation process by the main processing unit for counterclockwise circular interpolation; (a) simulation result on 100 μm scale (0.1 mm); (b) simulation result on 2 μm scale 0 500 1000 1500 2000 2500 0 200 400 600 800 1000 1200 Y -A x is ( μ m ) X-Axis (μm) Result Planning 0 5 10 15 20 25 30 35 40 45 0 5 10 15 20 Y -A x is ( μ m ) X-Axis (μm) Result Planning 0 100 200 300 400 500 600 0 100 200 300 400 500 600 Y -A x is ( μ m ) X-Axis (μm) Result Planning 0 2 4 6 8 10 12 0 20 40 60 80 100 Y -A x is ( μ m ) X-Axis (μm) Result Planning R.P. Saputra et al. / Mechatronics, Electrical Power, and Vehicular Technology 05 (2014) 37-44 43 for counterclockwise circular interpolation shown in Figure 12 was: G00 X000 Y000 G02 X500 Y500 I000 J500 While the set instruction for clockwise circular interpolation shown in Figure 13 was: G00 X000 Y000 G03 X500 Y500 I500 J000 From the description from Figure 11 to Figure 13, it can be seen that the algorithm designed for the main processing unit can perform the task as per requested. Figure 11(a), 12(a), and 13(a) show that on 0.1 mm scale, the resulted interpolation path looks smooth and coincides with the planned path. Figure 11(b), 12(b), and 13(b) show the actual interpolation path compared to the planned Pathon reduced scale up to 2 μm. It is proved that this design has advantages from its technical aspect. While on the economical aspect, the software can be self- developed and the only cost emerged is on the portable PC as the main processing unit and the electronic hardware for secondary processing unit. Table 1 shows the price list and the availability of the processing unit for two axes. It shows that the hardware cost is low and the availability is high even in domestic market. Overall, the cost of the whole processing system is approximately 5 million IDR. V. CONCLUSIONS According to these research results, it could be concluded that the designed distributed control system is applicable on the PC Based CNC Machine and can be considered as a low cost system. Distributed control system enables high flexibility and openness to adapt with more complex developed system. The system can vary the number of the axis by just simply installing the additional unit motor controller, driver, motor actuator, and sensor feedback corresponds to the number of the axis. In this paper, the case shows a distributed system for two axes CNC Machine. This proposed system also presents advantages in economical aspect. The economic analysis shows that this design is considered low cost and its component has a high availability in domestic market. Further economic analysis should consider the mechanical unit on CNC machine whether it was lathe, milling, etc. Further research is needed to improve the accuracy in more precision mechanism such as in nano scale. ACKNOWLEDGEMENT The authors would like to thank Indonesia TORAY Science Foundation (ITSF) for the Research Grant and to Research Centre for Electrical Power and Mechatronics (LIPI) for the support and the devices on the completion of this portable CNC research. The authors would also like to all parties correspond to the completion of this research. (a) (b) Figure 13. Simulation of G-Code interpretation process by the main processing unit for clockwise circular interpolation; (a) simulation result on 100 μm scale (0.1 mm); (b) simulation result on 2 μm scale Table 1. Component price list and availability Component Price Availability 1 Main Processing Hardware (PC) 3.000.000 IDR Available in domestic market 2 Main Processing Software N/A Can be self-developed 3 Secondary Processing Hardware 2.000.000 IDR Available in domestic market 4 Secondary Processing Software N/A Can be self-developed 0 100 200 300 400 500 600 0 100 200 300 400 500 600 Y -A x is ( μ m ) X-Axis (μm) Result Planning 0 20 40 60 80 100 120 0 2 4 6 8 10 12 Y -A x is ( μ m ) X-Axis (μm) Result Planning R. P. Saputra et al. / Mechatronics, Electrical Power, and Vehicular Technology 05 (2014) 37-44 44 REFERENCES [1] T. Masuzawa, "State of the Art of Micromachining," Annals of the ClRP, vol. 49, no. 2, pp. 473-488, 2000. [2] D. A.. Rangel, et al., "Development of a CNC Micro-lathe for Bone Microimplants," Escuela de Ingeniería de Antioquia, no. 15, pp. 113-127, Juli 2011. [3] M. Yamanaka; et al. , "Evaluation of Size Effect on Micro-machine-tools Design for Microfactory," in Proceedings of the 35th International MATADOR Conference, London: Springer, 2007, pp. 301-304. [4] W. D. Yang and J. Chang, "An Open CNC System Based on Motion Controller," Applied Mechanics and Materials, vol. 44 - 47, pp. 956-959, December 2010. [5] T.D. Atmaja and A. Muharam, "Open Source Software Implementation at Three Axis Table Control Algorithm for Three Dimensional Scanner Mechanism," in Proceeding of National Seminar of Open Source Software III, Bandung, November 2009, pp. B31-B36. [6] D.G. Subagio and T.D. Atmaja, "The Use of Open Source Software for Open Architecture System on CNC Milling Machine ," Journal of Mechatronics, Electrical Power and Vehicular Technology, vol. 2, no. 2, pp. 105-112, December 2011. [7] R. P. Saputra, et al., "Desain dan Implementasi Sistem Kendali CNC Router Menggunakan PC untuk Flame Cutting Machine," Journal of Mechatronics, Electrical Power and Vehicular Technology, vol. 2, no. 1, pp. 41-50, July 2011. [8] N. James, et al. , "PC-based low-cost CNC Automation of Plasma Profile Cutting of Pipes," ARPN Journal of Engineering and Applied Sciences, vol. 2, no. 5, 2007. [9] S. Kommareddy, et al., PC-Based Oper Architecture Servo Controllers for CNC Machining. [10] G. Zhiming, "Development of PC-based Adaptive CNC Control System," Automated Material Processing Group, Automation Technology Division, SIMTech Technical Report (AT/01/043/AMP) 2001. [11] G. C. Onwubolu, "Development of a PC- based Computer Numerical Control Drilling Machine," Journal of Engineering Manufacture , vol. 21, no. 6, p. 1509, 2002. [12] A. A. Loukianov, et al., "Implementing Distributed Control System for Intelligent Mobile Robot," in the 8th International Symposium on Artificial Life and Robotics, Oita, Japan, January 2003, pp. 24–26. [13] L. Cauffriez, et al., "Design of Intelligent Distributed Control Systems: A Dependability Point Of View," Reliability Engineering and System Safety, vol. 84, pp. 19-32, 2004. [14] D. Trentesaux, "Distributed Control of Production Systems," Engineering Applications of Artificial Intelligence , vol. 22, pp. 971–978, (2009). [15] Atmel, "8-bit Microcontroller with 128K Bytes In-System Programmable Flash (ATMega128/128L)," Atmel, Datasheet Rev. 2467X–AVR–06/11, 2011. [16] Atmel, "8-bit Microcontroller with 16K Bytes In-System Programmable Flash (ATMega16/16L)," Atmel, Datasheet Rev. 2466T–AVR–07/10, 2010. [17] Digi-Ware. (2013, Feb.) DigiWare Unlimited Innovations. [Online]. http://digi- ware.com [18] Oriental Motor. (2013, Feb.) Oriental Motor Website. [Online]. http://catalog.orientalmotor.com [19] Alibaba Corp. (2013, Feb.) Alibaba Website. [Online]. maxwelleletric.en.alibaba.com [20] AMCI Corp. (2013, Feb.) AMCI Advanced Micro Controls Inc. [Online]. http://amci.com/rotary-encoders/nr25- profibus-dp-absolute-multi-turn-rotary- encoder.asp [21] Atmel. (2010, July) Atmel Website. [Online]. http://www.atmel.com