Building a dot-matrix EV3 Lego printer

One of my early attempts to build a Lego printer. The print head here is driven by a rack and pinion. Later versions used a technic tread and sprocket.

In June and July, I borrowed the girls’ robotics team Lego pieces and EV3 brain in order to build my own dot-matrix printer.

At various FIRST events, I have seen a kid or two who built a printer. I’ve also seen some on YouTube. As a fan of retrocomputing and Legos, I thought it would be a lot of fun to make my own printer.

The basic idea is simple and requires three motors. One feeds the paper forward or backward. One slides a print head back and forth horizontally across the page. The last one moves a marker or a pen up and down to draw a dot.

I made a lot of iterations of this printer, trying to solve various problems. It wasn’t perfect, and I was particularly limited by the number and kinds of pieces I had available. But it DID work! I was able to print out some portraits that were recognizable, as well as a Print Shop-style banner.

This is a simple dot-matrix portrait of my dad made using an early version of my Lego printer. The right side gets distorted, but the left and center are pretty good.

The main challenges (for me, anyway), were how to move the marker up and down, and how to code the printer so that it had good resolution. Early on, I attached the motors directly to the axles, then measured how far to move things using tacho counts. But that led to very sloppy, inconsistent results. After a while, I realized I needed to use a technique called “gearing down”: The motor drives a small gear, which then turns a much larger gear on the axle. This decreases speed, requiring me to use many more tacho units to move the print head the same amount (it also increases torque). This might sound bad, but in fact it greatly reduces errors and inconsistency. I used “gearing down” to improve both the paper feeder, and the horizontal print head movement.

I wrote the code for the printer in Python, and controlled the EV3 using the ev3dev Linux system. Later versions of the code were capable of reading in a PNG file and converting it to a low-res black and white image to print.

At the end of the summer, I created a 3D model of the printer using Lego Digital Designer. Download the viper-printer.lxf file and try it yourself in either LDD or The model isn’t perfect (There are two blank slots in the tread where I couldn’t get things to connect, for example), but is a nearly exact replica.

Inexplicably, I failed to take photos of the final version of the printer. So, here instead are some renderings of the printer, made using

UPDATE (2021-05-12): I uploaded the Python scripts I wrote for the Viper Printer to the team’s GitHub repo: Check them out, and please let me know if you build a printer based on my idea!

9 Replies to “Building a dot-matrix EV3 Lego printer”

  1. Hey will it be possible for you to provide with more details of how you coded, source code, software you used and how to interlinked it to python. How did you integrate png reading. I am a teen very curious , Kindly help

      1. Thank You for the response. I have already completed building the model , took me a few hours. I already code in python since I do competitive coding , & I also use EV3 Dev OS for my EV3. I understood your code properly too, But I was facing a lot of issue regarding , importing requirements, versions, etc.
        It would be a great help if you could just tell or show step by step , how you would run your code , if you were me.
        I am using Visual Studio Code.

        Thank You A lot for the design and code 🙂

        -Kush Garg
        15 Years Old

      2. Hey , Just needed to inform that most of the issues got solved. The problem was that my VSCode Ev3 dev extension was the latest version, and yours version was different , Thus , there was a difference in syntax. If I run it on the old version it works properly. I am getting just 2 errors.

        ImportError: No module named ‘png’
        I don’t know why I am getting this, Since I have installed png module from the requirements.txt file.

        And, I also Cannot install ‘openrobertalab’ module
        I am getting this error
        ERROR: Could not find a version that satisfies the requirement openrobertalab==1.4.0 (from versions: none)
        ERROR: No matching distribution found for openrobertalab==1.4.0

        Thanks A lot for the source code , everything else runs smoothly.
        Kindly just tell me , the solution to the 2 problems.
        Thank You again for giving me your time.

        I will surely inform , if I am successfully able to print a png file properly. 🙂

        1. Kush, I think the main problem is that the my scripts were developed four years ago. Python and ev3dev both have changed a lot since then.

          Last night, I tested the script on our ev3 brick. It still worked. But when I used pip to try to install some new modules (virtualenv and virtualenvwrapper), I ran into a lot of module-related problems.

          I may try to reinstall a newer copy ev3dev and update my code to work better with it.

          In the meantime, I would suggest deleting the line `openrobertalab==1.4.0` from requirements.txt. I think it will resolve both problems you mentioned.

          (I suspect a separation installation of openrobertalab is unnecessary. And since installation is failing at the openreportalab step, pip never gets a chance to install pypng)

          1. Thank You for the response.
            I tried removing `openrobertalab==1.4.0` from requirements.txt, And when I had run it, pypng installed successfully, still I am unable to import it.
            And it also showing error in this line ‘python-ev3dev==VERSION’ from the requirements.txt.

        2. Kush,

          This weekend I re-installed ev3dev on my ev3 brick. I updated the code and the file with the changes necessary to make run in Python3.

          Please visit the repo again and try the new code and the new instructions. I tested them today, and they worked perfectly for me.

          1. Thank You Sir, I am still facing a problem.
            My model is able to print dots and make shapes and everything else in the code works perfectly.
            But the ‘purepng’ is causing an issue. Your code is perfectly right , I am sure of that, But with me , “purepng” package gets installed properly but I am not able to import it. It shows:
            ImportError: No module named ‘purepng’
            I have checked the settings too , My python and packages are installed in the right directory. Still it is causing an issue.
            Is it possible for you to help me ?

            I am using Python Version : 3.9.5
            I am using VSCode for it.

            Kindly tell if you need any other info to help me resolve the issue

            Thank You A lot.

          2. Sir,
            I don’t know, what the problem was, touch was also showing error while importing , so I reinstalled the ‘pypng’ Module and the old code started to work , For now I am tweaking the code a bit so that It could run according to my model. The code is running without errors and reading png too. I will surely contact you ,if I am able to successfully print the whole image.

            Thank You for your time and Support Sir.

            Is it possible for me to contact you via email or something else rather than open comments ?
            Thank You

Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of follow-up comments via e-mail. You can also subscribe without commenting.