Get Things Done!

Gorlu the plotter

Completed
Gorlu the plotter
Gorlu the plotter

A compact CNC plotter.
Based on Arduino and Canny edge algorithm, Gorlu is able to process any digital image and generate a physical, post it size, monochromatic representation of it.

#mechanical #mechatronics

Intro

This project has been probably the first one I did concerning the use of Arduino and Python. Inspired by a couple of videos on youtube and willing to give a try to the Python language, I decided to create this plotter.

Most of the effort was put into the Python code, which is responsible for the image processing and the communication with the Arduino. On the other hand, quite a bit of time was spent on the mechanical part, physically building the plotter's structure and testing the pen's movement.

Objectives

At the beginning of the project, I set the following objectives:

  • Learn the Python language by doing working on a personal project;
  • Print digital images by means of extrapolations of their main lines;
  • Print in real-time any freehand line drawn on a PC.

However, during the project development, I added a few more objectives and features:

  • Developing a complete GUI interface that could simplify the user's interaction;
  • Print text as a normal printer would have done.

The Code

Among the various challenges, the most significant was the image processing algorithm.

The main idea was to simplify the input image by extracting its main lines and printing them. To do so, I used the Canny edge detector to extract the main lines and save the pixels in a 2D matrix.

Canny's algorithm example
Canny's algorithm example

By leveragin the image processing to the OpenCV library (that contains the Canny() function), I was able to extract the main lines and store them in a 2D matrix. From this stage, the newly created matrix was scanned starting from the top-left corner looking for neighboring pixels and sending their coordinates to the Arduino. It's here clear the real difference between this project and real CNC machines: when an industrial based CNC machine works using the login of custom comman that correspond to different movement of the head, here my plotter performs single-coordinate based action.

In the following image, a graphical representation of the searching algorithm perfomerd on the 2D matrix is shown. Below, is the Python code that performs such an operation.

Algorithm example
Graphical simulation of the search algorithm

The Structure

As we have spoken about the software part, let's now focus on the hardware.

The structure is made of wood and recycled components coming from a couple of old-fashion CD/DVD drives. Their low voltage stepper motors can be easly controlled by the Arduino using an H-bridge shield. The vertical movement of the pen is instead controlled by a servo-motor that pulls the pen up and a rubber band used to push it down and apply a constant pressure on the paper.

In the video below, a couple of demonstrative movements are shown.

Conclusions

This project has been a great opportunity to learn new things and to experiment with different technologies. The final result is a working plotter that can print images and text processing them using the Canny edge Algorithm.

As always, a project is never perfect and some of the features that could be improved or addded are:

  • Implementing a mechanical system able to handle many shapes of pen in order to have the possibility to easly swap the marker;
  • Reducing the lag time and increasing the input rate when dealing with a real-time freehand plotting;
  • Increase robustness in the communication between the Arduino shield and the PC;
  • Switching to a G-Code based login in order to being compatible with the majority of the industrial CNC machines.

Gallery

Gorlu the plotter
Gorlu the plotter
Gorlu the plotter
Gorlu the plotter
Gorlu the plotter
Gorlu the plotter
Gorlu the plotter
Gorlu the plotter