My Projects

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
arduino:2dplotter [2021/09/16 22:35] – tonyarduino:2dplotter [2026/09/26 21:09] (current) – tony
Line 15: Line 15:
 Software needed consists of three parts. Software needed consists of three parts.
   - Code (eg //Grbl//  ((https://github.com/grbl/grbl/wiki))) to run in the plotter's embedded controller (in this case an Arduino), that interprets drawing commands (eg //G-code// ((https://en.wikipedia.org/wiki/G-code))) and moves the pen using motors to draw lines.   - Code (eg //Grbl//  ((https://github.com/grbl/grbl/wiki))) to run in the plotter's embedded controller (in this case an Arduino), that interprets drawing commands (eg //G-code// ((https://en.wikipedia.org/wiki/G-code))) and moves the pen using motors to draw lines.
-  - Code (eg //UGS// ((https://winder.github.io/ugs_website/guide/platform/))) to run on your PC/Mac etc, to send files containing drawing commands to the plotter.+  - Code (eg //UGS// ((https://web.archive.org/web/20200707184743/http://winder.github.io/ugs_website/guide/platform/))) to run on your PC/Mac etc, to send files containing drawing commands to the plotter.
   - Code (eg //Inkscape// ((https://inkscape.org/))) to run on your PC/Mac etc, to convert images into files containing drawing commands.   - Code (eg //Inkscape// ((https://inkscape.org/))) to run on your PC/Mac etc, to convert images into files containing drawing commands.
  
Line 35: Line 35:
 The CD/DVD drive laser LED carriage assembly (sled) provides a ready-made motor-driven axis.  So two CD/DVD drives can provide two independent axes.  Somehow these need to be arranged to move a drawing platform in two directions, or a pen in one direction and the platform in the other, or leave the platform stationary and move the pen in two directions.  The pen also needs to be raised and lowered, and this is perhaps the aspect that needs the most work creating a custom mechanism.  The pen mechanism could be another CD/DVD sled, a linear motor, or a servo. The CD/DVD drive laser LED carriage assembly (sled) provides a ready-made motor-driven axis.  So two CD/DVD drives can provide two independent axes.  Somehow these need to be arranged to move a drawing platform in two directions, or a pen in one direction and the platform in the other, or leave the platform stationary and move the pen in two directions.  The pen also needs to be raised and lowered, and this is perhaps the aspect that needs the most work creating a custom mechanism.  The pen mechanism could be another CD/DVD sled, a linear motor, or a servo.
  
-|{{:arduino:2dplotter:insert_image_here.png?400|X and Y axis move platform}}|{{:arduino:2dplotter:insert_image_here.png?400|X-axis move platform, Y-axis move pen}}|{{:arduino:2dplotter:insert_image_here.png?400|X and Y axis move pen}}|+|{{:arduino:2dplotter:insert_image_here.png?400|X and Y axis move platform}} 
 +|{{:arduino:2dplotter:insert_image_here.png?400|X-axis move platform, Y-axis move pen}} 
 +|{{:arduino:2dplotter:insert_image_here.png?400|X and Y axis move pen}}
  
 There seem to be three alternative motor types used in CD/DVD sleds; stepper motor, brushless motor with rotary encoder, and linear motor.  Most commonly mini CNC projects use the stepper motor version of these sleds, probably because all can be driven with the same readily available hardware (H-bridge drivers).  The other alternative motor types require further work determining the exact driver requirements. There seem to be three alternative motor types used in CD/DVD sleds; stepper motor, brushless motor with rotary encoder, and linear motor.  Most commonly mini CNC projects use the stepper motor version of these sleds, probably because all can be driven with the same readily available hardware (H-bridge drivers).  The other alternative motor types require further work determining the exact driver requirements.
  
-|{{:arduino:2dplotter:insert_image_here.png?400|stepper driven sled}}|{{:arduino:2dplotter:insert_image_here.png?400|brushless motor driven sled}}|{{:arduino:2dplotter:insert_image_here.png?400|linear driven sled}}|+|{{:arduino:2dplotter:insert_image_here.png?400|stepper driven sled}} 
 +|{{:arduino:2dplotter:insert_image_here.png?400|brushless motor driven sled}} 
 +|{{:arduino:2dplotter:insert_image_here.png?400|linear driven sled}}
  
  
Line 53: Line 57:
 I thought it might be useful to have a stepper motor controller that could do micro-stepping to improve resolution, but a quick calculation shows each normal step moves about 0.15 mm, less than one-fifth of the width of the pen tip being used (0.8 mm), and the 'slop' in the pen holding mechanism turns out to be rather larger than this too. I thought it might be useful to have a stepper motor controller that could do micro-stepping to improve resolution, but a quick calculation shows each normal step moves about 0.15 mm, less than one-fifth of the width of the pen tip being used (0.8 mm), and the 'slop' in the pen holding mechanism turns out to be rather larger than this too.
  
-A fibre tip pen produces nice drawings, but how the pen is delivered to the page needs to be considered.   With a solenoid activated pen loading mechanism, that spams the pen onto the page, the fibre tip gets compressed and distorted - as an example the 0.8mm pen tip that I was experimenting with, ended up about 1.2mm wide.+A fibre tip pen produces nice drawings, but how the pen is delivered to the page needs to be considered.   With a solenoid activated pen loading mechanism, that slams the pen onto the page, the fibre tip gets compressed and distorted - as an example the 0.8mm pen tip that I was experimenting with, ended up about 1.2mm wide.
  
 ---- ----
-======Construction ====== +===== Construction ===== 
-=====X and Y Axis=====+==== X and Y Axis ====
 I have a number of old CD/DVD drives and chose to use [[:electronic:equipment:cdrom:gd8000|Hitachi GD-8000]] drives as I had two of them, which allows me to have identical mechanisms for the X and Y axes. I have a number of old CD/DVD drives and chose to use [[:electronic:equipment:cdrom:gd8000|Hitachi GD-8000]] drives as I had two of them, which allows me to have identical mechanisms for the X and Y axes.
  
Line 79: Line 83:
 {{:arduino:2dplotter:p7139113a.jpg?800|Two sleds mounted at right angles to form X and Y axes}} {{:arduino:2dplotter:p7139113a.jpg?800|Two sleds mounted at right angles to form X and Y axes}}
  
-===== Attaching the Arduino===== +==== Attaching the Arduino ==== 
-The X and Y stepper motors each have four wires, their limit switches have two wires each.  The limit switches are normally open ("NO" contacts) and need to provide a low signal (0 V) when reached.  So one side of each switch is connected to a ground line (GND), and the other is brought out to a connector to attach the Arduino.   Continuing with the recycling theme, I used a 34 pin "IDE" to edge connector adapter from an old 5¼" floppy disk drive.  This has two rows of 17 pins, the bottom row are usually all connected together and grounded, but in this application they can be ignored.  The top 17 are sufficient for connecting our two axes and a pen raising mechanism (yet to be designed!).  The PCB edge connector is easy to solder wires to.+The X and Y stepper motors each have four wires, their limit switches have two wires each.  The limit switches are normally open ("NO" contacts) and need to provide a low signal (0 V) when the carriage reaches it's furthest travel and closes the switch.  So one side of each switch is connected to a ground line (GND), and the other is brought out to a connector to attach the Arduino.   Continuing with the recycling theme, I used a 34 pin "IDE" to edge connector adapter from an old 5¼" floppy disk drive.  This has two rows of 17 pins, the bottom row are usually all connected together and grounded, but in this application they can be ignored.  The top 17 are sufficient for connecting our two axes and a pen raising mechanism (yet to be designed!).  The PCB edge connector is easy to solder wires to.
  
 |{{:arduino:2dplotter:p7259149a.jpg?400|IDE to PCB edge connector adapter}}| |{{:arduino:2dplotter:p7259149a.jpg?400|IDE to PCB edge connector adapter}}|
Line 137: Line 141:
 </HTML> </HTML>
  
-=====Drawing platform===== +==== Drawing platform ==== 
-The drawing platform is fixed to the laser mount on the horizontal sled, and the plotting pen will be attached to the laser mount on the vertical sled.+The drawing platform is fixed to DVD drive's old laser mount on the horizontal sled, and the plotting pen will be attached to the laser mount on the vertical sled.
  
 A simple platform was made from scraps of wood then screwed to the former laser LED holder on the X-axis sled. A simple platform was made from scraps of wood then screwed to the former laser LED holder on the X-axis sled.
Line 144: Line 148:
 |{{arduino:2dplotter:p7179146a.jpg?400|Parts for wood platform}}|{{arduino:2dplotter:p7179145a.jpg?400|Assembled wooden platform (view from underneath).}}| |{{arduino:2dplotter:p7179146a.jpg?400|Parts for wood platform}}|{{arduino:2dplotter:p7179145a.jpg?400|Assembled wooden platform (view from underneath).}}|
  
-===== Drawing Pen ===== +==== Drawing pen ==== 
-====Fixed pen holder====+=== Fixed pen holder ===
 For testing purposes, a temporary fixed (no raising mechanism) pen holder was constructed from Meccano pieces: For testing purposes, a temporary fixed (no raising mechanism) pen holder was constructed from Meccano pieces:
  
Line 172: Line 176:
 {{arduino:2dplotter:p7215796a.jpg?200|2D Plotter test output.}} {{arduino:2dplotter:p7215796a.jpg?200|2D Plotter test output.}}
  
-====Pen moving mechanism==== +=== Pen moving mechanism === 
-As expected, construction of a pen raising/lowering mechanism requires a bit of work.  We need something fairly light as it must be carried by the lower power Y-axis CD sled and it extends out across the plotter bed so exerts leverage on the sled too.   The Arduino controller firmware expects to have stepper motors on all three axes, so that seemed to be the first choice for the pen lower/raise mechanism (effectively the Z-axis of this plotter).  I looked at using a lightweight CD sled from a laptop DVD drive - it has a very small (ie lightweight) stepper motor and a lightweight frame to hold it.  But in trying to connect leads to the motor I broke one of the phase winding connections, so decided it was too fiddly to persevere with.+As expected, construction of a pen raising/lowering mechanism requires a bit of work.  We need something fairly light as it must be carried by the lower Y-axis CD sled and it extends out across the plotter bed so exerts leverage on the sled too.   The Arduino controller firmware expects to have stepper motors on all three axes, so that seemed to be the first choice for the pen lower/raise mechanism (effectively the Z-axis of this plotter).  I looked at using a lightweight CD sled from a laptop DVD drive - it has a very small (ie lightweight) stepper motor and a lightweight frame to hold it.  But in trying to connect leads to the motor I broke one of the phase winding connections, so decided it was too fiddly to persevere with.
  
 A look through my recycled collection of motors and solenoids found a couple of possibilities.  One is a stepper from a 3.5" floppy disk drive, and the other is a [[:electronic:actuator:servo:tds05c|'sent' page marker]] from an old fax machine (used to stamp an 'X' on documents that pass through it to signify that they have been transmitted).   The latter mechanism seems to be the simplest to physically mount, and already has a sort of pen holder attached. A look through my recycled collection of motors and solenoids found a couple of possibilities.  One is a stepper from a 3.5" floppy disk drive, and the other is a [[:electronic:actuator:servo:tds05c|'sent' page marker]] from an old fax machine (used to stamp an 'X' on documents that pass through it to signify that they have been transmitted).   The latter mechanism seems to be the simplest to physically mount, and already has a sort of pen holder attached.
Line 190: Line 194:
 {{arduino:2dplotter:solenoid_driver_schem.png?300|2D Plotter pen solenoid driver.}} {{arduino:2dplotter:solenoid_driver_schem.png?300|2D Plotter pen solenoid driver.}}
  
-|{{arduino:2dplotter:p8230186a.jpg?400|2D Plotter pen side.}}| +|{{arduino:2dplotter:p8230186a.jpg?400|2D Plotter pen top.}}| 
-|{{arduino:2dplotter:p8230185a.jpg?400|2D Plotter pen top.}}|+|{{arduino:2dplotter:p8230185a.jpg?400|2D Plotter pen side.}}|
  
 {{arduino:2dplotter:p8230190a.jpg?400|2D Plotter pen front.}} {{arduino:2dplotter:p8230190a.jpg?400|2D Plotter pen front.}}
Line 205: Line 209:
  
 ---- ----
-====== Software and firmware ======+===== Software and firmware =====
  
 The plotter hardware needs some way to receive instructions of what to draw, and turn those into plotter movements.  //G-code// is often used as the instruction set, and //Grbl// software running on an Arduino is often used to interpret those instructions and convert them to movement of the plotter.  The G-code interpreter software for the Arduino is burnt into its erasable memory so is considered to be firmware. The plotter hardware needs some way to receive instructions of what to draw, and turn those into plotter movements.  //G-code// is often used as the instruction set, and //Grbl// software running on an Arduino is often used to interpret those instructions and convert them to movement of the plotter.  The G-code interpreter software for the Arduino is burnt into its erasable memory so is considered to be firmware.
Line 213: Line 217:
 Traditionally this sort of minimal plotter is set up to receive G-code commands from a 'sender' program Traditionally this sort of minimal plotter is set up to receive G-code commands from a 'sender' program
  
-===== Firmware =====+==== Firmware ====
  
 //Grbl// has many clever features and takes up most of the resources of an Arduino Uno, there are other G-code interpreters like //Mini_CNC_Arduino_Plotter// (simpler) and //Not_grbl// (simpler and faster). //Grbl// has many clever features and takes up most of the resources of an Arduino Uno, there are other G-code interpreters like //Mini_CNC_Arduino_Plotter// (simpler) and //Not_grbl// (simpler and faster).
Line 256: Line 260:
   $132=36.000 (Z - Max Travel, mm)   $132=36.000 (Z - Max Travel, mm)
  
-I had expected that the physical movement of the pen would be the limiting factor as far as speed was concerned, but it turns out that many g-code commands are sent to draw relatively simple objects, especially curves which are implemented as many short straight strokes.   Of the firmware that I tried out //Not_grbl// was by far the fastest, but the code was more difficult to modify than other simpler g-code interpreter software/firmware.  I needed to modify the firmware to implement driving my pen up/down hardware, and it was convenient to have it implement a fuller set of g-code, to minimise the number of edits required to run a variety of g-code files (eg examples found on the internet and g-code produced by inkscape extensions).+I had expected that the physical movement of the pen would be the limiting factor as far as speed was concerned, but it turns out that many g-code commands are sent to draw relatively simple objects, especially curves which are implemented as many short straight strokes.   Of the firmware that I tried out //Not_grbl// was by far the fastest, but the code was more difficult to modify than other simpler g-code interpreter software/firmware.  I needed to modify the firmware to implement driving my pen up/down hardware, and it was convenient to have it implement a fuller set of g-code, to minimise the number of edits required to run a variety of g-code files (eg examples found on the internet and g-code produced by Inkscape extensions).
  
 One interesting fact emerged, there are different interpretations/implementations of the time parameter of the pause/dwell command "G4 Pxxx".    Some use the parameter to specify the delay in milliseconds, others use it to mean a delay in seconds!  eg the command //G4 P180// will cause some g-code interpreters to dwell for 3 minutes, whereas others will take it to mean dwell for 180 milliseconds.  I am inclined to implement it as a delay in seconds when the parameter is specified with a decimal point (eg //G4 P0.500//) and interpret it as milliseconds when specified as an integer (eg //G4 P500//). One interesting fact emerged, there are different interpretations/implementations of the time parameter of the pause/dwell command "G4 Pxxx".    Some use the parameter to specify the delay in milliseconds, others use it to mean a delay in seconds!  eg the command //G4 P180// will cause some g-code interpreters to dwell for 3 minutes, whereas others will take it to mean dwell for 180 milliseconds.  I am inclined to implement it as a delay in seconds when the parameter is specified with a decimal point (eg //G4 P0.500//) and interpret it as milliseconds when specified as an integer (eg //G4 P500//).
  
-===== Sender software =====+==== Sender software ====
  
 We can communicate with the //Grbl// software on the plotter's Arduino controller through the Arduino IDE serial console, but for non-trivial drawing, we need something that can send complete lists of instructions - a 'sender' program such as //bCNC// or //UGS//. We can communicate with the //Grbl// software on the plotter's Arduino controller through the Arduino IDE serial console, but for non-trivial drawing, we need something that can send complete lists of instructions - a 'sender' program such as //bCNC// or //UGS//.
  
-One problem that I had was finding "sender" software that would communicate reliably with the Arduino firmware.  The communication protocol seems pretty simple (though I haven't found a definition of it anywhere) - but basically, for each command sent to the Arduino, it is expected to reply with a response of 'ok'.  I am not clear whether non G-code commands and comment lines are meant to be responded to.  I suspect some of the problem was just losing 'ok' responses from the Arduino (perhaps caused by electrical noise from the motors).+One problem that I had was finding "sender" software that would communicate reliably with the Arduino firmware.  The communication protocol seems pretty simple (though I haven't found a definition of it anywhere) - but basically, for each command sent to the Arduino, it is expected to reply with a response of 'ok'.  I am not clear whether non G-code commands and comment lines are meant to be responded to.  I suspect some of the problem was just losing 'ok' responses from the Arduino (perhaps caused by electrical noise from the motors).  Also some Arduinos use XON/XOFF flow control commands on the serial link (ie allowing the receiver to tell the sender to start and stop), while others ignore them.
      
 {{arduino:2dplotter:p8310258a.jpg?800|2D Plotter example output.}}((Examples:\\ {{arduino:2dplotter:p8310258a.jpg?800|2D Plotter example output.}}((Examples:\\
 Spur_gear (PD by //inductiveload//, [[https://en.wikipedia.org/wiki/File:Spur_Gear_12mm,_18t.svg|Spur Gear 12mm, 18t]])\\ Spur_gear (PD by //inductiveload//, [[https://en.wikipedia.org/wiki/File:Spur_Gear_12mm,_18t.svg|Spur Gear 12mm, 18t]])\\
 Reuse (CCBYSA by //Tony//, [[http://projects.scorchingbay.nz|My Projects]])\\ Reuse (CCBYSA by //Tony//, [[http://projects.scorchingbay.nz|My Projects]])\\
-Gear (PD trivial, [[https://File:Wikipedia_interwiki_section_gear_icon.svg|Interwiki gear]])\\ +Gear (PD trivial, [[https://commons.wikimedia.org/wiki/File:Wikipedia_interwiki_section_gear_icon.svg|Interwiki section gear]])\\ 
-Sheep-outline (PD? - can't find original source)\\+Sheep-outline [[https://pixabay.com/vectors/sheep-farm-lamb-animal-mammal-295337/|Lamb]] [[https://pixabay.com/get/gcf758a2e054e2602bbc9b8af2ace043f2968b2995fd999a0ed05a0e983ff9e5cd11d650d95f1132a1cc1b63f03049098e0cfdaed957fa3fb69c845673c565b9f68982a238f755a7417a169fa6170c416.svg|svg link]]\\
 Tux_Mono (CCBYSA //Larry Ewing//, [[https://commons.wikimedia.org/wiki/File:Tux_Mono.svg|Tux Mono by Iwan Gabovitch]])\\ Tux_Mono (CCBYSA //Larry Ewing//, [[https://commons.wikimedia.org/wiki/File:Tux_Mono.svg|Tux Mono by Iwan Gabovitch]])\\
-Penguin-outline (CC BY 4.0, [[https://svg-clipart.com/color/ScDgKbY-penguin-outline-clipart|ScDgKbY penguin outline]])\\+Penguin-outline (CC BY 4.0, [[https://www.clker.com/cliparts/C/U/d/B/Y/G/purple-penguin.svg|Cartoon penguin outline]])\\
 Finnish_bike (PD //Finnish Transport Agency//,  [[https://commons.wikimedia.org/wiki/File:Finnish_bike_symbol.svg|Finnish bike symbol]])\\ Finnish_bike (PD //Finnish Transport Agency//,  [[https://commons.wikimedia.org/wiki/File:Finnish_bike_symbol.svg|Finnish bike symbol]])\\
 Swellow (PD?, [[https://web.archive.org/web/20150428174110im_/http://www.disegnidacoloraregratis.it/foto/thumb/cartoni/pokemon2/pokemon_swellow.JPG|Swellow]])\\ Swellow (PD?, [[https://web.archive.org/web/20150428174110im_/http://www.disegnidacoloraregratis.it/foto/thumb/cartoni/pokemon2/pokemon_swellow.JPG|Swellow]])\\
 Sinnbild_E-Bikes (PD //German Government//,  [[https://commons.wikimedia.org/wiki/File:Sinnbild_E-Bikes.svg|Sinnbild E-Bikes]]) )) Sinnbild_E-Bikes (PD //German Government//,  [[https://commons.wikimedia.org/wiki/File:Sinnbild_E-Bikes.svg|Sinnbild E-Bikes]]) ))
-  + 
 +\\ 
 +===== Conclusions ===== 
 +==== Redesign considerations ==== 
 +It would have been more useful to have the limit switches detect the zer0 location on each axis, rather than the limit of travel, as the most common requirement, is to home the carriages back to the origin (0,0) as you might not be entirely sure where the carriages end up after a plot run, especially while still debugging software/firmware!  Of course if the hardware isn't forgiving when you hit the end-stops (ie it does physical damage), you need limit switches at both ends of each axis. 
 + 
 +One aspect that I thought was caused by a fault, was that the stepper motors heated up alarmingly when stopped , I've subsequently realised this is caused by the driver powering the motor windings to hold the carriage in position, which isn't necessary if you are not micro stepping as the motor rests at individual steps quite well (and there is not a lot of force trying to pull it out of position).  So the motor can be powered down when plotting is paused or stopped. 
 + 
 +\\
 ---- ----
 ====== References and Additional Resources ====== ====== References and Additional Resources ======
   * [[http://wiki.linuxcnc.org/cgi-bin/wiki.pl|LinuxCNC]] Knowledge Base.   * [[http://wiki.linuxcnc.org/cgi-bin/wiki.pl|LinuxCNC]] Knowledge Base.
   * **G-code**   * **G-code**
-    * [[https://wiki.shapeoko.com/index.php/G-Code|G-code]] reference.+    * [[https://web.archive.org/web/20211123161339/https://wiki.shapeoko.com/index.php/G-Code|G-code]] reference.
     * [[http://wiki.linuxcnc.org/cgi-bin/wiki.pl?CoordinateSystems|G-code]] coordinate systems.     * [[http://wiki.linuxcnc.org/cgi-bin/wiki.pl?CoordinateSystems|G-code]] coordinate systems.
     * [[http://www.diymachining.com/downloads/GRBL_Settings_Pocket_Guide_Rev_B.pdf|G-code]] pocket guide.     * [[http://www.diymachining.com/downloads/GRBL_Settings_Pocket_Guide_Rev_B.pdf|G-code]] pocket guide.
Line 289: Line 301:
       * [[https://github.com/gnea/grbl|Grbl github]]       * [[https://github.com/gnea/grbl|Grbl github]]
       * [[http://edutechwiki.unige.ch/en/Grbl|Grbl]] Edutech page.       * [[http://edutechwiki.unige.ch/en/Grbl|Grbl]] Edutech page.
 +      * [[https://github.com/grbl/grbl/wiki/Interfacing-with-Grbl|GRBL interface]]
     * Mini_CNC_Arduino_Plotter code     * Mini_CNC_Arduino_Plotter code
     * Not_grbl code     * Not_grbl code
Line 295: Line 308:
           * [[https://github.com/winder/Universal-G-Code-Sender|UGS github]]           * [[https://github.com/winder/Universal-G-Code-Sender|UGS github]]
       * [[https://github.com/vlachoudis/bCNC|bCNC]] G-code Sender, Python code.       * [[https://github.com/vlachoudis/bCNC|bCNC]] G-code Sender, Python code.
-          * [[https://wiki.shapeoko.com/index.php/BCNC|bCNC]] supporting documentation.+          * [[https://web.archive.org/web/20210716082139/https://wiki.shapeoko.com/index.php/BCNC|bCNC]] supporting documentation.
       * [[https://github.com/bborncr/gcodesender.py|gcodesender.py]] basic G-code sender, Python code.       * [[https://github.com/bborncr/gcodesender.py|gcodesender.py]] basic G-code sender, Python code.
       * https://web.archive.org/web/20190623183745/http://zapmaker.org/projects/grbl-controller-3-0/       * https://web.archive.org/web/20190623183745/http://zapmaker.org/projects/grbl-controller-3-0/