Introduction: Mini CNC Machine Arduino Based & Adafruit Driver Motor L293D V1 & 2*Mini Stepper CD/DVD Player #1

Picture of Mini CNC Machine Arduino Based & Adafruit Driver Motor L293D V1 & 2*Mini Stepper CD/DVD Player #1

In this project I will show you how to easily build your own low-cost Arduino Mini CNC Plotter!

For X and Y axis we will use stepper motors and rails from two dvd/cd roms! Printing area will be max 4x4cm.

Step 1: The Video in Youtube :

Step 2: Parts

Picture of Parts

For this project you will need:

- Part list for beginners:

- Arduino uno ( or Mega ) Breadboard

- Shield driver motor L293D adafruit v1

- Mini Servo motor 9g

- 2x DVD/CD Drives

Librairy For Adafruit Shield Driver Motors v1 :

Step 3: X Y Axe

Picture of X Y Axe

In first image above you will see the Y axis of our CNC machine. Attach it on your surface, in this part you will need some screws and nuts.

In second image you will see the X and Y axis. The X axis is attached to two plastic parts that I took from remaining 'garbage' stuff. I cut it to fit the construction. This is an easy procedure. Just make sure to put the Y axis straight to CNC base and the X axis vertically in this (90 degrees)

Step 4: The Z Axis

Picture of The Z Axis

That's the most difficult part of our construction.

You will need something to attach it on X axis, a flat surface. On that surface you will attach the servo motor (Z axis) and the pen base. Pen (or pencil) must be able to move up and down with the help of servo motor. Watch the above image to understand what you need to do to duild Z axis. Tip! Use your imagination ;)

Step 5: the Circuit

Picture of  the Circuit

Step 6: Uploading the CNC Code

Picture of Uploading the CNC Code

Here is the main CNC code embedded using codebender!

In this part you will see your pen goes up. If don't, change penUp and penDown variables that controlling the servo motor. Press the "Run on Arduino" button and program your board from your browser!

Step 7: Make Your Own Gcode Files

To make gcode files that are compatible with this cnc machine you have to use the Inkscape.

Inkscape is professional quality vector graphics software which runs on Windows, Mac OS X and Linux. It is used by design professionals and hobbyists worldwide, for creating a wide variety of graphics such as illustrations, icons, logos, diagrams, maps and web graphics. Inkscape uses the W3C open standard SVG (Scalable Vector Graphics) as its native format, and is free and open-source software. Download and install Inkscape from : https://inkscape.org/en/download/windows/

(Important: download 0.48.5 version)

Now you need to install an Add-on that enables the export images to gcode files. This add on can be found here with installation notes.

https://github.com/martymcguire/inkscape-unicorn

Setup Inkscape for first use
Open the Inkscape, go to File menu and click "Document Properties". See the 1st image above and make the changes, make sure to change first to "cm". Now close this window. We will use the area within 4 to 8 cm. See the 2nd image above. How to print texts Put text, change font to Times New Roman and size to 22. Now click on cursor icon and center the text like the 3rd image above. Select Path from menu and "Object to Path". How to print images This is more difficult than texts. Images must have a transparent background. Drag and drop the arduino logo image (download it from files) in Inkscape. Click ok to the next window. Now you have to re-size the image to fit our printing area, see the 4th image above. Click Path from menu and "Trace Bitmap". Make changes as the 5th image above. Click ok and close the window. Now, move the gray scale image, and delete the color one behind it. Move the grey image to the correct place again and click from Path menu "Object to path". The 6th image above show how to delete image outline. Export as gcode Final, go to file menu, click save as and select .gcode. Click ok on next window. That's it! Ready to go! Use the gctrl.pde app to print the gcode file on your new Arduino CNC Plotter! I will make a video on next days about this procedure because it's little complicated. It took me a lot of time to understand how it's working...

Step 8: The GCTRL Program

Picture of The GCTRL Program

Now we are ready to print our first image! To do this we will use the gctrl . This program sends 'gcode' images to the cnc plotter.

What is gcode? Gcode is a file with X,Y and Z coordinates. Header of this file is set to: M300 S30.00 (Servo down) G1 X10.00 Y10.00 F2500.00 G1 X20.00 Y10.00 F2500.00 M300 S50.00 (Servo up)

Click the "play" icon/button to start the program.

Download gctrl for Windows :

https://www.instructables.com/files/orig/F69/K945/I...

Click First time to " p " to select Port number for Arduino

and click to " g " to select Gcode file ...

Step 9: Examples Gcode File

Comments

OscarV70 (author)2017-12-13

Hi, my cnc only draw a line, the Y motor go to the limit and cant draw, all is in the same Y line. And i cant set a correct my work area all time only print another line and another..etc Tnx for Help i like this proyect but not is my day :(

smit01 made it! (author)2017-10-03

Hello sir, you are doing a great work. This Instructable is great. I am recently
introduced to Arduino and am extremely excited by the almost infinite
possibilities that it creates. I am just a layman or a dummy, so I don’t have much
knowledge about programming and stuff but I try to make some projects that
is both practically useful and fun to make so that I could gain
experience. I was inspired and excited to make the cnc plotter
because I could see that by making it I would receive a great deal of
experience and a very good product which has multiple practical uses. So
I made it by following your instructions given in this Instructable. everything is working properly. But, i have a minor issue, when i connect the servo motor to the motor shield, the gctrl software stops loading the co-ordinates as soon as the servo motor is given a command i.e- pen up or pen down. The plotter works properly without the servo motor connected but not with it. When the servo motor is connected, the gctrl either does not load a .gcode file ( I mean, the file to choose a .gcode file opens but after selecting a .gcode file, the dialogue box only shows " Loading file...

User selected C:\Users\manoj\Desktop\arduino cnc plotter\Sample1.gcode
(Scribbled version of C:\Users\ABDERR~1\AppData\Local\Temp\ink_ext_XXXXXX.svgISF45X @ 3000.00) " ) or, if i plug in the servo motor while the plotter is working and plotting a .gcode file, then the gctrl stops loading the .gcode file and the plotter stops working. So I require your help
with this problem. It would be great if you help me out with this.
Thank you. Your hard work will definitely give you a great result and
you would be successful.

O'DonovanM made it! (author)2017-02-05

Fantastic, Thanks a million for this.

I have it up and running.

You're a STAR.

Hai can u please send me that code which u uploaded on arduino am using arduino uno r3 model

SarojR (author)O'DonovanM2017-02-17

can you send me your circuit connection between stepper and shield .. every thing is perfect but my output is distorted

injobho made it! (author)2017-03-30

I made a bigger version using your code to make a large cnc router
(40cmx30cm) and it is nicely printing small images that you shared.
Unfortunately it is printing images within a 5cm x5cm zone only. I tried
increasing the Xmax, Ymax beyond 50 but anything beyond 5 cm in printed
at a different place. your cd rom lead screw has high pitch but my lead
screw has 1.25 mm pitch. After calibration, I ended up at
StepsPerMillimeterY=1250, StepsPerMillimeterX=650

I also checked
the stepper motor example in adafruit library and it also draws line of 5
cm only (motor.step(4000, FORWARD, MICROSTEP); I tried with number
larger than 4000. Is it a limitation of the hardware? Can you please
help? I am a mechanical engineer but new to arduinio.

DebojitK (author)injobho2017-08-12

Hi I am impressed by your design. Would you please share some more design details?

Like Servo details, lead screw detail, stepper driver (if not L293d based) etc.

Lead screws are very costly. Is it possible to use a long bolt and nut to replace proper lead screw?

injobho made it! (author)injobho2017-04-01

Fixed the problem. It was happening because of the low pitch of the screw the value of x1 was exceeding the range of int. I Just changed it to long and its solved the problem but at a cost of higher memory.

Yassineb12 (author)injobho2017-07-22

thanks for the solution !

DebojitK made it! (author)2017-08-12

I had to change the motor mode to INTERLEAVE instead of MICROSTEP.

DanielC807 made it! (author)2017-08-04

please help me

DebojitK (author)DanielC8072017-08-12

Are you still struggling to get a better drawing?

If so here are some things you can try out as I explain below.

If you are using L293d shield, the major problem can be with microstepping. If you see the Afmotor library documentation they clearly mention that microstepping looses torque severely and any sort of retracting force can stop the movement while the motor runs in microstepping mode. Even when the pen touches the sheet it can generate that friction that can create the problem. I changed the code a little bit to use INTERLEAVE mode instead of MICROSTEP.

Interleave is similar to microstep but with lesser resolution. I found with interleaving the motor traverses 16 mm for 200 steps. So steps per mm = 200/16=12.5. Torque is quite good. I also adjusted the speed of drawing and now it gives very neat drawings.

The setting that worked for me is as below:

const int stepsPerRevolution = 100;

float StepsPerMillimeterX = 12.5;
float StepsPerMillimeterY = 12.5;


myStepperX.setSpeed(50);
myStepperY.setSpeed(50);

snippet from drawline() method

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

DanielC807 (author)2017-08-04

Hello guys, now i'm making cnc, i've followed all the steps that already exist, but the output of the resulting image is very messy and i am confused the fact is where is the error?

Please help

Yassineb12 made it! (author)2017-07-19

baraka allah fik ! finally i've managed to reach a good output

i love to share my solution to my problem which was a distored image :

1/ not all the axe taken frm the drives are good ! i've tried 4 axel to find a good one my Y axel

2/ there was step skipping so the solution was in CNC_Code.INO i've changed :

this

float StepInc = 1;

int StepDelay = 0;

int LineDelay =0;

int penDelay = 50;

to this :

float StepInc = 1;

int StepDelay = 1;

int LineDelay =0;

int penDelay = 20;

salam

1/

Eduardo A.D (author)2017-07-03

Hi, very, very good project, I see that many people have been successful.

I have uploaded Test_X_Axis_CNC_Plotter and Y, and my engines have good movement.

I have a problem with gctrl.pde and gctrl.exe, but I do not know why. My engines have no movement with gctrl. Select the serial port (OK), use the arrows and no movement, load a gcode image with (G) and no movement. I do not know where the problem is.

You help me? Thank you

My beta-CNC without Arduino, only router with OpenWRT and L293 driver. Does not interpret GCODE yet:

https://www.youtube.com/watch?v=16uzCy-xsO0

LourivalI (author)2017-07-01

How do I fill out the drawing? I can only make outlines.

Juan ManuelK (author)2017-06-13

hello, my problem i:

Arduino:1.6.11 (Windows 10), Tarjeta:"Arduino/Genuino Uno"

C:\Users\Kriivo\AppData\Local\Temp\ccdbL8gd.ltrans0.ltrans.o: In function `loop':

ccdbL8gd.ltrans0.o:(.text+0xcb4): undefined reference to `AF_Stepper::onestep(unsigned char, unsigned char)'

ccdbL8gd.ltrans0.o:(.text+0xce2): undefined reference to `AF_Stepper::onestep(unsigned char, unsigned char)'

ccdbL8gd.ltrans0.o:(.text+0xd28): undefined reference to `AF_Stepper::onestep(unsigned char, unsigned char)'

ccdbL8gd.ltrans0.o:(.text+0xd56): undefined reference to `AF_Stepper::onestep(unsigned char, unsigned char)'

C:\Users\Kriivo\AppData\Local\Temp\ccdbL8gd.ltrans0.ltrans.o: In function `global constructors keyed to 65535_0_FKZY7W9IN4TTHPJ.ino.cpp.o.1877':

ccdbL8gd.ltrans0.o:(.text.startup+0xc4): undefined reference to `AF_Stepper::AF_Stepper(unsigned int, unsigned char)'

ccdbL8gd.ltrans0.o:(.text.startup+0xd2): undefined reference to `AF_Stepper::AF_Stepper(unsigned int, unsigned char)'

C:\Users\Kriivo\AppData\Local\Temp\ccdbL8gd.ltrans0.ltrans.o: In function `main':

ccdbL8gd.ltrans0.o:(.text.startup+0x2f6): undefined reference to `AF_Stepper::setSpeed(unsigned int)'

ccdbL8gd.ltrans0.o:(.text.startup+0x302): undefined reference to `AF_Stepper::setSpeed(unsigned int)'

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compilación en tarjeta Arduino/Genuino Uno.

Este reporte podría tener más información con
"Mostrar salida detallada durante la compilación"
opción habilitada en Archivo -> Preferencias.

Pardeepsaini (author)2017-06-13

hello sir my cnc not drow properly it can drow only a square it's urjent plz sir

Pardeepsaini (author)2017-06-13

my cnc not drow properly it can drow only square

Namangupta (author)2016-12-18

Hello sir...Thank u so much for this post...I have been working on this project from last one week..I have followed each and every step mentioned by u.. I have used Ur code and even followed Ur circuit diagram.. but still I m not getting a desired output... I mean I'm getting a distorted output... I think I'm facing the problem in wiring.. I'm sending u one picture with all the wiring configuration I have used.. if the wiring is not correct plz correct it by commenting the correct combination (like A1 A2 B2 B1 )... It's urgent sir plz help me out

SarojR (author)Namangupta2017-02-17

have you fixed it ? i m having same issue

vsk21 made it! (author)SarojR2017-05-01

hi O'Donovan I am also having same issue

My output is distorted and all jumbled up

So i request you .Please help sir its urgent

Varadgh (author)Namangupta2017-04-26

I am also having same issue
Please help anyone

O'DonovanM (author)Namangupta2017-02-05

Hi

In step 5 you're told to connect y Axe to M3 M4. This did not work for me, I connected my Y Axe to M1 M2.

If printed text is back to front switch a1a2 b1 b2 in reverse order eg a1 becomes b2, a2 becomes b1 and so on.

If only one axe moves and the other stays still then you may have a wire lose on the axe that is not moving or you need to switch only one pair of wires 1 and 2 to become 2 and 1.

If your image is printing in what looks like one corner then your start point in software may be incorrect.

My software settings are different for some images Inkskape images start in the centre:

Arduino settings (1) X -18 +18 - Y-18 +18 start plotting in the centre of page. Arduino settings (2) max X36 max Y36 starts closest to me to the right.

I hope this helps in some way.

It took me a while to figure this out.

K

O'DonovanM made it! (author)O'DonovanM2017-02-25

X Y Min Max

SarojR (author)O'DonovanM2017-02-17

hello , i am having same issue and output is distorted . how to change the starting point in software

O'DonovanM (author)SarojR2017-02-18

Hi SarojR

The starting point is where you start your pen or start plotting. Put the pen down on the paper and outline the edges of the paper. this is the Min max that your plotter can do, you will end up with a square.

Draw a line from one corner to the other to form a cross in the square already made, the center of this cross is where Inkskape starts the plotting.

In the program you download to the Arduino change the values for the X and Y from 36 to read -18 +18 and upload to the Arduino again.

K

renem67 made it! (author)2017-04-19

Thanks fro your good work. I made it but my cnc is based in an old printer and scanner. I print the test images directly on the glass of the scanner, the white paper below is just to highlight the drawing. I searched for a cnc with the adafruit stepper driver V1, so I found just what I needed. Thanks again.

itavaci (author)2017-04-14

Is gctrl compatible with Windows 10, I did run it a couple of times, cannot do any selections, pressing "p" or "g" button does not work. Your help is much appreciated.

nepenth0 (author)2017-03-14

all im getting from the z- axis servo is jitters, any help?

yusufgktsster2. (author)2017-03-14

I have heat problem. Both of motors and l293d are overheated in 30-40 second. can anyone give me some advice.

insructAbdo made it! (author)2017-03-08

thank youu of All :)

that other instructables to how make this project step by step :

https://www.instructables.com/id/How-to-Make-Mini-CNC-Router-Drawing-by-Arduino-and/

kentb7 (author)2017-02-26

Super nice project !

My project its up and running.

Now i have som ? about it.

Can`i change the motorer on X and Y from DVD step motorer to eks. 28BYJ-48 5 volt.

Sdyasin (author)2017-02-13

I've made it but it isn't working after uploading the code please any one help me

Anubhav8651 (author)2016-12-19

Hello, I Hav Made It But I Hav A Major Issue With Power Supply. Ones I Hav Supplied 19v 1.5Amp Then 1 Cap. Of 16v 100uf Blew Up I Hav Repaired It Will Any One Will Suggest Me Wat To Supply Power To L293D Motor Sheild

O'DonovanM (author)Anubhav86512017-02-05

Remove the jumper from the motor driver board L293D and supply 5V to the board this worked for me

JHON JAIMEL (author)2016-05-31

hola a todos; eh estado trabajando en este proyecto y podrian modificar ciertas cosa del codigo para mejorar el rendimiento de nuestro mini cnc y evitar daños en nuestra shield motor. ademas reducir el ruido de los motores y el calor que esto producen al trabajar.

entonces la parte del codigo que hay que modificar seria esta:

void setup() { // Setup

Serial.begin( 9600 );

TCCR2B = TCCR2B & B11111000 | B00000001;

TCCR0B = TCCR0B & B11111000 | B00000001;

penServo.attach(penServoPin);

penServo.write(penZUp);

delay(100);

// Decrease if necessary

myStepperX.setSpeed(500);

myStepperY.setSpeed(500);

}

que sea de su agrado!!!!!

Mitho66 (author)JHON JAIMEL2017-01-31

great thanks

saif2580 (author)2016-08-03

What is the main code to upload on arduino?
Plz tell me any one,...

Mitho66 (author)saif25802017-01-31

CNC_Code.INO

MirzaK5 (author)2017-01-01

If we change pcb drill with pen so it will work or not

MukaddemA (author)2016-12-09

hello. I made this one and its working properly. thanks for sharing. Now I am trying to increase the size of plot. here it plots only 4cm/4cm. I want to increase it by 20 cm by 20 cm . i have all the mechanical set up but when i upload the gcode it plots only the 4cm by 4cm area what can i do? please help.

Minh Vu Nguyen (author)2016-07-04

Hi insructAbdo, can you show me how to decrease speed of X and Y axis, i change the number in the line "myStepperX.setSpeed ()" from 500 to 100 but nothing happen, it still run the same speed.

JaimeJ16 (author)Minh Vu Nguyen2016-10-10

hola vu nguyen minh , como te fue con el problema ? lo solucionaste? me pasa lo mismo a mi y no se que hacer para poder bajar la velocidad del eje x e y :( ....

saludos

bwantha made it! (author)2016-09-20

i make it bro but no working . bro i dont't know adafruit motor shild libary and accelstepe master install from arduino bord uplode now please help me how to install this driver arduino bord ?

مدهشان (author)2016-05-21

very good

John Tan峻 (author)2016-05-10

If i am using the adafruit motor shield V2, can I use change the library without changing others code?

bgsdika (author)2016-05-07

hey, it's a great project. I've made this yesterday, can you tell me where is the zero point located (0,0)?

ToniV13 (author)2016-04-30

great

iqbal12392 (author)2016-04-28

wow, great build. can i use a salvage part from printer instead a dvd drive (i have 3 x A3 canon printer (ix6560,ix5000,ix4000))???? can you explain to me how it works??? thank you. you ROCKs!!!

About This Instructable

111,634views

958favorites

License:

Bio: My name is Abderrahim Aabida , 23 years , living in Morocco - Safi , holds a diploma in basic physics and electronics at the Faculty of Sciences in ... More »
More by insructAbdo:How to Make Mini CNC Router Drawing by Arduino and Shield L293DDrawing instructables robot by Mini CNC - Arduino - L293D ShieldMini CNC machine Arduino Based & Adafruit Driver Motor L293D v1 & 2*Mini Stepper CD/DVD player #1
Add instructable to: