28
Dec 09

Make It Work

Cartesian_CoordinatesBack in July I built RoboSketch which to this day still gets more traffic than any other post on my blog. People seem to love it. Somehow the spammers have figured this out because it gets dozens of comments daily hawking Acai Berry diets, Colon Cleansing products and my favorite which is a site that sells the book “How To Get Pregnant.” But the dirty little secret is that aside from the demo video, I was never able to get the RoboSketch to draw anything without failing in one way or another.

We’re not sending anyone to the moon here, so failure is always an option. In fact, failure isn’t feared, it’s desired. The best way to learn is hands-on, doing things and making mistakes. When you make a mistake yourself, that knowledge is ingrained in you in a concrete tangible way and you’re better off for it. So when my Etch A Sketch device was having conniptions, I took note of the failure and followed the advice of that most wise sage Tim Gunn. Make it work, people.

Adult Education

The first source of problems took a while to identify. It turns out that when you change directions on an Etch A Sketch – say you’re twisting the vertical knob clockwise and then you turn it counter-clockwise to back up – there’s slop in the mechanism. A lot of slop. You need to turn the knob in the new direction quite a ways before the pen starts moving in the new direction. So when I would tell the stepper motor to move from position 50 to position 100 and back to 50 I wouldn’t end up back where I started. For the longest time I thought this was a problem with my software or my motors.

Another issue was that the Etch A Sketch would shift around and sometimes pop out of alignment so the gears that meshed between the motors and the Etch A Sketch knobs would slip. And even when they didn’t completely slip, the shifting was enough to make the straight lines look very wobbly.

It turns out these are classic problems common to all machines of this type. The problems are so common that they’ve been given names. The slop when reversing direction is called backlash and the problem of keeping a part in place is called workholding. I learned this while taking a class in metal milling and recognized the concepts as the same ones I was encountering. If I had first heard about them in class, I suspect the information would not have stayed with me for very long. But having experienced these issues first-hand, I understood the discussion and the strategies to solve the problems.

Version 2

For the new version I wanted to get rid of slop wherever I could, so I designed it to be as rigid as possible. I also kept the mechanical linkages as simple as possible, so no more gears – the stepper motors would connect directly to the Etch A Sketch axles. This would require more powerful motors with enough torque to drive the axles directly. I purchased a pair of powerful 12V steppers from eBay for $1, and the AdaFruit Motor Shield allows your to use an external power supply to deliver >5V to the motors. I picked up some shaft couplers from Jameco to connect the motors to the Etch A Sketch axle shafts.

steppers Coupler

Rather than the flimsy single-layer acrylic enclosure I used before, I designed a stack of 6 sheets of acrylic to mount the motors. The result was solid and heavy and wouldn’t twist and warp as the motors turned like the old design.

acrylic loose acrylic stacked

The motors were mounted to the backmost sheet of white acrylic and then the red acrylic sheets were placed over the motors and the whole thing was bolted together to form a solid enclosure.

Motor Mounting PlateMotors Mounted  Pre Motor Shield

There was a dedicated space for the Arduino and Motor Shield board and the design had channels for routing the wires from the servos to the circuit board.

pre badge

Say It Isn’t So

Functional though it may be, it was lacking something. When Tim Gunn says “Make it work” he’s looking for style and so we needed something to round out the aesthetics. Since the whole basis of the mechanism is Cartesian Coordinates, I grabbed a picture of Descartes, ran it through my Paper Pixels software and lasered it into some smoke-colored arylic badge for the front of the enclosure.

rene

I was struck by two things after pulling the finished part out of the Epilog laser cutter. First, the resolution of the cuts is amazing. The thinnest pieces are half a millimeter in width, or about 2 hundredths of an inch. The second was that the picture bore a striking resemblance to the guy with the mustache in Hall and Oates. It’s not as obvious at full resolution but the resemblance is still there:

reneandoates

Finishing Touches

I affixed the badge and then attached the Etch A Sketch to the device using the shaft couplers. The final piece of the construction was a blue acrylic piece that held the Etch A Sketch tight to the motors so the couplers didn’t come apart at the rubber spider junction and also supported the whole mechanism so it stands upright.

with badge

coupling detail

The finished product not only works well, but looks great just sitting there on the desk.

RoboSketch

The software running on the microcontroller is fairly simple. It implements a serial protocol that receives commands from the PC to move the pen and then keeps track of the pen position and implements a Bresenham line drawing algorithm to coordinate the two motors. The PC runs software that can read in SVG vector art files and then sends a stream of line segment commands to the RoboSketch. For bezier curves I subdivide the curves into line segments and send those so the Arduino doesn’t have to worry about anything more complex than a straight line.

The video below shows it drawing an SVG file with a vector drawing of a 3D surface. There’s nothing I can do about the backlash, so I do my best to account for it in software and the results are pretty accurate. The picture it’s drawing consists of 5,500 points and it gets through them all while keeping pretty solid registration.

 


26
Jul 09

Toys for Bots

IMG_3069 I was at a local toy store recently and saw a display of Etch A Sketch toys. They were marketed as “retro” toys – something you would buy to remind you of a bygone era and feel thankful for having the great fortune to live in a more sophisticated period of history. I had an Etch A Sketch when I was a kid and I can assure you that when I played with it I did so without any cool ironic detachment. For me, that thing was bad-ass.

Keep in mind, this was before video games. I realize they’re putting Nintendo NES systems on key chains and giving them away in cereal boxes these days, but even NES was way beyond the first video games that came after my Etch A Sketch days. Atari 2600, Fairchild Channel-F, even Pong had yet to appear. But Etch A Sketch did exist and it’s true full name is the Etch A Sketch Magic Screen. It’s easy to overlook, but it’s designed to look like a TV. TVs used to have knobs on them – one for channel and the other for volume – just like the Etch A Sketch. So basically it was a TV that I could control and put any image I could imagine onto.

As long as that image was a rectangle, that is. Yes, in theory you can draw just about any image on an Etch A Sketch. It’s the same logic that states that just about any digital logic circuit can be built from only NAND gates or that just about any algorithm can be expressed in the form of a Turing tape machine. It’s possible to demonstrate these assertions mathematically, but they’re impossible in all practical terms. Unless you have some sort of monastic devotion you’d never accomplish it. Yes, there are the exceptions that prove the rule but at least in my case all the pictures were decidedly boxy.

I may lack in knob-twiddling ability, but I can build robots and write software. So I bought a magic screen with the plan of making some less-boxy pictures using technology. It’s been done before, in fact several times. But I wanted to give it a go myself.

We control the horizontal. We control the verical.

I had recently purchased a pair of 5V stepper motors and a motor driver shield from the fine folks at adafruit industries which seemed perfect for spinning the knobs. The question was how to connect the steppers to the knobs. As it happens I had also just bought a gear set from American Science & Surplus on a lark and they fit perfectly on the Etch A Sketch shafts and the stepper shafts. So I simply needed a way to line up the steppers over the knob gears.

There are few problems you’ll encounter in life that can’t be resolved with the judicious application of a laser beam. I drew up a set of parts in Corel Draw and popped in to TechShop to cut them out of acrylic with their Epilog laser cutter.

I cut most of the parts out of clear acrylic except for the side guides which you can see in blue acrylic. The side guides hold the Etch A Sketch in place so it doesn’t move around laterally.

IMG_3059 IMG_3065 

The parts screwed together and the stepper motors mounted on the top acrylic shelf. My 3AM measurements the night before were pretty accurate and when the whole thing was put together the gears meshed with the Etch A Sketch pretty well.

IMG_3067 IMG_3073

The irony of the fact that I’m essentially building toys to play with toys is not completely lost on me. There is a practical application of a sort here, as the goal is to produce some art that I can hang on the wall. For those wondering, I’ve gotten pre-approval from my wife so long as it’s in the basement.

A simple matter of typing

With the hardware done, all that’s left is some software to drive it. I have a friend at work named Eric who describes writing software as “typing.” That’s funny as hell, because it knocks software “engineering” down to the level of ditch-digging which is closer to the mark than folks who haven’t visited the sausage factory realize. I have a few ideas to experiment with to reproduce photographs on the robosketch, but only had enough time to do a bit of typing last night. So for the maiden voyage I ran a test with some simple vector art. I can’t quote the cartesian coordinates of many polygons off the top of my head, so I found myself typing in code to draw the only shape I could think of – a square, ironically.

In an amazing stroke of luck, a few days later there was a cool post by the Evil Mad Scientist crew, (who appear to be lovely folks despite being both evil and mad) with a bunch of nice vector art. I grabbed one of their pictures and extracted the list of vector coordinates from it and fed them into my Arduino code that drives the steppers.

SymmetriSketch-13943_ACD_1 IMG_3073

The results are passable for my first try. When the steppers change direction the acrylic tends to shift around which produces error in the first part of the new vector being drawn. This is what causes the corners to look rounded rather than sharp. Additional stabilization or just biting the bullet and directly attaching the steppers to the shafts will solve that.

The software also decided to go insane when it ran off the end of the vector table so there’s some bonus scribbles. It’s clearly a work in progress, but for those curious you can see the Arduino source code.

 

Here’s a video of the robosketch in action: