Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 52

“PORTABLE TWO AXIS CNC PRINTER”

PROJECT REPORT- 2017-18


“PORTABLE TWO AXIS CNC PRINTER”
Submitted in partial fulfillment of the requirements
For the diploma in
Electrical & Electronics Engg.

By:
AATISH KUMAR SINGH. L 433EE15001
AKSHAY KUMAR. R 433EE15007
ARCHANA. N 433EE15009
CHANDAN. B 433EE15012
RAKSHITH GOWDA. CK 433EE15045
ROOPESH. NP 433EE15048

DIRECTORATE OF TECHNICAL EDUCATION


Guided By:
Sri BHADRAPPA.H.R M.Tech
Lecturer Dept. Of E&EE

P.V.P POLYTECHNIC
(Recognized by AICTE New Delhi, AIDED and Affilliated by G.O.K)

1
“PORTABLE TWO AXIS CNC PRINTER”

Dr. AIT Campus, Mallathalli, Bengaluru – 560 056

DEPARTMENT OF TECHNICAL EDUCATION


P.V.P POLYTECHNIC
(Recognized by AICTE New Delhi, AIDED and Affiliated by G.O.K)
DR.AIT Campus, Mallathahalli, Bengaluru-560 056

CERTIFICATE

This is to certify that this project entitled “PORTABLE TWO AXIS CNC PRINTER”
which is being submitted by ROOPESH.NP Reg no 433EE15048 a student of P.V.P
Polytechnic in partial fulfillment for the award of Diploma VI semester, ELECTRICAL &
ELECTRONICS ENGG During the year 2017-18 is record of students own work carried out
under my/our guidance. It is certified that all corection/suggestion indicate for internal
assessment have been incorporate in the report and one copy of it being deposited to the
polytechnic library.
The project report has been approved as it satisfies the academic requirements in respect
of project work prescribe for the said Diploma.
It is further understood that this certificate the undersigned do not endorse or approve any
statements made, opimion expressed or conclusion draw there in but approve the project only for
the purpose for which it is submitted.

Signature of the lecturer Signature of H.O.D


incharge of the batch Head of the Department

Examiner’s signature
1.

2.

Dept. of E&EE

2
“PORTABLE TWO AXIS CNC PRINTER”

ACKNOWLEDGEMENT
With deep sense of gratitude and regards, we thank our honorable principal
Sri.G.P.MANJUNATH for taking extensive care while implementing our project.

We express our sincere gratitude to our beloved lecturer


Sri.H.R.BHADRAPPA for his guidance, encouragement and active participation
in completing this project.

We would like to acknowledge our head of the department


Sri.UMASHANKARA SWAMY.B for providing us the opportunity to work on
this project.
We thank our parents for their co-operation and support, without whom
project would have never seen the day light.
We also wish to thank all those who have been helped directly or indirectly
in carrying out this project work.

Project Team

3
“PORTABLE TWO AXIS CNC PRINTER”

CANDIDATE’S DECLARATION

I, ROOPESH.NP a student of Diploma in Electrical and Electronics Department bearing


Reg No. 433EE15048 of PVP Polytechnic hereby declare that I own full responsibility for the
information, results and conclusions provided in this project work titled “PORTABLE TWO
AXIS CNC PRINTER ”submitted to State Board of Technical Examinations, Government
of Karnataka for the award of Diploma in Electrical and Electronics.
To the best of my knowledge, this project work has not been submitted in part or full
elsewhere in any other institution/organization for the award of any certificate/diploma/degree. I
have completely taken care in acknowledging the contribution of others in this academic work. I
further declare that in case of any violation of intellectual property rights and particulars
declared, found at any stage, I, as the candidate will be solely responsible for the same.

Date:

Place:

Signature of candidate

4
“PORTABLE TWO AXIS CNC PRINTER”

Table of Contents

Page. No
Chapter 1
ABSTRACT
INTRODUCTION
Problem statement
Objective of project
Existing system
Justification of the Project
Scope of the Project
Specification of the report
Features of the Project
Organisation of report

Chapter 2
Purposed System
Block diagram
Components
Working

Chapter 3
Fundamentals of Robotic System
DC Stepper motor
DC Servo motor

5
“PORTABLE TWO AXIS CNC PRINTER”

Chapter 4
Hardware Module
Arduino Uno board
Stepper motor
Stepper motor
H-Bridge
Motor drive shield L293D
Chapter 5
Software module
Arduino IDE
Inkscape
G-CTRL
Chapter 6
Methodology of Robotic System
Algorithm
Test Plan
Test Result
Chapter 7
Conclusion

References

Appendix

6
“PORTABLE TWO AXIS CNC PRINTER”

CHAPTER 1
ABSTRACT
The invention of the XY-plotters is to recording or plotting 2dimensonal data on a
rectangular co-ordinated system. This study emphasizes the Fabrication of a XY-plotter by using
mechanisms from scanner and Microcontroller system (Arduino) to control the moment of XY-
axis .modeling and analysis on XY-plotter is carried out through the computer link with the
Arduino software.it is executed through the algorithms and g code and java programming.
Keywords: plotters, Arduino, g-code.

INTRODUCTION
In the present study, the XY plotter is designed to recording and plotting 2 dimensional
data on a rectangular coordinate system. The material selection of the mechanism was made
considering the cost and wide range of application such as servo motor. Servo motor can be
differentiated through the cost, peak torque capability, speed range to compromise the standard
and application of the system. Discuss the dynamic of a dual drive servo mechanism and
develops a n XY gantry model consisting of a 2 motors for y control with another motor sliding
the gantry in x direction. The design uses 2 parallel rails for y motion with a bar spanning across
the rails which holds the end effectors of the system.in the other hand, the accuracy of plotting is
the issue e to be concerned on the fabrication of XY plotter. Few papers have been devoted to
plotters in the term of their adjustment methods on the accuracy and moment of plotter. The XY
plotter system is a more simplified system comparing to the CNC system since CNC system is
running on 3 axis direction and the programming is more complicated never the less, the coding
for the CNC system which is the g code.

7
“PORTABLE TWO AXIS CNC PRINTER”

THE OPERATION IS AS BELOW:

 We insert a photo or a written context in to the folder.


 We open inkscape software and open properties and set the size of the paper.
 The inserted image is scanned by the inkscape software.
 Then the photo is converted from jpg form to G-Code form inkscape software.
 In inkscape it analize the image scale from curves to XY-axis of the motor moment
 Then the converted G-Code is save in unicorn G-Code form in the computer.
 Then GCTRL software is opened we run the g-code then select the port.
 For selecting the port we press P for serial port COM-6 port is selected.
 Then we press G for processing the converted G-Code in the cnc printer.
 Then the process repeats if some other image or written context.

PROBLEM STATEMENT
Problem chosen is to implementation of “PORTABLE TWO AXIS CNC PRINTER
“using microcontrollers, STEPPER MOTOR and SERVO MOTOR with MOTOR DRIVER
SHIELD.

OBJECTIVE OF PROJECT
The main objective of our project is to secured portable two axis cnc printer.as we see
nowadays cnc machines maintance is the major issue in the country.
The number of modern machines is increasing day by day. And machines produced are required
experienced worker. Or if we leave unexpernced person there won’t be having proper safety, and
also the machine owned by the owners are facing many problem, day by day. By observing all
this improper maintance and inexperienced person working with machines, our aim is to provide
proper safety and maintance free machine for the future we can achieve greater development in
the industry of CNC machines. By this implementation in industry can be relaxed by this
“PORTABLE TWO AXIS CNC PRINTER” her we provide the specific format of image (JPG),
contexts and software to be used by the person using and reduce maintance.

8
“PORTABLE TWO AXIS CNC PRINTER”

EXISTING SYSTEM
Cnc machines are very much essential in our day to day life in the production of the
industry. This is basic need for leading the nation to achieve the goals. The existing system of
cnc machines are:

HIGHLY SOPHISTICATED CNC MACHINES:-


This type of cnc machine are usually been seen in large scale industry and MNC
company. The operators provide is very highly skilled person who requires very high salary for
his skills it is not good for the company to give high wages.

JUSTIFICATION OF THE PROJECT


Our project is the best and efficient idea for cnc operated machine arrangement for this
problem seen in existing system. Our project named “PORTABLE TWO AXIS CNC PRINTER”
is reliable and highly efficient one and best though for the future cnc operated machine system it
can be implemented for their industries safely. We provide safe and maintance less nature to the
workers by this, we can say our project is the best and good, efficient, eco-friendly, stress less,
with high security provided for their cnc machines.

SCOPE OF THE PROJECT


This project is highly efficient and reliable system so this has a very good performance
and so it can be used in many applications for better protection of the workers.

9
“PORTABLE TWO AXIS CNC PRINTER”

SPECIFICATION OF THE REPORT


Input : digital input and output.
Output : DC stepper motor, DC servo motor.
Domain : embedded c.
Microcontroller : atmega328p.
Power supply : +12v, 1A regulated
DC Motor driver : ad fruit l293d motor driver shield.

FEATURE OF THE PROJECT


1. scalable as per client requirement.
2. Can be used in any cnc operating industry.
3. reliable in operation.
4. Can be implemented in steel, sewing machine industry.
5. eco-friendly and ease in maintance.
6. Cost effective.
7. Minimize on site health and safety.
8. Low maintance than traditional cnc machines.

ORGANIZATION OF REPORT

Chapter 1: Abstract, Introduction and Overview


Chapter 2: Block diagram, Components and Working
Chapter 3: Fundamentals of Robotic System
Chapter 4: Hardware module
Chapter 5: Software module
Chapter 6: Methodology of project
Chapter 7: Conclusion and Reference

10
“PORTABLE TWO AXIS CNC PRINTER”

CHAPTER 2
METHODOLOGY OF A PROJECT CARRIED OUT ROUND PLATFORM

A portable two axis cnc printer is a mechanical and electronic device that multiplies cnc
operated safe machines in the industry. Cnc machines are powered by Electric motor that moves
the cartridge to the required position.

BLOCK DIAGRAM

OPERATION OF CNC MACHINE:

For a CNC plotting machine to operate, 3 axes are required (x-axis, y-axis and z-axis.
The x-axis and y-axis work in unison to create a 2D image on a plain paper. These x and y axis
are placed 90 degrees to each other such that any point on the plain surface is defined by a
given value of x and y. The z-axis is used lift and lowers the pen onto the plain paper.

Depending on the image to be drawn, the computer will generate the appropriate coordinates
and send them to the microcontroller through the USB port. The microcontroller interprets
these coordinates and then controls the positions of the motors to create the image. Here we
have used Arduino as the Microcontroller to build this CNC Machine.

11
“PORTABLE TWO AXIS CNC PRINTER”

COMPONENTS REQUIRED:

1. Acrylic sheet (710mm x 710mm)


2. Old DVD drives
3. Bolts and nuts
4. Adopter 12v,1A
5. Arduino UNO
6. L293D motor driver shield
7. Mini servo motor
8. A pen

12
“PORTABLE TWO AXIS CNC PRINTER”

CHAPTER 3
FUNDAMENTALS OF CNC PRINTER SYSTEM

STEPPER MOTOR

Figure: stepper motor


 It is a 12V DC Stepper motor.
 A stepper motor is a brushless, synchronous electric motor that can divide a full rotation
into a large number of steps.
 The motor’s position can be controlled precisely without any feedback mechanism as
long the motor is carefully sized to the application.
 In the project stepper motor is used to run the platform to the required place (axis).

A. Efficiency:
Cnc printer machine provides maximum space for the motor to run freely.
B. cost efficiency:
This project system improves the viability of commercial and residual development of the
industry.

13
“PORTABLE TWO AXIS CNC PRINTER”

SERVO MOTOR

 It is motor which can be operated from 4.5v-10v max.


 It is used to give only half rotation of the angle required.
 In our project we used stepper motor for lifting the cartridge up and down as per the
required commands.

14
“PORTABLE TWO AXIS CNC PRINTER”

CHAPTER 4
HARDWARE MODULE
ARDUINO BOARD
The Arduino board controller was advanced, viable, quick and better accomplishment
of force framework control and administration utilizing installed segments. It containing the
oscillatory circuit, reset, equipment segments and so on. The MCU is essential thought of the
PWM for controlling DC Motor.
The output devices are used a LCD display which is connected on digital output of board.
This LCD screen is used to display real time value of PWM and information for individual in-
wheel DC Motors or otherwise voltage across each motor terminal.
A serial data communication method is used while the data transfer has intense to
passing MCU to external devices such as L293D DC Motor driver, LCD output device. In
Arduino controller board, the digital outputs provided through the pin no’s are (5), (6), (10) and
(11) are selected to transmit the PWM signal to DC Motor driver device

KEY FEATURES OF ARDUINO BOARD


Atmega328p microcontroller is a heart of the Arduino Uno boards. It is largest chip for
Arduino UNO. Microcontroller development platform board used along with Arduino IDE
(integrated development software) device programs. With simple C language, write programmers
over microcontroller as a brain for operation to tell or to read signal from outside world and
respond to this signal from arm imagination that how we want microcontroller react to the
outside world measuring whatever we control with the data. Microcontroller chip have basic
support circuitry chip that allow you to access information and respond to outside world. It has
3.3volt regulator 5volt regulator, and USB input port. The reset switch allows you to reset
Microcontroller to start programme again. This board essentially is an autonomous board.
Initially we need have to program it into flash memory, program remains in the chip even power
off conditions. Initially you can get power from USB cable through which we are programmed or
a separated 9V battery or from power source to the power this Board. The boards have a set of
output digital pin provided 5 volts, analog inputs accept
0-5volt input that can read a voltage signal from outside world and information to
microcontroller for realizing programs. We can access 3.3V and 5V for other customized

15
“PORTABLE TWO AXIS CNC PRINTER”

circuitry built various board called Arduino shield. This Arduino board is having preloaded
software called boot loader program does allow us to make simpler programming language and
store programs in a chip. In this board it also supports USB access a smaller microcontroller
ATMEL16U2 so we don’t need a separate circuit provide for USB support.
It also has something called ICSE (in circuit serial programmer) for an external piece of
hardware that used to programme a microcontroller to download software which actually in an
assembly language.

ARDUINO-UNO DEVELOPMENT BOARD


Function of each part explained below:
(i)PROGRAMME MEMORY: - kind of flash memory used to store the Arduino sketch, the
memory can be stored and cleared more number of time.
(ii) EEPROM: - this is ordinarily used to secure the basic data that should not be lost, even
though the power supply unexpectedly stops.
(iii) RAM: - Temporary or volatile memory utilized for project execution.
(iv) Analog and Digital port: - used to connect the controller and outside world. This has six
Analog pins, and fourteen digital pins.
(v) Central Processing Unit: - Atmega328P microcontroller is a heart of the Arduino Uno boards.
This block and executes the program.
(vi) Small controller ATmega16U2 on the board makes serial communication port to software on
the computer.

16
“PORTABLE TWO AXIS CNC PRINTER”

(vii) Peripherals: - The Arduino Uno external connections are used in this project as follows,
they are

General purpose I/O Ports:

Port C/ pin A0 : analog input

Port D : RX and TX pins for USB to serial

Port D/digital out 3, 4, 5, 6 : Used for LCD Display

ADC/digital out 6, 9, 10, 11 : PWM output

USB : Serial Communication

KEY FEATURE OF ATMEGA328P


Atmega328P works with operating clock frequency is 16MHz. The simple C language
is used in this project application. The programs written in C language are stored in the 32K
words of FLASH Memory. It has two types of data memory, one is a 2KB of SRAM and the
other is 1K EEPROM.

It has 32 working registers, 20 general purpose I/O lines, 3 timer/counters work with
compare modes, both external and internal interrupts, serial programmable USART, a byte-
oriented 2-wire serial interface, SPI serial port, 6-channel 10-bit ADC, programmable watchdog
timer along with internal oscillator, and five power saving modes. The device can operate as low
as 1.8-5.5 volts.

Atmega328p microcontroller architecture

17
“PORTABLE TWO AXIS CNC PRINTER”

UNIVERSAL SYNCHRONOUS AND ASYNCHRONOUS SERIAL


RECEIVER AND TRANSMITTER

The USART module is introduced for serial method of communication between master
control unit and Computer. It is response is always through I/O Port D. This module can be used
with the built-in serial monitor to communicate with an Arduino board to display the digital
output. This unit is designed to send and receive the signal to/from correspond component. Since
the parallel data communication has more speed than serial but it required multipin.

This is a highly flexible communication device, it can also be used in Master SPI mode.
The Power Reduction USART bit, PRUSART0, must be disabled by making register location in
to logical zero. A diagram of the USART is shown in Figure 5.4. I/O Registers and I/O pins
accessible by CPU are shown. Three main parts of the USART are a) Clock Generator, b)
Transmitter and c) Receiver. Control Registers are shared with all units. Synchronization logic
for external clock input is used by the baud rate generator, and synchronous slave operation for
Clock Generation.

18
“PORTABLE TWO AXIS CNC PRINTER”

STEPPER MOTOR:

A Bi-polar stepper motor or a step motor is a brushless, synchronous motor which


divides a full rotation into a number of steps. Unlike a brushless DC motor which rotates
continually when a fixed DC voltage is applied to it, a step motor rotates in discrete steps angles.
The Bi-polar stepper motors therefore are manufactured with steps per revolution of 12, 24,
74,144,180 and 200, resulting in stepping angles of 30, 15, 5, 2.5,2 and 1.8 degrees per step. The
Bi-polar stepper motor can be controlled with or without feedback.
Bi-polar stepper motors work on the principle of electro magnetism. There is a soft iron
or magnetic rotor shaft surrounded by the electromagnetic stators. The rotor and stator have
poles which may be teeth or not depending upon the type of stepper, when the stators are
energized the rotor moves to align itself along with the stator (in case of a permanent magnet
type stepper) or moves to have a minimum gap with the stator (in case of variable reluctance
stepper), this way the stators are energized in a sequence to rotate the stepper motor get more
information about working of stepper motors through interacting images at the stepper motor
insight.
ADVANTAGES
 Low cost for control achieved
 High torque at startup and low speeds
 Ruggedness
 Simplicity of construction
 Can operate in an open loop control system
 Low maintenance
 Less likely to stall or slip
 Will work in any environment
 Can be used in robotics in a wide scale.

19
“PORTABLE TWO AXIS CNC PRINTER”

SERVO MOTOR

We are using a 12v DC geared motor in order to provide the robot movement and for the
rotation of cartridge (pen). A geared DC motor has a gear assembly to the motor in order to
control its speed & it is counted.

A servo motor is an electrical device which can push or rotate an object with great
precision. If you want to rotate and object at some specific angles or distance, then you use servo
motor. It is just made up of simple motor which run through servo mechanism. If motor is used is
DC powered then it is called DC servo motor, and if it is AC powered motor then it is called AC
servo motor.

Servo motor works on PWM (Pulse width modulation) principle means its angle of
rotation is controlled by the duration of applied pulse to its Control PIN. Basically servo motor is
made up of DC motor which is controlled by a variable resistor (potentiometer) and some gears.
High speed force of DC motor is converted into torque by Gears.
Servo motors are available at different shapes and sizes. A servo motor will have mainly
there wires, one is for positive voltage another is for ground and last one is for position setting.
The RED wire is connected to power, Black wire is connected to ground and YELLOW wire is
connected to signal.

20
“PORTABLE TWO AXIS CNC PRINTER”

H-Bridge
How do we make a motor turn?
You take a battery; hook the positive side to one side of your DC motor. Then you connect the
negative side of the battery to the other motor lead. The motor spins forward. If you swap the
battery leads the motor spins in reverse.
Ok, that's basic. Now let’s say you want a Micro Controller Unit (MCU) to control the motor,
how would you do it?

Connections for clockwise rotation of motor

If you connect this circuit to a small hobby motor you can control the motor with a
processor (MCU, etc.) Applying a logical one, (+12 Volts in our example) to point A causes the
motor to turn forward. Applying a logical zero, (ground) causes the motor to stop turning (to
coast and stop).

Connections for anti-clockwise rotation of motor

An H-bridge is an electronic circuit which enables a voltage to be applied across a load in


either direction. These circuits are often used in robotics and other applications to allow DC

21
“PORTABLE TWO AXIS CNC PRINTER”

motors to run forwards and backwards. H-bridges are available as integrated circuits or can be
built from discrete components.
The key fact to note is that there are, in theory, four switching elements within the bridge.
These four elements are often called, high side left, high side right, low side right, and low side
left (when traversing in clockwise order).
The "high side drivers" are the relays that control the positive voltage to the motor. This
is called sourcing current. He "low side drivers" are the relays that control the negative voltage to
sink current to the motor. "Sinking current" is the term for connecting the circuit to the negative
side of the power supply, which is usually ground.

Figure 2.14 Schematic diagram of H-Bridge using relay

The switches are turned on in pairs, either high left and lower right, or lower left and high right,
but never both switches on the same "side" of the bridge. If both switches on one side of a bridge
are turned on it creates a short circuit between the battery plus and battery minus terminals. This
phenomenon is called shoot through in the Switch-Mode Power Supply (SMPS) literature. If the
bridge is sufficiently powerful it will absorb that load and your batteries will simply drain
quickly. Usually however the switches in question melt.

To power the motor, you turn on two switches that are diagonally opposed. In the picture
to the right, imagine that the high side left and low side right switches are turned on.

22
“PORTABLE TWO AXIS CNC PRINTER”

Figure 2.15 Working of basic bridge


Then for reverse you turn on the upper right and lower left circuits and power flows
through the motor in reverse.
MOTOR DRIVER SHIELD (L293D)

 Four H-Bridges: Two L293D Motor driver chips


 L293D is rated at 0.6A per bridge (1.2A peak) with thermal shutdown protection, internal
kickback protection diodes.
 Motor Voltages from 4.5VDC to 32VDC. (up to 36V if C6 and C7 are upgraded) Up to 4
bi-directional DC motors with individual 8-bit speed selection (256 speeds)
 Up to 2 stepper motors (unipolar or bipolar)
 Pull down resistors keep motors disabled during power-up
 Separate Logic and Motor power connections
 Terminal block connectors for motors and power.

23
“PORTABLE TWO AXIS CNC PRINTER”

Pin no Name Function

1 Enable1,2 Enable pin to control 1,2 driver

2 Input 1A Input to control 1Y

3 Output 1Y Output, connect to motor

4 GND Ground and heat sink

5 GND Ground and heat sink

6 Output Output, connect to motor 2Y

7 Input 2A Input to control 2Y

8 Vcc2 Output supply voltage

9 Enable3,4 Enable pin to control 3,4 driver

10 Input 3A Input to control 3Y

11 Output 3Y Output, connect to motor

12 GND Ground and heat sink

13 GND Ground and heat sink

14 Output 4Y Output, connect to motor

15 Input 4A Input to control 4Y

16 Vcc1 Supply voltage(7 max)

24
“PORTABLE TWO AXIS CNC PRINTER”

PIN FUNCTION

FEATURES

 Wide Supply-Voltage Range: 4.5 V to 36 V


 Separate Input-Logic Supply
 Internal ESD Protection
 Thermal Shutdown
 High-Noise-Immunity Inputs
 Output Current 600 mA Per Channel
 Peak Output Current 1.2 A Per Channel

25
“PORTABLE TWO AXIS CNC PRINTER”

74HC595

The 74HC595 consists of an 8−bit shift register and a storage register with three−state
parallel outputs. It converts serial input into parallel output so that you can save IO ports of an
MCU. The 74HC595 is widely used to indicate multipath LEDs and drive multi-bit segment
displays. "Three-state" refers to the fact that you can set the output pins as either high, low or
"high impedance." With data latching, the instant output will not be affected during the shifting;
with data output, you can cascade 74HC595s more easily.

PIN FUNCTION

26
“PORTABLE TWO AXIS CNC PRINTER”

No Name Function
8-bit parallel data output pins, able to control 8 LEDs or 8 pins
1 Q0-Q7
of 7-segment display directly.

Series output pin, connected to DS of another 74HC595 to


2 Q7’
connect multiple 74HC595s in series

3 MR Reset pin, active at low level; here it is directly connected to 5V.

Time sequence input of shift register. On the rising edge, the


data in shift register moves successively one bit

4 SHcp
i.e. data in Q1 moves to Q2, and so forth. While
on the falling edge, the data in shift register
remain unchanged.

Time sequence input of storage register. On the rising edge,


5 STcp
data in the shift register moves into memory register.

6 OE Output enable pin, active at low level


7 DS Serial data input pin
8 VCC Positive supply voltage
9 GND Ground

FEATURES
 8-Bit Serial-In, Parallel-Out Shift
 Wide Operating Voltage Range of 2 V to 6 V
 High-Current 3-State Outputs Can Drive Up To 15 LSTTL Loads
 Low Power Consumption, 80-µA Max ICC
 Typical tpd = 13 ns
 Low Input Current of 1
 Shift Register Has Direct Clear

27
“PORTABLE TWO AXIS CNC PRINTER”

THE SCHEMATIC DIAGRAM OF L293D DRIVER SHIELD

PERSONAL COMPUTER
Personnel computers are very important for programming the Arduino board through
serial communication. Boot loader with Arduino controller will simplify the uploading process
of sketches to the flash memory. If we see that any other microcontrollers need an external
programmer. But here in this case on chip flash memory and boot loader of Arduino board
straight forward make use of a PC as a programmer. Presently Arduino boards are
communicating with computers or programmed via USB with the help of adapter chips. When
used with traditional microcontroller tools instead of the Arduino IDE, standard AVR in-system
programming (ISP) programming is used.

28
“PORTABLE TWO AXIS CNC PRINTER”

CHAPTER 5
SOFTWARE MODULE
INTRODUCTION
A programming dialect is used to pass on the rules to CPU or microcontroller and obliges
CPU to perform a specific work. To create a framework for an undertaking, the basic thing is to
pick a programming expression. In this endeavor, to make an undertaking which executed by
CPU through programming area. By then, the venture heading of each bit of the structure is
finished by application. The programming lingo can be segregated into two novel levels which is
the low level and high state programming expression.
The machine correspondence and low-level processing develop are under the
characterizations of low level programming expression. The machine tongue is the primary
programming expression that can be fathomed by microcontroller it contains numbers (0's and
1's) for form or read the framework rule. Fortunately, there is a compiler that can be used to
make an elucidation of others programming correspondence into machine level. The charge of
low level processing build is particularly fundamental accordingly programming design needs to
use extra time and put more effort in completing a befuddled task. Consequently, both of these
correspondences are not reasonable for this endeavour even the low-level figuring build may
give a short program execution time yet the time customer is not a fundamental issue for this
endeavour. Besides, ATMEGA328P has an adequately unfathomable memory space to store the
framework.
High state writing computer programs is more straightforward to grasp by programming
engineer differentiated and low-level programming correspondence as it is more sorted out,
utilizations from the gear. Other than that, the irregular state programming composing involves
variables, shows, calculating or Boolean expression, limits and others while the low-level
programming composing just oversees register and memory address. Along these lines, the
programming expression that starts from high state programming expression is the primary
choice for some product engineer as the microcontroller ending up being all the more
confounding, code progression using gathering gets the chance to be great and requires a
considerable measure of data. Then again, there is a limitation for high state programming
correspondence where it requires an all the more competent compiler to make an understanding
of the framework into machine correspondence.

29
“PORTABLE TWO AXIS CNC PRINTER”

SOFTWARE COMPONENTS
C and C++ languages using special rules to organize code supports by the Arduino IDE.
Arduino integrated development environment (IDE) is an application written in the programming
language Java.

ARDUINO IDE
Arduino programs can be written in any language with a compiler that produces machine
code. Atmel provides an integrated development environment for microcontrollers, i.e. AVR
Studio and the newer Atmel Studio.

Arduino integrated development environment (IDE) is an application written in the


programming language Java. It originated from the Integrated Development Environment for the
languages processing. This software development is designed to introduce newcomers unfamiliar
with software for programming. It consists of a code editor with features such as automatic
indentation, syntax, and brace matching. Arduino integrated development environment (IDE)
provides compile and load programs to an Arduino board in one click mechanism. A program
written for Arduino with the integrated development environment is called a "sketch". C and
C++ languages using special rules to organize code supports by the Arduino IDE. The two
functions in Arduino C/C++ sketch compiled and linked with a program stub main () into an
executable cyclic executive program are:
Setup (): this is a function can initialize settings and runs once at the start of a program.
Loop (): a function called repeatedly.

SOFTWARE PROGRAMMING
The Arduino board can be programmed with the Arduino integrated development
environment (IDE) by Selecting the "Arduino/Genuine Uno" from the Tools. The ATmega328p
on the Uno built with a boot loader that allows you to upload new code to it therefore it doesn't
require external hardware programmer. It communicates using the original STK500 protocol. It
also has something called ICSP (in circuit serial programmer) for an external piece of hardware
that used to program a microcontroller to download software which actually in an assembly
language by selecting Arduino ISP or similar.

30
“PORTABLE TWO AXIS CNC PRINTER”

In this board it also supports USB programmer to access a smaller microcontroller The
ATmega16U2 firmware so we don't need a separate circuit provide for USB Support. After
compiling and linking with the GNU tool chain, also included

With the IDE distribution, an IDE employs the program argued is used to convert the
executable code into a text file. It’s in hexadecimal code that is loaded into the Arduino board by
a loader in the board's firmware.

31
“PORTABLE TWO AXIS CNC PRINTER”

INKSCAPE

Inkscape is a free and open-source vector graphics editor; it can be used to create or edit
vector graphics such as illustrations, diagrams, line arts, charts, logos and complex paintings.
Inkscape's primary vector graphics format is Scalable Vector Graphics (SVG), however many
other formats can be imported and exported

INTERFACING AND USABILITY

One of the main priorities of the Inkscape project is interface consistency and usability.
This includes efforts to follow the human interface guidelines, universal keyboard accessibility,
and convenient on-canvas editing. Inkscape has achieved significant progress in usability since
the project started.

The number of floating dialog boxes has been reduced, with their functions available using
keyboard shortcuts or in the docked toolbars in the editing window. The tool bar controls at the
top of the window always display the controls relevant to the current tool.

Inkscape provides mouse over tooltips and status bar hints for all buttons, controls, commands,
keys, and on-canvas handles. The status bar hint messages are dynamic: A given object can
display up to four hints while editing it with just one tool.

PLATFORM SUPPORT

 The latest version of Inkscape is available for Ubuntu, Open SUSE, Microsoft
Windows and macOS platforms. Both 32-bit and 64-bit versions are available for Windows PCs.

 Inkscape is packaged for all major Linux distributions (including Debian, Ubuntu,
Fedora, Open SUSE

32
“PORTABLE TWO AXIS CNC PRINTER”

GCTRL

Gctrl is a GUI (Graphical User Interface) program for use with GRBL. Gctrl is code that
is meant to run on the software called "Processing". Gctrl provides control options for jogging
and sending gcode.
G-code which has many variants is the common name for the most widely
used numerical control (NC) programming language. It is used mainly in computer-aided
manufacturing to control automated machine tools.
G-code is a language in which people tell computerized machine tools how to make
something. The "how" is defined by g-code instructions provided to a machine controller
(industrial computer) that tells the motors where to move, how fast to move, and what path to
follow. The most common situation is that, within a machine tool, a cutting tool is moved
according to these instructions through a tool path and cuts away material to leave only the
finished work piece. The same concept also extends to noncutting tools such as forming or
burnishing tools, photo plotting, additive methods such as 3D printing, and measuring
instruments.
Specific codes
G-codes, also called preparatory codes, are any word in a CNC program that begins with
the letter G. Generally it is a code telling the machine tool what type of action to perform, such
as:

 Rapid movement (transport the tool as quickly as possible in between cuts)


 Controlled feed in a straight line or arc
 Series of controlled feed movements that would result in a hole being bored, a work piece
cut (routed) to a specific dimension, or a profile (contour) shape added to the edge of a work
piece
 Set tool information such as offset
 Switch coordinate systems

33
“PORTABLE TWO AXIS CNC PRINTER”

34
“PORTABLE TWO AXIS CNC PRINTER”

CHAPTER 6
METHODLOGY OF THE PROJECT
ALGORITHM FOR WIFI CONTROLLED MILITARY ROBOT
Step 1 : we dump the code to microcontroller.
Step 2 : DC Stepper & servo Motor turns on and start running.
Step 3 : we process the image and convert it into g-code form.
Step 4 : we open Gctrl processor and select the port and the image to process.
Step 5 : stepper and servo motor starts running in both X&Y axis.
Step6 : stepper motor and servo motor turns off.

TEST PLAN
 command should be initialized
 The image should be converted into G-code form.

 In gctrl the port selection and G-code produced by the inkscape should be given to
controller.
 The 12v, 1A DC supply should be given to the driver supply.
 The DC stepper motor ran smoothly in both XY-axis of the limited shaft.
 The cartridge (pen) which is inserted to the holder must run up and down freely.
 The commanded Gcode image must be drawn on the board suspended on the Y-Axis of
the motor board.

TEST RESULTS
 Command successfully got initialized.
 The image in inkscape got converted to g-code easily.
 The gctrl code and port selection of the Arduino got selected initially.
 The G converted code was send to the MCU initially.
 Motor successfully turn ON as soon as process begins.
 The cartridge (pen) ran smoothly on the suspended paper.
 The image which was given has been drawn as per the given command.

35
“PORTABLE TWO AXIS CNC PRINTER”

CHAPTER 7

CONCLUSION
In this study, it was attempted to develop XY plotter that accurately synchronize with the
Arduino software system for better response for the moment of XY axis. Difference IDE and
different languages have been tried and used to complete this project to meet the objectives. With
a lot of new technologies been developing now days, this project serve to provide a good
platform for future development for XY plotter system and even other system. This capstone
project is the perfect way to demonstrate our understanding and the application of mechanical
electrical egg knowledge in to solving every day’s problem for the benefit for mankind.

36
“PORTABLE TWO AXIS CNC PRINTER”

REFERENCES

 https://www.youtube.com/watch?v=opZ9RgmOIpc

 https://github.com/martymcguire/inksc...

 https://playground.arduino.cc/Main/AdafruitMotorShield

37
“PORTABLE TWO AXIS CNC PRINTER”

ARDUINO
APPENDIX
CODE:
#include <Servo.h>
#include <AFMotor.h>

#define LINE_BUFFER_LENGTH 512

char STEP = MICROSTEP ;

// Servo position for Up and Down


const int penZUp = 115;
const int penZDown = 83;

// 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


struct point actuatorPos;

// Drawing settings, should be OK


float StepInc = 1;
int StepDelay = 0;

38
“PORTABLE TWO AXIS CNC PRINTER”

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 = 80;
float Ymin = 0;
float Ymax = 80;
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

Serial.begin( 9600 );

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

39
“PORTABLE TWO AXIS CNC PRINTER”

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;

while (1) {

40
“PORTABLE TWO AXIS CNC PRINTER”

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

41
“PORTABLE TWO AXIS CNC PRINTER”

}
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';
buffer[1] = '\0';

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

42
“PORTABLE TWO AXIS CNC PRINTER”

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();
}
if (Spos == 50) {
penUp();
}

43
“PORTABLE TWO AXIS CNC PRINTER”

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).
* 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) {
x1 = Xmax;
}
if (x1 <= Xmin) {
x1 = Xmin;
}

44
“PORTABLE TWO AXIS CNC PRINTER”

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;

if (dx > dy) {


for (i=0; i<dx; ++i) {
myStepperX.onestep(sx,STEP);

45
“PORTABLE TWO AXIS CNC PRINTER”

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);
// Update the positions
Xpos = x1;
Ypos = y1;

46
“PORTABLE TWO AXIS CNC PRINTER”

// 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.");

}
}

47
“PORTABLE TWO AXIS CNC PRINTER”

G-CODE

APENDEX
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;
//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(frame,
"Select the serial port that corresponds to your Arduino board.",
"Select serial port",
JOptionPane.QUESTION_MESSAGE,
null,
Serial.list(),
0);

if (result != null) {

48
“PORTABLE TWO AXIS CNC PRINTER”

portname = result;
openSerialPort();
}
}

void setup()
{
size(600, 400);
openSerialPort();
}

void draw()
{
background(155);
fill(0);
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");

49
“PORTABLE TWO AXIS CNC PRINTER”

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");
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) {

50
“PORTABLE TWO AXIS CNC PRINTER”

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++;
}

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?
}

51
“PORTABLE TWO AXIS CNC PRINTER”

52

You might also like