Diy Hand Crank Circle Drawing Machine

CNC Machines are Computerized Numerical Control Machines which are used to describe anything or pattern any mechanical part co-ordinate to the design program fed into their controller unit. Controller unit tin can exist either reckoner or microcontroller. CNC machines have stepper and servo motors to draw the design equally per the fed program.

Later researching on CNC machines, I decided to build my own CNC machine using locally bachelor materials. At that place are and so a many CNC machines in the world, some of which are much technical and complex to make or even operate them properly. For this reason, I decided to make a uncomplicatedCNC Plotter Motorcar based on Arduino which is by far the simplest to make. You tin can also use this as an Arduino CNC cartoon auto with footling modifications.

This DIY Arduino CNC Car can draw most of the basic shapes, texts and even cartoons. It's performance is similar to the way a man mitt writes. It's faster and more authentic compared to the style a human being can write or draw. Cheque the sit-in Video at the end of this tutorial.

Building an Arduino CNC Automobile:

For a CNC plotting motorcar to operate, 3 axes are required (ten-axis, y-axis and z-centrality. The x-axis and y-axis work in unison to create a 2nd image on a plain paper. These x and y centrality 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 lower the pen onto the plain paper.

Depending on the epitome 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. Hither we have used Arduino as the Microcontroller to build this CNC Machine. The iii-centrality movements are provided by stepper motors, which will be ocntrolled by the Arduino board. You can chec out how to interface stepper motor with Arduino if you are new to this.

So let's offset building our Arduino CNC device step by step.

What Yous Need:

Note: My design is quite different in hardware in terms of size and the materials used. I wasn't able to find old DVD drives so I opted for printer parts. Whichever you use, ensure that information technology has a stepper motor.

Hardware Requirement:

  1. Aluminium sheet (710mm 10 710mm)
  2. Former HP/Epson printer. You tin use sometime calculator DVD drives
  3. Bolts and basics
  4. Perspex glass
  5. Arduino UNO
  6. L293D motor commuter shield or an Arduino CNC shield
  7. Mini servo motor
  8. A pen

arduino motor driver shield for cnc plotter machine

printer cradle for arduino cnc machinealuminium plate for arduino cnc machine

Tools:

  1. Screwdriver
  2. Drill
  3. Cutting tool (hacksaw)
  4. Gum
  5. Bench device

Softwares:

For the efficient operation of this auto, the following softwares are used. Go to the diverse websites and download them.

  1. Arduino IDE version 1.half-dozen.half dozen or later versions from here
  2. Processing IDE version 3.1.1 or afterwards version from hither
  3. Inkscape version 0.48.5. Download it from hither.
  4. Grbl controller (optional)

The Base of operations for CNC Plotter Machine:

The main body of this device is the base which supports all the major parts of the machine together so that the car is house and is likewise portable. In this pattern we will employ aluminum to construct the base of operations since it is light, simple to curve and cutting and too it gives a good shiny appearance since it doesn't rust.

The design and dimensions of my base is shown beneath:

aluminium base dimensions for arduino CNC machine
Note: All dimensions are in millimeters.

After all the bending and cutting, I was able to produce a very business firm base as shown below:

aluminium base for arduino CNC plotter machine

Associates of the Ten, Y and Z Axes:

To make x and y axes, two printer cradles are used. Each of these parts contains a stepper motor and a belt drive machinery normally used to move the cartridge to and fro.

ASSEMBLY OF THE X, Y AND Z AXES

For the z-axis, a mini servo motor is fastened on the y-axis using glue. This servo motor is used to move the pen up and down. A good support mechanism should be constructed that will enable the free upward and downward motility of the pen.

assembling z-axis for arduino CNC machine

assembly of z-axis for arduino CNC machine

Drawing Platform for CNC Machine:

Due to the immense size of this automobile, the device is capable of drawing on an A5 sized paper. Therefore we will cut out an A5 (148mmx210mm) sized platform from the Perspex drinking glass then stick it onto the 10-axis moving function using mucilage.

drawing glass platform for arduino CNC machine

Wiring and Circuit of CNC Machine:

Insert the L293D motor driver shield onto the Arduino UNO board. This shield tin can drive two stepper motors at the same time and 2 servo motors. Connect the two stepper motors equally shown beneath. The ground connection should be left unconnected since the motors are bipoplar blazon. This will act as our Arduino CNC controller for our Plotter car.

wiring motor driver shield for arduino CNC machine

Too attach the mini servo motor to servo1. Connect a 7.5V - 9V power supply to the power port of the motor driver shield. The machine is at present ready for testing.

Arduino CNC Machine Lawmaking and Testing:

First we demand to test the stepper motors and meet whether they are connected correctly.

Since we are using the L293D motor driver shield, we need to download the AFmotor Library from here. Then add it into your Arduino IDE library folder. Ensure you rename it to AFMotor.  If the Arduino IDE was open close it and open it again and click on file -> examples -> Adafruit Motor Shield Library -> stepper. Ensure you choose the correct port and board in tools and then upload the code into the Arduino board.  Some movements should be observed on stepper motor i.

In order to test motor two, change the motor port from two to 1 in the post-obit line and then upload the code over again.

#include <AFMotor.h>  // Connect a stepper motor with 48 steps per revolution (7.v degree) // to motor port #2 (M3 and M4) AF_Stepper motor(48, 2);

Arduino Code for CNC Auto:

arduino code for CNC machine

Once the stepper motors are responding appropriately, copy the Arduino lawmaking for CNC motorcar from the Code section below and upload it to the Arduino lath. You can download the code from the below link.

Arduino CNC code download

G-Code for CNC Auto:

One thousand - CODE is the language in which we tell computerized machines (CNC) to exercise something. It's basically a file that contains X, Y and Z coordinates.

For example:

G17 G20 G90 G94 G54 G0 Z0.25X-0.5 Y0. Z0.1 G01 Z0. F5. G02 X0. Y0.5 I0.5 J0. F2.five X0.five Y0. I0. J-0.5 X0. Y-0.5 I-0.5 J0. X-0.5 Y0. I0. J0.5 G01 Z0.ane F5. G00 X0. Y0. Z0.25

Writing a 1000-Code for just a simple square can be really challenging but luckily we have a software which can help us generate a G-Code. This software is called "Inkscape", download information technology from here.

You tin can generate your own Thou-Lawmaking using Inkscape, which we have explained in next section or but yous can apply readily bachelor  G-Codes on the internet.

Before I show you how to generate One thousand-Codes using Inkscape lets discuss on how to send those G-Codes into the Arduino. The software that will enable us send G-Codes into the Arduino is called Processing.

Processing IDE to upload the G-Code:

This platform will help us send the G-Codes to the Arduino lath. To do so, you lot will have to download the GCTRL.PDE file.

Download GCTRL.pde file from here and open it using Processing IDE

processing IDE for uploading g-code in arduino CNC machine

Once y'all've opened information technology in the Processing IDE, click run. A window appears with all the instructions. Printing p on the keyboard. The arrangement will ask you to choose a port. Then select the port on which your Arduino lath is connected. I my case information technology'south port 6.

Now press chiliad and browse to the folder where you saved your Chiliad-Lawmaking. Select the correct G-CODE and printing enter. If everything was connected correct, you lot should meet you device starting to plot on the paper.

If you want to cease the process, just press x and the device volition finish whatsoever it was doing.

How to Generate Your Own G-Code:

We mentioned that Inkscape is the software we volition use to generate our G-CODES. In this example we will create a elementary text (HELLO World) as shown below.

inkscap for generating g-code for arduino CNC machine

Note : Inkscape has no in built way of saving files as G-Lawmaking. Therefore you need to install an Improver that enables the consign images to G-CODE files. Download this MakerBot Unicorn plugin from here with installation notes.

If the installation was successful, Open the Inkscape, go to File menu and click "Document Properties". Outset change dimensions from px to mm. Also reduce the width and height to 90 mm. At present shut this window. A square appears every bit the drawing surface area. This is the expanse that we will employ to write our text.

Now on the left side bar, click on the create and edit text object tab. Type the text "HELLO WORLD"  and position it at the top right corner of the square as shown beneath.

inkscap for generating g-code for arduino CNC machine

Click text and cull the type of font style that you prefer. Click apply and the close.

Now click on path and select "object to path"

Your text is now ready to be saved equally G-CODE. Click on file -> save as and so type the file name equally "how-do-you-do world"

Change the file type to "MakerBot Unicon G-Lawmaking" as shown in below motion-picture show. This volition only appear if the Improver installation was successful. Finally click on save and click ok on the pop-up window.

inkscap for generating g-code for arduino CNC machine

You have generated a Thou-Lawmaking and it can be plotted using the previous procedures.

The GRBL Controller:

grbl controller for arduino CNC machine

One time y'all've managed to generate a K-Code using Inkscape, it may be necessary to view the G-Lawmaking in order to ensure that it is within the drawing limits.

The drawing limits are gear up in the Arduino CNC Code in the lines shown below:

setting size limits in arduino code for cnc machine

The image equally show above in the GRBL controller should not go beyond those limit every bit shown in the CNC Arduino lawmaking to a higher place. If it goes across those limit for example towards the negative side of the x-centrality, that part on the negative side will not be plotted.

In this example x and y values range from 0mm to 40mm.

Since I am using printer parts which can plot on a larger area, I alter the max values from 40mm to 60mm.

Whenever you generate a G-Code using Inkscape, you can first open that G-Code in the GRBL program to run across whether it is within those limits. If non within, y'all need to resize you prototype in the Inkscape until information technology is inside your limits.

And so this is the cheap and simplest method to build a CNC Plotter machine using arduino uno at home. Try it out and let usa know in comments also check the Video below.

Lawmaking

/*
Send GCODE to this Sketch using gctrl.pde https://github.com/damellis/gctrl
Catechumen SVG to GCODE with MakerBot Unicorn plugin for Inkscape available here https://github.com/martymcguire/inkscape-unicorn
Arduino lawmaking for this Mini CNC Plotter based on: https://github.com/adidax/mini_cnc_plotter_firmware
*/

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

#ascertain LINE_BUFFER_LENGTH 512

char STEP = MICROSTEP ;

// Servo position for Upward and Down
const int penZUp = 115;
const int penZDown = 83;

// Servo on PWM pin ten
const int penServoPin =x ;

// Should be correct 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-span
AF_Stepper myStepperY(stepsPerRevolution,i);
AF_Stepper myStepperX(stepsPerRevolution,two);

/* Structures, global variables    */
struct bespeak {
float x;
float y;
float z;
};

// Current position of plothead
struct indicate actuatorPos;

//  Drawing settings, should be OK
float StepInc = one;
int StepDelay = 0;
int LineDelay =0;
int penDelay = l;

// Motor steps to go ane millimeter.
// Utilize test sketch to go 100 steps. Mensurate the length of line.
// Summate steps per mm. Enter here.
float StepsPerMillimeterX = 100.0;
float StepsPerMillimeterY = 100.0;

// Cartoon robot limits, in mm
// OK to kickoff with. Could get up to 50 mm if calibrated well.
float Xmin = 0;
bladder Xmax = 40;
float Ymin = 0;
float Ymax = 40;
float Zmin = 0;
float Zmax = 1;

float Xpos = Xmin;
float Ypos = Ymin;
bladder Zpos = Zmax;

// Set to true to get debug output.
boolean verbose = faux;

//  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.adhere(penServoPin);
penServo.write(penZUp);
delay(100);

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

  //  Set & move to initial default position
// TBD

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

/**********************
* void loop() - Primary 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) {

    // Serial reception - Mostly from Grbl, added semicolon support
while ( Serial.available()>0 ) {
c = Serial.read();
if (( c == '\northward') || (c == '\r') ) {             // End of line reached
if ( lineIndex > 0 ) {                        // Line is complete. Then execute!
line[ lineIndex ] = '\0';                   // Cease string
if (verbose) {
Series.print( "Received : ");
Serial.println( line );
}
processIncomingLine( line, lineIndex );
lineIndex = 0;
}
else {
// Empty or comment line. Skip block.
}
lineIsComment = imitation;
lineSemiColon = false;
Series.println("ok");
}
else {
if ( (lineIsComment) || (lineSemiColon) ) {   // Throw away all comment characters
if ( c == ')' )  lineIsComment = fake;     // End of comment. Resume line.
}
else {
if ( c <= ' ' ) {                           // Throw away whitepace and command characters
}
else if ( c == '/' ) {                    // Block delete non 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( "Mistake - lineBuffer overflow" );
lineIsComment = faux;
lineSemiColon = simulated;
}
else if ( c >= 'a' && c <= 'z' ) {        // Upcase lowercase
line[ lineIndex++ ] = c-'a'+'A';
}
else {
line[ lineIndex++ ] = c;
}
}
}
}
}
}

void processIncomingLine( char* line, int charNB ) {
int currentIndex = 0;
char buffer[ 64 ];                                 // Hope that 64 is enough for 1 parameter
struct betoken newPos;

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

  //  Needs to interpret
//  G1 for moving
//  G4 P300 (look 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 control, if any
case 'U':
penUp();
break;
example '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 control
case 0:                                   // G00 & G01 - Movement or fast motion. Aforementioned here
example ane:
// /!\ Muddied - Suppose that X is earlier Y
char* indexX = strchr( line+currentIndex, 'X' );  // Go 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.10 = actuatorPos.x;
}
else {
newPos.y = atof( indexY + 1);
indexY = '\0';
newPos.x = atof( indexX + 1);
}
drawLine(newPos.x, newPos.y );
//        Series.println("ok");
actuatorPos.x = newPos.10;
actuatorPos.y = newPos.y;
break;
}
break;
instance '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 == xxx) {
penDown();
}
if (Spos == fifty) {
penUp();
}
break;
}
case 114:                                // M114 - Repport position
Serial.print( "Absolute position : X = " );
Serial.impress( actuatorPos.10 );
Serial.impress( "  -  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) : Catastrophe coordinates
**********************************/
void drawLine(float x1, float y1) {

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

  //  Bring instructions inside limits
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.impress(Xpos);
Serial.print(",");
Serial.print(Ypos);
Serial.println("");
}

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

  //  Catechumen coordinates to steps
x1 = (int)(x1*StepsPerMillimeterX);
y1 = (int)(y1*StepsPerMillimeterY);
bladder x0 = Xpos;
bladder y0 = Ypos;

  //  Let's detect out the alter 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,Stride);
over+=dy;
if (over>=dx) {
over-=dx;
myStepperY.onestep(sy,Pace);
}
delay(StepDelay);
}
}
else {
for (i=0; i<dy; ++i) {
myStepperY.onestep(sy,STEP);
over+=dx;
if (over>=dy) {
over-=dy;
myStepperX.onestep(sx,Pace);
}
delay(StepDelay);
}
}

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

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

  //  Delay earlier any next lines are submitted
delay(LineDelay);
//  Update the positions
Xpos = x1;
Ypos = y1;
}

//  Raises pen
void penUp() {
penServo.write(penZUp);
filibuster(penDelay);
Zpos=Zmax;
digitalWrite(xv, Low);
digitalWrite(sixteen, High);
if (verbose) {
Series.println("Pen up!");

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

gageejew1987.blogspot.com

Source: https://circuitdigest.com/microcontroller-projects/arduino-cnc-machine-project-code/

0 Response to "Diy Hand Crank Circle Drawing Machine"

Kommentar veröffentlichen

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel