0% found this document useful (0 votes)
9 views

PC_based_CNC_machine_control_system

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

PC_based_CNC_machine_control_system

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Measurement Automation Monitoring, Jan. 2017, no. 01, vol.

63, ISSN 2450-2855  15


Marcin PAPROCKI 1, Andrzej WAWRZAK 1, Krystian ERWIŃSKI 1, Kazimierz KARWOWSKI 1,
Marek
1
KŁOSOWIAK 2
NICOLAUS COPERNICUS UNIVERSITY, INSTITUTE OF PHYSICS
5 Grudziądzka St., 87-100 Torun, Poland
2
INDUSTRIAL RESEARCH INSTITUTE FOR AUTOMATION AND MEASUREMENTS, DEPARTMENT IN TORUN (PIAP-OBRUSN)
107 Stefana Batorego St., 87-100 Torun, Poland

PC-based CNC machine control system with LinuxCNC software


Abstract

In the article a PC-based numerical machine control system is presented,


communicating over EtherCAT bus with servodrives and auxiliary I/O
devices. LinuxRTAI real-time operating system was implemented on the
PC controller along with the LinuxCNC control software. EtherCAT
software communication module was developed and integrated with
LinuxCNC. The software module implements CANOpen (CIA301)
application layer standard along with device profiles for servodrives
(CIA402) and I/O devices (CIA401). This allows for fast bidirectional
communication between the PC controller and servodrives or I/O devices.
The CNC control system developed by the authors has simple construction
and is very flexible. It can be easily adapted to machines of different
configuration.

Keywords: CNC control system, open control system, realtime operating


system, Linux RTAI, LinuxCNC, EtherCAT.

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.

4. Ethercat communication bus in the CNC


control sytem
Standard Ethernet used with the TCP/IP [7] protocol does not
allow sufficient time determinism required for synchronous
control of a CNC machine’s servo drives. EtherCAT protocol
performs isochronous communication fundamental for motion
Fig. 2. CNC software modules divided into real-time and non-real time tasks
control applications. The physical layer of EtherCAT is identical
to Ethernet. This enables the use of standard Network Interface
Figure 3 presents the structure of LinuxCNC software modules.
Cards in the master PC. The physical topology of the EtherCAT
LinuxCNC is divided into user-space Application Layer and the
network is usually linear with a single master while implementing
Hardware Abstraction Layer (HAL). The Application Layer
a logical link using full-duplex transmission. Usually a single
consists of the main program which loads all other real-time and
Ethernet frame is sent periodically by the master (PC-based CNC
non-real time modules, handles configuration files, graphical user
controller) which contains all data intended for every slave. The
interface (GUI), G-Code interpreter [6] and I/O control. The user
frame has also empty data fields reserved for data returned by
can choose from several available user space programs such as
each slave. If data size exceeds the frame’s payload several frames
different GUI’s, software oscilloscope or software PLC. Custom
are sent sequentially. When a slave device receives the frame, data
user-space applications can also be created in C, C++ or Python
is read and written on the fly and the updated frame is forwarded
such as GUI’s or program preprocessors. All of these software
to the next slave. The last slave returns the updated frame to the
modules run as standard Linux tasks and are therefore non-real
master. Because hardware frame processing is used by the slaves
time tasks.
propagation delays induced by each slave is minimal (between
230 ns and 1 µs). EtherCAT uses a distributed clock
synchronization mechanism in order to compensate for
propagation delay and cycle time jitter introduced by the PC-based
master. EtherCAT communication is therefore highly
deterministic and short cycle times are possible even when the
master is PC-based and the network consists of many different
devices. The dataflow schematic of EtherCAT communication is
shown in Figure 4.

Fig. 4. Dataflow in EtherCAT network

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.

The developed control system utilize Delta Electronics ASD-


A2-0721-E servodrives. The basic drive parameters are: power
750 W, rated torque 2.4 Nm, rated speed 3000 rev/min, position
measurement resolution 1280000 inc/rev.

Fig. 7. Linear motion module

Fig. 5. ASDA-A2-0721-E servo drive controller structure in Cyclic Synchronous


Position Mode

Fig. 6. Position and velocity controller structure of ASD-A2-0721-E servo drive

Fig. 8. 3-axis machine with the developed CNC control system


The control system uses CIA402 Cyclic Synchronous Position
Mode for servo drive communication. In this mode position Tab. 1. CNC control system with ASDA-A2-0721-E servo drives
demands and velocity and acceleration feedforward values are
transmitted at every 1 ms communication cycle. Each servodrive No. Test
Parameters
Details
responds with actual position, actual velocity and actual torque achieved
producing current (Fig 5). The drive control structure is presented Motor position
measurement fluctuations ±2×2π/1280000
in Figure 6 and is comprised of P position controller, PDFF for a stationary motor no position change
Actual position equal
(pseudo derivative feedback with feed-forward) velocity to the demanded
1 measured using the from position.
controller. Torque and velocity feedforward values from the CNC Hiperface encoder in the the incremental No movement.
motor and the incremental encoder
controller are added to the torque and velocity demand values. The encoder.
torque controller is factory defined and is inaccessible by the user. Movement
ASD-A2-0721-E controller gains were tuned using ASDA-Soft performed in both
drive configuration software provided by the manufacturer. Two Measurement of small directions.
sets of controller gains were computed: displacement equal to: Demanded rotary
+1×2π/144000 rad displacements were
 First set was computed using default autotuning implemented in 2 and 1×2π/144000 rad
+1×2π/144000 rad,
performed and were
ASDA-Soft, achieved velocity controller bandwidth was 68 Hz, 1×2π/144000 rad equal to
(single increment of the
 Second set was computed based on frequency analysis incremental encoder in both ±0.03472 µm of
directions). linear displacement
performed on the drive and using internal anti-resonance notch for a 5 mm/rev
filters. Using this method, the velocity controller achieved ballscrew pitch.
160 Hz bandwidth with 14 dB gain margin and 55o phase Movement
margin [8]. Measurement of small performed in both
displacement equal to: directions.
+1×2π/144000 rad Demanded rotary
6. Achieved drive parameters, example and 1×2π/144000 rad +1×2π/144000 rad,
displacements were
application 3 (single increment of the performed and were
1×2π/144000 rad equal to
incremental encoder in both
directions) with 1.8 Nm ±0.03472 µm of
The presented control system consisted of an Intel Core i3 PC load torque on the motor linear displacement
with a Realtek 8111/8168 NIC, four numerically controlled axes shaft for a 5 mm/rev
ballscrew pitch.
with ASD-A2-0721-E EtherCAT servodrives and Beckhoff I/O
Measurement of maximum
modules (EK1828 EtherCAT coupler, EL1008 digital inputs, position error due to
Motor was stationary
EL2008 digital outputs and EL5101-0010 incremental encoder before loading.
momentary change in load
4 103×2π/144000 rad Position demand
interface). Tests were performed using an experimental setup with torque from 0 to 1.8 Nm.
equal to actual
a linear motion module (Fig. 7) and a 3-axis machine (Fig. 8) No change in demanded
position.
position.
developed at PIAP-OBRUSN Torun. The linear motion module
Following error
was equipped with ESSA linear encoder with 0.1 µm resolution measurement while Measurement
and a Kubler incremental encoder with a resolution of Maximum
performing movement performed for a
5 following error less
144000 inc/rev placed at the end of the ballscrew. Ballscrew pitch along a test toolpath (Fig.
than 0.1 mm
single axis with a
9) with motor rated speed 5 mm/rev ballscrew.
was 5 mm/rev. The motor connected to the ASD-A2-0721-E servo
(3000 rev/min, 15 m/min).
drive was equipped with a Hiperface encoder with a resolution of
18  Measurement Automation Monitoring, Jan. 2017, no. 01, vol. 63, ISSN 2450-2855

(1)

where: – position demand, factor was experimentally


fine-tuned in order to achieve minimum following error. The
following error was decreased below 0.1 mm. According to
Figs 10b and 11b largest values of following errors are present
during acceleration and deceleration.
c) With additional acceleration feedforward:

(2)

Following error was further decreased. According to the


presented figures largest following errors are present when the
Fig. 9. Toolpath used to test following errors acceleration is changing (non-zero jerk). The negative side-
effect are large current spikes during changes to acceleration.

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

Marcin PAPROCKI, PhD, eng. Kazimierz KARWOWSKI, PhD, eng.

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.

e-mail: [email protected] e-mail: [email protected]

Andrzej WAWRZAK, MSc, eng. Marek KŁOSOWIAK, MSc, eng.

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] e-mail: [email protected]

Krystian ERWIŃSKI, PhD, eng.

MSc in Technical Physics in 2008 at Faculty of Physics


Astronomy and Informatics, Nicolaus Copernicus
University in Torun. PhD in Automation and Robotics
in 2014 at the Faculty of Electrical Engineering, Warsaw
University of Technology. His research interests include
numerical machine control in particular time-optimal
trajectory generation algorithms.

e-mail: [email protected]

You might also like