Skip to main content
Version: ACS CC

Pen Plotter

A machine that draws an user defined image using a pen.

info

Author: Andrei Stan
GitHub Project Link: https://github.com/UPB-PMRust-Students/proiect-andreistan26

Description

A pen plotter is similar to any 2.5-3 axis machine like a CNC or a 3D printer, it works by moving a pen in cartesian coordiantes in order draw something on a piece of paper.

Motivation

I thought this would be a challenging, yet fun project that requires different skills to pull of, it has software, electrical and mechanical complexities. It would also make me do more CAD work.

Architecture

image

Log

Week 20 - 27 April

  • started making the CAD and looking for online resources
  • started to order the mechanical components and 3D printed some prototypes
  • tested the electronic components like the power supply, voltage regulator and stepper motors

Week 28 - 4 May

  • tested the 3D printed parts and iterated on them
  • finished the documentation

Week 5 - 11 May

  • assembled the mechanical parts
  • made some more 3D prints (display mount, improved pen holder)
  • finished prototyped electrical wiring

Week 12 - 18 May

  • finished final assembly
  • base software for moving to coordinates, parsing GCode, uart communications and optimizations for line plotting
  • got a fully working version capable of plotting streamed Gcode

Week 19 - 25 May

  • added a progress bar to the display and also modified the UART client to send M73 commands for updating the progress bar
  • improved the code for better plotting performance

Hardware

  • Mechanical:

    • Steel 8mm rods
    • Brass 4mm rods
    • GT2 Timing belt
    • Tooth timing pulleys and idler pulleys
    • 3D printed parts
  • Electronics:

    • AC-DC Power Supply 12v 10A
    • DC-DC Voltage regulator 12v-5v
    • SG90 Servo Motor
    • 2 x Nema-17 Stepper motor
    • 2 x DRV8825 Stepper Motor Driver
    • R-PI Pico 2
    • LCD Display
    • 2 x 100uF capacitors
    • Other small components (wires, breadboards, etc.)

Schematics

image

Pictures

image

image

Bill of Materials

DeviceUsagePrice/Unit
Raspberry Pi Pico 2WMicrocontroller39.66
2 x DRV8825 Stepper Motor DriverDriver for the stepper motor14.49
2 x Stepper Motor 17HS8401SStepper motor driving each axis linear system34.99
LM2596 Voltage RegulatorConverting the ouput of the power supply (12V) to 5V16.49
TFT-LCD Display 1.44"LCD Display for displaying information about the plotter29.99
SG90 ServoServo that lifts the pen on the Z axis11.99
Power Supply 12V 10APower supply for the porject41.6
8 x Linear Bearing 8mmLinear bearings for sliding the gantry4.07
2 x GT2 Timing BeltBelt for moving the gantry3.96
2 x Tooth timing pulleyTransmits power from the motor shaft to the belt4.50
2 x Smooth pulleyGuides the timing belt and keeps tension on the timing belt9.32
1.5 x 8mm Steel RodThe gantry will slide on it49.00
2 x 4mm Brass RodFor sliding the pen holder19.99
2 x Breadboard 830pFor wiring stuff up9.99

Software

LibraryDescriptionUsage
embassy-*Async framework for embedded systems in RustFramework used for the whole system including rp235x specific drivers
mipidsiDisplay driver for ST7735Used for the display for the Pico Explorer Base
embedded-graphics2D graphics libraryUsed for drawing to the display
defmtDeffered loggingLogging for the plotter during testing
heaplessStatic allocated containersAllocate data structures for holding GCode commands
format_no_stdFormatting library for no_std environmentsUsed for formatting the progress bar text
display_interface_spiSPI interface for displaysUsed for communicating with the display

Software Design

The software that runs on the pico was designed using the embassy framework. Thus I've separated all the hardware subsystems into tasks that are run on the default executor.

These tasks communicate via channels, simply, tasks produce values for other tasks to consume. For example the command manager task produces coordinates for the stepper and servo tasks.

The tasks running are:

  • servo task
  • stepper x and y task
  • display task
  • command manager task
  • UART task

When the plotter starts reciving data the following steps are usually performed:

  1. The plotter is initialized and all the tasks are spawned.
  2. Data from an UART connection in the form of G-code commands.
  3. G-code commands are parsed and sent to the command manager.
  4. The command manager plans the path of the plotter.
    • Lines are drawn using Bresenham's algorithm in order to avoid hockey stick lines.
    • The plotter then sends positions to the stepper and servos and waits for them to finish before sending new ones.
  5. Once we receive M73 commands, the plotter updates the progress bar on the display.
  6. This is repeated until all uart commands are processed.

Brasenham's line drawing algorithm helps us sample the line in the correct pixels that need to be drawn. The idea is that when we need to write a line at a 20 degree angle, the X component is bigger than the Y component. If we sent the commands to the X and Y components at the same time, we would get a 45 degree line then a straigt line. By using Bresenham's line drawing algorithm, we limit the number of pixels drawn at a time by the plotter thus making the line more precise. This could have been done by just modifying the RPM of each stepper, but this solution has been unsuccessful empirically.

image

For streaming GCode to the plotter I am using a python client that also preprocesses the plotter commands before sending them via UART. The GCode is generated by Lightburn, inkscape or vpype.

  1. Where I took the starting 3D models
  2. Lab resources