Professional Documents
Culture Documents
Arduino Finel2
Arduino Finel2
Arduino Finel2
By
Muhammad Irfan
2015-GCUF-S011755
Sumair Ikram
2015-GCUF-020401
BACHELOR OF SCIENCE
IN
COMPUTER SCIENCE
June, 2019
DECLARATION
This project work, is carried out by Muhammad Irfan and Sumair Ikram under
the supervision of Sir Nafees Ayub (Computer Science Department) and Sir
Rao Sohail (Lecturer, Computer Science Department) Govt. College University,
Faisalabad, Pakistan. We feel please to declare that the “CNC Drawing
Machine” and contents of this project is the productive result of our
hardworking, studies and research and no part of this is copied from any
published source. This work has been conducted under the practical
atmosphere of our studies not for the award of any other degree / diploma. The
University may take action if the information provided is found guilty at any
stage.
Signatures of Students
Muhammad Irfan…………………
2015-GCUF-S011755
Sumair Ikram…………………..…
2015-GCUF-020401
ACKNOWLEDGEMENTS
Bowing our head to almighty ALLAH, who is the most merciful and giving all
honor to the HOLY Prophet (PBUH) as the model and beacon light for all the
mankind. Prior to anyone Else, all gratitude and praises are due to the almighty
Allah, who gave us health and capacitance to achieve this goal.
Muhammad Irfan
Roll No: 2175
Sumair Ikram
Roll No: 20401
Dedication
At this Moment of joy, we dedicate our hardworking to our beloved Parents, other family
members and friends who encourage us and give us timely support in different ways. We
further dedicate it to our honorable teachers, who played an important role in entire period
of learning in the College, especially to Sir Nafees Ayub and Mr. Rao Sohail, who
encourage us with their broadness in the field and gave us innovative ideas for successful
completion of our project.
Muhammad Irfan
2015-GCUF-S011755
Sumair Ikram
2015-GCUF-020401
CERTIFICATE BY THE PROJECT SUPERVISOR
We certify that the contents and form of thesis submitted by Mr. Irfan Khalid, Registration
No. 2015-GCUF-14528 and Miss Sana Shoukat, Registration No. 2015-GCUF-14537
has been found satisfactory and in accordance with the prescribed format. We
recommend it to be processed for the evaluation by the External Examiner for the award
of degree.
Internal Examiner
Name: _____________
Signature: _____________
External Examiner
Name: _____________
Signature: _____________
Chairperson
Department of Computer Science G.C University Faisalabad
1.1 Background
The pen of the machine can be replaced by a laser to make it work like a laser engraving
or cutting machine. Engraving machine can be used on wood. 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.
1.2 The purpose of the Project
A CNC plotter is able to draw complex line drawings. The coordinates are uploaded to the
machine controller by a separate program. The image file is transformed into a G-code via
Software.Then the code is transferred to the micro controller by which the motor mechanism
is instructed to draw the image. In this project, we are going to present a simple design for a
CNC plotter. Our idea is an Arduino based design using ATMEGA 328P micro controller.The
machine will have three motors to implement the X, Y, and Z axis. A servo motor will be used
along the Z axis for positioning the pen which will go up for logic 0 and down for logic .
Drawing will be done on the X-Y plane where the positioning will be controlled by stepper
motors.System overview is provided in Block diagram of CNC Plotter.
1.6 Mission
It is easy to use and understand to each other. Drawing perfect sketch by hand can now
be done by machines too..This is an amazing machine I will show you how to easily build
your own low cost Arduino Mini Sketching Machine .It can draw any image uploaded from
PC.It is very amazing to see how this tiny machine draw images so nicely with a good
accuracy.
CNC plotter
Machine
This board comes with all the features required to run the controller and can be directly connected to
the computer through USB cable that is used to transfer the code to the controller using IDE
(Integrated Development Environment) software, mainly developed to program Arduino. IDE is
equally compatible with Windows, MAC or Linux Systems, however, Windows is preferable to use.
Programming languages like C and C++ are used in IDE.
Apart from USB, battery or AC to DC adopter can also be used to power the board.
Arduino Uno boards are quite similar to other boards in Arduino family in terms of use and
functionality, however, Uno boards don’t come with FTDI USB to Serial driver chip.
There are many versions of Uno boards available, however, Arduino Nano V3 and Arduino Uno are
the most official versions that come with Atmega328 8-bit AVR Atmel microcontroller where RAM
memory is 32KB.
When nature and functionality of the task go complex, Mirco SD card can be added in the boards to
make them store more information.
1.8.1 Features of Ardiuno UNO
Arduino Uno comes with USB interface i.e. USB port is added on the board to develop serial
communication with the computer.
Atmega328 microcontroller is placed on the board that comes with a number of features like
timers, counters, interrupts, PWM, CPU, I/O pins and based on a 16MHz clock that helps in
producing more frequency and number of instructions per cycle.
It is an open source platform where anyone can modify and optimize the board based on the
number of instructions and task they want to achieve.
This board comes with a built-in regulation feature which keeps the voltage under control
when the device is connected to the external device.
Reset pin is added in the board that reset the whole board and takes the running program in the
initial stage. This pin is useful when board hangs up in the middle of the running program; pushing
this pin will clear everything up in the program and starts the program right from the beginning.
There are 14 I/O digital and 6 analog pins incorporated in the board that allows the external
connection with any circuit with the board. These pins provide the flexibility and ease of use to the
external devices that can be connected through these pins. There is no hard and fast interface
required to connect the devices to the board. Simply plug the external device into the pins of the
board that are laid out on the board in the form of the header.
The 6 analog pins are marked as A0 to A5 and come with a resolution of 10bits. These pins
measure from 0 to 5V, however, they can be configured to the high range using analogReference()
function and AREF pin.
13KB of flash memory is used to store the number of instructions in the form of code.
Only 5 V is required to turn the board on, which can be achieved directly using USB port or
external adopter, however, it can support external power source up to 12 V which can be regulated
and limit to 5 V or 3.3 V based on the requirement of the project.
1.8.2 Ardiuno UNO Pinout
Arduino Uno is based on AVR microcontroller called Atmega328. This controller comes with 2KB
SRAM, 32KB of flash memory, 1KB of EEPROM. Arduino Board comes with 14 digital pins and 6
analog pins. ON-chip ADC is used to sample these pins. A 16 MHz frequency crystal oscillator is
equipped on the board. Following figure shows the pinout of the Arduino Uno Board.
There are several I/O digital and analog pins placed on the board which operates at 5V. These pins come
with standard operating ratings ranging between 20mA to 40mA. Internal pull-up resistors are used in
the board that limits the current exceeding from the given operating conditions. However, too much
increase in current makes these resisters useless and damages the device.
LED. Arduino Uno comes with built-in LED which is connected through pin 13. Providing HIGH value
to the pin will turn it ON and LOW will turn it OFF.
Vin. It is the input voltage provided to the Arduino Board. It is different than 5 V supplied through a
USB port. This pin is used to supply voltage. If a voltage is provided through power jack, it can be
accessed through this pin.
5V. This board comes with the ability to provide voltage regulation. 5V pin is used to provide
output regulated voltage. The board is powered up using three ways i.e. USB, Vin pin of the board or
DC power jack.
USB supports voltage around 5V while Vin and Power Jack support a voltage ranges between 7V to
20V. It is recommended to operate the board on 5V. It is important to note that, if a voltage is supplied
through 5V or 3.3V pins, they result in bypassing the voltage regulation that can damage the board if
voltage surpasses from its limit.
GND. These are ground pins. More than one ground pins are provided on the board which can be used
as per requirement.
Reset. This pin is incorporated on the board which resets the program running on the board. Instead of
physical reset on the board, IDE comes with a feature of resetting the board through programming.
IOREF. This pin is very useful for providing voltage reference to the board. A shield is used to read the
voltage across this pin which then select the proper power source.
PWM. PWM is provided by 3,5,6,9,10, 11pins. These pins are configured to provided 8-bit output
PWM.
SPI. It is known as Serial Peripheral Interface. Four pins 10(SS), 11(MOSI), 12(MISO), 13(SCK)
provide SPI communication with the help of SPI library.
AREF. It is called Analog Reference. This pin is used for providing a reference voltage to the analog
inputs.
TWI. It is called Two-wire Interface. TWI communication is accessed through Wire Library. A4 and
A5 pins are used for this purpose.
Serial Communication. Serial communication is carried out through two pins called Pin 0 (Rx) and Pin
1 (Tx).
External Interrupts. Pin 2 and 3 are used for providing external interrupts. An interrupt is called by
providing LOW or changing value.
Arduino Uno comes with an ability of interfacing with other other Arduino boards, microcontrollers and
computer. The Atmega328 placed on the board provides serial communication using pins like Rx and
Tx.The Atmega16U2 incorporated on the board provides a pathway for serial communication using
USB com drivers. Serial monitor is provided on the IDE software which is used to send or receive text
data from the board. If LEDs placed on the Rx and Tx pins will flash, they indicate the transmission of
data.Arduino Uno is programmed using Arduino Software which is a cross-platform application called
IDE written in Java. The AVR microcontroller Atmega328 laid out on the base comes with builtin
bootloader that sets you free from using a separate burner to upload the program on the board.
1.8.4 Applications
Arduino Uno comes with a wide range of applications. A larger number of people are using Arduino
boards for developing sensors and instruments that are used in scientific research. Following are some
main applications of the board.
"The open-source Arduino Software (IDE) makes it easy to write code and upload it to the
board"(https://www.arduino.cc). It is simplified C/C++ functions language- based
programming can be download functionality with a rich set of library functions. After
download and install on pc can be write the program by C language and from tools and port
must be choose the port connection between computer and Arduino through USB. After this
step can be verify the program by error checking and the message is done compiling when it
finished and no error. After this step can be upload the program on the Arduino. Figure 9
shows Arduino software IDE.
To make the CNC plotter machine plote and write needing a software tools to
design the graphs and then convert this graph to G-code because CNC
machine operate and understanding G language, this tools can be achieved by
easel software tools, this software must be setting material dimensions X is
235 mm, Y is 215 mm, Z is 1 mm and set Bit to 0.15 mm because Z axis is pen.
Through this software can be set positions of X, Y and Z axes, also can be
control on the speed of CNC machine mm/min from feed rate. Figure 10.
showing the tools of easel software.
EZ-Robots use servos which manage the movement of joints, pan & tilt, and
continuous rotational movement. The EZ-B v4, sends an electrical signal that tells the
servo what position to reach and how quickly to get there. Servos come in a variety of
shapes and sizes for different applications. You may want a large, powerful one for
moving the arm of a big robot, or a tiny one to make a robot's eyebrows go up and
down. By linking many of these servos together, you can very easily create robots that
perform complex real world operations. Our Revolution robots utilizes the two most
common sizes as shown below.
Servo vs PWM
PWM stands for Pulse Width Modulation. PWM is the process of turning ON and
OFF digital voltage quickly to simulate a range of voltage. For example... If the
digital output pin of a micro is 3.3v, and the PWM is set for a 50% duty cycle, the
output voltage would be approx 1.65v. This is because the microcontroller is turning
ON and OFF the digital 3.3v pin real quick, which is producing a simulated lower
voltage. You can use PWM to vary the brightness of an LED, for example.
A servo uses PWM as well. The "frame" of a servo PWM signal is 20ms. Many
controllers, such as Arduino libraries do not maintain the 20ms specification defined
for servos. Because of this, challenges have been introduced to servo manufacturers
when decoding incoming PWM signals. This has caused the need for servos to be
"Smarter" by adapting to the unusual PWM transmitted by poorly written libraries
which do not adhere to the servo PWM Standard. The EZ-B does adhere to servo
PWM standards.
The simplicity of a servo is among the features that make them so reliable. The heart
of a servo is a small direct current (DC) motor, similar to what you might find in an
inexpensive toy. These motors run on electricity from a battery and spin at
high RPM (rotations per minute) but put out very low torque (a twisting force used
to do work— you apply torque when you open a jar). An arrangement of gears takes
the high speed of the motor and slows it down while at the same time increasing the
torque. (Basic law of physics: work = force x distance.) A tiny electric motor does not
have much torque, but it can spin really fast (small force, big distance). The gear
design inside the servo case converts the output to a much slower rotation speed but
with more torque (big force, little distance). The amount of actual work is the same,
just more useful. Gears in an inexpensive servo motor are generally made of plastic to
keep it lighter and less costly. On a servo designed to provide more torque for heavier
work, the gears are made of metal (such as with EZ-Robot Servos) and are harder to
damage.
With a small DC motor, you apply power from a battery, and the motor spins. Unlike
a simple DC motor, however, a servo's spinning motor shaft is slowed way down with
gears. A positional sensor on the final gear is connected to a small circuit board. The
sensor tells this circuit board how far the servo output shaft has rotated. The electronic
input signal from the computer or the radio in a remote-controlled vehicle also feeds
into that circuit board. The electronics on the circuit board decode the signals to
determine how far the user wants the servo to rotate. It then compares the desired
position to the actual position and decides which direction to rotate the shaft so it gets
to the desired position.
Servos come in many sizes and in three basic types: positional rotation, continuous
rotation, and linear.
Positional rotation servo: This is the most common type of servo motor. The
output shaft rotates in about half of a circle, or 180 degrees. It has physical
stops placed in the gear mechanism to prevent turning beyond these limits to
protect the rotational sensor. These common servos are found in EZ-Robot's
arms, legs, limbs, etc.. For example, the JD or Six robots use these servos.
Continuous rotation servo: This is quite similar to the common positional
rotation servo motor, except it can turn in either direction indefinitely. The
control signal, rather than setting the static position of the servo, is interpreted
as the direction and speed of rotation. The range of possible commands causes
the servo to rotate clockwise or counterclockwise as desired, at varying speed,
depending on the command signal. You might use a servo of this type on a
radar dish if you mounted one on a robot. Or you could use one as a drive
motor on a mobile robot. The EZ-Robot AdventureBot uses two continuous
rotation servos with wheels. The center (90 degrees) is the center of a
continuous rotation's STOP position. The further you move away from 90
degrees in either direction controls the speed of the continuous rotation servo
in that direction
Linear servo: This is also like the positional rotation servo motor described
above, but with additional gears (usually a rack and pinion mechanism) to
change the output from circular to back-and-forth. These servos are not easy to
find, but you can sometimes find them at hobby stores where they are used as
actuators in larger model airplanes.
A standard servo is what you normally find in R/C Hobby Toys. They are high
precision devices that can rotate a shaft up to 180 degrees. With the EZ-B and a
Standard Servo, you can easily configure how many degrees to rotate the output shaft.
1.11.1 By pitch(spacing):
Pitch refers to the distance or space between two pins in electronic community, more
details check Wikipedia
Figure 1.8 P.C.B LAYOUT
-2.54mm (.100”) inch pitch pin header connectors ( typically and widly used)
-2.00mm (.079”) inch pitch pin header connectors ( widly used)
-1.27mm (.050”) inch pitch pin header connectors ( used as well)
-1.00mm (.039”) inch pitch pin header connectors ( for small device)
-0.80mm (.032”) inch pitch pin header connectors ( for smaller device)
Number of rows depend on the PCB board’s design, and considering the Current.
Single and Dual row are normally than others.
1.11.4 Version:
The motor control center (MCC) or Enclosed Package Solution is a NEMA tradition.
Most NEMA products are sold as starters, in either open-style or various enclosed
versions.
A Step Motor is defined as a device whose normal shaft motion consists of discrete
angular movements of essentially uniform magnitude when driven from a sequentially
switched DC power supply. A step motor is a digital input-output device. It is
particularly well suited to the type of application where control signals appear as digital
pulses rather than analog voltages. One digital pulse to a step motor drive or translator
causes the motor to increment one precise angle of motion. As the digital pulses
increase in frequency, the step movement changes into continuous rotation.
Parallel connect the lead wires for best torque over the widest speed range
If not enough current is available from the drive, series connect the lead wires
for full torque at low speeds
Keep motor case temperature below 100 °C. This can be achieved by lowering
the motor current or limiting the duty cycle
Allow sufficient time to accelerate load
Use a microstepping drive for smoothest motor performance over a wide
speed range
For open loop operation, size the motor with a 30-50% torque margin at speed.
Including an encoder in the system and using a Stall Prevention feature may
allow operation all the way down to a 0% torque margin
Do not disassemble motors. A significant reduction in motor performance
will result
Do not machine shafts without consulting Electromate® first
Do not disconnect motor from drive while power is applied. Remove power
from the drive before disconnecting the motor
Do not use holding torque/detent torque of motor as fail-safe brake
Use an Electromate® recommended stepper drive with your step motor to
ensure optimal performance
Electromate® sells a family of 2-phase hybrid type step motors with a 1.8° step angle in
NEMA frame sizes from NEMA 8 to NEMA 42. Stepper motors from
Electromate® are available in 4, 6 or 8 lead configurations for bipolar or unipolar
operation. All motors can be wired in series or parallel, depending on the requirement.
Motors are available with optional rear shaft extensions, encoders, brakes, cables,
gearboxes and IP65 sealing.
Brief Data:
GRBL 0.9 compatible. (Open source firmware that runs on an Arduino UNO that
turns G-code commands into stepper signals)
4-Axis support (X, Y, Z , A-Can duplicate X,Y,Z or do a full 4th axis with custom
firmware using pins D12 and D13)
2 x End stops for each axis (6 in total)
Coolant enable
Uses removable A4988 compatible stepper drivers. (A4988, DRV8825 and
others)(Not Included)
Jumpers to set the Micro-Stepping for the stepper drivers. (Some drivers like the
DRV8825 can do up to 1/32 micro-stepping )
Compact design.
Stepper Motors can be connected with 4-pin Molex connectors or soldered in place.
Runs on 12-36VDC. (At the moment only the DRV8825 drivers can handle up to
36V so please consider the operation voltage when powering the board.)
. GRBL Control Software/Firmware for Arduino
Before you can use this CNC shield with Arduino, a control firmware need to be
downloaded into Arduino board. We are going to use „GRBL‟ to accomplish our job.
GRBL is open-source software that runs on an Arduino Uno that takes G-Code
commands via Serial and turns the commands into motor signals. Grbl is a
no-compromise, high performance, low cost alternative to parallel-port-based motion
control for CNC machine. It accepts standards-compliant g-code and has been tested
with the output of several CAM tools with no problems. Arcs, circles and helical
motion are fully supported, as well as, all other primary g-code commands. Macro
functions, variables, and most canned cycles are not supported, but we think GUIs can
do a much better job at translating them into straight g-code anyhow.
A copy of this open-source firmware can be downloaded from the below link:
Following the below steps to prepare this CNC Shield board to function properly:
1. Download a copy of GRBL from: https://github.com/grbl/grbl
Unzip this file into your local hardisk location, you may want to create a special new
folder for this purpose for easy locating of all files needed in your project. Locate an
Arduino sketch „grblUpload.ino‟ in this folder where you have unzip the files.
Below is the files structures located in my local hardisk:
Click the upload icon as usual to „compile/upload‟ as you normally upload Arduino
sketch. When you see „done uploading‟, click the „Serial Monitor‟ on Arduino IDE as
shown below:
Figure 1.15 grblupload command
If you can receive response message “ Grbl 0.9j ['$' for help] ” from your Serial
Monitor, congratulation! You have successful uploaded the „GRBL‟ firmware into
your Arduino board.
3. Hooking Up the Stepper Motor to CNC Shield
Connect steppers motor to CNC Shield board as the below block diagram. of the CNC
Shield connected to 3-stepper motor:
. G-Code Sender
To send commands to your CNC/3-axis stepper motor driver board you need a g-code
sender to send command and instruction.
Download the Universal-G-Code-Sender.
Universal GcodeSender is a Java based GRBL compatible cross platform G-Code
sender. Use this program to run a GRBL controlled CNC machine. Once downloaded,
connect the UNO board USB to your computer and take note of the COM port it is
connected to.
Run the start-windows.bat or the JAR file directly.
You will be presented with the following screen:
Click the “Machine Control” tab. Select the “Port” number which your Arduino board
is attached to. Select 115200 as the Baud rate as this is the speed configured in
“GRBL” firmware. Click “Open” button to start the communication for controlling
this shield board.
Now, you are ready to control the XYZ stepper motor connected to shield board.
Click X+ or X- for example, the stepper motor attached to X terminal will turn in
forward or reverse direction.
This will complete our initial setup for driving 3-axis stepper motor connected to this
shield board with “GRBL” loaded to Arduino controller board using “Universal
G-Code Sender” user interface.
1.14 Summary
From last decade technology is also coming in Pakistanis a very faceting
mode. Everyone likes to use printer, computer and Internet. So, if we
utilize this technology for Educational purposes it will surely raise the
stander of education.
CHAPTER NO.2
REQUIREMENT ANALYSIS
2 Requirement Analysis
In this chapter analysis of requirement is carried out using HMI
diagrams and separating functional and non -functional diagram. Business
requirement have also considered because this Product is made for office
use.
Technological Yes
experience
Planning
Design
Design
Development
Testing Developer 2
Developer 1
Implementation
Turn on
Arduino UNO
Application1
Arduino IDE
Application
2(Google
Task)
2.8 Summary
In this chapter we underscored analysis of system requirement tha t
helps us to understand design and feature for this product. UML diagrams
and analysis of each requirement is performed to get into each requirement
duly.
Chapter 3
System Design
Project planning
Step 1: Disassembly DVD/CD Drives First step to start building this CNC machine is
to disassemble two DVD/CD drives and take off them the stepper motors. Use the
screwdriver to open them and take off them the rails. Next step is to choose our base
for this CNC machine. I used one surface from remaining DVD garbage' stuff. Finally
we will need to find something to attach the one of the stepper-rails vertically to our
construction. (you will understand what I mean in our next step) Watch the above
image.
Image Notes 1.
1. 1st Stepper motor with rails
2. 2nd stepper motor with rails
3. This metal will be our CNC "base"
4. We will cut this plastic to attach on it later one of the stepper-rails
Step 2: X and Y axis In first image above you will see the Y axis of our CNC
machine. Attach it on your surface, in this part you will need some screws and nuts in
second image you will see 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 4x4cm
Following is the list of risks that may get in the way during the development of
the project. Table given below describes each of risk with the probability of
occurrence and its effect with scale from 0-10. 0 means nothing and 10 means at
peak point and middle value shows the medium occurrence.
Step 5: The Circuit
Now that we have our contraction ready, it's time to build the circuit and test stepper
motors (X and Y axis).Watch the above image with breadboard circuit schematic.
Steppers motors wiring is something that need patient. On next step you will find a
'testing' code for x and y axis. If yours steppers doesn't work properly you must find
correct working combination by changing the cables between them and the L293D IC
On mine CNC , X axis motor connection are: L293 A: Pins 1 and 3 & B: 2 and 4, but
on Y axis motor connection are A: 1 and 2 & B: 3 and 4
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!
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!
Term Defination
RAT Rational
DEP Dependency
Module ON -Pin ON
+CallActivatepin() +Activatepin()
-CallDeactivatepin( -Deactivatepi()
)
3.2 Sequance Digram
A sequence diagram shows object interactions arranged in time sequence.
It depicts the objects and classes involved in the scenario and
the sequence of messages exchanged between the objects needed to carry
out the functionality of the scenario. ...Sequence diagrams are sometimes
called event diagrams or event scenarios.
Module
Activate
PC Fetch
UNO IDE
Name: Planning
Actors: Developer
Purpose: The developer plans the things in the CNC what should
be here and for what purpose should be.
Description: The developer will plan all the modules in the CNC and
user friendly will be as well.
Cross References: None
Pre-Conditions: None
Alternative Course
Table 2:Designing
Section: Main
Name: Designing
Pre-Conditions: Do Planning
Successful All the designing has been done in this phase in order to
Post-Conditions make a final full platform.
Failure Syntax error, Logical error or any other error related to
Post-Conditions coding is occurred.
Typical Course of Events
1 Developer and coder and other 2 A system shows the code which is
software team will make the to be done.
coding to do the design.
Alternative Course
Step3: Code error in the designing.
Table 3:Developemrnt
Section: Main
Name: Development
Actors: Developer
Pre-Conditions: Designing
Successful The development has been done and final product has
Post-Conditions been developed.
Failure The development has not been finally done in the
Post-Conditions development.
Typical Course of Events
Table 4:Testing
Section: Main
Name: Testing
Table 5:Implentation
Section: Main
Name: implementation
Table 6:Update
Section: Main
Name: Update
1 The developer will add new 2 The mirror has been finally
features in the CNC. updated.
Alternative Course
Step2: The hardware may not suitable for the app that is
designed.
Actors: User
Purpose: The user can use ARDUINO.
Description: The aim is to get the new information that has required to
user.
Cross References: None
Alternative Course
Table 6:Feedback
Section: Main
Name: Feedback
Actors: User
Description: The aim is to get response from user while he was using
CNC Drawing Machine.
Cross References: None
Pre-Conditions: None
Alternative Course
METHODOLOGY
We have supply the current in Arduino with USB DATA cable to transfer Data from
Computer to Arduino Board [1], Here we have used 3 Stepper Drivers to supply the G
codes in Sequence to the stepper motors. Arduino will be mounted on CNC shield.
CNC shield will be distributing the Current in the command of Arduino. CNC shield
will be converting the command of G codes in digital pulse by Stepper motor. In X
direction Stepper motor will be move left and Right ,Y direction stepper motor will be
move in front and back direction, Z direction Stepper motor will be move in Up and
down[2]. We have made much difficult design via using this machine. The accuracy
of this machines result is very high. So we have used in industry to reduce the cost of
design printing and maintain accuracy level. Drafting and Scaling of CNC Plotter
machine is very precious.
3.1 DESIGN OF CNC MACHINE
There are 3 movements of using 3 CD ROMs. The horizontal movement(X) i.e.
forward & backward movement is provided by the lower CD Rom. The 2nd CD Rom
is mounted between the 2 columns which provide side movements(Y) i.e. left and
right hand side movements. The spindle which is mounted on the 3rd CD Rom
provides vertical movement (Z) for feed of tool
3.2 PROBLEM DEFINITION
The available Arduino controlled CNC machines are having only 2 axis movement.
The structure is weak and can machine foam only.
3.3 WORKING
We have supply the current in Arduino with USB DATA cable to transfer Data from
Computer to Arduino Board [1], Here we have used 3 Stepper Drivers to supply the G
codes in Sequence to the stepper motors. Arduino will be mounted on CNC shield.
CNC shield will be distributing the Current in the command of Arduino. CNC shield
will be converting the command of G codes in digital pulse by Stepper motor. In X
direction Stepper motor will be move left and Right ,Y direction stepper motor will be
move in front and back direction, Z direction Stepper motor will be move in Up and
down[2]. We have make many difficult design via using this machine. The accuracy
of these machines results is very high. So we have used in industry to reduce the cost
of design printing and maintain accuracy level. Drafting and Scaling of CNC Plotter
machine is very precious.
3.4 Main parts of CNC plotter
Mini CNC Plotter Machine is worked on input as a G codes of Design and Converting
it via use of Arduino, Stepper Drivers, CNC Shield, Stepper Motor in to a Rotation of
Lead screw. We have work on to maintain lowest cost of our project. We have design
a simple construction of our project. This is easier way to use stepper motor with lead
screw, CNC shield, Stepper drivers, Arduino Board, etc. The Setup of machine is
flexible that’s why it will be easily transported and Maintenance time is short. The
basic diagram of CNC Plotter machine is shown in figure.
2.9 Summary
In this we described in a very detail that what are the components in
this system, how they interact with each other and what are the steps a user
will take to achieve his target using features and functions of this above
system.
CHAPTER No.4
IMPLEMENTATION
IMPLEMENTATIONS
In this chapter main coding of application is described. It describes that
how mirror works. It helps us to understand features and user interaction
with these features, for instance such a product that will help to user to
control their electronics from anywhere .
CODE
#include <Servo.h>
#include <AFMotor.h>
// Should be right for DVD steppers, but is not too important here
const int stepsPerRevolution = 48;
// 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);
// 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
Serial.begin( 9600 );
penServo.attach(penServoPin);
penServo.write(penZUp);
delay(100);
// Decrease if necessary
myStepperX.setSpeed(600);
myStepperY.setSpeed(600);
// 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;
while (1) {
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!
/*********************************
* Draw a line from (x0;y0) to (x1;y1).
* 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("");
}
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("");
}
long i;
long over = 0;
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);
// 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.");
}
}
INKscape Design
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.
Summary
In this chapter we described the main coding of mirror. It described
that how the main features of mirror work. How user interact with these
modules and what are the steps a user will take to achieve his target using
modules.
CHAPTER No:5
TESTING
3 Testing
In this chapter test case are designed to test the application.
This test case is designed to test working of installation option to check whether
these options are working perfectly or not.
I tried to install the application. I tested this case on android smart phone.
Table 2: Module Working
TC#01 Date created:20/05/2019
Created by: Muhammad Umer
Requirement# 01 Controller UI
Description User will be able to view all of option to change the schedule.
This test case is specially designed to check whether a list of schedules can be
added so that it can be viewed on CNC Drawing Machine. These drawing appear on
the right side of the paper.
I checked this test case on CNC Drawing Machine using pc.
Table 3: CNC Drawing Machine Working
TC#01 Date created:20/05/2019
Created by: Muhammad UMER
Requirement# 01 CNC Drawing installation
Description User will be able to see the modules and picture that he uploaded.
This test case is specially designed to check the working of smart mirror and its
modules work well.
CONCLUSION
In this paper we have presented the concept of a low cost three-axis mini 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.
FUTURE SCOPE
The pen of the machine can be replaced by a laser to make it work like a laser
engraving or cutting machine. Engraving machine can be used on wood. 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.