Introduction: Etch-a-Sketch LOGO - EASiLOGO
What do you get when you cross a Turtle with an Etch-a-Sketch?
This is the first programming language designed specifically for the world famous toy from Ohio Arts - the Etch-a-Sketch. If you've never seen an Etch-a-Sketch, you owe it to yourself to go out and get one now. It's one of half a dozen essential toys in everyone's life - regardless of age. It's a simple design - you turn the knobs, and it draws on the screen. But the simplicity of the design doesn't mean that it's easy to draw on, in fact there are very few people who can make good art with the Etch-a-Sketch!
But instead of drawing on an Etch-a-Sketch by hand, we've built a system that lets you write a simple computer program to do the drawing for you! The programming is easy and uses the LOGO programming language that was designed to be used by 10-yr olds - hence the name, EASiLOGO!
Step 1: What Is an Etch-a-Sketch?
(Image courtesy of GeekDad on Wired)
The Etch-a-Sketch is a toy that was invented in 1955 by a French electrician, André Cassagnes. You use two knobs to move an internal stylus across a screen to scratch grey powder off the screen's under-surface. It's entirely mechanical technology - no electronics at all. Horizontal and vertical lines can be drawn easily but diagonals and curves take a lot of practice.
As a maker I suspect you may be more interested in the mechanics of the Etch-a-Sketch than the art it produces, so check out this teardown for the inside scoop. It's actually pretty cool how the axes are connected to the knobs and it's a technique that you might be able to use if you're building a homemade pen-plotter or a laser cutter etc, as Super Awesome Sylvia did with her watercolor bot...
By the way if you feel the urge to strip one down yourself, do it outdoors - the aluminium powder inside the device clings to everything!
Step 2: Turtle Graphics
(Image courtesy of http://www.classicacorn.freeuk.com/8bit_focus/logo/logo.html)
Turtle Graphics is a way of doing computer graphics that is based on a simple model that children can easily understand. Ask a child to stand in the middle of a room, walk forward ten paces, turn right, walk another ten steps, and keep repeating this until they get back to where they started. Explain after they've done this that they've paced out the shape of a square. Now tell them that you have a trained turtle, and if you tell the turtle to do what the child just did, the turtle will also pace out a square on the ground.
Now we pull out the robotic turtle and we tell it do do just that by typing commands on a keyboard. These turtle robots actually exist - they were invented in the early 70's and used with the programming language LOGO which was specifically designed by Marvin Minsky and Seymore Papert for teaching children.
(Seymore Papert was a teacher who proposed an educational philosophy called 'constructionism', which was basically encouraging kids to learn through making rather than passively absorbing other people's teachings. In particular he used programming as a learning tool to think and to reason out solutions to problems. He was very much the grandfather of the Maker Movement.)
So modern turtle graphics on a computer is just like the turtle robots that Papert used in the 70's - you tell a simulated turtle to walk and turn with simple commands like FORWARD 10 and RIGHT 90 and the turtle will draw a square on the computer screen. You can find regular LOGO systems on the web and also the really cool "Scratch" programming language uses the same ideas to draw lines. We're going to build something very similar to a turtle graphics system - but we're going to use an Etch-a-Sketch instead of a robotic turtle. Of course, we love robots, so naturally it's going to be a robotic Etch-a-Sketch :-) Now read on...
Step 3: Build an Etch-a-Sketch Robot
Have a good look around on Instructables (and elsewhere if you look via Google) - there are lots of people who have built computer-controlled etch-a-sketch systems. It's a great way to cut your teeth on learning how to build a CNC system - all you need are two stepper motors and a computer to send commands to it. In my case I'm currently using an Arduino to drive the stepper motors and a Windows portable to drive the Arduino over a USB serial port. I could just as easily have used a Raspberry Pi to do both jobs, but this was what I had handy. I'm also using the Adafruit stepper motor shield and their associated software to make the motors turn.
Not every project works first time, and I have to confess I tried quite a few different mechanisms for turning the Etch-a-Sketch knobs with a motor. Despite the knobs being slightly knurled, friction drive with a belt doesn't work. I tried a more high-tech timing-belt drive like the ones used in 3D printers but it wasn't very reliable either, likewise driving via gears was painful too. To cut a long story short I ended up discovering about metal drive shaft couplers which I used to directly connect the stepper shaft to the knob shaft. It works almost perfectly - there's virtually no slack or backlash introduced by the linkage. (Although there's internal backlash, but we'll come to that later)
The motors are held in place by a couple of brackets and the brackets are held steady by being screwed into a block of wood. Very simple hardware to build, anyone can do it - here are the parts you'll need:
- Stepper motors (2)
- Bracket set (2) (and a screwdriver)
- Couplers (2) (and a 2mm Allen key)
- Arduino and 12V power supply
- Stepper motor shield
I should warn you that I trashed two of these devices while developing the software - if you drive the knobs too far and move the stylus off the screen, you pretty much ruin the device for use with a computer ever again! By the time I bought my third Etch-a-Sketch I had added code to the driver to get it to halt the motors if the stylus approached too close to the edge of the screen. Other people have also implemented systems using a Big Red Switch that you can hit in an emergency to shut down immediately)
Step 4: Low-level Driver: GCODE
(Image courtesy of http://www.gcodemcode.com/gcode.htm)
The computer will need to send drawing commands to the Arduino. I considered using remote procedure calls, I thought about implementing Hewlett Packard Graphics Language (HPGL) as used in pen plotters, but in the end for fun I decided to use GCODE as my drawing protocol - GCODE is how laser cutters and 3D printers and many other CNC machines are driven, so it seemed like good experience to learn a bit about how it worked. I found an Arduino GCODE interpreter and modified it to suit my project. Mostly the mods were just to remove the Z-axis code that wasn't needed (you can't lift or lower the pen in an etch-a-sketch - when you move, it always draws a line) but the main modification was to remove some machine-dependent stepper-motor-driving code and replace it with portable calls to the Adafruit libraries.
I discovered during this process that the AccelStepper library isn't suitable for moves that have both an X and a Y component - instead of drawing a straight line you get something that starts off a bit curved. It's OK for horizontal or vertical moves but for diagonal moves you have to use a constant speed, or (as I ended up doing) calculate your own diagonal moves by breaking down a diagonal line into lots of 1-step horizontal and vertical moves.
Step 5: The LOGO Interpreter
In a mammoth 30-hr session over the weekend, we got the LOGO interpreter working and sending drawings to the Etch-a-Sketch!
The drawings looked pretty bad, but they were recognizable.
Step 6: Curse You Backlash!
An Etch-a-Sketch is not exactly a precision CNC device. However it is great for learning about backlash!
Backlash is what happens when you turn a knob one way, and then when you turn it back the other way, nothing happens at first until all the slack in the mechanical parts catches up and then whatever it is you're controlling starts moving back in the other direction. In the case of the Etch-a-Sketch, the knobs are connected to the stylus by something that looks remarkably like nylon fishing line (although in the old days they used wire which I think worked better). There's a good video of how the Etch-a-Sketch works on YouTube.
When backlash happens in a mechanical drawing system, lines don't join up when they should, squares become rectangles, and corners get rounded off.
You fix this by moving a certain fixed amount extra, any time you change direction on either the X or Y axis.
With the Etch-a-Sketch, every unit has to be calibrated differently, by hand.
Not a big deal really, and once it was done, it turned out some pretty nice drawings!
Step 7: Big Plans...
We hope to polish the software and make it robust, so that anyone can use it without needing a physical Etch-a-Sketch robot! The emulation of the computer-controlled Etch-a-Sketch on our web page is very accurate and we'll continue to work on it to make it look and perform even better. Programs that run on the web page will run just as nicely on the real hardware. If you can't build the hardware, you can do the human simulation we described in the introduction, by writing down the instructions on a piece of paper, and giving them to your kids to execute on a real Etch-a-Sketch toy by hand. It's a great way to learn to program, even without a computer!
You can try EASiLOGO in the Etch-a-Sketch emulator on our web page, at http://www.gtoal.com/easilogo/
(We've been trying to get in touch with the folks at Ohio Arts to pass the project over to them so it can be accessed via the official Etch-a-Sketch web page. If you're reading this, guys, check your emails! The software is Open Source and we're not asking for money - it's yours if you want it! We love your products, we'd be glad to help)
If you try EASiLOGO and need help, there's a general LOGO mailing list where Marcio and I hang out ... and the programming language is the same as Papert LOGO except that you can't do "pen up" and "pen down" and a few other device-dependent drawing commands.
After we've polished the software, we hope to work with educators in the LOGO community to put together a lesson plan that will make it fun for anyone to learn the basics of programming using the EASiLOGO web page and a regular Etch-a-Sketch. Until then, you should find attached to this step a short lesson plan that I wrote myself... it is targetted at a readership around the 10 or 11 yr old range, but when my wife proof-read it for me she said it was fine except she wasn't sure if it was intended for 10 yr olds or PhD students :-) Maybe I didn't quite hit the mark for age-appropriateness, or maybe PhD students are getting younger and younger nowadays :-)
The complete software suite (both the LOGO web system, and the arduino driver code) has been uploaded to GitHub.
Step 8: Meet the Makers!
I'm putting this up on Instructables the same day as we're demonstrating the system at the McAllen Mini Maker Faire 2014. Here's our "Meet the Makers" video we produced for the Faire if you want to see the sort of person who builds stuff like this...
Now go have fun with EASiLOGO!
Graham & Marcio
We have a be nice policy.
Please be positive and constructive.