2K14 Group Report
2K14 Group Report
Authors
Supervisor
Engr. M Shoaib Rabbani
BAHAWALPUR
July, 2018
(In the Name of Allah, the Most Gracious, the
Most Merciful)
Design of Computer Numerical Control Plotter Using
July, 2018
University College of Engineering & Technology
Department of Electrical (Power) Engineering
CERTIFICATE
This is to certify that work presented in this project thesis on
Computer Numerical Control Plotter Using Combination of Servo Mo
and Stepper Motor” is entirely written by following students under
supervision of Engr. M Shoaib Rabbani
Submitted By:
Hafiz Khurram Iqbal 14EL07
Date:
ABSTRACT
The method that allows computer to automate machine is called Computer Numerical
Control (CNC). The machine which can move along different axis like x and y, is
machine can also be controlled. The same concept is used in mini 3D printers. The
We use two stepper motors and a servo motor for the construction of machine. Stepper
motors are used to cover the movement along x and y axis. Servo motor is used for up
and down movement of z axis. The movement of motors are controlled by main
controller called Arduino UNO. The UNO controller controls the movement of motors by
interpreting the G-code. G-code is the code which tells the machine where to go in terms
of distance co-ordinates. Any SVG diagram drawn in computer is converted into G-code.
Keywords: CNC, plotter, Automate, 3D printer, Stepper Motor, Arduino, G-code, Grbl,
UGS.
i
UNDERTAKING
We certify that the research work titled “Design of Computer Numerical Control Plotter
Using Combination of Servo Motor and Stepper Motor” is our own work. The work has
not been presented anywhere else for assessment. Where material has been used from
__________________________
__________________________
__________________________
ii
ACKNOWLEDGMENTS
First, thanks to Almighty Allah, the most Beneficent and Merciful, who provided us with
It is pleasuring to add heartfelt words for the people who provide us with ending support,
precious time and inspiration. We would like to express thanks of gratitude to our project
supervisor Engr. M Shoaib Rabbani as well as Head of Department Dr. Abdur Raheem
We are thankful to our parents, teachers and friends for their sincere cooperation,
iii
TABLE OF CONTENTS
Abstract.................................................................................................................................i
Undertaking.........................................................................................................................ii
Acknowledgments...............................................................................................................iii
Table of Contents................................................................................................................iv
List of Figures.....................................................................................................................vii
List of Tables......................................................................................................................viii
Chapter 1: Introduction....................................................................................................1
1.3 Methodology..............................................................................................2
iv
3.6 Servo Motor.............................................................................................18
3.7.1 Programming........................................................................................22
3.7.2 Power...................................................................................................22
4.1 G-Code.....................................................................................................30
4.3 GRBL.......................................................................................................36
5 Conclusion.......................................................................................................41
Abbreviations.....................................................................................................................44
v
References.........................................................................................................................45
vi
list of figures
vii
LIST OF TABLES
viii
CHAPTER 1
1 Introduction
CNC plotter is capable of drawing sketches which are fed by computer in the form of
Geometric code that are x, y and z co-ordinates. This G-code is sent to microcontroller
using Universal G-code Sender (UGS). Microcontroller interprets the commands and
send signals to motor drivers which drive the motors through steps. It provides easiness
in manufacturing complex curved geometries. The exciting features are much greater
precision than the hand work and mass number of sketches in short time. It can also draw
circuit layout directly on the printed circuit board (PCB). Keeping in view of above
mentioned benefits, the purpose of this project is to develop a low-cost CNC plotter
capable of drawing accurately. Plotter can be modified by using pen with 3D printer
head, milling tool or any other cutting tool for different purpose of cutting materials
instead of sketching.
Drawing of simple and small sketches is quite easy but for complex sketches it requires
highly skilled professionals. For this purpose, many years of education and training is
There are wide ranges of technologies for the fabrication of CNC machines but are very
The purpose of this project is control movement of electrical motors using mechanical
structures. To explain the key idea behind numeric control and interaction between
1
hardware, software and communication between them. The Printed Circuit Board (PCB)
has made an enormous contribution in electrical and electronic devices industry. This
Computer Numerical Control machine is run by CNC machine language (G-code) that
are generated by unique method, moreover, there is microcontroller and drivers to control
the movement of motors. The user just needs to generate the G-code of any circuit
diagram or a sketch. The machine will automatically respond to the generated G-code and
will draw the desired result. Thus, this project will be helpful for engineering students
and for them having interest in art and designing during project implementation.
1.3 Methodology
method is not too much complex due to multiple steps and easy to implement. The block
The sketch of any drawing or circuit layout is designed in CAD. This layout is then
imported in software that produce g-code file of that image. The G-code is sent to
Microcontroller interprets the commands and send signals to motor driver. Motor driver
2
Fig 1.1: Block Diagram of Project
The thesis work is divided into 5 chapters. The contents of these chapters are summarized
as:
brief introduction of technology, project overview and problem statement. The main
3
Chapter 3 is the introduction to Computerized Numerical Control and the technology
behind CNC. After detailed introduction, main hardware components and its working is
described.
Chapter 4 is about software and coding of project. It described the flow of tasks among
different components. The libraries and standard directives used in the coding are also
enlisted.
4
CHAPTER 2
2 Literature Review
Numeric control (NC) was the first step in the designing of computer numeric control
(CNC) machine. So, in the era of 1940’s ,50’s United State Airforce and Parson’s
company introduced the method for moving two axis simultaneously and utilizing punch
machine tool. Due to lack of transistors and IC’s the NC was very much huge in size due
Although this technology proved to be cost effective but do not provided with any
universal code, so every individual manufacturer used their own language for defining
part programs. The NC consist of fixed logical functions.no changes in the function could
As the time passes other technologies were also developing at the same time. In these
technologies the DNC (Direct numerical control) ONC (Open Numerical Control) and
other like CNC were developing as each technology has its own features and drawbacks.
As direct control was not so simple and complex engineering was required for controlling
purposes and as open control was not so precise so the requirement was the simple
Computer numeric control (CNC) took a step in this field in 1960’s because of the
5
control was the magnificent step in revolutionizing the industry [2]. CNC is the very vast
term that encircles a variation of types of machines with diversity in shape size and
CNC machine would include plotters, cutters,3D printers, milling machines and many
other which keeps on modifying with the impressive development in technology. The
manufacturing methods for PCB’s also proved to be the milestone for industry [6]. The
PCB’s electronic circuit are operated by the flow of current through specific paths. These
paths are not possible to be traced without the assistance of CNC machines, previously
liquid ferric chloride was used to carve the board for clearance of current flow path but it
CNC machines are most efficiently utilized in the industry where there is excessive work
load. CNC machine is the form of automatic machine, which is provided with motors that
provides us with favorable merits that include much greater precision than hand working,
high efficiency, less working time, less human interference, greater dimensional
accuracy, reduces energy cost and consumable materials so that production is efficient
and profitable. If they are correctly programmed, they do not require advanced skills and
The modern CNC system, uses an internal microprocessor, thus the machine operator or
the part programmer can vary the program of control system [2]. CNC’s are controlled
using a special programming language called G-code. G-code provides with ease to
gather information of all the moving motors, as the status of the moving motors is seen,
thus the control over motors can be gained. G-code is much simpler than any other high-
6
level programming language. There is the possibility to generate g-code either manually
or automatically. Computer aided design (CAD), CAE etc. are the software that assist in
generating the g-codes[9]. So, the combination of hardware and g-code yields advantages
that include the higher accuracy and reducing the work load. In actual the CNC machine
As the technology developed gradually the CNC machines that make use of the motors to
carry out their work, are becoming more and more cost effective and highly demanding
and can be easily constructed by the individuals or companies. CNC plotters are very
versatile and fully automatic machineries that integrate the function of drawing, sketching
etc. using computer controlled pen. This is 2D plotting machine which can be further
modified for 3D plotting by further advancement. Even new tools such as the 3D printers
can be programmed using mostly the same algorithms used for more classical processes
[11]. These machines ensure the controlled and precise movement of motors.
7
CHAPTER 3
Components
Computer numerical control is a method in which motion of machines (i.e. servo and
stepper motors) is controlled by computers using numeric [12]. The design or sketch is
converted into special codes using computers with which the interacted motion of motors
controls the tools, for example pen, drills or lathes. As the machine is driven by
computer, a software program is needed to modify or create shapes and develop the paths
Prior to CNC machines, conventional machines have 2-axis and the working bed move
vertically. The spindle did not move as it is fixed with machine body. In CNC machine,
there are minimum 3-axis. The construction of CNC is more rigid than conventional
machines.
To command in the subject of CNC there are a few key areas which should be
concentrated on:
i. Computer Skills
There are 2 types of tasks performed during the process. Firstly, we will be
working with software programs for editing, copying, saving files, starting and
8
stopping operation. Meanwhile CNC is run by a computer, which can be a PC or
Before the machine start drawing, we need to create design layout in software
program that the machine will follow. The chosen software will play significant
role in creating projects successfully using CNC. This design software allows us
It is important to properly maintain and adjust CNC to know its limitations and to
set it up to do a job correctly. While building own machine, its size, speed,
i. Part Program:
All the CNC machining begins with a part program, which is sequential
instructions or coded commands that direct the specific machine functions. When
running, a part program is interpreted one command line at a time until all lines
are completed.
9
Feed and speed codes
Miscellaneous codes
Program input device imports the part program into the CNC control. Input device
MCU performs all the controlling actions of CNC according to the part program.
Drive system consists of motor drivers, timing belt and lead screws. The control
signal consisting position and speed are sent by MCU to the amplifier circuit.
These control signals trigger motor drivers which in turn rotate the lead screws to
v. Machine Tool:
10
A CNC machine always has a working bed and a clamp for the machine tool.
Machine tool could be one of following: laser, lathe, mill, plasma, pen etc. In our
Input
device
Part Program
MCU
Motion Data Miscellaneous Function
Driving
Machine tool
system
i. Resolution
Control resolution (BLU) is the space separating two adjacent points in the axis motion.
The electromechanical elements of the positioning system that influence the resolution
are the lead screws, the gear ratio and the step angle in stepper motor.
ii. Accuracy
11
Accuracy of a CNC system depends on the resolution, the computer control algorithm
and machine inaccuracies. The inaccuracy due to resolution is considered half of BLU on
the average. The control algorithm inaccuracy is due to the rounding off error in
computer which is insignificant. The machine inaccuracy could be due to many reasons.
iii. Repeatability
associated with that programmed point. the repeatability is always better than accuracy.
Each basic length unit corresponds to the position resolution of the axis of motion. For
example, 1 BLU = 0.0001” means that the axis will act 0.0001 inch for every electrical
Points to point system are those that move the tool or the work piece from one point to
another point and then the tool perform the required task. Upon completion, the tool (or
work piece) moves to the next position and the cycle is repeated. In this system, the feed
value and the track of the pen or work piece have no signification on the machine
operation. The accuracy of placement depends upon the system’s resolution in terms of
12
Fig 3.3: Path in point to point system
These systems provide continuous path such that the tool can perform while the axis is
moving, enabling the system to generate angular surfaces, two dimensional curves, or
Velocity error effectively impact the location of the pen. It is often more significant
sketching where one axis adopts sine function while the other compiles cosine function.
Hardware Details
In the context of technology, hardware refers to physical elements that make up a system.
The implementation of hardware component is the major task in project designing. The
A stepper motor is a special type of synchronous motor which is designed such that its
rotor rotates in discrete step for an electric signal received by its driver [13]. Due to this
property exhibited by stepper motors, these motors are used for precise positioning of
13
shaft or other machinery. Therefore, stepper motors are the base of computer numerical
control plotter to precisely move the drawing pen. The control signal to the stepper motor
must be sent one at a time. The direction of rotation of shaft depends on the sequence of
electric signal. The complete revolution of shaft is divided into equal length of steps and
The stepper motor used in our project is NEMA 17, 4-wire, bipolar stepper motor. Two
stepper motors are used for x and y axis each. The operation of stepper motor is open
loop control which means no feedback system about position is required. Thus, it
the principle that rotor tooth are attracted by minimum gap due to minimum
reluctance.
features of PM and VR, and give favorable results. The stepper motors used in
14
3.5.3 Hybrid Stepper Motor
The exciting features of these motors are there better performance in torque, speed and
step resolution, compared with PM and VR stepper motor. It borrows the favorable
features of PM and VR. The rotor of hybrid stepper motor is a permanent magnet and it
is split in two halves and each half is multi-toothed/ geared. Steps range of hybrid stepper
motor is 100-400 steps per resolution. The angle resolution is 1.8°. It does not create any
noise.
The rotor is magnetized and its teeth. Stator has number of teeth or poles as well. The
rotor consists of two cups, one in the front and one in the back. The two rotor cups are
opposite in polarity. The teeth on one cup is offset by one tooth to the teeth on the other
cup. When a phase is energized, it energizes four poles on stator. Suppose, initially the
stator poles A and A’ are aligned perfectly with one of the rotor cup teeth. On the other
hand, B and B’ stator poles are halfway of the pole attracting the one cup’s teeth while
repelling the other. In the next step the direction of current is changed by reversing the
15
current direction. Winding B maintains the current direction from previous stage. Now,
the stator poles A and A’ are half on each rotor cup while B and B’ align up perfectly
with each cup. The rotor has rotated a very small amount due to this construction of
hybrid motor.
Technical specifications of Nema 17 stepper motor used in this project are as follows:
1 Phases 2
2 Steps/ Revolution 200
3 Step Accuracy ±5%
4 Rated current 2A
5 Rated voltage 12V
7 Holding Torque 0.48 Nm
16
3.5.6 Step Modes
For the configuration of step resolution, there are three pins for each motor. Many step
modes can be obtained by using different configuration schemes of pins. These modes
Hybrid stepper motors usually have two hundred rotor teeth; therefore, they complete a
revolution in two hundred steps. So, in full step mode one phase is energized at a time. In
this way the step angle of motor is 1.8°. In this step mode motor requires less amount of
power.
In half step mode, a phase is energized sequentially just before the previous de-energizes.
Thus, rotor tooth moves halfway the distance of tooth width. In this way the rotor
completes one revolution in four hundred steps and provide more smoother operation.
17
Fig 3.6: Half step Excitation
Micro-stepping Mode
This mode of step resolution is used in situations where very accurate positioning is
required. It improves the motion control at the cost of low torque. In micro step operation
one rotation of rotor is obtained in very small steps i.e. fifty-one thousand two hundred
steps. The step angle becomes very small. Thus, the motor can position every small
distance.
Servo are small, light-weight and efficient motors. The selection of motor depends on the
types of use and requirements. For example, for reliable and long run time use the motor
with metal gears instead of plastic gears is used to compensate for wear and tear. Next,
18
the task may be accomplished by half or full circle rotation so one of the 180°∨360 °
rotating gear arrangement can be used. The most important parameter of concern is the
torque. It determines the amount of load that the motor can pick. For our requirement a
1.8kg is sufficient. On receiving the pulse signal servo rotates a specified degree i.e. 180
In CNC plotter servo motor is used is to lift drawing pen up and down. Servo has it its
own feedback and gear box yet it is compact in size. 3 wires come out of the servo motor:
Brown (ground), Red (5V), Orange (PWM). Through orange wire PWM signal is given
Serve operates using the three wires, two for the power supply to make motor rotating.
The third wire is for PWM signal that is generated from microcontroller. The direction
and degrees of rotation is controlled by varying the on time of pulse. Suppose the on time
of signal is 2ms out of total 20ms for 50Hz frequency. Thus, when the on time is 1ms
19
Table 3.2: Technical Specification of SG90 Servo Motor
1 Voltage 4.8V
2 Weight 9g
3 Torque 1.80kg-cm
4 Speed 0.12s/60°
5 Rotation 0°-180°
input/output pins, 6 analog input pins, a 16 MHz quartz crystal oscillator, a USB port, an
external power jack, 5 power pins and a reset button. There is a test LED and two TX/RX
connecting the board to a computer with the help of a USB cable or with a DC adapter or
20
Fig 3.9: Arduino UNO
UNO is an Italian word which means “one’ and it was chosen to mark the release of
Arduino Software IDE 1.0. The Arduino UNO and version 1.0 of Arduino Software IDE
were the reference versions of Arduino, now there are several new releases. The UNO
board was the very first in the series of USB Arduino boards. The technical specifications
1 Micro-controller ATmega328
5 No. of Digital Input/Output Pins 14 from which 6 can provide PWM output
21
9 DC Current for 3.3 V Input Pin 50mA
12 Size EEPROM 1 kB
3.7.1 Programming
Arduino Software (IDE) is used to program the Arduino UNO board. The ATmega328
that allows the user to upload new code into the board without the need of an external
hardware programmer. The Arduino UNO communicates with computer by using the
original STK500 protocol. Arduino IDE is used to program Arduino for the computer
numerical control plotter. User can also program the micro-controller by using the ICSP,
3.7.2 Power
The power can be provided to the Arduino UNO board via the USB connection or with
an external DC power supply. The power source is chosen automatically by the board.
adapter can be attached by plugging in a 2.1mm center-positive plug into the Arduino
board's power jack. Wires coming from a DC battery can be putted in the GND and Vin
22
Fig 3.10: Arduino UNO Pinout
In computer numerical control plotter, there are two sources of power. External 12V
power supply power to motors. USB power supply of laptop/pc is used to power Arduino
UNO board. The UNO board can also be run on an external power supply ranging from 7
to 12V. If the power supplied is less than 7V, the 5V pin may provide less than 5V and
the UNO board may become unstable. If power is supplied more than 12V, the voltage
regulator may overheat and destroy the board. The suggested range of power is 7 to 12V.
Vin: It is the input voltage pin on the Arduino UNO board. When using an external
power source, voltage can be provided via this pin. Or if providing voltage through
23
5V: The function of this pin is to provide a regulated five volts from the voltage
regulator installed on the UNO board. Applying voltage through the 5 or 3.3 volts
pins bypasses the voltage regulator and can severally damage the board.
The 14 digital pins on the UNO board can be used as either input or output by using
pins, pin 2, 3 and 4 are used for sending step signals to each corresponding motor and pin
5, 6 and 7 for controlling the direction of movement of motors. These pins are connected
to ‘step’ and ‘dir’ pins of motor driver. In this way, pin 2 and 5 are step and direction pins
for first motor and so on. Each pin can supply or receive only 20 mA current as suggested
operating condition and has an internal pull-up resistor of 20-50 kilo ohm. The current
must not exceed greater than 40mA on any digital pin to prevent permanent damage to
TTL serial convertor chip. In CNC plotter these pins are used for serial
controller.
Reset Pin: Bring the value of this pin LOW to reset the microcontroller. It used to
add a reset button to external shields which block the reset button on the board.
This pin is used to reset the Controller manually. By connecting this pin to GND
24
pin the Controller will be reset and all the positions and variables values will be
lost. All motions and movements will be halted and Controller will reboot.
CNC shield helps in building large number of projects including CNC drawing, CNC
routers, printers, robotics and other linear motion projects. An open source software
‘grbl’ is used on Arduino to control any required number of motors ranging from one to
four using the same number of A4988 motor drivers. The CNC shield used in this project
GRBL compatible
Enable Coolant
12-36 VDC
The CNC shield fits well on the top of Arduino without any extra jumper. CNC shield
25
Fig 3.11: CNC Shield Pinout
A4988 Motor driver is used to control the motion of stepper motors. It is shown in fig
2.6. It can control the stepper motor with only two pins namely step and direction, one for
controlling the steps and the other for direction of rotation, either clockwise or
anticlockwise. The function of motor driver is to convert the step and direction signals
into electronic pulses. These signals are sent from Arduino. The built-in translator in
motor driver makes its function easy. The supply pins on motor driver are VDD and
GND. VDD can range from 3-5.5V. It is supplied with 5V from Arduino board. Next 4
pins are to connect motor wires, 1A and 1B for one coil, 2A and 2B for the other coil.
Following next two pins are used for powering motor, so VMOT and GND are connected
to 8-35V power supply through a capacitor for protection against voltage spikes. Now the
actual pins for motor control are STEP and DIR. Whenever a pulse is sent to STEP pin,
the motor moves one step. The resolution of these steps is controlled by three pins MS1,
26
MS2, MS3. Reset pin is used to put the translator to home state and sleep is for
minimizing power consumption when motor is not doing any job. The value of current is
limited by potentiometer on the board to make sure that it is within the motor limits.
There are 3 pins with each motor driver on CNC shield for configuring step resolution
according to one’s requirements. So, there are 5 different step resolutions. Following is
As we are using full step mode so we don’t insert any jumper. For full step the step angle
360
Stⅇpanglⅇ =
no of steps
27
360
stⅇp anglⅇ= =1.8°
200
The linear distance travelled by one step depends on the pitch of leadscrew.
Timing belt is a toothed belt which provide non-slippery motion. Timing belts are used to
convert the rotational motion of motors into linear motion. GT2 timing belt is 1164mm
long. The pitch of belt is 2mm and it is 6mm wide. It means for one revolution the
distance moved is 2mm. If there are 200 steps per resolution, the step resolution comes
described:
Power Adaptor: 12V AC-DC adapter is used to power Arduino UNO. Its current
tension in the belt. For this purpose, a pulley or tensioner is used. An idler pulley
is a device that held the belt in place tightly to avoid slipping. We have used a 20
X and Y-axis Clamps: x-axis and y-axis clamps are used to mount x and y stepper
Pen Holder: Pen holder is also 3d printed part. It consists of support for the
28
29
CHAPTER 4
4 Software Description
Software provide a set of instructions to the physical hardware developed, to perform the
specific job. In CNC working methodology a variety of software can be used to perform a
task such as to generate G-code, pass the instructions to controller and process them.
4.1 G-Code
for CNC to communicate with machine tools. Codes vary depending on the type and
construction of machine. G-code are preparatory codes and stand for ‘geometric codes’.
The name G-code implies because each instruction starts with the symbol G. Commands
under G-code are like positioning, speed of positioning, linear feed, tool offsets. It tells
Coordinate switching
It is one component of CNC whereas other codes are also used in conjunction to perform
a task.
30
To write a G-code program a programmer must have wide knowledge of machine actions
and the limits of machine tools. At first, the machining parameters are decided. Second,
the optimal sequence of procedure is measured. Third, the tool path is computed. Fourth,
a program is written. G-code interpreters are case sensitive and whole program is in
G-code is not easily readable by human but it is quite easy to look at the program and
know how it all working. Here is an example: G0 X22 Y10. This command makes the
tool to move at maximum speed to the coordinate following the G0. Similarly, for G1 the
feed rate of tool is specified which means the tool moves with specified speed. For
example,
G1 X22 Y10 F540, where feed is in mm/min or in/min. G2 and G3 are used to specify the
The general methodology of CNC is that machine tool for example, a cutting tool follows
the instructions and moves accordingly to cut away unnecessary stuff leaving only useful.
The same idea is behind the non-cutting tools such as brushing, plotting and 3D printing.
31
G10 Programmable Data Input
G17 XY plane selection
G18 ZX plane selection
G19 YZ plane selection
G28 Return to machine zero
G33 Thread cutting, constant lead
G40 Cancel tool nose radius compensation
G41 Tool nose radius compensation - left
G42 Tool nose radius compensation - right
G43 Cutter length compensation
G44 Cancel cutter length compensation
G50 Define maximum spindle speed
G70 Dimensions in inches
G71 Metric dimensions
G90 Absolute dimensions
G91 Incremental dimensions
G94 Feed rate/min
G95 Feed rate /rev
G-codes are modeled to use multiples code in same line and also to differentiate the
codes that can’t be used together to avoid over riding. These groups are as follows:
Group 1 (motion): G00, G01, G02, G03, G80, G81, G82, G83, G84, G85, G86,
N: Line number, to label codes lines with an increment of 5 for easy understanding
X: Horizontal position
Y: Vertical Position
Z: only use two symbols, Z1 for up movement and Z-1 for down movement
F: Feed rate
M: Miscellaneous Functions
When the programming is complete a series of functions are used to stop and reset the
33
M09 Coolant off
M10 Clamp
M11 Unclamp
G-code programming is easy to learn and understand for beginners. But, writing a g-code
program even for a simple square is quite difficult, time consuming and challenging.
Fortunately, there is software that can generate g-code of any user desired picture. This
software is “Inkscape”. For example, we want to get g-code of a written text, following
Properties”. Change the dimension from px to mm. Also adjust height and width
of the area. When we close this window a square drawing area appears on screen.
Saving as g-code: Inkscape can’t save files as g-code on its own. It is required to
files as g-code.
34
4.1.3 Example G-code
For instance, we want to draw a square box with following dimensions as shown in Fig
4.1:
M5 (servo up)
G4 P1 (delay)
G1 F1800.00000
35
G1 X20.1406 Y99.8594 (from point 1 to 2 with pen down)
M5 (pen up)
G4 P1
G1 F3000
G1 X0 Y0 (back to point 1)
It is used to send g-code to Arduino board through grbl. Arduino is a best software that is
specially designed for such projects used with Arduino boards. The program can be
written in C or C++ language. Program is written in fully optimized C language and then
executed to interface and run through the Arduino boards. Program and coding for this
project is not much. As most of Arduino libraries are used. These libraries are open
source and can be used and modify as desired under the public license.
4.3 GRBL
The g-code file is uploaded to Arduino by grbl. Grbl is commonly used for stepper
motors but as we are using servo motor, grbl servo master is necessary to be installed. It
runs on an Arduino with Atmega 328 controller. It supports all primary g-code functions
as well as full support for arcs, helical and circular motion. It also has ability to look
ahead at future commands to predict velocity for jitter free and smooth motion.
Set the maximum S value by using command $30= any number upto 255
36
The baud rate is set to 115200 bps and connect using Arduino serial monitor. A welcome
message grbl 0.9i [‘$’ for help], appears which assures the correct working.
The proper scale for drawing is not stored in grbl, so it needs to be set it before starting
drawing. All settings can be accessed from the command tab of UGS by typing $$. These
are system settings that are persistent and stored in EEPROM of Arduino. Check for $100
and $101 commands, that define the number of steps that the machine will go for 1mm.
For a 200-step motor, GT2 timing belt and 20 teeth pulley the correct number of steps is
80. If the value is correct the machine will draw accurately according to inkscape
dimension.
Written libraries and standard directives are used to organize and control the motion.
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <avr/interrupt.h>
#include <avr/wdt.h>
#include <util/delay.h>
#include <math.h>
#include <inttypes.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <config.h>
#include <coolant_control.h>
37
#include <cpu_map.h>
#include <defaults.h>
#include <eeprom.h>
#include <gcode.h>
#include <grbl.h>
#include <limits.h>
#include <motion_control.h>
#include <nuts_bolts.h>
#include <planner.h>
#include <print.h>
#include <probe.h>
#include <protocol.h>
#include <report.h>
#include <serial.h>
#include <settings.h>
#include <spindle_control.h>
#include <stepper.h>
#include <system.h>
#endif
Program codes are written in C language and compiled with AVR compiler. GRBL
library is standard motion control library, that is used in this project. It is an open source
library and can be modified easily. Standard motion control library is used in this project
38
that is GRBL library. GRBL is an open source library and can be modified. So, it is
modified according requirements of the project. Code is basically consisting of two parts
that is header file and actual code of the project. Header file contains the initialization of
different variables and functions. As per standard format of C libraries. Header files of
GRBL are listed above. C files are uploaded to Arduino to perform basic function
Universal g-code sender is a g-code platform that provide visual inside with color coded
segments. It also provides real time tool position feedback and duration estimation. Latest
versions of UGS requires Java 8 or higher. This application is used to send commands to
machine. It has to do nothing with G-code generation, it has already done by inkscape.
Find the right port for hardware from windows start menu and ‘devices and printers’.
Open the specified hard properties and look for the port number specified as COM30.Use
this port number in the UGS window, select baud rate 115200 bps and firmware ‘grbl’.
UGS can execute commands manually or in file mode. These two methods can be
performed selecting any tab either file mode or machine control [l7].
File Mode: In file mode, a complete g-code file is uploaded, saved and sent to the
machine. The software also provides real time tool positioning features like total
commands rows, sent rows, remaining rows and remaining estimated time. At the end of
execution, the total time of duration is displayed in dialog box. Thus, it is very useful
software.
Machine Control: Machine control provide feature of manual control in single steps
using keyboard. It can be done by selecting the ‘Enable Keyboard Movement’ checkbox.
39
On the left side of command window, the machines status is continuously figured out. It
also side by side states the commands work position and machine position to check
40
CHAPTER 5
5 Conclusion
CNC are very versatile and fully automatic machineries. The faster computing
capabilities have made it possible to perform more complex calculations in a short period
of time. CNC machines require an understanding of motion and position for both the
machine and the workpiece. CNC machines require a combination of hardware and
software to perform operations. The hardware is the physical equipment and software
All machining begins with a part program that is the coded commands or sequential
instructions that direct specific machine functions. These commands are interpreted line
by line until all lines are completed. These part programs can be either generated
CNC machines have a machine control unit(MCU) that interprets the numerical
information and helps in guiding the movement of machine. The part program supplies
The Cartesian coordinate system is the most common system describing the motion, it
has three linear axis X Y Z axis. Each axis is supplied with a separate motor and
individual motor drivers for each motor. X Y axis are supplied with stepper motors
whereas Z axis is being supplied with servo motor. stepper motor drivers are open loop
system, motor drivers with micro-stepping mode to minimize torque pulsation and to
increase angular resolution, while servo mechanism is supplied with feedback sensor,
41
The g-code of each picture is transmitted via the serial communication to the Arduino.
Arduino feeds signal in the form of pulses to the motor drivers which in response control
the motor movement. the pen is attached to the Z axis and the pen movement is
controlled by the controlled and precise movement of servo motor and the progress of the
CNC allows motion control in a revolutionary manner. CNC machines are very efficient,
For the time being the machine control system is open loop. By using a positioning
sensor, the close loop feedback system could be implemented. The smoother motion of
rails may be obtained by using ball bearings with lead screws. For further improvements,
more precision with higher resolution could be obtained using more number of steps per
After CNC machines outstanding performance in industry, its work is being enlarged in
terms of speed, by increasing number of axis for higher accuracy, replacement of pen by
CNC machines are under further modifications and in future CNC machines might be
networked or linked together, it means programs may be transferred to the CNC control
from a central location in an office around or around the world. Wireless connectivity
might be applied either by using Bluetooth technology or by internet. The working area
42
could be enlarged. The efficiency could be increased by using the higher rating motors
43
ABBREVIATIONS
44
REFERENCES
[1] S.-H. Suh, S.-K. Kang, D.-H. Chung, and I. Stroud, Thoery and Designs of CNC
Systems. 2008.
[2] https://eng.najah.edu/sites/eng.najah.edu/files/report.pdf
[3] Tao Yu, Tan Liu, Shuzhen Yang, Wenbin Wang “Research on System Theory of
[4] P. Hood-Daniel and J. F. Kelly, Build Your Own CNC Machine. Paul Manning,
2009.
[5] http://www.academia.edu/27429000/Computer_Numerical_Control_CNC_IC
PROFESSIONAL_TRAINING_SERIES
[7] W. Bosshart, Printed circuit boards. New Delhi: Tata McGrawHill, 1983.
9780831133474.
[9] F.W. Liou, "Rapid Prototyping and Engineering Applications: A Toolbox for
[10] B.K. Haldar, "CNC Tool Path Generation for Free-Form Surface Machining",
thesis submitted in partial fulfilment of the requirement for the degree of master
45
of production engineering, Faculty of Engineering and Technology, Jadavpur
University, 2010.
[11] J.F. Kelly, "3D Printing: Build Your Own 3D Printer and Print Your Own
[13] https://www.elprocus.com/stepper-motor-types-advantages-applications/
[14] https://www.rs-online.com/designspark/stepper-motors-and-drives-what-is-full-
step-half-step-and-microstepping
[16] https://www.mediafire.com/file/wxsy99vzdu6dlvg/MIGRBL.zip
[17] https://jtechphotonics.com/?p=4910
46