Download as pdf or txt
Download as pdf or txt
You are on page 1of 49

SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

A
Project Report On
2D CNC PEN PLOTTER MACHINE

Prepared by
Vrajesh shah (D20DCS174)
Kushal vadhar (D20DCS184)

Under the Supervision of


Prof. AISHWARIYA BUDHRANI
Submitted to
Charotar University of Science & Technology (CHARUSAT)
for the Partial Fulfillment of the Requirements for the
Degree of Bachelor of Technology
in Computer Science &Engineering
CE244 – Software Group Project-I
of 3rd Semester of B.Tech CSE

Submitted to

Accredited with Grade A by NAAC


Accredited with Grade A by KCG

DEPSTAR

1|Page
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

CERTIFICATE

This is to certify that the report entitled “2d CNC PEN PLOTTER
MACHINE ” is a bonafied work carried out by Vrajesh shah (D20DCS174) &
Kushal vadhar( D20DCS184) under the guidance and supervision of Prof.
Aishwariya Budhrani for the subject CE244 Software Group Project-I (CE) of 3rd
Semester of Bachelor of Technology in DEPSTAR at Faculty of Technology &
Engineering – CHARUSAT, Gujarat.

The best of my knowledge and belief, this work embodies the work
of candidate himself, has duly been completed, and fulfills the requirement of the
ordinance relating to the B.Tech. Degree of the University and is up to the standard
in respect of content, presentation and language for being referred to the examiner.

2|Page
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

ACKNOWLEDGEMENT
The presentation of this report gives us the feeling of fulfilment .
With immense pleasure we would like to present this report on this
Dissertation report of “2D CNC PEN PLOTTER MACHINE”.

The success of any task relies on the efforts made by person but it
cannot be achieved without cooperation of other persons which are being
helpful. So, we would like to thank DEPSTAR for giving us the
opportunity of doing this project.

The entire session of our phase I completion was a great experience


providing us with the insight & invocation into learning various software
engineering concepts & benefits of team work. We would like to take this
opportunity to express our sincere thanks to all those people without
whose support and co-operation, it would have been difficult to complete
this project.

3|Page
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

ABSTRACT

This project shows how to design and building low cost Arduino plotter
machine based on the open source hardware and software. The Arduino plotter
machine has been dependent on the principle of Computer Numerical Control with
limited area depends on the motion X, Y and Z axes. The objectives of this project
are to design the Plotter and to develop open source software for control the machine.
Basically, the system of this plotter machine is modeling by solid work software to
work with three axes stepper motors (as X, Y and Z axes), these three stepper motors
are controlled by shield for movement (X, Y and Z axes). This machine’s movement
on the X axis is 215 mm and Y axis is 235 mm. Length of travel means the linear
movement of stepper motors that control for X, Y and Z axes from point to another
point. The left and right movement controlled by X axis stepper motor, front-back
movement controlled by Y axis stepper motor and the pen is up-down that is
controlled by Z axis stepper motor.

4|Page
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

Table of Contents
Chapter 1 Introduction……………………………………………………………6-10
Chapter 2 Project Management………………………………………………….11-16
Chapter 3 System requirement study…………………………………….………17-19
Chapter 4 System analysis……………………………………………………….20-26
Chapter 5 system design…………………………………..……………………..27-41
Chapter 6 system implementation and testing…………………………..……….41-42
Chapter 7 future enhancement…………………………..……………………….43-44
Chapter 8 conclusion and references………...…………………………………..45-47

5|Page
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

CHAPTER 1: INTRODUCTION

6|Page
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

1.1 PROJECT OVERVIEW

INTRODUCTION
CNC stands for Computer Numerical Control and typically refers to a machine whose operation is
controlled by a computer . It also is a specialized and versatile form of a Soft Automation and its
applications cover many kinds, although it was initially developed to control the motion and
operation of machine tools. A CNC machine takes codes from a computer and converts the code
using software into electrical signals. The signals from the computer are then used to control
motors. Since the motors can turn very small amounts the machine is able to move in highly
precise movements over and over again .There are many types of CNC machine. The common
CNC machines are two-axis and three-axis CNC machine. The two- axis machine can move on
vertical and horizontal only which are X and Y axis. Three-axis machine can do movement
starting with three primary axis which are X, Y and Z axis. The Z axis is being parallel with the
spindle. By controlling a CNC machine through a PC it is possible for the user to design a product
on-screen , convert it to CNC-readable code and then send that data to CNC machine for it to
produce a physical copy of the item designed.

Mini CNC plotter machine is described as it is based on Arduino controller and CNC shield. CNC
is computer numerical control machine. G codes are preparatory Function. G codes are pre-define
Function Associated with the movement on machine axes. In CNC Plotter Machine only G codes
are used. G codes are giving the Direction to move the pen in X, Y directions .Pen can be changed
by tools of drilling, laser cutting tool, milling it can be worked, if it is made in large size. The aim
of over is to make a mini CNC plotter machine which is capable to draw difficult design in paper
or surface of metal, To cut it with a great accuracy .We have used stepper motors with lead screw
in Cartesian coordinate X,Y directions. Stepper motor is convert digital pulse into lead screw
rotations. Stepper drivers are used to give command to the system. The main aim is to fabricate a
Mini CNC plotter Machine to draw an object with using G codes. We also work on to reduced
cost of the project and increase Reliability and Flexibility. In we have replace pen with mechanical
tools drilling, grinding, machining etc. This will be used for soft material cutting or machining,
laser cutting machine tool is also worked on this setup. We have reduced the cost, in the setup of
mini CNC plotter machine.

Computer Numerical Control takes digitized data, a computer and CAM program is used to
control, automate, and monitor the movements of a machine. The machine can be a milling
machine, lathe, welder, grinder, laser, sheet metal stamping machine, robot, or many other types
of machines. For larger industrial machines, the computer is generally an on-board dedicated
controller. But for more hobbyist types of machines, or with some retrofits, the computer can be
an external PC. The CNC controller works together with a series of motors and drive components
to move and control the machine axes, executing the programmed motions. On the industrial

7|Page
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

machines there is usually a sophisticated feedback system that constantly monitors and adjusts the
cutter's speed and position.

CAM

Computer Aided Machining or Manufacturing



Refers to the use of various software packages to create tool paths and NC code to run a CNC
controlled machine ,based on 2D or 3D computer model. CAM does not actually run the CNC
machine but just creates code for it to follow.

CNC code

A special relatively simple computer language that a CNC machine can understand and execute.
These languages were originally developed to program parts directly at the machine keyboard
without the aid of a CAM program. They tell the machine what moves to execute, one by one, as
well as controlling other machine functions such as spindle and feed speeds, coolant. The most
common language is G

8|Page
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

1.2OBJECTIVE
The objectives of this project are to design the CNC Plotter Machine and to
develop open source software and hardware to control it.
The main objective of this project is to provide plotting operation as an alternative
for traditional manual operations done by manually operated mechanism.

9|Page
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

1.3 SCOPE
The pen of machine can be replace with laser to make it work like a laser engraving
or cutting machine. The engraving machine can be used on wood. The pen can be
also be replace with a powerful drill machine so that it can be used for both milling
and drilling purpose. The servo motor can be replace with a stepper motor and the
pen with 3D pen to make the 3D printer which can print objects with dimension. And
by extrapolation of the axes, the working area of the machine can be extended
keeping with the algorithm unaltered.

1.4 TOOLS & TECHNOLOGY USED


1.4.1 HARDWARE TOOLS
• stepper motor
• arduino uno r3
• l293d motor driver
• servo motor
• 12v charger a adapter
• jumper wires
• wood base

1.4.2 SOFTWARE TOOLS


• ARDUINO IDE
• INKSCAPE
• PROCESSING
• G-CODE
• GRBL CONTROLLER

10 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

CHAPTER 2: PROJECT MANAGEMENT

11 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

2.1 PROJECT PLANNING


Step 1: we purchasing an Arduino , Stepper motors, servo motors, jumper wires
,motor driver.

Step 2: X and Y axis of our CNC machine. Attach it on your surface, in this part you
will need some screws and nuts the X and Y axis. The X axis is attached to two
plastic parts that I took from remaining 'garbage' stuff. I cut it to fit the construction.
This is an easy procedure. Just make sure to put the Y axis straight to CNC base and
the X axis vertically in this (90 degrees)

Step 3: The Z axis That's the most difficult part of our construction. You will need
something to attach it on X axis, a flat surface. On that surface you will attach the
servo motor (Z axis) and the pen base. Pen (or pencil) must be able to move up and
down with the help of servo motor .Watch the above image to understand what you
need to do to build Z axis Image Notes 1. Servo motor must be able to move up and
down the pen.

Step 4: :Paper base Now you will have to attach a wood (or plastic) surface on Y axis
(5x5cm will be fine).On this you will put the paper piece to print your texts or images
Remember, printing area is a4 size.
Step 5: The Circuit

Step 6: Testing X and Y axis movement


Here is the X and Y axis testing code embedded using code bender For X axis: For Y
axis: If you see any movement here that means that the stepper motors wiring is
correct! if you don't, try to change the cables.

Step 7: : Uploading the CNC code


Here is the main CNC code embedded using code bender In this part you will see
your pen goes up. If don't, change pen Up and pen Down variables that controlling
the servo motor. Press the "Run on Arduino" button and program your board from
your browser!

12 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

Step 8: The GCTRL program


Now we are ready to print our first image! To do this we will use the gctrl.pde
processing program. This program sends 'G code' images to the CNC plotter. What is
G code? G code is a file with X,Y and Z coordinates. Header of this file is set to:
M300 S30.00 (Servo down) G1 X10.00 Y10.00 F2500.00 G1 X20.00 Y10.00
F2500.00 M300 S50.00 (Servo up) Download Processing from here, now download
and open GCTRL.pde application. Click the "play" icon/button to start the program.
~Watch the above image~ Now press 'p' and select your Arduino serial port. Press 'g'
and select the 'drawing g code' file.

Step 9 : Make your own G code file


To make g code files that are compatible with this CNC machine you have to use the
Inkscape. Inkscape is professional quality vector graphics software which runs on
Windows, Mac OS X and Linux. It is used by design professionals and hobbyists
worldwide, for creating a wide variety of graphics such as illustrations, icons, logos,
diagrams, maps and web graphics. Inkscape uses the W3C open standard SVG
(Scalable Vector Graphics) as its native format, and is free and open-source software.
Download and install Inkscape from here (Important: download 0.48.5 version) Now
you need to install an Add-on that enables the export images to g code files. This add
on can be found here with installation notes. Setup Inkscape for first use Open the
Inkscape, go to File menu and click "Document Properties". See the 1st image above
and make the changes, make sure to change first to "cm". Now close this window.
We will use the area within 4 to 8 cm. See the 2nd image above. How to print texts
Put text, change font to Times New Roman and size to 22. Now click on cursor icon
and center the text like the 3rd image above. Select Path from menu and "Object to
Path". How to print images This is more difficult than texts. Images must have a
transparent background. Drag and drop the arduino logo image (download it from
files) in Inkscape. Click ok to the next window. Now you have to re-size the image to
fit our printing area, see the 4th image above. Click Path from menu and "Trace
Bitmap". Make changes as the 5th image above. Click ok and close the window.
Now, move the gray scale image, and delete the color one behind it. Move the grey
image to the correct place again and click from Path menu "Object to path". The 6th
image above show how to delete image outline. Export as g code Final, go to file
menu, click save as and select g code. Click ok on next window. That's it! Ready to
go! Use the gctrl.pde app to print the g code file on your new Arduino CNC Plotter!

13 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

2.1.1 Project Development Approach and Justification


In today's days scenario CNC is widely used in worldwide . As it is used worldwide
the cost of 3D CNC model is very much. So taking this initiate to making this
project of 2D CNC pen plotting machine in very less cost . And in future we are
planning on making the 3D CNC model in effective and in less cost.

Justification

CNC machines deliver a production capacity ideal for creating large quantities of
items which require accurate, consistent, complex cuts. The advantages of this
method of manufacturing has led many companies to completely replace engineer-
operated equipment with the efficient, tireless precision of automated machines.
By solving As it is used worldwide the cost of 3D CNC model is very much. So
taking this initiate to making this project of 2D CNC pen plotting machine in very
less cost . And in future we are planning on making the 3D CNC model in effective
and in less cost.

CNC machines are more expensive and require a greater initial investment than
machines that can be operated manually. However, as this technology becomes the
standard, supply is increasing resulting in costs gradually decreasing.

2.1.2 Project Effort and Time, Cost Estimation

EFFORT
As we are members of this project we got the idea of the project from a friend by
visiting the company And there we saw a cnc machine. That time we saw a cnc
machine and we thought that we could make it . As we had base knowledge of the
Arduino. We tried our best making the project successful. And we thought of this
project as 3D cnc model cost is very much and by making one in future in low cost
could be effective . So we started with the 2D cnc model . And we had research about
this topic and reference from open source programs
14 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

Time
Development time : 1.5 months
TIME : Weekend – 8-9 hours

Cost estimation
Arduino uno 400
R3
Stepper motor 200
(70 mm)
L293D 190
(MOTOR
DRIVER IC)
Servo motor 1800
(180
rotation)*2
Jumper wires 100

Drawer 1200
channel *3
Wood Base 400
Steel base 500
PEN 20
Handle for 75
pen

15 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

2.2 PROJECT WORK SCHEDULING

Task name Duration Start Finish Resource


name
1 2d cnc pen plotter 42 days Thu Wed Laptop
26/11/2020 06/1/2021 ,manpower
2 Survey and analysis of 02 26/11/2020 27/11/2020 Laptop .
project
3 analysis of proposed 03 28/11/2020 30/11/2020 Laptop ,
system Manpo44wer
4 Coding 10 1/12/2020 10/12/2020 Arduino
,laptop
5 Modelling 05 11/12/2020 15/12/2020 Previous
mention
components
and laptop.
6 Testing and error 15 15/12/2020 30/12/2020 Previous
solving mention
components
and laptop.
7 Real time testing 05 1/1/2021 5/1/2021 Previous
mention
components
and laptop.

16 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

CHAPTER 3: SYSTEM REQUIREMENTS STUDY

17 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

3.1 USER CHARACTERISTICS

3.1.1 Use Case Diagram

18 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

3.2 HARDWARE AND SOFTWARE REQUIREMENTS

HARDWARE REQUIREMENTS
-ARDUINO UNO R3
-SERVO MOTOR
-STEPPER MOTOR
-L293D (MOTOR DRIVER IC)
-12V ADAPTER

SOFTWARE REQUIREMENTS
-ARDUINO IDE
-INKSCAPE
-PROCESSING
-G-CODE
-GRBL CONTROLLER

3.3 ASSUMPTIONS AND CONSTRAINTS

ASSUMPTIONS

-Constant Use With Minimal Maintenance.


-Precision. The precision of a machine refers to how fine a tolerance it can produce.
-Accuracy
-Versatility
-Size Limitations of CNC
-Operator Error.
-It's an open source program and thus a free one, it supports various kinds of ----------
-hardware and configurations and it's very easy to use.
-The stepper motor never misses any step. Hence the whole operation is reliable.
-Through inkscap software we can very easily generate gcode.
-The whole project is cheaper and can be easily constructed through used parts of -
hardware form computers.
CONSTRAINTS

1.Apart from the great advantages, there are major limitations too for Mini CNC
PLOTTER 1. As per the size and capacity of the project, it can't operate in larger
load applications and cutting forces as well. It cannot withstand higher cutting forces
while cutting and the higher weight of cutting tools as well.

2. Because of the circuit used the shapes that can be draft are limited. Arduino Uno
capacity is limited up-to limited shapes considering of Grbl software used as well.

19 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

3. The maximum height of the cd-drive carriage is limited up to 50-60 mm. Hence
3D projects can be small dimensions only.

4. Less workers are required to operate CNC machines compared to manually


operated machines. Investment in CNC machines can lead to unemployment.

CHAPTER 4: SYSTEM ANALYSIS

20 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

4.1 STUDY OF PROPOSED SOLUTION


Nowadays, technology is getting advanced with a lot of things become smaller and
thinner. This project is about to overcome the problem of machining the small part of
work.
CNC machine builds up with simple mechanical assembly so if we are able to add
more hardware and enhance the effective code for programming help it to use over
broad areas. They are flexible and give accurate results, so provides better
performance facilities over long period of time and save human labour. So , install
ARDUINO IDE ,INKSCAPE ,PROCESSING ,G-CODE.

Software side

ARDUINO IDE-
The Arduino IDE Is a cross-platform application written in java, and is derived from
the IDE for the processing programming language .It is designed to introduce
programming to artists and other newcomers unfamiliar with software development
.It includes a code editor with features such as syntax high lighting ,brace matching,
and automatic identification .and is also capable of compiling and uploading
programs to the board with a single click .There is typically no need to edit make
files or run programs on a command-line interface. The Arduino IDE comes with a
C/C++ library,which makesmany common input/output operation much easier.
Arduino programs are written in C/C++,although users only need define two
functions to make a run able program

Setup()-a function run once at the start of a program that can initialize settings
Loop()-a function called repeatedly until the board powers off

INKSCAPE

21 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

Inkscape is used to design the plotted diagram or text. In this project by using this
software G-code file of a selected image or text is created. G-code is a commonly
used numerical control programming language which includes X, Y, Z coordinates.

PROCESSING
Processing is open source programming language software which is used for
electronic drawings. GTCRL processing program is used to send G-code file from
user interface to CNC plotter. The Fig shows the user interface of processing
software after running GTCRL program. The port of Arduino nano is selected by
press in.
g „P‟ button on keyboard hence ―G‟ button is used to upload our desired G
-code file. Immediately CNC machine will start sketching selected G-code file.
Sketching can be stopped by pressing ―X‟ button.

G-CODE :

To draw a text file or design a circuit layout by the CNC plotter firstly the files need
to be converted into G-Code. G-Code is a set of instruction that contains number of
X, Y, Z, coordinates depending on the file. G-Code instructs X axis of the machine to
travel fromX1 to X2 points with a specific speed and same is true for Y axis, but for
Z axis the coordinates are fixed because only vertically up & down movements are
involved. G-code is a type of function used in Numerical Control programming
language that contains the information to position a tool to do actual work. G-code is
separate from M-code and T-code, codes that control the machine and tooling.
Although G-code as after m is often used interchangeably with Numerical Control
(NC), it is actually only one component and works in conjunction with other codes to
perform the appropriate tasks. The standard version of G-code is known as RS-274D,
although other versions do exist for CNC machines with compatibility issues.

Hardware side
Arduino Uno r3
The Arduino Uno is an open-source microcontroller board based on the Microchip
ATmega328P microcontroller and developed by Arduino.cc. The board is equipped
with sets of digital and analog input/output pins that may be interfaced to various
expansion boards and other circuits.

22 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

SERVO MOTOR
A servo motor shown in figure is used for the movement of sketching pen in up and
down. This will help the CNC 2D sketcher to point the pen in A4 sheet and with
drawing it from the sheet to stop drawing. Servo motors are not actually a specific
class of motor but are a combination of specific parts, which happen to include a DC
or AC motor, and are suitable for use in a closed-loop control system. They are used
in robotics, automated manufacturing and computer numerical control (CNC)
machining applications .The servo motor is a closed-loop servomechanism that uses
position feedback in order to control its rotational speed and position. The control
signal is the input, either analog or digital, which represents the final position
command for the shaft. A type of encoder serves as a sensor, providing speed and
position feedback. In most cases, only the position is reported. The final position is
reported to the controller and this is compared to the initial position input, and then if
there is a discrepancy, the motor is moved in order to get to the correct position .The
simplest servo motors use DC motors and position sensing through a potentiometer
and also use big-bang control, which means that the motor moves at maximum speed
until it stops at the designated position or is stopped. This is not widely used in
industrial motion control as it can be quite inaccurate, but these kinds of servo motors
are popular in radio-controlled devices such as model aircraft and toy cars.
Sophisticated servomotors for industrial use have both position and speed sensing as
well as implement proportional-integral-derivative control algorithms, allowing the
motor to be brought to its position quickly and precisely without overshooting, as the
speed of the shaft can also be controlled.

23 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

STEPPER MOTOR
A stepper motor is an electromechanical device it converts electrical power into
mechanical power. Also it is a brushless, synchronous electric motor that can divide a
full rotation into an expansive number of steps. The motor‘s position can be
controlled accurately without any feedback mechanism, as long as the motor is
carefully sized to the application. Stepper motors are similar to switched reluctance
motors. The stepper motor uses the theory of operation for magnets to make the
motor shaft turn a precise distance when a pulse of electricity is provided. The stator
has eight poles, and the rotor has six poles. The rotor will require 24 pulses of
electricity to move the 24 steps to make one complete revolution. Another way to say
this is that the rotor will move precisely 15° foreach pulse of electricity that the
motor receives.

24 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

L293D (MOTOR DRIVER IC)

L293D is a 16-pin IC which can control a set of two DC motors simultaneously in


any direction. It means that you can control two DC motor with a single L293D IC.In
a single L293D chip there are two h-Bridge circuit inside the IC which can rotate two
dc motor independently.

12V ADAPTER
A 12V adapter as a power supply to run the CNC machine. This adapter enables to
run the microcontroller, servo motor and stepper motor to perform the required
drawing.

25 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

Process
Uploading the CNC code Here is the main CNC code embedded using code bender
In this part you will see your pen goes up. If don't, change pen Up and pen Down
variables that controlling the servo motor. Press the "Run on Arduino" button and
program your board from your browser!

• The GCTRL program Now


we are ready to print our first image! To do this we will use the gctrl.pde
processing program. This program sends 'G code' images to the CNC plotter.
What is G code? G code is a file with X,Y and Z coordinates. Header of this
file is set to: M300 S30.00 (Servo down) G1 X10.00 Y10.00 F2500.00 G1
X20.00 Y10.00 F2500.00 M300 S50.00 (Servo up) Download Processing from
here, now download and open GCTRL.pde application. Click the "play"
icon/button to start the program. ~Watch the above image~ Now press 'p' and
select your Arduino serial port. Press 'g' and select the 'drawing g code' file

• Make your own G code file


To make g code files that are compatible with this CNC machine you have to
use the Inkscape. Inkscape is professional quality vector graphics software
which runs on Windows, Mac OS X and Linux. It is used by design
professionals and hobbyists worldwide, for creating a wide variety of graphics
such as illustrations, icons, logos, diagrams, maps and web graphics. Inkscape
uses the W3C open standard SVG (Scalable Vector Graphics) as its native
format, and is free and open-source software. Download and install Inkscape
from here (Important: download 0.48.5 version) Now you need to install an
Add-on that enables the export images to g code files. This add on can be
found here with installation notes. Setup Inkscape for first use Open the
Inkscape, go to File menu and click "Document Properties". See the 1st image
above and make the changes, make sure to change first to "cm". Now close
this window. We will use the area within 4 to 8 cm. See the 2nd image above.
How to print texts Put text, change font to Times New Roman and size to 22.
Now click on cursor icon and center the text like the 3rd image above. Select
Path from menu and "Object to Path". How to print images This is more
difficult than texts. Images must have a transparent background. Drag and drop
the Arduino logo image (download it from files) in Inkscape. Click ok to the
next window. Now you have to re-size the image to fit our printing area, see
the 4th image above. Click Path from menu and "Trace Bitmap". Make
changes as the 5th image above. Click ok and close the window. Now, move
the gray scale image, and delete the color one behind it. Move the grey image
to the correct place again and click from Path menu "Object to path". The 6th
image above show how to delete image outline. Export as g code Final, go to
file menu, click save as and select g code. Click ok on next window. That's it!

26 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

Ready to go! Use the gctrl.pde app to print the g code file on your new
Arduino CNC Plotter!

27 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

CHAPTER 5: SYSTEM DESIGN

28 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

5.1 REAL TIME WORK


https://drive.google.com/drive/folders/1tezxEiMLheVel3hP_Vzf_stAA30bifmc

5.2 CODE
#include <Servo.h>
#include <AFMotor.h>

#define LINE_BUFFER_LENGTH 512

char STEP = MICROSTEP ;

// Servo position for Up and Down


const int penZUp = 140;
const int penZDown = 165;

// Servo on PWM pin 10


const int penServoPin =10 ;

// Should be right for DVD steppers, but is not too important here
const int stepsPerRevolution = 48;

// create servo object to control a servo


Servo penServo;

// Initialize steppers for X- and Y-axis using this Arduino pins for the L293D H-
bridge
AF_Stepper myStepperY(stepsPerRevolution,1);
AF_Stepper myStepperX(stepsPerRevolution,2);

/* Structures, global variables */


struct point {
float x;
float y;
float z;
};

// Current position of plothead

29 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

struct point actuatorPos;

// Drawing settings, should be OK


float StepInc = 1;
int StepDelay = 1;
int LineDelay =0;
int penDelay = 50;

// Motor steps to go 1 millimeter.


// Use test sketch to go 100 steps. Measure the length of line.
// Calculate steps per mm. Enter here.
float StepsPerMillimeterX = 100.0;
float StepsPerMillimeterY = 100.0;

// Drawing robot limits, in mm


// OK to start with. Could go up to 50 mm if calibrated well.
float Xmin = 0;
float Xmax = 40;
float Ymin = 0;
float Ymax = 40;
float Zmin = 0;
float Zmax = 1;

float Xpos = Xmin;


float Ypos = Ymin;
float Zpos = Zmax;

// Set to true to get debug output.


boolean verbose = false;

// Needs to interpret
// G1 for moving
// G4 P300 (wait 150ms)
// M300 S30 (pen down)
// M300 S50 (pen up)
// Discard anything with a (
// Discard any other command!

/**********************
* void setup() - Initialisations
***********************/
void setup() {
// Setup

30 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

Serial.begin( 9600 );

penServo.attach(penServoPin);
penServo.write(penZUp);
delay(100);

// Decrease if necessary
myStepperX.setSpeed(600);

myStepperY.setSpeed(600);

// Set & move to initial default position


// TBD

// Notifications!!!
Serial.println("Mini CNC Plotter alive and kicking!");
Serial.print("X range is from ");
Serial.print(Xmin);
Serial.print(" to ");
Serial.print(Xmax);
Serial.println(" mm.");
Serial.print("Y range is from ");
Serial.print(Ymin);
Serial.print(" to ");
Serial.print(Ymax);
Serial.println(" mm.");
}

/**********************
* void loop() - Main loop
***********************/
void loop()
{

delay(100);
char line[ LINE_BUFFER_LENGTH ];
char c;
int lineIndex;
bool lineIsComment, lineSemiColon;

lineIndex = 0;
lineSemiColon = false;
lineIsComment = false;
31 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

while (1) {

// Serial reception - Mostly from Grbl, added semicolon support


while ( Serial.available()>0 ) {
c = Serial.read();
if (( c == '\n') || (c == '\r') ) { // End of line reached
if ( lineIndex > 0 ) { // Line is complete. Then execute!
line[ lineIndex ] = '\0'; // Terminate string
if (verbose) {
Serial.print( "Received : ");
Serial.println( line );
}
processIncomingLine( line, lineIndex );
lineIndex = 0;
}
else {
// Empty or comment line. Skip block.
}
lineIsComment = false;
lineSemiColon = false;
Serial.println("ok");
}
else {
if ( (lineIsComment) || (lineSemiColon) ) { // Throw away all comment
characters
if ( c == ')' ) lineIsComment = false; // End of comment. Resume line.
}
else {
if ( c <= ' ' ) { // Throw away whitepace and control characters
}
else if ( c == '/' ) { // Block delete not supported. Ignore character.
}
else if ( c == '(' ) { // Enable comments flag and ignore all
characters until ')' or EOL.
lineIsComment = true;
}
else if ( c == ';' ) {
lineSemiColon = true;
}
else if ( lineIndex >= LINE_BUFFER_LENGTH-1 ) {
Serial.println( "ERROR - lineBuffer overflow" );
lineIsComment = false;
lineSemiColon = false;
32 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

}
else if ( c >= 'a' && c <= 'z' ) { // Upcase lowercase
line[ lineIndex++ ] = c-'a'+'A';
}
else {
line[ lineIndex++ ] = c;
}
}
}
}
}
}

void processIncomingLine( char* line, int charNB ) {


int currentIndex = 0;
char buffer[ 64 ]; // Hope that 64 is enough for 1 parameter
struct point newPos;

newPos.x = 0.0;
newPos.y = 0.0;

// Needs to interpret
// G1 for moving
// G4 P300 (wait 150ms)
// G1 X60 Y30
// G1 X30 Y50
// M300 S30 (pen down)
// M300 S50 (pen up)
// Discard anything with a (
// Discard any other command!

while( currentIndex < charNB ) {


switch ( line[ currentIndex++ ] ) { // Select command, if any
case 'U':
penUp();
break;
case 'D':
penDown();
break;
case 'G':
buffer[0] = line[ currentIndex++ ]; // /!\ Dirty - Only works with 2 digit
commands
// buffer[1] = line[ currentIndex++ ];
// buffer[2] = '\0';
33 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

buffer[1] = '\0';

switch ( atoi( buffer ) ){ // Select G command


case 0: // G00 & G01 - Movement or fast movement. Same
here
case 1:
// /!\ Dirty - Suppose that X is before Y
char* indexX = strchr( line+currentIndex, 'X' ); // Get X/Y position in the string
(if any)
char* indexY = strchr( line+currentIndex, 'Y' );
if ( indexY <= 0 ) {
newPos.x = atof( indexX + 1);
newPos.y = actuatorPos.y;
}
else if ( indexX <= 0 ) {
newPos.y = atof( indexY + 1);
newPos.x = actuatorPos.x;
}
else {
newPos.y = atof( indexY + 1);
indexY = '\0';
newPos.x = atof( indexX + 1);
}
drawLine(newPos.x, newPos.y );
// Serial.println("ok");
actuatorPos.x = newPos.x;
actuatorPos.y = newPos.y;
break;
}
break;
case 'M':
buffer[0] = line[ currentIndex++ ]; // /!\ Dirty - Only works with 3 digit
commands
buffer[1] = line[ currentIndex++ ];
buffer[2] = line[ currentIndex++ ];
buffer[3] = '\0';
switch ( atoi( buffer ) ){
case 300:
{
char* indexS = strchr( line+currentIndex, 'S' );
float Spos = atof( indexS + 1);
// Serial.println("ok");
if (Spos == 30) {
penDown();
34 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

}
if (Spos == 50) {
penUp();
}
break;
}
case 114: // M114 - Repport position
Serial.print( "Absolute position : X = " );
Serial.print( actuatorPos.x );
Serial.print( " - Y = " );
Serial.println( actuatorPos.y );
break;
default:
Serial.print( "Command not recognized : M");
Serial.println( buffer );
}
}
}

/*********************************
* Draw a line from (x0;y0) to (x1;y1).
* Bresenham algo from https://www.marginallyclever.com/blog/2013/08/how-to-
build-an-2-axis-arduino-cnc-gcode-interpreter/
* int (x1;y1) : Starting coordinates
* int (x2;y2) : Ending coordinates
**********************************/
void drawLine(float x1, float y1) {

if (verbose)
{
Serial.print("fx1, fy1: ");
Serial.print(x1);
Serial.print(",");
Serial.print(y1);
Serial.println("");
}

// Bring instructions within limits


if (x1 >= Xmax) {
35 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

x1 = Xmax;
}
if (x1 <= Xmin) {
x1 = Xmin;
}
if (y1 >= Ymax) {
y1 = Ymax;
}
if (y1 <= Ymin) {
y1 = Ymin;
}

if (verbose)
{
Serial.print("Xpos, Ypos: ");
Serial.print(Xpos);
Serial.print(",");
Serial.print(Ypos);
Serial.println("");
}

if (verbose)
{
Serial.print("x1, y1: ");
Serial.print(x1);
Serial.print(",");
Serial.print(y1);
Serial.println("");
}

// Convert coordinates to steps


x1 = (int)(x1*StepsPerMillimeterX);
y1 = (int)(y1*StepsPerMillimeterY);
float x0 = Xpos;
float y0 = Ypos;

// Let's find out the change for the coordinates


long dx = abs(x1-x0);
long dy = abs(y1-y0);
int sx = x0<x1 ? StepInc : -StepInc;
int sy = y0<y1 ? StepInc : -StepInc;

long i;
long over = 0;
36 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

if (dx > dy) {


for (i=0; i<dx; ++i) {
myStepperX.onestep(sx,STEP);
over+=dy;
if (over>=dx) {
over-=dx;
myStepperY.onestep(sy,STEP);
}
delay(StepDelay);
}
}
else {
for (i=0; i<dy; ++i) {
myStepperY.onestep(sy,STEP);
over+=dx;
if (over>=dy) {
over-=dy;
myStepperX.onestep(sx,STEP);
}
delay(StepDelay);
}
}

if (verbose)
{
Serial.print("dx, dy:");
Serial.print(dx);
Serial.print(",");
Serial.print(dy);
Serial.println("");
}

if (verbose)
{
Serial.print("Going to (");
Serial.print(x0);
Serial.print(",");
Serial.print(y0);
Serial.println(")");
}

// Delay before any next lines are submitted


delay(LineDelay);
37 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

// Update the positions


Xpos = x1;
Ypos = y1;
}

// Raises pen
void penUp() {
penServo.write(penZUp);
delay(penDelay);
Zpos=Zmax;
digitalWrite(15, LOW);
digitalWrite(16, HIGH);
if (verbose) {
Serial.println("Pen up!");

}
}
// Lowers pen
void penDown() {
penServo.write(penZDown);
delay(penDelay);
Zpos=Zmin;
digitalWrite(15, HIGH);
digitalWrite(16, LOW);
if (verbose) {
Serial.println("Pen down.");

}
}

3-Axis-mini-CNC-machine/gctrl.pde

import java.awt.event.KeyEvent;
import javax.swing.JOptionPane;
import processing.serial.*;

Serial port = null;

// select and modify the appropriate line for your operating system
// leave as null to use interactive port (press 'p' in the program)
String portname = null;
38 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

//String portname = Serial.list()[0]; // Mac OS X


//String portname = "/dev/ttyUSB0"; // Linux
//String portname = "COM6"; // Windows

boolean streaming = false;


float speed = 0.001;
String[] gcode;
int i = 0;

void openSerialPort()
{
if (portname == null) return;
if (port != null) port.stop();

port = new Serial(this, portname, 9600);

port.bufferUntil('\n');
}

void selectSerialPort()
{
String result = (String) JOptionPane.showInputDialog(this,
"Select the serial port that corresponds to your Arduino board.",
"Select serial port",
JOptionPane.PLAIN_MESSAGE,
null,
Serial.list(),
0);

if (result != null) {
portname = result;
openSerialPort();
}
}

void setup()
{
size(500, 250);
openSerialPort();
}

void draw()
{
background(0);
39 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

fill(255);
int y = 24, dy = 12;
text("INSTRUCTIONS", 12, y); y += dy;
text("p: select serial port", 12, y); y += dy;
text("1: set speed to 0.001 inches (1 mil) per jog", 12, y); y += dy;
text("2: set speed to 0.010 inches (10 mil) per jog", 12, y); y += dy;
text("3: set speed to 0.100 inches (100 mil) per jog", 12, y); y += dy;
text("arrow keys: jog in x-y plane", 12, y); y += dy;
text("page up & page down: jog in z axis", 12, y); y += dy;
text("$: display grbl settings", 12, y); y+= dy;
text("h: go home", 12, y); y += dy;
text("0: zero machine (set home to the current location)", 12, y); y += dy;
text("g: stream a g-code file", 12, y); y += dy;
text("x: stop streaming g-code (this is NOT immediate)", 12, y); y += dy;
y = height - dy;
text("current jog speed: " + speed + " inches per step", 12, y); y -= dy;
text("current serial port: " + portname, 12, y); y -= dy;
}

void keyPressed()
{
if (key == '1') speed = 0.001;
if (key == '2') speed = 0.01;
if (key == '3') speed = 0.1;

if (!streaming) {
if (keyCode == LEFT) port.write("G91\nG20\nG00 X-" + speed + " Y0.000
Z0.000\n");
if (keyCode == RIGHT) port.write("G91\nG20\nG00 X" + speed + " Y0.000
Z0.000\n");
if (keyCode == UP) port.write("G91\nG20\nG00 X0.000 Y" + speed + "
Z0.000\n");
if (keyCode == DOWN) port.write("G91\nG20\nG00 X0.000 Y-" + speed + "
Z0.000\n");
if (keyCode == KeyEvent.VK_PAGE_UP) port.write("G91\nG20\nG00 X0.000
Y0.000 Z" + speed + "\n");
if (keyCode == KeyEvent.VK_PAGE_DOWN) port.write("G91\nG20\nG00
X0.000 Y0.000 Z-" + speed + "\n");
if (key == 'h') port.write("G90\nG20\nG00 X0.000 Y0.000 Z0.000\n");
if (key == 'v') port.write("$0=75\n$1=74\n$2=75\n");
//if (key == 'v') port.write("$0=100\n$1=74\n$2=75\n");
if (key == 's') port.write("$3=10\n");
if (key == 'e') port.write("$16=1\n");
if (key == 'd') port.write("$16=0\n");
40 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

if (key == '0') openSerialPort();


if (key == 'p') selectSerialPort();
if (key == '$') port.write("$$\n");
}

if (!streaming && key == 'g') {


gcode = null; i = 0;
File file = null;
println("Loading file...");
selectInput("Select a file to process:", "fileSelected", file);
}

if (key == 'x') streaming = false;


}

void fileSelected(File selection) {


if (selection == null) {
println("Window was closed or the user hit cancel.");
} else {
println("User selected " + selection.getAbsolutePath());
gcode = loadStrings(selection.getAbsolutePath());
if (gcode == null) return;
streaming = true;
stream();
}
}

void stream()
{
if (!streaming) return;

while (true) {
if (i == gcode.length) {
streaming = false;
return;
}

if (gcode[i].trim().length() == 0) i++;
else break;
}

println(gcode[i]);
port.write(gcode[i] + '\n');
i++;
41 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

void serialEvent(Serial p)
{
String s = p.readStringUntil('\n');
println(s.trim());

if (s.trim().startsWith("ok")) stream();
if (s.trim().startsWith("error")) stream(); // XXX: really?
}

https://drive.google.com/drive/folders/1tezxEiMLheVel3hP_Vzf_stAA30bifmc

42 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

CHAPTER 6: SYSTEM IMPLEMENTATION AND


TESTING

43 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

6.1 RESULT

We have used concept of low cost mini 2d CNC plotter machine, which is user
friendly and easy to operate. By using this we can make difficult and complex design
on paper or any writable material. This is small machine which is easily transportable
and assembled everywhere as per requirement .It will be free to make big size of
design on paper. We have used G codes to giving commands. G-codes are language
to give the command to the machine to move right, left or up and down.

i) Text File
A text file has been designed and sent to the CNC plotter for drawing the text. We
can draw any alphabets small or capital letter .The original file and the plotted files
are shown.
A input

B> output

44 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

CHAPTER 7: FUTURE ENHANCEMENT

45 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

FUTURE ENHANCEMENT

The pen of the machine can be replaced by a laser to make it work like a laser
engraving or cutting machine.
The pen can also be replaced with a powerful drill so that it can be used for both
milling and drilling purposes.
The servo can be replaced with a stepper motor and the pen with a 3-D pen to make it
a 3-D printer which can print objects with dimensions.
By extrapolation of the axes, the working area of the machine can be extended
keeping the algorithm unaltered.
A multi station tool can be incorporated in the existing CNC machine.
Automatic clamping mechanism can be installed(Draw bar Mechanism).
Automatic tool changing(ATC) devices using Robotic Arm Technology
By extrapolation of the axes, the working area of the machine can be extended
keeping the algorithm unaltered.
1. Actual industrial CNC milling:

It is planned to scale up the prototype CNC machine in terms of size, use more
powerful motors, strengthen the frame and worktable with materials like aluminum
or cast iron, and augment the CNC control software wilt software for simulation
ahead of actual run. The implementation of 3D printing technology to the same
hardware abstract is going for printing of 3D models.

2. The PCB Mill:

In the manufacturing of précised PCBs (Printed Circuit Board) ie. etching or printing
the conductive paths which connects

46 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

CHAPTER 8
CONCLUSION AND REFERENCES

47 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

CONCLUSION
In this paper we have presented the concept of a low cost three-axis CNC plotter. The
existing CNC machines are of high cost, difficult to maintain and requires highly
skilled operators. Our CNC plotter overcomes these problems. It is of low cost and
easy to control and there is no need of highly skilled operators. It can be used for
long hours at a stretch which is not possible in existing ones. It is hoped to extend
this work for future development. Small drawing machine or CNC was built. It is a
digital electromechanical machine with digital control through a piece of wood and
low cost components. Two main axes (x & y) and a vertical axis (z) were used to
draw image or figure with a specific dimension and speed. This project design was
success prototype design since it can draw any figure or image easily and in a short
time as compared to human drawing time. As per result oriented we can complete
abstract a serial communication based CNC Pen Plotter. 2d Mini CNC Plotter
Machine is an embedded system that works on the Principle on ‘Computer Numeric
control (CNC).CNC is a very popular method of creating parts. These machines offer
extreme precision at a fast rate. CNC machines are very complex and being able to
efficiently operate one takes much time and practice. Although most of the codes are
similar, CNC machines are different from model to model. CNC milling is not easy
at first but mastery of it allows you to create a usable parts in a very short time
frame. In modern CNC systems, end-to-end component design are highly automated
using computer aided design (CAD) and computer-aided manufacturing (CAM)
programs. The programs produce a computer file that is interpreted to extract the
commands needed to operate a particular machine by use of a post processor, and
then loaded into the CNC machines for production. Since any particular component
might require the use of a number of different tools - drills, saws, etc. With the
increasing demand for small scale high precision parts in various industries, the
market for small scale machine tools has grown substantially. Using small machine
tools to fabricate small scale parts can provide both flexibility and efficiency in
manufacturing approaches and reduce capital cost, which is beneficial for small
business owners. In this project, a small scale three axis "2d CNC PEN PLOTTER"
is designed and analyzed under very limited budget.

48 | P a g e
SOFTWARE GROUP PROJECT -I 2D CNC PEN PLOTTER MACHINE

REFERENCES

-https://github.com/beardicus/awesome-plotters
-https://github.com/Tahoor27/3-Axis-mini-CNC-machine
-V.K. Pabolu and K.N.H. Shrinivas, "Design and implementation of a three
dimensional CNC machine", Int. J. Computer Science and Engineering, vol. 2,pp.
2567-2570 2010
-Nae and T. Andrei, "Designing and building a CNC router using stepper
motors", Serial Technical, vo. LXII, pp. 55-62, 2010.
-https://create arduino.cc/projecthub/Yogeshmodi/sketch-it-cnc-ploster-950190

BOOK
Build Your Own CNC Machine (Technology in Action) by Lases Floyd Kelly.

49 | P a g e

You might also like