100% found this document useful (1 vote)
420 views54 pages

Make A Mini CNC Plotter With Old DVD Players Arduino and L293D

NC Plotter With Old

Uploaded by

brahim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
420 views54 pages

Make A Mini CNC Plotter With Old DVD Players Arduino and L293D

NC Plotter With Old

Uploaded by

brahim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 54

25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

Deals finder AliExpress Coupons Gearbest Coupons Banggood Coupons Find a Tutorial Contact

Home Home Automation  IoT  Mini PC  ESP8266 & Arduino  DIY Projects

Discounts 
 

Home » Difficulty level » Advanced » Make a Mini CNC Plotter with old DVD players Arduino and L293D

Advanced Difficulty level DIY Projects

Make a Mini CNC Plotter with old


DVD players Arduino and L293D
23 June 2016  16028  33 comments

 Facebook  Twitter  

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 1/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

There are many projects to recycle old DVD players into a mini CNC Plotter based
on Arduino. It is a nice project and ideal to start with its Arduino. The mechanical
construction and more particularly the pencil holder can be difficult. I propose in
this article to realize a mini plotter by realizing the mechanical elements by 3D
printing. We will use two L293D H bridges to drive the engines of the DVD players. We find it for
less than €2 in China. You can develop your mini CNC Plotter directly from this post.

Contents [show]

Step 1 : BOM
You can buy all components on internet or DIY
store.

1x Arduino Uno
1x Breadboard 400 points
2x L293D motor drives ‫اﻟﻣطﺎﺑﻊ اﻟﻣﯾﻛﺎﻧﯾﻛﯾﺔ ﻣﺻﻧّﻊ‬
1x servo motor SG90 ‫ﻣﻌدّات و ﺗﻘﻧﯾﺎت ﻣن أﻋﻠﻰ‬
‫ﺟودة ﻓﻲ ﻣﺟﺎل آﻻت‬
2 old CD/DVD players ‫ ﻧﻘدّم اﻟﺧدﻣﺎت ﻓﻲ‬.‫اﻟﺿﻐط‬
‫اﻟﺧﺎرج أﯾﺿﺎ‬
2 wires 22AWG (yellow) 15cm (0.6 in)
2 wires 22AWG (green) 15cm (0.6 in)

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 2/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

2 wires 22AWG (red) 15cm (0.6 in)


2 wires 22AWG (white) 15cm (0.6 in)
Some shrink tubing
1x plywood sheet 200 x 160mm (7.87 in x 6.3 in) for X Axis.Thickness : 10mm (0.39in) or 5mm
plexiglass (0.2 in)
2x plywood sheet 150 x 50mm (5.91 in x 0.2 in) for Y Axis.
1x plexiglass plate (0.2 in) 76 x 76 mm (size of a post it, 3 x 3 in)
1x 3mm rod (0.12 in) x 80 mm (3.15 in)
Glue gun
2x screw M2 or glue to fix servo
8x M4x35mm and nuts
1x screw M5x20mm and nut

Step 2 : Prepare translation systems


Dismantle the old DVD players to get the translation system with the stepper motor.

Micro OLEDs for clear


images with high contrast
and no color breakup, great …
Ad FRAMOS

Learn more

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 3/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

Stepper Motor and DVD player translation system ready to use.

Step 3 : Prepare stepper motors (X and Y axis)


It’s better to sold the wires on the flexible connector. You may have problems if you sold directly
on the stepper motor. If you can, try to use 4 different colors, one for each Pin. There is no
identification on the engine but the connection is quite simple. The first wire corresponds to the
first output of the L293D (usually) and so on.

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 4/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

Step 4 : Print 3D parts


You can download the STL files of this project onThingiverse or Cults3D.

Custom Made Carbide Router


Bit - Lowest Cost, Call Us Now
Ad We Provide Custom Brazed on Carbide
and Solid Carbide Bits and Shaper Cutters
orbittools.com

Learn more

Part 3D design Number

Mounting brackets (X axis) 4x

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 5/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

Spacers 8x

Breadboard spacers 4x

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 6/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

Z axis basis 1x

Pencil case (8mm diam.) 1x

Pencil anti-tilt ring 1x

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 7/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

I prefer to use PLA filament because it’s an environmental friendly and non toxic material. If you
print all parts, you need about 3 hours. I use the French 3D printer Dagoma discovery200.

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 8/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

Step 5 : Prepare the plywood structure


Just cut the 3 parts (see the BOM for dimensions)

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 9/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

Step 6 : Prepare the circuit


The circuit is really easy as you can see bellow. One L293D for each axis and a servo motor for
the Z-axis.

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 10/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

2x L293D motor divers

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 11/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

Arduino Uno

Step 7 : Assembling the Mini CNC Plotter


X and Y Axis

Use 4 spacers and 4 screws M4 x 30mm to assembling the X axis on the playwood (200 x
160mm). Do the same for the Y axis. Use the picture bellow to setup the position of

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 12/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

elements. Finally attach the Y axis on the vertical uprights. The height is not important, we just
need to adjust the position of the pen in its holder.

Drawing surface

Use a glue gun to fix the drawing surface on the axis. To find the good position move the stepper
motor to the max. position and fix it.

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 13/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

Drawing surface (front vue)

Pencil case (Z-axis)

Follow the drawing to assembly the pencil holder. Fix the servo motor with 2x M2 screws or glue.

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 14/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

Custom Made Carbide Router


Bit - Lowest Cost, Call Us Now
Ad We Provide Custom Brazed on Carbide
and Solid Carbide Bits and Shaper Cutters
orbittools.com

Learn more

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 15/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

Pencil holder design

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 16/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

Pencil holder (left vue)

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 17/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

Pencil holder (right vue) with the servo motor

Breadboard and Arduino

Use spacers to fix the breadboard.

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 18/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

Breadboard and Arduino (rear vue)

Step 8 : Setup X and Y axis


https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 19/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

Now, we can start programming ! First, we need to test if the X and Y axis are properly
connected. After that, we will calibrate the stepper motors.

X axis test

X-Axis use the pins 8,9,10 and 11 by default. Start this program. If all is correct, the stepper
motor must do 100 steps. Measure the distance and divide by 100 to obtain the X-Axis
calibration value.

Custom Made Carbide Router


Bit - Lowest Cost, Call Us Now
Ad We Provide Custom Brazed on Carbide
and Solid Carbide Bits and Shaper Cutters
orbittools.com

Learn more

1 /*
2   Mini Traceur Arduino (CNC Plotter)
3   Test X Axis
4   Projets DIY 02/2016
5 */
6 #include <Stepper.h> // Include the stepper Motor librarie
7  
8 const int pasParRotation = 20;         // Number of steps by turn. Standard value for CD/DV
9
10 // Indicate X axis stepper motor Pins
11 Stepper myStepperX(pasParRotation, 8,9,10,11);
12
13 void setup() {
14 myStepperX.setSpeed(100); // Stepper motor speed
15 // Indicate the number of steps the drive need to do.
16 // CD/DVD drive can do about 250 steps max.
17 // Negative number to reverse direction of the movement
18 myStepperX.step(100);         // Measure the distance the pencil move to calculate X

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 20/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

19 delay(100);
20 }
21
22 void loop() {}

Y axis test

Do the same for the Y axis.

Micro OLEDs for clear


images with high contrast
and no color breakup, great …
Ad FRAMOS

Learn more

1 /*
2   Mini Traceur Arduino (CNC Plotter)
3   Test de l'axe Y
4   Projets DIY 02/2016
5 */
6 #include <Stepper.h> //Librairie pour piloter les moteurs pas à pas
7
8 const int pasParRotation = 20; //Nombre de pas pour réaliser un tour
9
10 //Pins sur lesquels est relié le moteur de l'axe X
11 Stepper myStepperX(pasParRotation, 2,3,4,5);
12
13 void setup() {
14 myStepperX.setSpeed(100); //Vitesse de déplacement
15 //Indiquer le nombre de pas que le moteur pas à pas doit faire
16 //Généralement un moteur de lecteur CD/DVD peut faire 250 pas au maxium
17 //Indiquer un chiffre négatif pour inverser le sens de déplacement
18 myStepperX.step(100);
19 delay(100);
20 }
21

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 21/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

22 void loop() {}

In case of problem

The main problems I encountered during the development of my plotter :

The engine does not move: first check the wiring of the L293D. The IN and OUT Pins may be
reversed.
The direction of movement is reversed. Reverse Pins on the L293D.
The engine never stops, do not go to the end or “jump”. There is probably an obstacle in its
path. Check if one screw is not too long …

Step 9 : Upload the CNC code into the Arduino


Before uploading the CNC program, maybe you need to update the configuration

penZUp : angle of the servo when the pen is Up


penZDown : angle when the pen is Down (on the paper sheet)
Pins : servo, X and Y axis

 Calibration values of the X and Y-axis 

 Warning: do not use the servo motor to press the pencil on


the paper sheet. The force exerted
  bythe actuator may be too

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 22/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

strong and prevent movement of the axis X. The pen is pressed


on the sheet by the spring.

Custom Made Carbide Router


Bit - Lowest Cost, Call Us Now
Ad We Provide Custom Brazed on Carbide
and Solid Carbide Bits and Shaper Cutters
orbittools.com

Learn more

1 /* Arduino
2 Mini Traceur CNC Arduino
3 Traduction de la configuration du traceur en français et ajout d'une variable "vitesseDepl
4 Projets DIY - 02/2016
5
6 D'après
7 Mini CNC Plotter firmware, based in TinyCNC https://github.com/MakerBlock/TinyCNC-Sketche
8 Send GCODE to this Sketch using gctrl.pde https://github.com/damellis/gctrl
9 Convert SVG to GCODE with MakerBot Unicorn plugin for Inkscape available here https://gith
10
11 More information about the Mini CNC Plotter here (german, sorry): http://www.makerblog.at/
12   */
13  
14 #include <Servo.h>
15 #include <Stepper.h>
16  
17 #define LINE_BUFFER_LENGTH 512
18  
19 /*
20    PARAMETRES DE CONFIGURATION
21 */
22  
23 const int penZUp = 130; // Angle servomoteur, crayon relevé
24 const int penZDown = 40;            // Angle servomoteur, crayon baissé
25 const int penServoPin = 6; // Pin sur lequel est relié le servomoteur
26 const int stepsPerRevolution = 20; // Valeur par défaut
27 const int vitesseDeplacement = 250; // Vitesse de déplacement des axes X et Y
https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 23/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

28  
29 Servo penServo;   // Objet pour actionner le servomoteur
30  
31 // Initialisation des moteurs pas à pas pilotés à l'aide d'un pont H L293D
32 Stepper myStepperY(stepsPerRevolution, 2,3,4,5); // Axe X        
33 Stepper myStepperX(stepsPerRevolution, 8,9,10,11);  // Axe Y
34  
35 // Calibration, nombre de pas par millimètre
36 float StepsPerMillimeterX = 6.0;
37 float StepsPerMillimeterY = 6.0;
38  
39 /*
40   FIN DE LA CONFIGURATION
41 */
42  
43 /* Structures, global variables    */
44 struct point {
45   float x;
46   float y;
47   float z;
48 };
49  
50 // Current position of plothead
51 struct point actuatorPos;
52  
53 //  Drawing settings, should be OK
54 float StepInc = 1;
55 int StepDelay = 0;
56 int LineDelay = 50;
57 int penDelay = 50;
58  
59 // Drawing robot limits, in mm
60 // OK to start with. Could go up to 50 mm if calibrated well.
61 float Xmin = 0;
62 float Xmax = 40;
63 float Ymin = 0;
64 float Ymax = 40;
65 float Zmin = 0;
66 float Zmax = 1;
67  
68 float Xpos = Xmin;
69 float Ypos = Ymin;
70 float Zpos = Zmax;
71  
72 // Set to true to get debug output.
73 boolean verbose = false;
74  

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 24/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

75 //  Needs to interpret
76 //  G1 for moving
77 //  G4 P300 (wait 150ms)
78 //  M300 S30 (pen down)
79 //  M300 S50 (pen up)
80 //  Discard anything with a (
81 //  Discard any other command!
82  
83 /**********************
84 * void setup() - Initialisations
85 ***********************/
86 void setup() {
87   //  Setup
88   Serial.begin( 9600 );
89   
90   penServo.attach(penServoPin);
91   penServo.write(penZUp);
92   delay(200);
93  
94   // Decrease if necessary
95   myStepperX.setSpeed(vitesseDeplacement);
96   myStepperY.setSpeed(vitesseDeplacement);  
97  
98   //  Set & move to initial default position
99   // TBD
100  
101   //  Notifications!!!
102   Serial.println("Mini CNC Plotter alive and kicking!");
103   Serial.print("X range is from ");
104   Serial.print(Xmin);
105   Serial.print(" to ");
106   Serial.print(Xmax);
107   Serial.println(" mm.");
108   Serial.print("Y range is from ");
109   Serial.print(Ymin);
110   Serial.print(" to ");
111   Serial.print(Ymax);
112   Serial.println(" mm.");
113 }
114  
115 /**********************
116 * void loop() - Main loop
117 ***********************/
118 void loop()
119 {
120   delay(200);
121   char line[ LINE_BUFFER_LENGTH ];

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 25/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

122   char c;
123   int lineIndex;
124   bool lineIsComment, lineSemiColon;
125  
126   lineIndex = 0;
127   lineSemiColon = false;
128   lineIsComment = false;
129  
130   while (1) {
131  
132     // Serial reception - Mostly from Grbl, added semicolon support
133     while ( Serial.available()>0 ) {
134       c = Serial.read();
135       if (( c == '\n') || (c == '\r') ) {             // End of line reached
136         if ( lineIndex > 0 ) {                        // Line is complete. Then execute!
137           line[ lineIndex ] = '\0';                   // Terminate string
138           if (verbose) {
139             Serial.print( "Received : ");
140             Serial.println( line );
141           }
142           processIncomingLine( line, lineIndex );
143           lineIndex = 0;
144         }
145         else {
146           // Empty or comment line. Skip block.
147         }
148         lineIsComment = false;
149         lineSemiColon = false;
150         Serial.println("ok");    
151       }
152       else {
153         if ( (lineIsComment) || (lineSemiColon) ) {   // Throw away all comment characters
154           if ( c == ')' )  lineIsComment = false;     // End of comment. Resume line.
155         }
156         else {
157           if ( c <= ' ' ) {                           // Throw away whitepace and control c
158           }
159           else if ( c == '/' ) {                    // Block delete not supported. Ignore c
160           }
161           else if ( c == '(' ) {                    // Enable comments flag and ignore all
162             lineIsComment = true;
163           }
164           else if ( c == ';' ) {
165             lineSemiColon = true;
166           }
167           else if ( lineIndex >= LINE_BUFFER_LENGTH-1 ) {
168             Serial.println( "ERROR - lineBuffer overflow" );

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 26/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

169             lineIsComment = false;


170             lineSemiColon = false;
171           }
172           else if ( c >= 'a' && c <= 'z' ) {        // Upcase lowercase
173             line[ lineIndex++ ] = c-'a'+'A';
174           }
175           else {
176             line[ lineIndex++ ] = c;
177           }
178         }
179       }
180     }
181   }
182 }
183  
184 void processIncomingLine( char* line, int charNB ) {
185   int currentIndex = 0;
186   char buffer[ 64 ];                                 // Hope that 64 is enough for 1 parame
187   struct point newPos;
188  
189   newPos.x = 0.0;
190   newPos.y = 0.0;
191  
192   //  Needs to interpret
193   //  G1 for moving
194   //  G4 P300 (wait 150ms)
195   //  G1 X60 Y30
196   //  G1 X30 Y50
197   //  M300 S30 (pen down)
198   //  M300 S50 (pen up)
199   //  Discard anything with a (
200   //  Discard any other command!
201  
202   while( currentIndex < charNB ) {
203     switch ( line[ currentIndex++ ] ) {              // Select command, if any
204     case 'U':
205       penUp();
206       break;
207     case 'D':
208       penDown();
209       break;
210     case 'G':
211       buffer[0] = line[ currentIndex++ ];          // /!\ Dirty - Only works with 2 digit c
212       //      buffer[1] = line[ currentIndex++ ];
213       //      buffer[2] = '\0';
214       buffer[1] = '\0';
215  

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 27/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

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


217       case 0:                                   // G00 & G01 - Movement or fast movement. S
218       case 1:
219         // /!\ Dirty - Suppose that X is before Y
220         char* indexX = strchr( line+currentIndex, 'X' );  // Get X/Y position in the string
221         char* indexY = strchr( line+currentIndex, 'Y' );
222         if ( indexY <= 0 ) {
223           newPos.x = atof( indexX + 1);
224           newPos.y = actuatorPos.y;
225         }
226         else if ( indexX <= 0 ) {
227           newPos.y = atof( indexY + 1);
228           newPos.x = actuatorPos.x;
229         }
230         else {
231           newPos.y = atof( indexY + 1);
232           indexY = '\0';
233           newPos.x = atof( indexX + 1);
234         }
235         drawLine(newPos.x, newPos.y );
236         //        Serial.println("ok");
237         actuatorPos.x = newPos.x;
238         actuatorPos.y = newPos.y;
239         break;
240       }
241       break;
242     case 'M':
243       buffer[0] = line[ currentIndex++ ];        // /!\ Dirty - Only works with 3 digit com
244       buffer[1] = line[ currentIndex++ ];
245       buffer[2] = line[ currentIndex++ ];
246       buffer[3] = '\0';
247       switch ( atoi( buffer ) ){
248       case 300:
249         {
250           char* indexS = strchr( line+currentIndex, 'S' );
251           float Spos = atof( indexS + 1);
252           //          Serial.println("ok");
253           if (Spos == 30) {
254             penDown();
255           }
256           if (Spos == 50) {
257             penUp();
258           }
259           break;
260         }
261       case 114:                                // M114 - Repport position
262         Serial.print( "Absolute position : X = " );

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 28/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

263         Serial.print( actuatorPos.x );


264         Serial.print( "  -  Y = " );
265         Serial.println( actuatorPos.y );
266         break;
267       default:
268         Serial.print( "Command not recognized : M");
269         Serial.println( buffer );
270       }
271     }
272   }
273 }
274  
275  
276 /*********************************
277 * Draw a line from (x0;y0) to (x1;y1).
278 * Bresenham algo from https://www.marginallyclever.com/blog/2013/08/how-to-build-an-2-axis
279 * int (x1;y1) : Starting coordinates
280 * int (x2;y2) : Ending coordinates
281 **********************************/
282 void drawLine(float x1, float y1) {
283  
284   if (verbose)
285   {
286     Serial.print("fx1, fy1: ");
287     Serial.print(x1);
288     Serial.print(",");
289     Serial.print(y1);
290     Serial.println("");
291   }  
292  
293   //  Bring instructions within limits
294   if (x1 >= Xmax) {
295     x1 = Xmax;
296   }
297   if (x1 <= Xmin) {
298     x1 = Xmin;
299   }
300   if (y1 >= Ymax) {
301     y1 = Ymax;
302   }
303   if (y1 <= Ymin) {
304     y1 = Ymin;
305   }
306  
307   if (verbose)
308   {
309     Serial.print("Xpos, Ypos: ");

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 29/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

310     Serial.print(Xpos);
311     Serial.print(",");
312     Serial.print(Ypos);
313     Serial.println("");
314   }
315  
316   if (verbose)
317   {
318     Serial.print("x1, y1: ");
319     Serial.print(x1);
320     Serial.print(",");
321     Serial.print(y1);
322     Serial.println("");
323   }
324  
325   //  Convert coordinates to steps
326   x1 = (int)(x1*StepsPerMillimeterX);
327   y1 = (int)(y1*StepsPerMillimeterY);
328   float x0 = Xpos;
329   float y0 = Ypos;
330  
331   //  Let's find out the change for the coordinates
332   long dx = abs(x1-x0);
333   long dy = abs(y1-y0);
334   int sx = x0<x1 ? StepInc : -StepInc;
335   int sy = y0<y1 ? StepInc : -StepInc;
336  
337   long i;
338   long over = 0;
339  
340   if (dx > dy) {
341     for (i=0; i<dx; ++i) {
342       myStepperX.step(sx);
343       over+=dy;
344       if (over>=dx) {
345         over-=dx;
346         myStepperY.step(sy);
347       }
348       delay(StepDelay);
349     }
350   }
351   else {
352     for (i=0; i<dy; ++i) {
353       myStepperY.step(sy);
354       over+=dx;
355       if (over>=dy) {
356         over-=dy;

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 30/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

357         myStepperX.step(sx);
358       }
359       delay(StepDelay);
360     }    
361   }
362  
363   if (verbose)
364   {
365     Serial.print("dx, dy:");
366     Serial.print(dx);
367     Serial.print(",");
368     Serial.print(dy);
369     Serial.println("");
370   }
371  
372   if (verbose)
373   {
374     Serial.print("Going to (");
375     Serial.print(x0);
376     Serial.print(",");
377     Serial.print(y0);
378     Serial.println(")");
379   }
380  
381   //  Delay before any next lines are submitted
382   delay(LineDelay);
383   //  Update the positions
384   Xpos = x1;
385   Ypos = y1;
386 }
387  
388 //  Raises pen
389 void penUp() {
390   penServo.write(penZUp);
391   delay(LineDelay);
392   Zpos=Zmax;
393   if (verbose) {
394     Serial.println("Pen up!");
395   }
396 }
397 //  Lowers pen
398 void penDown() {
399   penServo.write(penZDown);
400   delay(LineDelay);
401   Zpos=Zmin;
402   if (verbose) {
403     Serial.println("Pen down.");

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 31/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

404   }
405 }

Step 10 : Install Processing or use gctrl.exe


Last step before your first draw. We need to install a program that send gcode file to the Arduino
controler.

If you are a Windows user you can directly use the compilated version of gctrl. You can download
it here.

For macOS or Linux users, you need to install Processing (here) then run gctrl.pde (download
here)

Step 11 : Plot your rst draw with gctrl


Before making your first draw :

Make sure the plot surface is at the origine.


Check that nothing blocks the movement of the axes
Place a sheet on the drawing area

gctrl is an efficient but basic program in the sense that it does not check the selected file. The
plotter start just after the selection of the gcode file. So, be sure before validate. In case of
problem, press “x” !

Press “p” to choose the serial port.

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 32/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

Press “h” to go at home position


Press “g” to chose the gcode file

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 33/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

A short video (in french at the moment…be patient) that explains how to make your Mini
CNC plotter.

DIY Mini Traceur Arduino - Mini CNC Plotter

I hope you find everything you need to make your Mini CNC Plotter. I hope I did not forget
anything. Feel free to share your experience or add your tricks. Comments are there for.

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 34/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D


SUBSCRIBE TO THE WEEKLY NEWSLETTER

Enter your email Subscribe

No spam and no other use will be made of your email. You can unsubscribe anytime.

 Facebook  Twitter  

RELATED ARTICLES

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 35/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

Gateway RFLink with Weather station with WebSocket


RobotDyn Arduino Mega ePaper display communication with an
2560 Pro Mini and 3D (Dashboard) for Jeedom ESP8266 or Arduino in
printed case on Raspberry Pi (via the Python. Test with the
JSON RPC API) ws4py library on
Raspberry Pi

OLED display SSD1306 in MicroPython tutorial, FarmBot Genesis XL, the


MicroPython, example manage WiFi connection robotic garden is growing.
with a I2C digital at startup on ESP8266 / A project based on
barometer BME280 (or ESP32 Raspberry Pi 3 and
BMP180) Arduino Mega 2560

30 Comments diyprojets.io 
1 Login

Sort by Best
 Recommend 1 ⤤ Share

Join the discussion…

LOG IN WITH
OR SIGN UP WITH DISQUS ?

Name

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 36/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

helder jose • 4 months ago


Hi I'm trying to build the mini plotter :)
I put the code in the arduino IDE and it appeared to me this :

mini_cnc_plotter__franc_s_:407: error: expected '}' at end of input

exit status 1
'gt' was not declared in this scope

Should I replace "gt" with something?


△ ▽ • Reply • Share ›

Projets DIY Mod > helder jose • 4 months ago

Hello Jose. It's strange, I just compile the program with the Arduino IDE (1.8.2) without
any error. Is this the program of step 9?
△ ▽ • Reply • Share ›

helder jose > Projets DIY • 4 months ago


Yes it is.
I just copied again to arduino IDE and the error is gone :)
Thank you for your reply and for your sharing!
△ ▽ • Reply • Share ›

Projets DIY Mod > helder jose • 4 months ago

Great, it's cool. Have fun :D


△ ▽ • Reply • Share ›

helder jose > Projets DIY • 4 months ago


Somehow instead of '<' or '>' it appeared '& g t' (without the space
between the letters).
△ ▽ • Reply • Share ›

Eduardo A. Díaz Mesa • 10 months ago


Hi d j t I
https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s
th t l h b f l 37/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D
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:

see more

△ ▽ • Reply • Share ›

Projets DIY Mod > Eduardo A. Díaz Mesa • 10 months ago

Hello Eduardo. Great project. I'm sorry but I have no skills on openwrt (at the moment
;-))
△ ▽ • Reply • Share ›

Sadam Lubowa • a year ago


hi am called sadam i have got a problem i have used the same wiring and code used but my
cd rom stepper motor they dont move at all think the problem it ld293 ic but i have just bought
them what can i do now because am stack
△ ▽ • Reply • Share ›

kro-nos • a year ago

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 38/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D
Hi, please help me.
Have same error as Mahadi....

Arduino: 1.8.3 (Windows 7), Board: "Arduino/Genuino Uno"


cnc_plotter:14: error: #include expects "FILENAME" or <filename> etc...

Included servo and stepper libraries as suggested from sketch menu


but still the same error.
I am not an expert please may you give me detailed info on how to solve.
Thanks a lot.
△ ▽ • Reply • Share ›

Mahadi • a year ago


I have this error please help.......

Arduino: 1.8.1 (Windows 7), Board: "Arduino/Genuino Uno"

cnc_plotter:14: error: #include expects "FILENAME" or <filename>

#include <Servo.h>

cnc_plotter:15: error: #include expects "FILENAME" or <filename>

#include <Stepper.h>

exit status 1
#include expects "FILENAME" or <filename>

This report would have more information with


"Show verbose output during compilation"
option enabled in File -> Preferences.
△ ▽ • Reply • Share ›

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 39/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D
Projets DIY Mod > Mahadi • a year ago

Hi Mahadi. You need to install the servo library. You just need to install it directly from
the library manager (sketch menu). After that, you can download the program. Have a
good day.
△ ▽ • Reply • Share ›

Avatar This comment was deleted.

Projets DIY Mod > Guest • a year ago

Sorry Mahadi, it's totally impossible to help you like that. Could you send
me your sketch by using the contact form. Thank's
△ ▽ • Reply • Share ›

Mahadi > Projets DIY • a year ago


I Figure-out the problem and fix it ...But now i got a serious problem
about G- Code making ...Can u Please tell me How can i generate G-
Code With out inkscape ?

Actually i Use inkscape 0.48.5 version and also it's plugin But i don't find
g code export ...option.. So..How can i Generate G- Code .?
And How you generate G code For Yourself.
△ ▽ • Reply • Share ›

Projets DIY Mod > Mahadi • a year ago


Hello Mahadi. I'm glad if you found the solution ! To prepare your gcode
files, just follow this post http://www.diyprojects.io/p...
See you soon
△ ▽ • Reply • Share ›

Itihash • a year ago


Step 6
I haven't find similarity between drawing and real photo.
△ ▽ • Reply • Share ›
https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 40/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D
py

greg • a year ago


Isn't a little mistake on connection from axis Y , l293d and pin 11 (white path) on breadboard? I
guess it should be on oposite pins for l293d ?
△ ▽ • Reply • Share ›

Projets DIY Mod > greg • a year ago

Hi Greg. You probably right. Depending your drive, you may need to switch pins to find
the correct direction. I hope you'll succeed with your project. See you soon.
△ ▽ • Reply • Share ›

Itihash • a year ago


What i need to do for test X & Y axis?
△ ▽ • Reply • Share ›

Projets DIY Mod > Itihash • a year ago

Hi Itihash. Can you tell at what step your are ?


△ ▽ • Reply • Share ›

Itihash > Projets DIY • a year ago


I'll make it so i following you but i didn't understand the step 8.
△ ▽ • Reply • Share ›

Projets DIY Mod > Itihash • a year ago

OK. We want to know how many steps are needed to move the pencil
(for example 10mm). So, run X drive with 100 steps, after measure the
distance (x) and then divide 100/x mm. Now replace the value of the
variable StepsPerMillimeterX (by default, it 6s/mm) . Do the same for the
Y axis. After that, the X and Y axis are ready. I hope it's clear enough
now. Have a good day. Christophe
△ ▽ • Reply • Share ›

Itihash > Projets DIY • a year ago


https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 41/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D
t as ojets a yea ago
I can do it using gctrl or I need another application?
△ ▽ • Reply • Share ›

Projets DIY Mod > Itihash • a year ago

No. Use the Arduino IDE. Create a new file (for example TestX.ino) and
past the code of the step 8 (X axis step). Start the program and do as
indicate before. Do the same for the Y axis (or just change the Pins of
the Y stepper motor). I'm sorry i forgot to translate in English the
comments... but now, i'm sure you read French very well ;-). Bye
△ ▽ • Reply • Share ›

Itihash > Projets DIY • a year ago


Thanks.
△ ▽ • Reply • Share ›

Sadanand Kale • a year ago


I have problem when I'm trying to execute g code... It's just showed.... Loading file.... And
nothing..... What to do
△ ▽ • Reply • Share ›

kro-nos > Sadanand Kale • a year ago


Solved.
Thanks
△ ▽ • Reply • Share ›

Projets DIY Mod > kro-nos • a year ago


Great. Maybe you could explain to everyone how you solved the problem.
Thank's
△ ▽ • Reply • Share ›

bujari • a year ago


I did all steps like you but the stepper motors are not running. The servo motor is running but
the steps not can you help me please
https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 42/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D
the steps not. can you help me please
△ ▽ • Reply • Share ›

Projets DIY Mod > bujari • a year ago

Hi Bujari. Can you tell me how you power the stepper motors? May be that there is not
enough power. The problem with recycling stepper motors from older dvd drives is that
you do not know pin marking. You have to look for the right wiring. See you soon.
△ ▽ • Reply • Share ›

bujari > Projets DIY • a year ago


I tried by stepper test, is running properly.
Power I tried 12V and 9V the same.
1△ ▽ • Reply • Share ›

✉ Subscribe d Add Disqus to your siteAdd DisqusAdd 🔒 Privacy

Follow Us

      

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 43/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 44/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 45/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 46/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 47/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 48/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 49/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 50/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 51/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 52/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 53/54
25/04/2018 Make a Mini CNC Plotter with old DVD players Arduino and L293D

© Copyright 2017, All Rights Reserved. Disclaimer: The trademarks and photographs visible on diyprojects.io property of their
respective authors and owners. Sitemap

https://diyprojects.io/make-mini-cnc-plotter-old-dvd-players-arduino-l293d/#.WuEHbBsvy1s 54/54

You might also like