project autosaved 1

47
Table of Contents CHAPTER 1: PERSPECTIVES 3 1.1. Introduction.............................................3 1.2. Description..............................................3 1.3. Uses of CNC..............................................4 Mills....................................................... 4 Lathes...................................................... 4 CNC Plasma Cutting Machine..................................4 1.4. Perspectives into the Modern History.....................4 1.5. Building and Mini CNC and Our Perspective................5 CHAPTER 2: PARAPHERNALIA 6 2.1. Electrical Equipments....................................6 Arduino Uno................................................. 6 Bread Board................................................. 7 DVD Writer (ASUS 24D3ST)....................................7 Jumper Wire................................................. 8 Servo Motor................................................. 8 Lithium Polymer battery.....................................9 Motor driver (l293D)........................................9 2.2. Mechanical Parts........................................10 L shaped base.............................................. 10 Pen holder assembly........................................11 Y Axis..................................................... 11 X Axis..................................................... 12

Upload: gonkil

Post on 13-Apr-2016

17 views

Category:

Documents


0 download

DESCRIPTION

killer intention

TRANSCRIPT

Page 1: Project Autosaved 1

Table of ContentsCHAPTER 1:PERSPECTIVES 3

1.1. Introduction...........................................................................................................................3

1.2. Description............................................................................................................................3

1.3. Uses of CNC.........................................................................................................................4

Mills..........................................................................................................................................4

Lathes.......................................................................................................................................4

CNC Plasma Cutting Machine.................................................................................................4

1.4. Perspectives into the Modern History...................................................................................4

1.5. Building and Mini CNC and Our Perspective......................................................................5

CHAPTER 2:

PARAPHERNALIA 62.1. Electrical Equipments...........................................................................................................6

Arduino Uno.............................................................................................................................6

Bread Board..............................................................................................................................7

DVD Writer (ASUS 24D3ST).................................................................................................7

Jumper Wire.............................................................................................................................8

Servo Motor..............................................................................................................................8

Lithium Polymer battery..........................................................................................................9

Motor driver (l293D)................................................................................................................9

2.2. Mechanical Parts.................................................................................................................10

L shaped base.........................................................................................................................10

Pen holder assembly...............................................................................................................11

Y Axis.....................................................................................................................................11

X Axis.....................................................................................................................................12

Nuts and Bolts........................................................................................................................12

Z Axis.....................................................................................................................................13

Page 2: Project Autosaved 1

CHAPTER 3:SYSTEM DYNAMICS 14

3.1. Mechanism..........................................................................................................................14

The CNC Controller or Drive control....................................................................................14

3.2. Circuit Design and Integration............................................................................................15

3.3. Software Components.........................................................................................................16

Arduino IDE...........................................................................................................................16

Processing...............................................................................................................................17

Inkscape..................................................................................................................................18

INDEX 19Arduino Program........................................................................................................................19

Processing Program (gtcrl.pde) App..........................................................................................29

Page 3: Project Autosaved 1

CHAPTER-1

PERSPECTIVES1.1. Introduction:

Numerical control (NC) is the automation of machine tools that are operated by precisely programmed commands encoded on a storage medium, as opposed to controlled manually by hand wheels or levers, or mechanically automated by cams alone. Most NC today is computer (or computerized) numerical control (CNC), in which computers play an integral part of the control.

Fig.1.1: Modern CNC Tool

1.2. Description:

Motion is controlled along multiple axes, normally at least two (X and Y), and a tool spindle that moves in the Z (depth). The position of the tool is driven by direct-drive stepper motor or servo motors in order to provide highly accurate movements, or in older designs, motors through a series of step down gears. Open-loop control works as long as the forces are kept small enough and speeds are not too great. On commercial metalworking machines, closed loop controls are standard and required in order to provide the accuracy, speed, and repeatability demanded.

CNC-like systems are now used for any process that can be described as a series of movements and operations. These include laser cutting, welding, friction stir welding, ultrasonic welding, flame and plasma cutting, bending, spinning, hole-punching, pinning, gluing, fabric cutting, sewing, tape and fiber placement, routing, picking and placing, and sawing.

Page 4: Project Autosaved 1

1.3. Uses of CNC:

Mills:

CNC mills use computer controls to cut different materials. They are able to translate programs consisting of specific numbers and letters to move the spindle (or workpiece) to various locations and depths. Many use G-code, which is a standardized programming language that many CNC machines understand, while others use proprietary languages created by their manufacturers.

Lathes:

CNC lathes are able to make fast, precision cuts, generally using indexable tools and drills. They are particularly effective for complicated programs to make parts that would be more difficult to make on manual lathes. CNC lathes have similar control specifications to CNC mills and can often read G-code as well as the manufacturer's proprietary programming language.

CNC plasma cutting Machine:

Plasma cutting involves cutting a material using a plasma torch. It is commonly used to cut steel and other metals, but can be used on a variety of materials. In this process, gas (such as compressed air) is blown at high speed out of a nozzle; at the same time an electrical arc is formed through that gas from the nozzle to the surface being cut, turning some of that gas to plasma.

1.4. Perspectives into the Modern History:

The first commercial NC machines were built in the 1950's, and ran from punched tape. While the concept immediately proved it could save costs, it was so different that it was very slow to catch on with manufacturers. In order to promote more rapid adoption, the US Army bought 120 NC machines and loaned them to various manufacturers so they could become more familiar with the idea. By the end of the 50's, NC was starting to catch on.

A number of key developments brought CNC rapidly along during the 1960's like: standard G-

Code Language for Part Programs, CAD, Minicomputers.

By 1970, the economies of most Western countries had slowed and employment costs were rising. With the 60's, having provided the firm technology foundation that was needed, CNC took off and began steadily displacing older technologies such as hydraulic tracers and manual manufacturing.

More recently, microprocessors have made CNC controls even cheaper, culminating with the availability of CNC for the hobby and personal CNC market. The Enhanced Machine Controller project, or EMC2, was a project to implement an Open Source CNC controller that was started by NIST, the National Institute of Standards and Technology as a demonstration.

Page 5: Project Autosaved 1

1.5. Building and Mini CNC and Our Perspective:

Fascination towards numerically computerized systems was our main motivator when it comes to

giving our project the existence it has now. Primarily our thought was on using CNC for writing

or in general plotting .as it is used in any modern CNC the mathematical or coordinate system to

represent any graphical system for instance –images, letters or any kind of symbol.

Now-a-days graphical softwares like processing are used in a great deal to control precise cutting

or writing. From the very beginning it was one of our purposes to combine our work with

processing and making it an all-purpose writer. Same technology can easily be used for the

purpose of cutting or shaping making mechanical shapers and cutters a lot more precise.

For understanding we have separated our technicalities like-mechanical, electrical and computerized tasks and parts in several formats. Unlike the real CNCs our CNC is small in size and hence portable making it a lot easier to use.

CHAPTER-2

Page 6: Project Autosaved 1

PARAPHERNALIABased on the miscellaneous equipments we used to build the mini CNC, there are mainly two groups of equipments-1) Electrical equipments and 2) Mechanical parts. We tried our best to build the project from scratch and not to use custom built parts.

2.1. Electrical Equipments:

Arduino Uno:

The Uno is a microcontroller board based on the ATmega328P. It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header and a reset button. It contains everything needed to support the microcontroller; simply connecting it to a computer with a USB cable or powering it with a AC-to-DC adapter or battery gets it started.

Technical specs:

Microcontroller: ATmega328P

Operating Voltage: 5V

Input Voltage (recommended): 7-12V

Input Voltage (limit): 6-20V

Digital I/O Pins: 14 (of which 6 provide PWM output)

PWM Digital I/O Pins: 6

Analog Input Pins: 6

DC Current per I/O Pin: 20 mA

DC Current for 3.3V Pin: 50 mA

Flash Memory: 32 KB (ATmega328P)

EEPROM:1 KB (ATmega328P)

Clock Speed: 16 MHz

Length: 68.6 mm

Width : 53.4 mm

Weight: 25 g

Page 7: Project Autosaved 1

Fig.2.1. Arduino Uno

Bread Board:

A breadboard is a construction base for prototyping of electronics. Originally it was literally a bread board, a polished piece of wood used for slicing bread. In the 1970s the solderless breadboard (AKA plugboard, a terminal array board) became available and nowadays the term "breadboard" is commonly used to refer to these.

Fig.2.2. Bread board

DVD Writer (ASUS 24D3ST):

In computing, an optical disc drive (ODD) is a disk drive that uses laser light or electromagnetic waves within or near the visible light spectrum as part of the process of reading or writing data to or fromes optical discs. Some drives can only read from certain discs, but recent drives can both read and record, also called burners or writers. Compact disks, DVDs, and Blu-ray disks are common types of optical media which can be read and recorded by such drives. Optical disc drives that are no longer in production include CD-ROM drive, CD writer drive, and

Page 8: Project Autosaved 1

combo (CD-RW/DVD-ROM) drive. As of 2015, DVD writer drive is the most common for desktop PCs and laptops. There are also DVD-ROM drive, BD-ROM drive, Blu-ray Disc combo drive, and Blu-ray Disc writer drive which are not so much demand in the market.

We used ASUS DRW-24D3ST. SUS DRW-24D3ST is a powerful 24X DVD±R/12X DVD±R(DL)/8X DVD+RW/6X DVD-RW/16X DVD-ROM/12X DVDRAM/ 48X CD-R/32X CD-RW/48X CD-ROM for a seamless function of flexibility, high quality and

Fig.2.3.ASUS DVD Writer

Jumper Wire:

A jump wire, is a short electrical wire with a solid tip at each end (or sometimes without them, simply "tinned"), which is normally used to interconnect the components in a breadboard. PE: among others, they are used to transfer electrical signals from anywhere on the breadboard to the input/output pins of a microcontroller.

Fig.2.4. Jumper wire

Servo Motor: (Tower pro micro servo-9g)

A servomotor is a rotary actuator or linear actuator that allows for precise control of angular or linear position, velocity and acceleration.It consists of a suitable motor coupled to a sensor for position feedback. It also requires a relatively sophisticated controller, often a dedicated module designed specifically for use with servomotors.Servomotors are not a specific class of motor although the term servomotor is often used to refer to a motor suitable for use in a

Page 9: Project Autosaved 1

closed-loop control system.Servomotors are used in applications such as robotics, CNC machinery or automated manufacturing

Fig.2.5. Tower Pro Servo

Lithium Polymer battery: (7.4volts)

We used lithium polymer battery as a power source in our project. A lithium polymer battery, or more correctly lithium-ion polymer battery (abbreviated variously as LiPo, LIP, Li-poly andothers), is a rechargeable battery of lithium-ion technology in a pouch forma.

Fig2.6.LIPO battery

Motor driver (l293D):

L293D is a typical Motor driver or Motor Driver integrated circuit which is used to drive direct current on either direction. It is a 16-pin IC which can control a set of two DC motors simultaneously in any direction. It means that two DC motors can be controlled by a single L293D IC. Dual H-bridge Motor Driver integrated circuit (IC).The l293d can drive small and quite big motors as well. It works on the concept of H-bridge. H-bridge is a circuit which allows the high voltage to be flown in either direction. As you know voltage should change its direction to able to rotate the motor in clockwise or anticlockwise direction, Hence H-bridge IC are ideal for driving a DC motor.Using micro-controllerIn a single l293d IC there two h-Bridge circuit inside the it which can rotate two dc motor independently. Due to its size it is very much used in robotic application for controlling DC motors.There are two Enable pins on l293d. Pin 1 and pin 9, for being able to drive the motor, the pin 1 and 9 need to be high. For driving the

Page 10: Project Autosaved 1

motor with left H-bridge you need to enable pin 1 to high. And for right H-Bridge you need to make the pin 9 to high. If anyone of the either pin1 or pin9 goes low then the motor in the corresponding section will suspend working. It’s like a switch

Fig.2.7.motor driver l293D

2.2. Mechanical Parts:

L shaped base:

When it came to choosing material for our project portability was always a pririty . keeping it lighter and flexible was our main motto when we designed the base. So wood was chosen as material.to make it L shaped two wooden slabs were clamped together exactly at 90 degrees,for the accommodation of the two axes which need to be exactly perpendicular to each other . two 25x25 cm wooden slabs with a thickness of 4 cm were chosen primarily. Two slabs were temporarily joint by iron clamps .the upper slab was clamped at a bit away from the edge to accommodate the stroke of the stepper motor stage used as the y axis .all the structural materials were supplied by the carpentry shop BUET.

Fig.2.8. L shaped base

Pen holder assembly:

Page 11: Project Autosaved 1

The pen holder is made of wooden block of 10x5 cm . a hole through the block is made to hold the pen which is tapped to be tightened by a screw. The hole is of 1 cm bore . the screw is of 5 mm bore .The screw passes through a tapped front hole in the block .The block has another hole of 5 mm bore in the back whole throuh,throuh which a 5.5 mm bore steel rod of 7 cm length slides.The rod is smoothly machined to slide freely throuh the hole or minimize the friction,as more friction would mean more power loss for the servo motor .The rod is hold to the main platform of X axis throuh two partial holes of two wooden blocks .these two small wooden blocks of 3x2 cm is glued to the main X axis base.To guide the return motion of the pen there are spring tappings to

Limit the stroke .And there is a spring with a good restoration force and small elasticity to give the return stroke restoration force after compression to push it downwards.the whole pen up and down mechanism is based on this .

Fig.2.9. Pen Holder Assembly

Y Axis:

The Y axis is made to accommodate one of the dvd writers which is used for guiding the x co-ordinate motion of the mechanism .basically it’s a wooden pad to hold a piece of paper on it .the wooden pad is about 7x7 cm beneath which there is a wooden support to increase the height to reach the pen tip.the axis is mounted on the horizontal plane of the L shaped base.the pad which is glued on the dvd writer with the whole assembly is mounted through couple of nuts and bolts which also give it a desired height to meet the pen tip.

Page 12: Project Autosaved 1

Figure.2.10: Y axis.

X Axis:

The X axis accommodates the whole pen holder assembly and guides the motion of the x ordinate of the whole mechanism .the pen holder assembly is glued to it with the help of strong glue.and the whole axis is mounted on the vertical plane of the L shaped base.It is also heightened by using several nuts through bolts which again serves the purpose of mounting it .

Fig.2.11. X axis

Nuts and Bolts:

In the whole project we have used several nuts and bolts of various sizes according to our need.

Page 13: Project Autosaved 1

Fig.2.12. Nuts and Bolts

The bolts have been used for several mountings such as the x axis and y axis,also to heighten the axes to give them the desired location upto their limited stroke.

Z Axis:

The Z axis is simply a servo which is mounted to the verical base of the L shaped frame.The servo is mounted by a mounting which is made of sheet metal and is of L shape of .Which has several holes through it to screw it by nuts.The Z axis guides the motion of the z coordinate of the mechanism .Which is basically the up and down motion of the pen.

The Z axis has a very little stroke though the measurement is really important as it will make the pen contact with the writing paper.

Fig.2.13. Z axis with the servo mounting

Page 14: Project Autosaved 1

CHAPTER- 3

SYSTEM DYNAMICSAs far any CNC this plotter pretty much depends on computer coltrol and precise depiction of motion.to depict each and every step as for mathematics coordinates are always used.Machines can be driven to such points with precision .To guide the pen to write something there are some important things that we did. The DVD writers were dismantled to use the stepper motor with its rail . basically two stepper with their rails and a servo motor to control the up and down motion make up the total mechanism .

3.1. Mechanism:

The total mechanisms can be divide into three axes –The X ,Y,Z axes.The X axis is as mentioned above a stepper motor derived from one of the dvd writers.This stepper motor has a rail,which like any shaft rotates as the motor turns.But the rail is threaded and there is small plastic surface attached to it.When the motor truns at a particular speed the plastic surface with the help of the rail moves along the X axis (left to right or right to left).This axis controls the movement of the pen along left to right.

The Y is also controlled by a stepper which has a rail attached to it.This rail also has a plastic surface attached to it.this surface moves back and forth to guide the movement of the writing platform along the y axis .

For any 2-D object there are only two dimensions and coordinates.Basically any position at a certain time can be depicted by two numbers or co-ordinates.so these two axes depict the motions of the writing paper and the pen.And during the working stroke –tip of the pen and the writing paper merges together to write someething.But when a certain letter is done then it needs to move towards another one,so certainly the pen is to uprise and go to its new loctaion.This is pretty much done with the Z axis .the srvo blade only has a 180 degree motion .That means the servo can turn its blade to a certain position then again move back to its old position.A servo can be controlled to give much smaller angle rotation and the rotations are pretty much precise.

The CNC Controller or Drive control:

The CNC controller is the brain of a CNC system. A controller completes the all important link between a computer system and the mechanical components of a CNC machine. The controller's primary task is to receive conditioned signals from a computer or indexer and interpret those

Page 15: Project Autosaved 1

signals into mechanical motion through motor output. There are several components that make up a controller and each component works in unison to produce the desired motor movement.

The word “controller” is a generic term that may refer to one of several devices, but usually refers to the complete machine control system. This system may include the protection circuitry, stepper or servo motor drivers, power source, limit switch interfaces, power controls, and other peripherals. Owners, operators, designers, and builders of CNC devices should understand the tasks performed by these components and how they affect machine performance.

The following sections will discuss the primary task of each component in the controller and how they work together to create a complete CNC system.

Fig.3.1.basic control system of cnc

3.2. Circuit Design and Integration:

The circuits consists of mainly of-

1) Two stepper motors2) One servo motor3) Several jumper wires both male-male and female-male.4) Breadboard5) Two l293d s6) One arduino Uno7) One Lipo Battery

Page 16: Project Autosaved 1

The circuit diagram is given below-

Fig.3.2. electrical circuit

3.3. Software Components:

Arduino IDE:

Arduino programs may be written in any programming language with a compiler that produces binary machine code. Atmel provides a development environment for their microcontrollers, AVR Studio and the newer Atmel Studio.

The Arduino project provides the Arduino integrated development environment (IDE), which is a cross-platform application written in Java. It originated from the IDE for the Processing programming language project and the Wiring project. It is designed to introduce programming to artists and other newcomers unfamiliar with software development. It includes a code editor with features such as syntax highlighting, brace matching, and automatic indentation, and provides simple one-click mechanism for compiling and loading programs to an Arduino board. A program written with the IDE for Arduino is called a "sketch".

The Arduino IDE supports the C and C++ programming languages using special rules of code organization. The Arduino IDE supplies a software library called "Wiring" from the Wiring project, which provides many common input and output procedures. A typical Arduino C/C++

Page 17: Project Autosaved 1

sketch consist of two functions that are compiled and linked with a program stub main() into an executable cyclic executive program:

setup(): a function that runs once at the start of a program and that can initialize settings.

loop(): a function called repeatedly until the board powers off.

After compilation and linking with the GNU toolchain, also including with the IDE distribution, the Arduino IDE employs the program avrdude to convert the executable code into a text file in hexadecimal coding that is loaded into the Arduino board by a loader program in the board's firmware.

Fig.3.3 Arduino

Processing:

Processing is an open source programming language and integrated development environment (IDE) built for the electronic arts, new media art, and visual design communities with the purpose of teaching the fundamentals of computer programming in a visual context, and to serve as the foundation for electronic sketchbooks. The project was initiated in 2001 by Casey Reas and Benjamin Fry, both formerly of the Aesthetics and Computation Group at the MIT Media Lab.

One of the stated aims of Processing is to act as a tool to get non-programmers started with programming, through the instant gratification of visual feedback. The language builds on the Java language, but uses a simplified syntax and graphics programming model. In 2012, they started the Processing Foundation along with Daniel Shiffman, who formally joined as a third project lead.

Processing includes a sketchbook, a minimal alternative to an integrated development environment (IDE) for organizing projects.

Every Processing sketch is actually a subclass of the PApplet Java class which implements most of the Processing language's features.

When programming in Processing, all additional classes defined will be treated as inner classes when the code is translated into pure Java before compiling. This means that the use of static variables and methods in classes is prohibited unless you explicitly tell Processing that you want to code in pure Java mode.

Page 18: Project Autosaved 1

Processing also allows for users to create their own classes within the PApplet sketch. This allows for complex data types that can include any number of arguments and avoids the limitations of solely using standard data types such as: int (integer), char (character), float (real number), and color (RGB, ARGB, hex).

Fig.3.3.Processing

Inkscape:

With Inkscape an artist can create most of the same illustrations that can be made with Adobe Illustrator. However, many of the functions and tools that the two applications share are used in different ways, with different names, shortcuts, and approaches. Please add to this document any relevant information on Inkscape/Illustrator parallels, constrasts, hits, and misses.

Illustrator can import Inkscape SVG and export SVG which Inkscape usually opens without problems (there's one issue to be aware of). Conversely, Inkscape opens Adobe's AI (since version 9) and PDF files (with some limitations: gradient meshes are approximated by lattices of small paths, and transparency modes don't work). Inkscape can also export its documents as PDF.

But we used it to create G-codes to give instruction to the gtcrl.pde application.

Anchor Points: in Inkscape, anchor points are known as "Nodes"

Palettes: in Inkscape, "palettes" are called "dialogs", such as the Fill and Stroke dialog.

Marquee: this is called "the rubberband" when selecting

Tools: see AdobeToolMap for complete tool equivalency reference.

Page 19: Project Autosaved 1

Fig.3.4.inkscape

INDEXArduino Program:

#include <Servo.h>

#include <Stepper.h>

#define LINE_BUFFER_LENGTH 512

const int stepsPerRevolution = 20;

Servo penServo;

Stepper myStepperY(stepsPerRevolution, 2,3,4,5);

Stepper myStepperX(stepsPerRevolution, 8,9,10,11);

struct point {

float x;

float y;

float z;

};

float StepInc = 1;

int StepDelay = 0;

int LineDelay = 50;

int penDelay = 50;

float Xmin = 0;

float Xmax = 40;

float Ymin = 0;

float Ymax = 40;

float Zmin = 0;

float Zmax = 1;

float Xpos = Xmin;

float Ypos = Ymin;

Page 20: Project Autosaved 1

float Zpos = Zmax;

void setup() {

Serial.begin( 9600 );

penServo.attach(penServoPin);

penServo.write(penZUp);

delay(200);

myStepperX.setSpeed(250);

myStepperY.setSpeed(250);

Serial.println(“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()

{

delay(200);

char line[ LINE_BUFFER_LENGTH ];

char c;

int lineIndex;

bool lineIsComment, lineSemiColon;

Page 21: Project Autosaved 1

lineIndex = 0;

lineSemiColon = false;

lineIsComment = false;

while (1) {

while ( Serial.available()>0 ) {

c = Serial.read();

if (( c == '\n') || (c == '\r') ) {

if ( lineIndex > 0 ) {

line[ lineIndex ] = '\0';

if (verbose) {

Serial.print( "Received : ");

Serial.println( line );

}

processIncomingLine( line, lineIndex );

lineIndex = 0;

}

else {

}

lineIsComment = false;

lineSemiColon = false;

Serial.println("ok");

}

else {

if ( (lineIsComment) || (lineSemiColon) ) {

if ( c == ')' ) lineIsComment = false; }

else {

if ( c <= ' ' ) {

Page 22: Project Autosaved 1

}

else if ( c == '/' ) {

}

else if ( c == '(' ) {

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';

}

else {

line[ lineIndex++ ] = c;

}

}

}

}

}

}

void processIncomingLine( char* line, int charNB ) {

int currentIndex = 0;

Page 23: Project Autosaved 1

char buffer[ 64 ];

struct point newPos;

newPos.x = 0.0;

newPos.y = 0.0;

while( currentIndex < charNB ) {

switch ( line[ currentIndex++ ] ) {

case 'U':

penUp();

break;

case 'D':

penDown();

break;

case 'G':

buffer[0] = line[ currentIndex++ ];

buffer[1] = '\0';

switch ( atoi( buffer ) ){

case 0:

Case 1:

char* indexX = strchr( line+currentIndex, 'X' );

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;

Page 24: Project Autosaved 1

}

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

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();

}

Page 25: Project Autosaved 1

if (Spos == 50) {

penUp();

}

break;

}

case 114:

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

}

}

}

}

void drawLine(float x1, float y1) {

if (verbose)

{

Serial.print("fx1, fy1: ");

Serial.print(x1);

Serial.print(",");

Serial.print(y1);

Serial.println("");

}

Page 26: Project Autosaved 1

if (x1 >= Xmax) {

x1 = Xmax;

}

if (x1 <= Xmin) {

x1 = Xmin;

}

if (y1 >= Ymax) {

y1 = Ymax;

}

if (y1 <= Ymin) {

y1 = Ymin;

}

if (verbose)

{

Serial.print("Xpos, Ypos: ");

Serial.print(Xpos);

Serial.print(",");

Serial.print(Ypos);

Serial.println("");

}

if (verbose)

{

Serial.print("x1, y1: ");

Serial.print(x1);

Serial.print(",");

Serial.print(y1);

Serial.println("");

Page 27: Project Autosaved 1

}

x1 = (int)(x1*StepsPerMillimeterX);

y1 = (int)(y1*StepsPerMillimeterY);

float x0 = Xpos;

float y0 = Ypos;

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.step(sx);

over+=dy;

if (over>=dx) {

over-=dx;

myStepperY.step(sy);

}

delay(StepDelay);

}

}

else {

for (i=0; i<dy; ++i) {

myStepperY.step(sy);

over+=dx;

if (over>=dy) {

Page 28: Project Autosaved 1

over-=dy;

myStepperX.step(sx);

}

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(LineDelay);

Xpos = x1;

Ypos = y1;

}

void penUp() {

Page 29: Project Autosaved 1

penServo.write(penZUp);

delay(LineDelay);

Zpos=Zmax;

if (verbose) {

Serial.println("Pen up!");

}

}

void penDown() {

penServo.write(penZDown);

delay(LineDelay);

Zpos=Zmin;

if (verbose) {

Serial.println("Pen down.");

}

}

Processing Program (gtcrl.pde) App:

import java.awt.event.KeyEvent;

import javax.swing.JOptionPane;

import processing.serial.*;

Serial port = null;

boolean streaming = false;

float speed = 0.001;

String[] gcode;

int i = 0;

Page 30: Project Autosaved 1

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

portname = result;

openSerialPort();

}

}

void setup()

{

size(500, 250);

openSerialPort();

}

void draw()

Page 31: Project Autosaved 1

{

background(0);

fill(255);

int y = 24, dy = 12;

text("INSTRUCTIONS", 12, y); y += dy;

text("p: select serial port", 12, y); y += dy;

text("1: set speed to 0.001 inches (1 mil) per jog", 12, y); y += dy;

text("2: set speed to 0.010 inches (10 mil) per jog", 12, y); y += dy;

text("3: set speed to 0.100 inches (100 mil) per jog", 12, y); y += dy;

text("arrow keys: jog in x-y plane", 12, y); y += dy;

text("page up & page down: jog in z axis", 12, y); y += dy;

text("$: display grbl settings", 12, y); y+= dy;

text("h: go home", 12, y); y += dy;

text("0: zero machine (set home to the current location)", 12, y); y += dy;

text("g: stream a g-code file", 12, y); y += dy;

text("x: stop streaming g-code (this is NOT immediate)", 12, y); y += dy;

y = height - dy;

text("current jog speed: " + speed + " inches per step", 12, y); y -= dy;

text("current serial port: " + portname, 12, y); y -= dy;

}

void keyPressed()

{

if (key == '1') speed = 0.001;

if (key == '2') speed = 0.01;

if (key == '3') speed = 0.1;

if (!streaming) {

if (keyCode == LEFT) port.write("G91\nG20\nG00 X-" + speed + " Y0.000 Z0.000\n");

Page 32: Project Autosaved 1

if (keyCode == RIGHT) port.write("G91\nG20\nG00 X" + speed + " Y0.000 Z0.000\n");

if (keyCode == UP) port.write("G91\nG20\nG00 X0.000 Y" + speed + " Z0.000\n");

if (keyCode == DOWN) port.write("G91\nG20\nG00 X0.000 Y-" + speed + " Z0.000\n");

if (keyCode == KeyEvent.VK_PAGE_UP) port.write("G91\nG20\nG00 X0.000 Y0.000 Z" + speed + "\n");

if (keyCode == KeyEvent.VK_PAGE_DOWN) port.write("G91\nG20\nG00 X0.000 Y0.000 Z-" + speed + "\n");

if (key == 'h') port.write("G90\nG20\nG00 X0.000 Y0.000 Z0.000\n");

if (key == 'v') port.write("$0=75\n$1=74\n$2=75\n");

if (key == '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 {

Page 33: Project Autosaved 1

println("User selected " + selection.getAbsolutePath());

gcode = loadStrings(selection.getAbsolutePath());

if (gcode == null) return;

streaming = true;

stream();

}

}

void stream()

{

if (!streaming) return;

while (true) {

if (i == gcode.length) {

streaming = false;

return;

}

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

else break;

}

println(gcode[i]);

port.write(gcode[i] + '\n');

i++;

}

void serialEvent(Serial p)

{

String s = p.readStringUntil('\n');

println(s.trim());

if (s.trim().startsWith("ok")) stream();

Page 34: Project Autosaved 1

if (s.trim().startsWith("error")) stream();

}

After running the code it shows a message like this:

Page 35: Project Autosaved 1

Fig.3.5.gtcrl.pde

G-code:

G-code (also RS-274), 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 sometimes called G programming language.G-code is a language in which people tell computerized machine tools how to make something. The "how" is defined by instructions on where to move, how fast to move, and what path to move. The most common situation is that, within a machine tool, a cutting tool is moved according to these instructions through a toolpath and cuts away material to leave only the finished workpiece. The same concept also extends to noncutting tools such as forming or burnishing tools, photoplotting, additive methods such as 3D printing, and measuring instruments.

G-codes are also called preparatory codes, and 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:

1)Rapid movement (transport the tool as quickly as possible through space to the location where it will cut)

2)Controlled feed in a straight line or arc

3)Series of controlled feed movements that would result in a hole being bored, a workpiece cut (routed) to a specific dimension, or a profile (contour) shape added to the edge of a workpiece

4)Set tool information such as offset

5)Switch coordinate systems

6)There are other codes; the type codes can be thought of like registers in a computer.

Students and hobbyists have pointed out over the years that the term "G-code" is imprecise. It comes from the literal sense of the term, referring to one letter address and to the specific codes that can be formed with it (for example, G00, G01, G28). But every letter of the English alphabet is used somewhere in the language. Nevertheless, "G-code" is established as the common name of the language.

Page 36: Project Autosaved 1

Fig.3.6.Gcode

CHAPTER -4

Future modifications

4.1)Input and control mode:

We suggest that including more efficient input system will make the machine more user friendly .For instance ,using keyboard to make the entry of dessired output.If all the gcodes can be created according to desired work ,then the cnc can pretty much function as a printer.If all the alphabets are generated as g-codes and inputs are given from keyboards meaning that

Page 37: Project Autosaved 1

Pushing the desired alphabet or number key the desired g-code is selected ,the cnc will function almost like a printer .here are some modes of input and control that are suggested-

4.1.1)Manual Data Input Mode

This mode includes two positions on the mode switch, the edit position, and the manual data input (MDI) position. In each case, the operator will be entering data through the keyboard on the control panel and display screen.

Though these mode switch positions have substantial differences, we consider them together for two reasons. First, both mode switch positions involve entering data through the keyboard. With the edit position of the mode switch, a program is entered or modified. With the MDI position of the mode switch CNC commands are entered and executed.

Second, both provide manual capabilities that can also be done in a more automatic way. In edit mode, an operator can enter CNC programs into the control memory. This can also be accomplished by loading the program from some outside device, such as a computer or tape reader. In MDI mode, CNC commands are entered through the keyboard and display screen manually and can be executed once. If the command must be executed a second time, the operator must enter the MDI command a second time. However, if the same command is included in a program, it can be executed automatically, over and over without having to be re-typed.

4.1.2)Edit Mode:

If the user has ever worked with a word processor, they will find the use of the edit mode of a CNC control familiar and easy to work with. In this mode, the operator is allowed to do two basic things. He can enter CNC programs into the control memory and modify current programs. Almost all CNC controls allow the operator to store multiple programs. Programs are typically organized by program number (commonly the O word). The operator will be allowed to call up the desired program from within the control's memory, making it the active program.

All true CNC controls give the user the ability to do at least three basic things in the edit mode. The operator can insert new information into the program, alter the current information in the program, and delete information from the program. Some CNC controls also allow the operator to do global editing, meaning they can cut and paste, and find and replace data.

Page 38: Project Autosaved 1

Along with these basic features, the operator will be allowed to search or scan the program for key information. For example, the control can quickly search to the next occurrence of any programming word. If the programmer used sequence numbers (N words) the operator could use the sequence number of an incorrect command as the word used to search.

4.2)Small and more easily portable structure:

Though we have minimized structural complications there are still ways to make it more convenient in the eyes of an operator.the frame is 25x25 cm .This can be brought into much smaller frame .This would increase the portability and flexibility.

4.3)Adequate Space For Writing:

Due to motor stroke constrictions we are stuck up with a 5x5 cm writing space,which makes it unusable for practical puposes.If the space can be enlarged keeping the base size small this cnc plotter can be much efficient in the real world.Making a larger shaft for the rail can be a good way to do this.