da Vinci





Intro

Using a system of gears and stepper motors, da Vinci is capable of etching low resolution images in grey-scale on an Etch-A-Sketch. The images are first processed into a text file using a custom written piece of computer software before being loaded onto an SD card for da Vinci to read and draw.


Part Sourcing

When I decided to make this project, I first needed to track down an etch-a-sketch. I would need to know some general stuff about it to start my design. I needed the dimensions of it and I also just wanted to play around with it. It has been a while since that last time I used one. My first thought was that maybe I had one around the house somewhere. Shouldn’t everyone have an etch-a-sketch, a Rubik’s Cube, and a Slinky? Well I did not have one... So now that I was in the market for an etch-a-sketch, I went online and was not able to find a local store that carried them. I ended up having to order one from Amazon.



Once I was done playing around with it, it was time to get down to business. I was most interested in the knobs. They popped off easily and under them were metal shafts. Some how I would have to get da Vinci to spin these. I used my digital calipers to measure the diameter of them.



Well I think it should be obvious that I went with stepper motors for this project. They can be accurately controlled, and that is just what I needed. These are cheap ($4.75) 5v stepper motors that came with a motor controller. I tested them out with the Arduino Stepper library and they worked fine.




So next I had to tackle the issue of how to go about spinning the etch-a-sketch’s shafts. I decide I would laser cut gears. This would allow me to make any size I needed. The real issue was how to attach them to the etch-a-sketch’s shaft. The two worse ideas in my mind were press fitting and gluing. The first seemed unreliable and the second is too permanent. I remember I used a thing called a “collet” on one of my RC airplanes that did exactly what I needed. They are meant for holding a propeller onto the shaft of a RC airplane’s motor. Luck would have it that I found a 5mm collet online (they were not as cheap as I was expecting, but very light weight aluminum). The shafts of the etch-a-sketch I measured to be 4.8mm. Sounds like it was meant to be.




I didn’t have any gears yet so I put some washers and cardboard in place of them. The collet tightened on the shaft really well.




Design

It was now time to design. I first needed to choose what material I would make da Vinci out of. Acrylic? Wood? Carbon fiber? Okay, the last one is a joke, but the coolest of them all. I went with wood because it is strong and easy to glue. The local hardware store does not have nice plywood. I had to order some hobby grade birch plywood online. This is the good stuff. So good in fact that I only had enough money for three 6”x12” sheets. Do those sheets sound small? They are. That set my first design constraint.



It was time to start CADing. For the first time I cut out the design in foam board to see how it would fit together. This was crucial because with only 3 small sheets of plywood, I had little room to mess up. After a few hours, I had my initial design completed. The whole thing is angled backwards a little like a picture frame. This will make it easily viewable. The etch-a-sketch slides in upside down. This seemed like the best way to slide it in and out.






There were a few things that were obviously missing in this design that I knew I would eventually add. The first is a front panel that would house one of my ezLCDuinos, a potentiometer, and a button. These things will allow the user to select the image they want to etch. The second was a way of mounting the motors. I went ahead and edited the design to include motor mounts.




This first design was not perfect. Are they ever? So onto design #2... I added the front panel and tweaked what needed tweaking.





The last things to design were the gears. In fact, I did not design them at all. I found a website with CAD files of different gears. I found ones that would work, scaled them, and ended up with this:




CAD

I present to you the final design: (Click here to download the CAD file)


The Wooden Pieces




The Acrylic Pieces




Assembly

With the design finalized, I went to school to cut it out on a laser cutter. It took 2 passes of the laser cutter to cut all the way through the wood. The gears came out better than I thought they would. Below are the parts freshly cut out and temporarily assembled.








Next I glued all the wood pieces together. The acrylic pieces are not glued in. They are simply sandwiched into the design. Now all the hardware is complete.







Tests

With the electronics partially complete, I did a quick scribble test. This program simply was etching away a section of the screen to reveal the inner workings of the etch-a-sketch.



Well the scribble test was a success, but I wanted to try something more interesting. At this time I was still waiting on the rest of the electronics (SD card shield, SD card, potentiometer, and a button). I decided I could still generate an image and save it in an array in the micro-controller’s program memory. So I started working on da Vinci’s code. Here is a photo I took while I was writing and tweaking the program:



Once I finished testing and tweaking the code, I finally was able to etch a low resolution Apple logo. Success!





It took some courage, but I erased the etch-a-sketch and tried to etch another image. This time I did the Adafruit logo, which is a flower.






Electronics

The mail finally arrived with the rest of my electronics. I received an Arduino microSD card Shield, potentiometer, knob, push button, and some cables.



I also ordered a 4GB microSD card ($6 at Walmart). This card will store a bunch of data files for etching images.



The prototyping area on the microSD card shield was the selling point to me. It allowed me to easily wire up all of the required connections. This included 8 digital outputs for the stepper motor controllers, a serial communication connection to the ezLCDuino, 1 digital input for the button, 1 analog input for the potentiometer, and of course necessary power distribution.




That concludes the build process. They grow up so fast!




Software

First let me talk about the computer software I wrote (click here to download the software). Below are some images you should have already seen:




Above are two different screen shots of the piece of software I wrote using the Processing language. This program takes an image, averages the pixels, displays a preview, and then generates a file. Ok that was a lot of stuff. Let me break it down.

Step 1 (“takes an image”): As you can see in the screen shot, there are quite a few different controls in the bottom left of the program. The upper most box is labeled “file name.” This is where the user simply types in the name of the image file they would like to load into the software. The image files must be in the Processing Sketch’s (sketch is just what they call a Processing program) folder to be loaded in, else there will be an error. The image will automatically be scaled to fit within the window, but there are user controls for scaling as well. The “scale factor” control allows the user to alter the scale of the image. There are numerator and denominator slide control bars. This is how the user sets the scale factor, which is in the form of a fraction. The program will not react to a set scale that is too big to display the image properly within the window.

Step 2 (“averages the pixels”): In order to etch the image on the etch-a-sketch it needs a resolution adjustment. Obviously an image with tons of pixels is simply impossible to display on an etch-a-sketch. This is not an HD T.V. we are talking about. So what the program does to lower the resolution is what I call “averaging the pixels.” There are two more controls I will bring your attention to, the “pixel size” and “average pixels” controls. These control the image averaging. The pixel size slide control bar is what sets the size of the averaging grid. You can see this red grid in the screen shots above. It is overlaid on the loaded image. The length of each side of the squares in the grid is equal to the pixels size set by the user. The smaller the pixel size, the tighter the grid, and the higher resolution the image is when averaged. The larger the pixel size... well you get the idea. The program will also automatically alter the image’s dimensions a little to fit it exactly within the grid. Simply setting the grid size does not average the image. The “average pixels” check box must be checked for the image to be averaged. When this is checked, the program takes all of the pixels in each square of the grid and averages their grey-scale value (i.e. all images are converted to shades of grey). It then display a square over the picture that represents this average grey-scale value, and you are presented with a lower resolution image.

Step 3 (“displays a preview”): The last control is the “Etch” button. When this is enabled, the program will virtually etch the image. There is a “virtual” etch-a-sketch on the right side of the software window. This virtual etch-a-sketch’s screen is almost exactly the same size of real one. The program takes the data from the averaged image and displays it as lines on the virtual etch-a-sketch. Different grey-scale values are created by varying the distance between each line. This generated preview and the actual etched image on da Vinci look very similar, so that is good. You wouldn’t want to etch an image, which takes hours, and not know what it is going to look like in the end would you? So the feature is very handy, but I actually put that feature in way before I built da Vinci simply to see how well the software worked. It is very common for me to write software for a project I have yet to start.

Step 4 (“generates a file”): Finally the last step is to generate a file. This is the whole reason the program was created, to extract useful data from an image that I could then read into da Vinci and etch. This file is saved in the Processing Sketch’s folder. The name of the file is the same name as the loaded image and the extension is .txt. The contents of the file includes the width of each column in pixels, the number of rows, the number of columns, and the etch width for each averaged grey-scale value. The etch width is the number of pixels between each line in the preview image. This file can then be put onto a microSD card, which is then inserted into da Vinci.


Now that we have data on a microSD card da Vinci’s Arduino program is ready to take over.

The Arduino program is pretty simple, but I will break it down into steps again.

Step 1: The user selects which file to etch. The user can navigate through the different file names using the potentiometer. The potentiometer’s analog value gets mapped to the number of files on the SD card. The file that corresponds with that number is displayed on the ezLCDuino (the ezLCDuino is a LCD with an Arduino backpack I made). The communication between the main Arduino micro-controller and the ezLCDuino is done over serial using Bill Porter’s EasyTransfer Library. When the user has selected the file they want etched they can hit the button to begin etching.

Step 2: This is the second and last step. The data of the chosen file on the microSD card is read in. The width of each column, the number of rows, and the number of columns first get put into variables. The width of each column is used to fit the image within the etch-a-sketch’s screen. The number of rows and columns are simply used to terminate for-loops. One by one, the etch width data for each index of the image is read in and etched. This etch width is originally in pixels, but is then scaled to stepper motor steps. After each row is etched the program returns the etch-a-sketch’s stylus to the left hand side before etching the next row.

General Comments: There were a lot of little things to figure out and add in the code. Most of it was compensation for backlash and slop. It would be hard to completely explain all of the nuances in the code. So I have simplified the concept a little in my explanation.