PC_based_CNC_machine_control_system
PC_based_CNC_machine_control_system
1. Introduction
Fig. 1. Block schematic of the CNC control system
CNC machine control systems can be divided into closed
systems dedicated to particular machine types and open systems The CNC controller is a typical desktop PC with Intel Core i3
which are often based on industrial PC’s (IPC) with CNC control dual-core processor. Most kinds of modern PC’s can be used but
software [1]. Open PC-based automation control systems can be those with Intel Core i3, i5 or i7 series multi-core processors with
easily adapted to machines of different configurations. These SSD hard-drives achieve by far the best performance. As
kinds of systems are becoming increasingly more popular among a standard, the LinuxCNC software can control up to 9
machine manufacturers. numerically controlled Cartesian axes. If necessary, the number of
Different kinds of communication interfaces between the physically controlled joints (individual motors) can be much larger
controller and servodrives are used. Often these are simple stepper by using custom components and non-trivial kinematic
drive digital interfaces (CLK/DIR/EN). Most advanced IPC based transformations. The number of controlled I/O devices can be very
systems utilize some form of Industrial Ethernet to interface large, even in the hundreds. In most CNC applications, all slave
servodrives and I/O devices. One popular solution is Beckhoff devices (drives, I/O’s, VFD’s) are handled by a single Ethernet
Automation TwinCAT CNC using EtherCAT [2] variant of frame with EtherCAT datagrams for each device embedded in the
Industrial Ethernet. EtherCAT is defined by IEC 61158 norm. frame’s payload. The number of handled devices is limited by the
EtherCAT datagrams are encapsulated in standard Ethernet frames EtherCAT communication cycle imposed by the controller and the
(IEEE 802.3). Because of this standard Ethernet cables can be payload size of the Ethernet frame (around 1500 bytes). In the
used to connect servodrives and I/O modules to the PC using presented control system, the PC controller communicates with 4
a standard network interface card (NIC). The application layer servo drives and an I/O module cyclically every 1 ms. Devices
uses the CANOpen [3] protocol with different device profiles from different manufacturers can be used provided they support
depending on the devices used. EtherCAT is an excellent protocol EtherCAT communication conformant with the CANOpen
for real-time control of servodrives. Communication with each application layer protocol. The presented system uses Delta
drive and I/O device is handled by a single Ethernet frame Electronics ASD-A2-E servodrives and Beckhoff Automation I/O
cyclically transmitted by the master with data updated on the fly modules.
by each slave. There are many drives on the market that support
CANOpen EtherCAT communication. 3. CNC control software
One solution for numerical control systems is LinuxCNC [4]
implemented on a IPC with a real-time operating system and LinuxCNC control software is implemented on the PC-based
EtherCAT communication bus. This solution has large capabilities CNC master controller. The software operates under LinuxRTAI
for controlling machines of different configurations. Using open (Real-Time Application Interface) real-time operating system [5],
control systems based on IPC’s and EtherCAT is an excellent which enables deterministic execution of time-critical tasks. These
alternative to closed systems due to low cost and large are mainly motion control and real-time communication via
programming capabilities. EtherCAT. LinuxRTAI is based on a patched version of the
standard Linux kernel using the microkernel approach. The real-
2. Control system architecture time microkernel handles all real-time tasks and has full control
over hardware interrupts. Since CNC control requires periodic
The prestented control system consists of a PC computer (with execution of the motion control algorithms and communication,
real-time Linux, LinuxCNC control software and EtherCAT rate monotonic priority scheduling approach is used for the real-
communication stack implemented), servodrives, auxiliary devices time tasks. Priorities are assigned based on task execution period
such as I/O modules or variable feed drives for spindle control. All with the shortest period task having highest priority. Task
components of the control systems communicate with each other priorities are static which means that the higher priority task
using EtherCAT bus with CANOpen application layer. Figure 1 always preempts lower priority task and priorities cannot be
presents the block schematic of the control system. changed while the tasks are running. All non-real time tasks of the
standard Linux kernel have priorities lower than real-time tasks
16 Measurement Automation Monitoring, Jan. 2017, no. 01, vol. 63, ISSN 2450-2855
which effectively makes them run in background when real-time CIA401 standard. Other custom real-time modules can be
operation is in effect. Priorities also apply to hardware interrupts implemented in the HAL. All modules can share data with each
so that non-real time drivers cannot interfere with real-time other using shared memory. Shared memory blocks as well as
operation. In order to improve performance, real-time and non- FIFO’s can also be used to exchange data between user space
real-time tasks can be assigned to different processor cores. Figure applications and HAL modules.
2 presents a block diagram of real-time and non-real time modules LinuxCNC implements a wide variety of G-Code instructions
executed by the CNC controller. used to program the multiaxis machine. These include
technological cycles such as drilling or pocket machining and
program flow instructions (conditional statements, loops). Using
G-code the user can also control the look-ahead functionality
which is part of the trajectory generation. G61 code forces the
machine to reach every defined point. G64 implements look-ahead
toolpath smoothing with optional tolerance which greatly
improves program execution speed and improves machining
accuracy especially for toolpaths comprised of short line
segments.
Fig. 3. Structure of LinuxCNC software blocks EtherCAT application layer is based on the CANOpen protocol.
The CANOpen application layer, defined in CIA301 standard is
The HAL includes real-time modules operated by the built around the Object Dictionary (OBD). The Object Dictionary
LinuxRTAI microkernel. Standard HAL modules loaded by is a data structure containing all communication parameters and
LinuxCNC include the main motion control module (Motion) process data exchanged between devices in the network. Device
which includes the trajectory generator with trapezoidal federate profiles are used to define a standard OBD structure for each
profiling and interpolator. Different kinematic transformation device type. Device profiles for I/O modules and servodrives are
modules can be used such as Cartesian or Tripod depending on the defined by CIA401 and CIA402 standards respectively. CIA402
machine’s configuration. In order to connect LinuxCNC with defines standard addresses for position demand, feedforward
slave devices (servodrives and I/O modules) custom HAL values, controller gains, I/O state, drive status, following error,
modules had to be implemented by the authors. These included the operating mode and other typically used variables. It also defines
real-time EtherCAT driver of the network interface card, operating modes such as homing, cyclic or profiled position,
EtherCAT stack conformant with the CANOpen application layer velocity and torque mode. Because EtherCAT is based upon
standard and device profile module. The device profile module standard Ethernet it allows sending standard TCP/IP messages
controls Delta Electronics ASD-A2-E servodrives according to the when the bus isn’t utilized by EtherCAT transmissions.
CIA402 standard and Beckhoff I/O module according to the
Measurement Automation Monitoring, Jan. 2017, no. 01, vol. 63, ISSN 2450-2855 17
5. ASD-A2-0721-E servo drives, controller 1280000 inc/rev. Basic parameters of the system were presented in
parameter tuning Table 1.
(1)
(2)
7. Conclusions
The control system has simple construction, the components
used are inexpensive and easily available. The LinuxCNC
software enables execution of complex G-Code programs
including toolpaths defined as polynomial splines (NURBS). The
control system is easy to adapt to control machines of different
configurations. EtherCAT communication is deterministic with
very small cycle jitter. A single EtherCAT frame can handle all
servo drives and I/O modules with propagation delays and jitter
compensated by the servodrives. The CNC control system used
with ASD-A2-E servodrives the was able to perform very small
displacements (below 1 µm). It also achieved small following
errors while performing movements with rated motor speeds. The
Fig. 10. Velocity (a) and acceleration (b) demand during execution of the test
toolpath on the linear motion module presented CNC control system is a good alternative to existing
solutions present on the market especially expensive closed CNC
controllers.
8. References
[1] Huang H., Chi G. & Wang, Z.: Development and application of
software for open and soft multi-axis EDM CNC systems, Int J Adv
Manuf Technol, Vol. 86, No. 9 (2016): pp. 2689÷2700,
DOI:10.1007/s00170-016-8353-6
[2] Chen Xin; Li Di; Wan Jiafu; et al.: A clock synchronization method
for EtherCAT master, Microprocessors and Microsystems, Vol. 46,
Part B, (2016): pp. 211÷218. DOI: 10.1016/j.micpro.2016.03.002
[3] López-López F., Gomis-Bellmunt O., Teixidó-Casas M., Rafecas-
Sabaté J. and Muñoz-Gazquez J. P.: A novel educational platform to
teach CANopen field bus. Comput. Appl. Eng. Educ., Vol. 19, No. 2,
(2011): pp. 377÷384. DOI:10.1002/cae.20319
[4] Wawrzak A., Erwiński K., Karwowski K., Paprocki M., Kłosowiak
M.: PC based CNC control system with EtherCAT fieldbus. Pomiary
Fig. 11. Following error during execution of the test toolpath on the linear motion Automatyka Robotyka, R. 20, Nr 2/2016, 29-34, DOI:
module.: a) without feedforward, b) feedforward – formula (1), 10.14313/PAR_220/29.
c) feedforward – formula (2) [5] Erwinski K., Paprocki M. Grzesiak L. M., Karwowski K., Wawrzak
A.: Application of ethernet powerlink for communication in a linux
The toolpath used to test following error was presented in Figure rtai open cnc system”, IEEE Trans. on Industrial Electronics, vol. 60,
9. Feedrate and acceleration achieved during realization of the test no. 2, pp. 628-636, Feb. 2013. DOI: 10.1109/TIE.2012.2206348
toolpath were presented in Figure 10. The feedrate programmed in [6] Ferreira J.C.E., Benavente J.C.T. & Inoue P.H.S.: A web-based
G-Code was 15000 mm/min which equaled to the rated motor CAD/CAPP/CAM system compliant with the STEP-NC standard to
speed with the ballscrew used. Following error measurement was manufacture parts with general surfaces. J Braz. Soc. Mech. Sci. Eng.,
performed on the linear motion module equipped with precise Vol. 39, No. 1, (2017): pp. 155÷176. DOI:10.1007/s40430-016-0528-4
measurement devices. Test results which show servo drive [7] Mejías A, Herrera RS, Márquez MA, Calderón AJ, González I,
following error while realizing the above toolpath were presented Andújar JM.: Easy Handling of Sensors and Actuators over TCP/IP
in Figure 11. Networks by Open Source Hardware/Software. Sensors. Vol. 17(1),
a) Without feedforward ( , Fig. 6), No. 94; (2017): pp. 1÷23. DOI:10.3390/s17010094.
following errors were proportional to the velocity due to [8] Aström K.J. and Hägglund T.,: PID Controllers: Theory, Design, and
position P controller. At 160 Hz controller bandwidth and Tuning. 2nd ed., Research Triangle Park, NC: Instrum. Soc. Amer.,
nominal speed the following error was 2.5 mm, 1995.
b) With velocity feedforward, proportional to velocity demand: _____________________________________________________
Received: 02.10.2016 Paper reviewed Accepted: 02.12.2016
Measurement Automation Monitoring, Jan. 2017, no. 01, vol. 63, ISSN 2450-2855 19
MSc in Technical Physics in 2006 at Faculty of Physics BSc in Mechanical Engineering in 1970 at the
Astronomy and Informatics, Nicolaus Copernicus University of Science and Technology in Bydgoszcz.
University in Torun. PhD in Automation and Robotics MSc in Physics in 1975 at Poznan University. PhD in
in 2016 at the Faculty of Electrical Engineering, Warsaw 1982 at Warsaw University of Technology. His research
University of Technology. His research interests include interests include CNC control systems, industrial
numerical machine control in particular trajectory error automation and drive control systems.
minimization using artificial intelligence.
MSc in Electronics in 1986 at the AGH University of MSc in Electronics in 1981 at the Faculty of Electronics,
Science and Technology in Krakow. His research Telecommunications and Informatics, Gdańsk
interests include automation of technological processes, University of Technology. His research interests include
electrical drive control systems and numerical machine CNC control systems, CAD/CAM systems and
control systems. technological process automation. Currently employed
at PIAP-OBRUSN in Torun.
e-mail: [email protected]