CNC Drawing Machine
Want a physical copy of a digital art piece with an authentic look that can't be replicated by a printer? This Arduino CNC drawing machine moves along its x-, y-, and z-axes to plot digital images and text onto paper and contains mechanical, electrical, and software components. Its function is largely aided by software that translate paths and images into GCODE for the machine to read.
Many thanks to my family members and to Ms. Berbawy, who provided resources and guidance for this project, which was created for her Principles of Engineering class and was based on the instructions of DIY Machines.
Process
- Take measurements of existing parts to design and print 3D printed components
- Assemble the x-, y-, and z-axes
- Connect the electronic components
- Download and set up the necessary software
- Test the hardware
Supplies
- Prusament PETG filament
- Wooden panel
- Nuts, bolts, and screws
- 300mm long linear rail with block
- 8 x 15 x 45mm linear bearings
- 8 x 15 x 25mm linear bearing
- 8mm chromed steel rods (350mm x2 & 100mm x1)
- 6mm idler wheel - 3mm bore
- GT2 timing belt and pulleys
- 12V Nema 17 stepper motors
- Micro servo
- Limit switches
- Electrical wire
- Arduino Uno
- Arduino-compatible CNC shield
- Stepper drivers
- 12V power supply - 2A or greater
3D Printed Parts
These 3D printed parts allow for the attachment of other components, acting as "joints." The x-axis parts house the stepper motor that controls the machine's side-to-side movement, while the y-axis parts house the stepper motor that controls the back-and-forth movement. The rail mount connects these two axes. A micro servo on the y-axis servo end controls the z-axis, lifting the pen up and down using the servo horn attachment and the pen slider.
Necessary 3D printed parts:
- X-axis idle end
- X-axis powered end
- Rail mount
- Y-axis servo end
- Y-axis pen end
- Pen slider
- Servo horn attachment
These were printed using a Prusa Mini:
- 0.15mm layer height
- 40% infill
Part CAD and Assembly
The first step is to CAD the parts listed below while ensuring that each is able to attach to the bulleted list of parts listed underneath. I measured the bulleted parts as precisely as possible using dial calipers and CADDED those first before creating the parts I would 3D print. I used Autodesk Fusion 360 to model the machine's components and assemblies.
1. X-axis idler end: This is one of two parts that will be drilled into the wooden board to stabilize the machine. Its main purpose is to hold one end of the linear rail and to house the toothed pulley to be used for the x-axis movement. A small extrusion will also be needed for the x-axis limit switch to contact since the limit switches on the machine will allow it to locate its position.
- Wooden board (wood screw x2)
- Linear rail (M3 x 12 bolt and nut)
- Toothed pulley (M3 x 18 bolt and nut)
- (limit switch contact location)
2. X-axis powered end: This is the second part that will be drilled into the wooden board. It will hold the other end of the linear rail and house the x-axis stepper motor. A toothed pulley will need to be attached to the motor's shaft later on.
- Wooden board (wood screw x2)
- Linear rail (M3 x 12 bolt and nut)
- Stepper motor (M3 x 6 bolts x4)
3. Rail mount: The rail mount rests on the linear rail block and clamps the ends of the x-axis timing belt. As a result, this 3D printed part will move along the x-axis as the machine moves. The y-axis stepper motor is housed here, and the y-axis timing belt will move along the toothed pulley attached to the motor's shaft and the idler pulley also housed in the rail mount. Linear bearings fitted into this part will hold the long metals rods that will guide the y-axis movement. The x-axis and y-axis limit switches are also housed here.
- Linear rail block (M3 x 6 bolt x4)
- X-axis timing belt
- Stepper motor (M3 x 6 bolt x4)
- Idler pulley (M3 x 12 bolt and nut)
- 8 x 15 x 45 linear bearing x2
- Limit switch x2
4. Y-axis servo end: One end of the long metal rods and one end of the y-axis timing belt will be attached to the y-axis servo end. The micro servo will lie on its side, ensuring that there is enough room for the servo horn and servo horn attachment. An extrusion will be needed for the y-axis limit switch to contact.
- 350mm metal rod x2
- Y-axis timing belt
- Micro servo
- (limit switch contact location)
5. Y-axis pen end: The other end of the rods and the y-axis timing belt is attached here. A location for a linear bearing will be needed for the metal rod that will guide the movement of the z-axis along a toothed pulley.
- Y-axis timing belt
- 350mm metal rod x2
- 8 x 15 x 25 linear bearing
- Toothed pulley (M3 x 18 bolt and nut)
6. Pen slider: The metal rod that guides the z-axis movement is attached to the pen slider, along with one end of the z-axis timing belt. When moving up and down, there should be minimal side-to-side movement, which can be ensured by using a rectangular shape instead of a circular one. The pen or other drawing device can be attached by housing M3 nuts on the inside of the part and inserting M3 bolts from the outside.
- 100mm metal rod
- Z-axis timing belt
- Pen/pencil (M3 x 25 bolts and nut x2)
7. Servo horn attachment: This part fits onto a one-sided micro servo horn to hold the other end of the z-axis timing belt so that the servo can pull the pen slider up and down.
- Micro servo horn
- Z-axis timing belt
Tips:
*Use hole sizes of 3.4mm for the M3 bolts (if printed on a Prusa Mini with a 4mm nozzle)
**For the timing belt attachment areas, use enough of an offset that the center extrusion doesn't break apart when the belt is removed, and align the components so that the belt is parallel to its corresponding axis (the z-axis timing belt should be parallel to the y-axis).
Wooden Base Board
Use a circular power tool to cut a wooden board to approximately 15in x 17in
Materials used:
- Circular power tool
- 14.75in x 28in wooden board
- Smaller wooden board with a length of at least 15in
- 2 clamps
- Tape measurer
- Gloves
- Pencil
- Crates/table
Steps:
- Draw a vertical line at 17in on the large wooden board.
- Align the power tool onto the line drawn.
- Align the smaller board on the left of the tool to use as a guide.
- Clamp the boards together.
- Ensure the part of the board that will be cut off is not on top of the crates/table.
- Adjust the blade position in the power tool so that the protruding part is only slightly longer than the thickness of the board.
- Put on gloves and power on the tool.
- Cut with a steady speed and motion.
Electronics Testing
The three main electronic components of this machine are the limit switches, the micro servo, and the stepper motors. These tests ensure that the parts, especially if they aren't new, are working as they're supposed to. Testing them before completely assembling the machine allows for a better understanding of how the components work and interact and prevents any major issues during the full test.
Limit switch testing:
1. Set the multimeter to 200Ω. The following should be observed (this can also be used to determine the identity of each terminal if they aren't labeled):
- When the probes are in contact with the common and normally open terminals, there's a reading when the switch is pressed.
- When the probes are in contact with the common and normally closed terminals, there's a reading when the switch is not pressed.
2. Connections to the Arduino board:
- Common → ground
- Normally open → any digital pin
- The code used for switch testing prints "UNTOUCHED" or "TOUCHED" on the serial monitor depending on the state of the switch
*Debounce time = the amount of time that must pass before the switch can be pressed again for a response
Micro servo testing:
1. Connections to the Arduino board:
- Brown = ground wire → ground
- Red = power wire → 5V output
- Orange = signal wire → any digital pin
The code used for micro servo testing (Arduino IDE → File → Examples → Servo → Sweep) turns the servo from 0° to 180°, pauses, turns it from 180° to 0°, pauses, and repeats.
Stepper motor testing:
1. Determine the stepper motor pinout if the model number is unknown or the datasheet is unavailable:
- Set the multimeter to 200Ω. There should be a reading when paired pins are in contact with the probes. Male-to-female jumper wires can be used for testing, with the female ends on the pins and the male ends in contact with the multimeter probes.
- Additionally, when paired pins are in contact, there should be resistance when turning the motor. When each pin is connected to its pair, the motor should be very difficult to turn.
- The stepper motor wires should be aligned so that the end connecting to the CNC shield has each pin next to its pair. This isn't always the case since different stepper motors have different pinouts, so the wire order may need to be carefully changed.
2. Connections to the CNC shield and Arduino board:
Materials:
- 2 stepper motors
- 2 stepper motor wires
- 2 stepper drivers and 2 heat sinks
- 1 CNC shield
- 1 Arduino board and USB (for the final electronics connections, the Arduino Uno should be used for compatibility with the CNC shield, but for testing, a different board can be used, such as the Arduino Mega 2560)
- 12V power supply or 12V battery and wires
Stack (from bottom to top): Arduino board, CNC shield, stepper drivers (on the x and y locations of the shield), heat sinks
Adjust the current limits of the stepper drivers (current ratings can be found on the stepper motor's datasheet)
- Turn the screwdriver clockwise all the way on the potentiometer of the stepper drivers to set the current limit to 0 before plugging in or turning on the power supply and plugging the Arduino into the computer.
- Set the multimeter to 20V DC.
- One multimeter probe contacts ground while the other one clamps to the screwdriver using an alligator clip.
- Turn the screwdriver counterclockwise to increase the limit with the power supply on and the Arduino plugged in.
*The current limit should be set close to but below the current rating since too low of a setting could cause missteps and lower precision while a higher setting could cause overheating. (DRV8825 stepper driver: VREF = 2 x current rating, A4988 stepper driver: VREF = 8 x current rating x current sense resistance)
The code used for stepper motor testing rotates the motor.
Soldering
Solder wires onto the limit switches to allow for a connection to the CNC shield.
- Solder a female-to-male connector to each of two electrical wires (use different colors for differentiation such as one black and one white) with the connector part on the male end removed.
- Since the electrical wire was in a twisted pair, a multimeter was used to identify the individual wires.
- Solder the remaining ends of the electrical wire to the common and normally open terminals of each limit switch.
- End result: a black wire with a female end connected to the common terminal and a white wire with a female end connected to the normally open terminal of each limit switch
Physical Part Assembly
The assembly will be easiest if done in this order:
- X-axis (x-axis idle end, x-axis powered end, rail mount)
- Y-axis (y-axis servo end, y-axis pen end)
- Z-axis (pen slider, servo horn attachment)
*Epoxy glue can be used to join the 3D printed parts to the linear rods (and the linear bearings if needed), but tape is strong enough to keep the components together during testing.
Finally, drill the x-axis idle end and x-axis powered end into the wooden board, making sure that the range of the pen doesn't go off the board.
Electronics Connections
Stack the stepper drivers, CNC shield, and Arduino board in the same way as during stepper motor testing.
X-axis limit switch
- White wire → X- white column
- Black wire → X- black column
Y-axis limit switch
- White wire → Y- white column
- Black wire → Y- black column
Micro servo (if the wires aren't long enough, use male-to-female connectors to extend the lengths)
- Brown wire → GND
- Red wire → 5V
- Orange wire → Z+ white column
Stepper motors
- Corresponding axes
*Use electrical tape to group and organize the wires
GRBL
Install the GRBL library in Arduino IDE.
- Open the serial monitor.
- Set the band rate to 115200.
- Type "$$" in the serial monitor to show the configuration.
- Edit the configuration as needed (ex. $100 and $101 can be changed using the formula: previous steps/mm x inputted distance ÷ distance traveled = updated steps/mm).
Important commands:
- "$H" = homing (moves the axes towards the limit switches until contact is made, then "bounces" off)
- "M3 S90" raises the z-axis
- "M5" lowers the z-axis
- "G92 X0 Y0" sets the origin at the ends of the x- and y- axes ("$H" followed by "G92 X0 Y0" should be performed every time before starting a drawing)
- "G00" = rapid positioning (linear movement at maximum speed)
- "G01" = linear interpolation (linear movement at a set feed rate: G01 X# Y# F#)
- "G02" = circular interpolation clockwise (set endpoint and center point offset: G02 X# Y# I# J#)
- "G03" = circular interpolation counterclockwise
- "G20" = sets feed rate units to in/min
- "G21" = sets feed rate units to mm/min
- "G28" = return home
- "G90" = absolute mode
- "G91" = relative mode
To draw the boundaries of the drawing space:
- M3 S90
- $H
- G92 X0 Y0
- M5
- G1 X0 Y215 F2000
- G1 X210 Y215 F2000
- G1 X210 Y0 F2000
- G1 X0 Y0 F2000
After the boundaries are determined, use a pencil to mark the paper placement on the wooden board for future reference.
Chilipeppr
Chilipeppr GRBL can be used to send GCODE automatically instead of having to input commands line by line.
- Install a serial port JSON server for a connection to the Arduino.
- Open the application.
- Click "Home Axis" in the axes window.
- Click "Zero Out" to reset the coordinates.
- Import the test drawing created by DIY Machines.
- Press start at the upper left to perform a dry run.
G Code Generators
Drawings can be created on Inkscape, CadSoftTools, DFX2GCODE, and other GCODE generating software, then translated into GCODE on Chilipeppr.
Inkscape settings to change:
- Download the MI Inkscape Extension by DIY Machines
- File → Document Properties for units and dimensions
- Stroke Style and Fill
- Path → Object to Path → MI GRBL Z AXIS Servo Controller → MI GRBL Z AXIS Servo for servo up (M5), servo down (M3), x-axis speed (10000), y-axis speed (4000), angle for servo (90), and delay (0.2)
Possible Inkscape actions:
- Import drawings and convert into paths
- Freehand or using paths
- Shapes
- Combine/merge shapes
Using these software, any shape or digital image can be drawn by the CNC drawing machine. You can now create original artwork produced by a machine!