TinyCNC Drawing Robot Software User Guide

Arduino, Processing, and Inkscape

Arduino, Processing, and Inkscape

This Tiny 3-axis CNC software guide is designed to assist the user of the robot in quickly and easily operating their robot.  The TinyCNC robot uses three separate pieces of software to operate as a 3-axis CNC or, if you prefer, a drawing robot.  These are an Arduino sketch, a Processing sketch, and a plugin for Inkscape. ((For the sake of brevity and to maintain a focus on the operation of this particular robot, this guide assumes the user is able to install these programs, install any necessary drivers, and troubleshoot any problems with their particular computer, operating system, and microcontroller.)) Each piece of software in this toolchain is entirely open source and multi-platform.

  • An Arduino sketch is necessary for the Arduino attached to the robot to interpret basic Gcode CNC instructions.  The only instructions this sketch will interpret are G1 (to move the robot to a particular XY coordinate) and M300 (to raise or lower the Z axis).  The sketch “listens” for a line of Gcode, interprets it, and then moves the robot accordingly.
  • A Processing sketch is used to open a text file containing Gcode and send the commands over a serial USB connection to the robot.
  • The open source vector graphics program Inkscape is used to convert vector graphic images into a series of Gcode instructions, using an extension.

There are three different Arduino sketches that provide an increasingly sophisticated level of sophisticated operation.  This guide will assist the user in using each of these three sketches, culminating in the ability to draw images.

  1. Download all software
    1. Download and install Inkscape.
    2. Download and install the Arduino IDE.
    3. Download and install Processing.
    4. Download the Inkscape extension for outputting G-Code for the MakerBot Unicorn Pen Plotter by Marty McGuire.  (Look for the download button along the right side of the page)
    5. Download the various TinyCNC sketches.  (Look for the download button along the right side of the page)
  2. Setting up Arduino IDE
    1. Install the TinyCNC sketches
      1. Copy the “TinyCNC_Shapes.ino” Arduino sketch folder into your Arduino IDE’s sketch folder.
      2. Copy the “TinyCNC_WASD.ino” Arduino sketch folder into your Arduino IDE’s sketch folder.
      3. Copy the “TinyCNC_Gcode.ino” Arduino sketch folder into your Arduino IDE’s sketch folder.
    2. Using a USB cable, connect your Arduino microcontroller to your computer.
    3. Open the Ardiuno IDE.
    4. Select your particular Arduino variant board by going to “Tools -> Board” and choosing it from the list.
    5. Select the serial port for your Arduino by going to “Tools -> Serial Port” and choosing it from the list.
    6. The following slideshow will take you through the above steps.

      This slideshow requires JavaScript.

  3. Draw Basic Shapes
    1. Open the Arduino IDE.
    2. Open the “TinyCNC_Shapes.ino” by going to “File -> Sketchbook -> TinyCNC -> TinyCNC_Shapes”.
    3. Upload the “TinyCNC_Shapes.ino” sketch into your Arduino by going to “File -> Upload” or clicking the arrow upload button.
    4. If you have a pen attached to the Z axis, the robot should start drawing a rectangular spiral.
    5. The following slideshow will take you through the above steps.

      This slideshow requires JavaScript.

  4. Control the Tiny CNC with the Keyboard
    1. Open the Arduino IDE.
    2. Open the “TinyCNC_WASD.ino” by going to “File -> Sketchbook -> TinyCNC -> TinyCNC_WASD”.
    3. Upload the “TinyCNC_WASD.ino” sketch into your Arduino by going to “File -> Upload” or clicking the arrow upload button.
    4. Open the Arduino Serial Monitor (which lets you communicate with the Arduino) by going to “Tools -> Serial Monitor”. (You can also click “Control + Shift + M”)
    5. The Arduino Serial Monitor will appear as a popup window with a box for entering text, a “Send” button, and a large field where it will display any messages coming from the Arduino.
    6. Use the “WASD” and “OL” keyboard keys to control the robot by typing a character into the Serial Monitor and clicking “Send” or hitting the “Enter” button.
    7. The robot will move left or in the -X direction (“A”), right or in the +X direction (“D”), forward or in the +Y direction (“W”), back or in the -Y direction (“S”), raise or in the +Z direction (“O”), and lower or in the -Z direction (“L”).
    8. The following slideshow will take you through the above steps.

      This slideshow requires JavaScript.

  5. Setting up Inkscape
    1. We’ll need to install the Inkscape extension for outputting Gcode in order to convert SVG files into Gcode.
    2. Copy the extension files into your “Inkscape/extensions” folder.  If you choose to use PortableApps.com version of Inkscape, you’ll find the extensions folder at “InkscapePortable\App\Inkscape\share\extensions”.
  6. Create Gcode with Inkscape
    1. Open Inkscape.
    2. Go to “File -> Open” and locate the SVG (vector graphics) file of your choice.
      1. Why not try this Open Source Hardware logo (2314 downloads ) ?
      2. There are some nuances to converting SVG files into Gcode, which I will cover at the end of this post.
    3. Go to “File -> Save As” and type in the file name of your choice with the file extension “.gcode”.
    4. Under “Save as type:” choose “MakerBot Unicorn G-code (*.gcode)” and click “Save”.
    5. A popup window will appear with several settings.  Make sure the “Pen Up Angle” is set to exactly “50.0” and the “Pen Down Angle” is set to exactly “30.0”.
    6. The following slideshow will take you through the above steps.

      This slideshow requires JavaScript.

  7. Control the Tiny CNC with Gcode (and draw a picture!)
    1. Open the Arduino IDE.
    2. Open the “TinyCNC_Gcode.ino” by going to “File -> Sketchbook -> TinyCNC -> TinyCNC_Gcode”.
    3. Upload the “TinyCNC_Gcode.ino” sketch into your Arduino by going to “File -> Upload” or clicking the arrow upload button.
    4. At this point you can close the Arduino IDE – or leave it open if you wish.  However, make sure the Serial Monitor is closed since the Arduino Serial Monitor will interfere with the Processing program’s ability to communicate over the serial connection.
    5. Open Processing.
    6. Open the “SendingSerial003.pde” Processing sketch by going to “File -> Sketchbook -> Sketches -> SendingSerial003”.
    7. Change the “filename” variable from “r2d2a” to whatever your Gcode filename happens to be.  (The program will assume a “.gcode” after the file prefix.
    8. Run the Processing sketch by going to “Sketch -> Run”, clicking “Control + R”, or clicking the triangular “Run” button.
    9. The Processing sketch will open a tiny popup window and start to stream Gcode commands to your robot and the robot should perform each command  in turn.  The commands will be echoed in the black message area at the bottom of the Processing screen.
    10. The following slideshow will take you through the above steps.

      This slideshow requires JavaScript.

  8. Subsequent Gcode Operations
    1. Once the user has uploaded the “TinyCNC_Gcode.ino” sketch to the Arduino, the user does not need to bother with the Arduino IDE again.
    2. From this point forward, the operation of the robot becomes remarkably simplified.  The user may simply craft Gcode with Inkscape and then send that Gcode to the Arduino operating the robot using the Processing sketch.  If the user wishes to simply draw images from a library of Gcode files,
  9. Converting SVG files to Gcode, Special Considerations
    1. Layers and Objects.  Text, complex paths, paths that have been grouped together, and objects are not as easily converted directly into Gcode using the Inkscape plugin instructions above.  In order to simplify the SVG file for converting into Gcode, it is necessary to break up the various groups and objects into one set of paths the extension can translate.  The easiest way to do this is to:
      1. Select all the contents of the image by using the command “Control + A” or going to “Edit -> Select All”.
      2. Ungroup all the groups (often these aren’t obvious) by using the command “Shift + Control + G” or going to “Object -> Ungroup”.
      3. Convert all the objects to paths (the Gcode converter only converts paths into Gcode) by using the command “Shift + Control + C” or going to “Path -> Object to Path”.
      4. Break all the paths apart by using the command “Shift + Control + K” or going to “Path -> Break Apart”.
      5. Subtract the various paths from one another by using the command “Control + -” or going to “Edit -> Difference”.  (Note:  This may make your image look really weird.  Don’t panic.  This is entirely normal and actually a good sign.)
      6. Once steps 1-5 have been completed, try to save the SVG file into Gcode.  If you get an error, repeat steps 1-6 and try to save the file into Gcode again.  Sometimes I’ve need to go through steps 1-6 as many as two or three times.
      7. The following slideshow will take you through the above steps.

        This slideshow requires JavaScript.

    2. Size.  The image you’re using may be much larger than the robot you’re using can accommodate.  If you are using the TinyCNC robot platform, you will want to make sure your image is only about 3″ wide by 2″ tall.  Much larger than this and your robot may have a difficult time drawing the image.  The best way to ensure your Gcode will only describe an area your robot can draw is by resizing the entire page to be only 3″x2″.
    3. The easiest way to do this is to:
      1. To change the “page” size of the document, go to “File -> Document Properties” or click “Shift + Control + D”.
      2. A new popup window will appear with the current page dimensions listed under “Custom size”.
      3. First change the “Units” to “in”, then adjust the “Width” to “3.00” and the “Height” to “2.00”.
      4. Click the “X” button in the top right corner of the popup window to exit the Document Properties.
      5. You should now see your SVG image on a different sized page.  You may need to zoom in or out using the “Z:” box in the bottom right corner of the window.
      6. The following slideshow will take you through the above steps.

        This slideshow requires JavaScript.

Back to the Drawing Robot AFRON Ultra Affordable Educational Robot 2013 Design Challenge Entry.