100% found this document useful (1 vote)
288 views

Design and Implementation of 3 Axis Linear Interpolation Controller in Fpga For CNC Machines and Robotics

Design and Implementation of 3 Axis Linear Interpolation Controller in Fpga for Cnc Machines and Robotics
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
288 views

Design and Implementation of 3 Axis Linear Interpolation Controller in Fpga For CNC Machines and Robotics

Design and Implementation of 3 Axis Linear Interpolation Controller in Fpga for Cnc Machines and Robotics
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

International Journal of Advanced Research in Engineering and Technology (IJARET), ISSN 0976 6480(Print),

ISSN 0976 6499(Online) Volume 5, Issue 9, September (2014), pp. 52-62 IAEME
52











DESIGN AND IMPLEMENTATION OF 3-AXIS LINEAR INTERPOLATION
CONTROLLER IN FPGA FOR CNC MACHINES AND ROBOTICS


1
Mufaddal A. Saifee,
2
Dr. Usha S. Mehta

1
(M.Tech. by Research Student, Institute of Technology, Nirma University, Ahmedabad,
Gujarat, India)
2
(Associate Professor, Institute of Technology, Nirma University, Ahmedabad, Gujarat, India)


ABSTRACT

This paper presents the design and implementation of a 3 axis Linear Interpolation Controller
in a Xilinx Spartan 6 Field Programmable Gate Array (FPGA) to control a 3D linear motion ofa
Computer Numerical Control (CNC) machine or robotic arm. It is implemented using Verilog HDL.
Linear motion is the most fundamental motion. Any motion trajectory can be traced through series of
small linear motion. Therefore linear interpolation controller is very important part of any motion
controller. The algorithm implemented avoids large amount of complex mathematical calculations,
making it suitable for real time applications. Moreover, the hardware implementation of linear
interpolation algorithm as compared to software gives this implementation high real time
performance, precision and lower power. The simulation results of the linear motion in 3D space
verify the effectiveness of the implemented algorithm.

Keywords: 3D Linear Interpolation, CNC, FPGA, Motion Controller, UART.

1. INTRODUCTION

The Heart of Industrial Automation Devices like CNC Machines, Assembly Machines and
Robotic Arms are Motion Controllers.Motion controllers control the motion in a predetermined
direction through motors. The circular motion of the motor is translated to the robotic arm or CNC
tool linearly in small steps. A motor each is required for motion in one particular axis. Therefore, for
a 3D motion, the arm or tool is controlled by providing varying rate of pulses to each of the three
motors, corresponding to an axis. The controlled motion (line/arc) along the required path trajectory
is achieved through various interpolation algorithms run in 2D or 3D space, which are responsible
for providing varying rate of pulses to corresponding axis.
Interpolation algorithms are classified as software and hardware interpolation algorithms.
Software algorithms are run by processors or controllers serially through instructions, while
INTERNATIONAL JOURNAL OF ADVANCED RESEARCH IN ENGINEERING
AND TECHNOLOGY (IJARET)


ISSN 0976 - 6480 (Print)
ISSN 0976 - 6499 (Online)
Volume 5, Issue 9, September (2014), pp. 52-62
IAEME: www.iaeme.com/ IJARET.asp
Journal Impact Factor (2014): 7.8273 (Calculated by GISI)
www.jifactor.com


IJARET
I A E M E
International Journal of Advanced Research in Engineering and Technology (IJARET), ISSN 0976 6480(Print),
ISSN 0976 6499(Online) Volume 5, Issue 9, September (2014), pp. 52-62 IAEME
53

hardware algorithms are run by dedicated hardware blocks. Most of the interpolation algorithm uses
complex parametric function like sine and cosine for necessary calculations. Software
implementation of such algorithms by serial pipelined processors is time consuming and as well as
difficult and impractical for real time applications. Thus the efficient, real time complex computation
approach is only feasible with hardware logic circuits like FPGA or ASIC having parallel and lower
power processing architectures. As compared to ASIC, FPGAs have lower time to market and
simpler design cycle making it an excellent solution for the implementation of motion controllers.
Linear motion controller is the fundamental part of any motion controller. For a 3D linear
movement, Linear interpolation controller controls 3 motors by driving each of them with varying
angular velocities to achieve a linear movement from start to end coordinates. Linear motion is
approximated by series of small steps. Many Linear interpolation algorithms rely upon parametric
functions such as sine and cosine to perform the necessary calculations. Such calculations require
high degree of numeric precision which makes them too time consuming for real time applications.
This paper implements a novel algorithm which doesnt require complex calculations and has high
real time performance [1]. The paper is organized as follows: Section 2 describes the algorithm.
Section 3 describes its implementation and Section 4 describes Synthesis and Simulation results.
Conclusions are detailed in Section 5.

2. LINEAR INTERPOLATION ALGORITHM

Any line in 3D space can be decomposed into three planes by dropping perpendiculars into
each plane. This line is then equal to lines traced in any of two planes. Thus the 3D linear
interpolation becomes two 2D linear interpolations. This principle forms the basis of our
interpolation algorithm.

2.1 3D Line Movement In Space
We define the axis as long axis which has the longest distance movement in our 3D
interpolation process. We call the other two axes as short axis. As shown in the figure 1, space line
from O to P can be decomposed in 3 ways: OB and OC, or OB and OA, or OA and OC. The
decomposition method of the space movement is decided by long axis. If Z axis is the long axis, the
linear movement OP is decomposed into OB in XOZ plane and OC in YOZ plane. The interpolation
algorithm starts by outputting a pulse train to the long axis and the driving pulses of two short axes
depends on the relationship of the corresponding axis with the long axis. Thus two concurrent 2D
interpolation movements of lines OB and OC implements the 3D linear interpolation of line OP.


Fig.1: Decomposition of 3-D Line movement in XYZ space
International Journal of Advanced Research in Engineering and Technology (IJARET), ISSN 0976 6480(Print),
ISSN 0976 6499(Online) Volume 5, Issue 9, September (2014), pp. 52-62 IAEME
54

2.2 2D Linear Interpolation Algorithm


Fig.2: 2-D Line movement in XY plane

Figure 2 shows the first quadrant of XY rectangular coordinate system with origin O. For a
2D line movement OP, its start point is origin O and endpoint is P(Xe,Ye). Point P0(Xi,Yi) is a
random point in the quadrant. If P0 is on the straight line OP, according to geometric relationship of
a line we can write the following equation.

Ye / Xe = Yi / Xi = k (1)

In the equation 1, the variable k is slope of OP. From equation 1 we can write equation 2 as.

Xe*Yi = Ye * Xi (2)

We define error variable Fi as:

Fi =(Xe*Yi)(Ye * Xi) (3)

If P0 is on the line, then Fi =0; if its to the left of line then Fi<0, and if to the right than Fi>0.

If X axis moves one step in positive direction, then the new value of Fi is:

Fi = (Xe*Yi) ((Xi+1) * Ye) = Fi - Ye (4)

If Y axis moves one step in positive direction, then the new value of Fi is:

Fi = (Xe* (Yi+1)) (Xi * Ye) = Fi +Xe (5)

From the equation 4 and 5, we can conclude that if we move one step in either X or Y
direction, the new error result Fi is equal to the previous error result Fi plus a constant value which
depends upon the end points of the line in XY coordinates. Detailed interpolation flow is given in
figure 3.
International Journal of Advanced Research in Engineering and Technology (IJARET), ISSN 0976 6480(Print),
ISSN 0976 6499(Online) Volume 5, Issue 9, September (2014), pp. 52-62 IAEME
55

In the Linear interpolation process, the long axis will generate the speed pluses continuously,
causing long axis to move without interval. Linear interpolation module will continuously calculate
the new error value Fi, and accordingly will make judgment that whether the short axis should also
move one step or not.
Error value calculation is done by an accumulator whose initial value is 0, the accumulator
will subtract Ye, if the X moves one step, or the accumulator will add Xe if the X moves one step.
Thus through iterative addition/subtraction of a constant value Xe or Ye, the previous multiplication
of large data is replaced. Thus the interpolation has a better real-time performance and cost fewer
hardware resources. When the long axis reaches its destination, the interpolation algorithm will stop
feeding speed pluses to long axis motor, completing the interpolation process.

























Fig.3: Flowchart of linear interpolation



Finish
Begin
Main Axis Is X?
Axis?
Initialize Registers
Calculate Interpolation Parameters
Start Generating Pulses
Interpolation Axis Determination
A Pulse? A Pulse?
Fi < 0? Fi > 0?
End Point?
Fi = Fi + Xe
Yi = Yi + 1
Xi = Xi + 1
Fi = Fi - Ye
End Point?
Fi = Fi - Ye
Xi = Xi + 1
Yi = Yi + 1
Fi = Fi + Xe
Y N
Y
N N
Y Y
Y
N
N
N N
Y
Y
Stop Generating Pulses
International Journal of Advanced Research in Engineering and Technology (IJARET), ISSN 0976 6480(Print),
ISSN 0976 6499(Online) Volume 5, Issue 9, September (2014), pp. 52-62 IAEME
56

3. IMPLEMENTATION

Block diagram of the Linear Interpolation module is shown below in figure 4. It has 7 main modules.

3.1 Buf DcmSync Reset(Buffer, Digital Clock Manager and Synchronous Reset)
This module does the buffering, differential to single ended and down conversion of input
clock. It also converts asynchronous reset to synchronous reset which is then used as reset,to the
entire design.

3.2 UART
UART (Universal Asynchronous Receiver Transmitter) is used for asynchronous serial data
communication with the Interpolation module. Its a generic UART supporting all baud rates. Our
design uses the 115200 baud rate. UART architecture is based on Recursive Running Sum Filter
which provides better noise performance [2].


Fig.4: Linear Interpolation module
International Journal of Advanced Research in Engineering and Technology (IJARET), ISSN 0976 6480(Print),
ISSN 0976 6499(Online) Volume 5, Issue 9, September (2014), pp. 52-62 IAEME
57

3.3 UART Register Interface
UART Register Interface block is responsible for configuring the Linear Interpolation
module. It provides the glue logic between UART and the configuring part. It configures 5, 32 bit
registers which are then used for controlling the Linear Interpolation design. Registers function are
given in table 1. In addition to the configuring of above registers, it also writes the 32 bit coordinates
of the X, Y and Z axes in a 32 bit x 64 block ram.

Table 1: Registers
No Register Description
1 Control
Bit 0 define the coordinates in the RAM are given in incremental
or absolute mode. Rest bits are unused.
2
Displacement
coefficient X
No of millimeters moved in x direction / 1 revolution of motor
3
Displacement
coefficient Y
No of millimeters moved in y direction / 1 revolution of motor
4
Displacement
coefficient Z
No of millimeters moved in z direction / 1 revolution of motor
5 Feedrate
No of revolutions per second of motor. It basically provides the
pulse width of the long axis

3.4 RAM
Ram used is a 32 bit wide x 64 deep simple dual port block ram of Spartan 6 FPGA. It is used
to hold coordinates of the 3d axis in bunch of three, one corresponding to each axis, one after other.
Thus in total maximum of 21, 3d coordinates (21x3=63) can be stored into the Ram.

3.5 Top Control
Top Control module controls the entire linear interpolation process. It receives data like
absolute/incremental addressing of 3D coordinates, displacement coefficients in X, Y and Z axes for
the respective servo drives and feed rate of the machining process from the UART Register Interface.
On detection of start signal it starts fetching 3D coordinates from the Ram in bunch of 3 for X, Y and
Z axis respectively. Depending on the current axes position and the fetched coordinates it calculates
interpolation parameters and direction of rotation of servo motors. It then passes the actual
movement required in the 3 axes to the Linear Interpolation Control and Algorithm module, which
then accordingly generate pulses to the servo drives of respective axes. On getting done signal from
Linear Interpolation Control and Algorithm module it fetches the next coordinate set and repeats the
above process again. A FSM is designed to take care of this.

3.6 Linear Interpolation Control and Algorithm
The 3D Linear Interpolation algorithm is implemented in this block as two 2D line
movements. This module shown in figure 5, applies the linear interpolation algorithm according to
the given coordinates and generates the pulses to the servo drives for the respective axis.
International Journal of Advanced Research in Engineering and Technology (IJARET), ISSN 0976 6480(Print),
ISSN 0976 6499(Online) Volume 5, Issue 9, September (2014), pp. 52-62 IAEME
58


Fig.5: Linear Interpolation Control& Algorithm

3.6.1 Parameter Calculation &Axis Determination
The inputs to this module are absolute displacement coordinates and the displacement
coefficient for the respective x, y and z axis. Feed rate provided as input to it is directly given out to
pulses generation module. Depending on the current input coordinates, it has priority mux based
comparators which decides the long, first and second axis. Accordingly the input coordinates and
their respective displacement coefficient are mapped to long, first and second axis and given to linear
interpolation algorithm control FSM. It also divides the 3d into two 2d planes for the interpolation
algorithm, as described in introduction part. Therefore one 2d plane is made of long axis and first
axis, while other 2d plane is made of long axis and second axis. As from equation 4 and 5 in Section
2, for error calculation for first 2d plane made of long and first axis, the amount to be subtracted
when servo motor moves 1 step in long axis direction is displacement coefficient in first axis
(mov_rotf) and the amount to be added when servo motor moves 1 step in first axis direction is
displacement coefficient in long axis (mov_rotl1). Similarly for second 2d plane made of long and
second axis, they are displacement coefficient in second axis (mov_rots) and displacement
coefficient in long axis (mov_rotl2). The pulses generated by the linear interpolation algorithm
module are also mapped back to respective axis from l, f and s to x, y and z axis. On detecting start
pulse this module calculates above parameters and issues a start pulse for the linear interpolation
algorithm to start working.

3.6.2 Linear Interpolation Algorithm &Control FSM
This module performs the interpolation algorithm described in introduction section. It
controls the pulse generation module, and pulses generated by it are given directly to long axis. It
also generates enable signals for first and second axis which are ended with the pulses generated for
the main axis to generate pulses for first and second axis. This algorithm is designed using FSM.
This FSM shown in figure 6 has three states 1) idle, 2) cal and 3) wt_dn.
International Journal of Advanced Research in Engineering and Technology (IJARET), ISSN 0976 6480(Print),
ISSN 0976 6499(Online) Volume 5, Issue 9, September (2014), pp. 52-62 IAEME
59


Fig.6: Linear_Interpolation_control_and_algorithm FSM

Idle
In idle state, until start is equal to 1 is detected, all the outputs that enable and pulses signals
for three axis, actual movement of long axis, error signals for 2, 2d planes and start and stop
interpolation signals are all 0. When start is 1 FSM jumps to Cal state.

Cal (Calculation)
In this state if actual movement becomes equal to the movement required in long axis then
FSM jumps to idle state resetting all its output and raising linear interpolation done signal (l_done) to
1, indicating the interpolation algorithm is complete for the current 3d coordinates. If its not equal, it
continues to enable the Pulse Generation module to generate pulses makes long axis enable signal to
1 and adds long axis current coordinates with the displacement coefficient of long axis. According to
the algorithm described in section II for both 2d planes, error values for respective planes are
calculated and accordingly enable signal for first and second axis are generated. FSM moves to
wt_dn state.

Wt_dn (Wait pulse done)
In this state FSM waits for the pulsedone signal from pulse generator. When it is detected it
moves to Cal state for further interpolation calculation. While it is in this state all output values are
preserved, while pulse outputs to respective long, first and second axis are given out by anding their
respective enable pulses with the pulse generated from pulse generator module.

3.7 Pulse Generation
Depending on the feedrate, pulse generation module provides the pulses to the Linear
Interpolation Control & Algorithm module. It starts generating pulses of 50% duty cycle on getting
Start Rotation signal (rot_start) from Interpolation Control & Algorithm module and stops providing
the pulses on receiving Linear interpolation done signal (l_done). Its heart is control FSM which
generates pulses and pulsedone signal. A counter counts up to half of the feed rate register value for
International Journal of Advanced Research in Engineering and Technology (IJARET), ISSN 0976 6480(Print),
ISSN 0976 6499(Online) Volume 5, Issue 9, September (2014), pp. 52-62 IAEME
60

both digital levels and a comparator provides the equal signal to the FSM when count equals half the
feedrate value, indicating change of state. Pulsedone signal is given back as feedback to linear
interpolation module to have a count of no of pulses generated and thus the linear motion moved by
the long axis.Its control FSM shown in figure 7 has 3 states as 1) Idle, 2) Pos_half (Logic 1 half
cycle) and 3) Neg_half (Logic 0 half cycle).


Fig.7: Pulse_generation FSM

4. RESULTS

4.1 Synthesis Report - Device utilization summary

Selected Spartan 6 FPGA Device:6slx45tfgg484-3

Table 2: Device utilization summary
Type of Resource Utilization Number Utilization Percentage
Number of Slice Registers 1420 out of 54576 2%
Number of Slice LUTs 2210 out of 27288 8%
Number of Slice LUTs used as Logic 2210 out of 27288 8%
Number of bonded IOBs 13 out of 296 4%
Number of Block RAM/FIFO 1 out of 116 0%
Number of BUFG/BUFGCTRLs 2 out of 16 12%
Number of DSP48A1s 22 out of 58 37%

Device utilization summary shows that the implemented algorithm is highly hardware
efficient consuming only 2210, 6 input LUTs and 1420 flip flops.
International Journal of Advanced Research in Engineering and Technology (IJARET), ISSN 0976 6480(Print),
ISSN 0976 6499(Online) Volume 5, Issue 9, September (2014), pp. 52-62 IAEME
61

4.2 Simulation results
Below figure 8, Waveform1 shows Control, displacement coefficients and feed rate registers
values configured through UART. Absolute addressing is used for coordinates. The address and data
lines logic of RAM are shown below. Coordinates are fetched from the RAM and updated to
destination coordinates required along 3 axes. Three different 3d coordinate values are shown below.
The respective pulses and direction signals are at the top of waveform.


Fig.8: Waveform1

In Waveform2, figure 9, the calculations performed and axis identification signals are shown.
Current position of each servo motors are also visible in waveform. From the destination coordinates
value, actual movement with respect to current coordinates are calculated. Long, first and second
axes are accordingly identified and are shown below.


Fig.9: Waveform2

The linear interpolation algorithm signals can be viewed in figure 10, Waveform3. The FSM,
error signals for both 2d planes, pulses from pulse generator, pulse enable for each axis and pulses
for the long, first and second axis generated are shown below. Start and stop signals indicating start
and end of linear interpolation algorithm for each updated 3d coordinates are also there in
Waveform3.
International Journal of Advanced Research in Engineering and Technology (IJARET), ISSN 0976 6480(Print),
ISSN 0976 6499(Online) Volume 5, Issue 9, September (2014), pp. 52-62 IAEME
62


Fig.10: Waveform3

5. CONCLUSION

This paper explains the implementation of 3D linear interpolation controller. The algorithm
principle is explained and its detailed hardware architecture design and implementation are
discussed. Verification results, shown through waveform show that approximating precision of the
algorithm is excellent. Concurrent FPGA based hardware processing make the module have good
real-time performance. Moreover, synthesis report shows that the module costs very few hardware
resources. Simpler algorithm, fewer hardware resources, real time performance and excellent
precision of the linear interpolation controller indicate its usefulness and high value for FPGA based
practical motion controllers for CNC machines and Robotic arms.

6. REFERENCES

[1] Weihai Chen, Zhaojin Wen, ZhiyueXu and Jingmeng Liu, Implementation of 3-axis Linear
Interpolation in a FPGA-based 4-axis Motion Controller
[2] Himanshu Patel, Sanjay Trivedi, R. Neelkanthan, V. R. Gujraty, A Robust UART Architecture
Based on Recursive Running Sum Filter for Better Noise Performance Conference Proceedings:
20th VLSI Design - 6th Embedded Systems, The Institute of Electrical and Electronics Engineers,
Inc. January 2007, pp 819-823.
[3] K Goldberg, and M Goldberg, XY interpolation algorithms, ROBOTICS AGE, No 5,
May 1983, pp.104-105
[4] Z. Zhang, C. W. Peng, and L. G. Yin, Motion Controller Introduction and Application of
MCX314, Electronics World, No. 5, 2005, pp. 45-46
[5] J. L. Liu, W. Liu, and C. Y. Yu, Complete Numeric CNC System and Its Kernel Chip
MCX314, Electronic Design & Application World, no.8, 2004, pp.104-106
[6] P. Q.Yue, and J. S. Wang, Motion Controller IC MCX314 and Numerical Control System
Design, Beijing: Beihang University Press .Nov.2002
[7] Fengge Li, Jiaxin You and Weiming Tong, A Design of Full-Digital CNC Interface Based on
FPGA, 2009 International Conference on Information Technology and Computer Science
[8] Jung Uk Cho, Quy Ngoc Le, and Jae WookJeon, An FPGA-Based Multiple-Axis Motion
Control Chip IEEE Transactions on Industrial Electronics Vol. 56, No. 3, Mar. 2009
[9] Xilinx Spartan 6 data sheet from www.xilinx.com.
[10] Vani. Surapaneni, V. Shanthi Sri, Monitoring and Fall Detection of Patients using Mobile
3-Axis Accelerometers Sensors, International Journal of Electronics and Communication
Engineering & Technology (IJECET), Volume 3, Issue 2, 2012, pp. 41 - 47, ISSN Print:
0976- 6464, ISSN Online: 0976 6472.

You might also like