Toys for Bots

Friday, 24 July 2022 00:22 by yergacheffe

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.

 

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.

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.

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:

Tags:   , ,
Categories:   arduino | atoms | electrons
Actions:   E-mail | Permalink | Comments (4) | Comment RSSRSS comment feed

Octobrite Picture Frame

Sunday, 19 July 2022 00:58 by yergacheffe

daft-punk I’m obsessed with LEDs. If I go to Halted to pick up 30 cents worth of capacitors, I will leave with 10 bucks worth of LEDs. When I first started learning about Arduino a few months back, most of my project ideas centered around LEDs. I imagined building my own Daft Punk helmet or a video wall made of LEDs.

That’s the best part of getting a new hobby – those first few weeks when everything is pure possibility and you have no idea how hard anything is. Maybe you recently decided to get into shape and have started exercising, so you read about Tabata Intervals or 20-rep squats and say to yourself “That sounds fun!” Naiveté like this tends not to last very long – doing anything that’s truly impressive requires hard work and this applies to LEDs just the same as it applies to squats.

The first roadblock in the way of my imagined LED projects was just how many of the damn things you need to do anything remotely interesting. Most of my ideas contemplate using LEDs as pixels, so to even draw a single character you need at least a 5×5 matrix or 25 LEDs. And of course you may as well multiply that by 3 because it’s gotta be RGB. But wait a minute…the Arduino microcontroller I’m using only has 12 discretely controlled digital outputs. How is this going to work exactly? After a bit more studying I’m up to speed on various types of multiplexing that push a lot of complexity into the software. You know, if I wanted to write a bunch of software to compensate for limited embedded hardware I could just drive in to work. It’s 8 reps into the 20-rep squat routine and reality is starting to set in.

That’s when I discovered macetech.com. They make specialized LEDs that are addressable and just generally full of awesomeness. The flagship is the ShiftBrite module which is a RGB LED that you can string together and control with a serial protocol that only requires a few pins. Its 10 bits of red, green and blue theoretically give you a gazillion potential colors. The smarts are in the LED, so the software stays simple – it’s the perfect solution. “But it’s expensive” I hear you cry. Yes, it costs more. If that’s an issue, I suggest you go back to scotch-taping your grandma’s hearing-aid batteries to 9 cent red LED throwies with the rest of the kids from your dorm. ShiftBrites are something entirely different – these things are practically sentient. To paraphrase Ferris Bueller, “I highly recommend them, if you have the means.”

octobrite_LRG

At Maker Faire this year, the macetech.com folks were showing off their newest product – the Octobrite. It’s sort of like 8 ShiftBrites stuck together on a board. Each is an individually addressable RGB LED controlled via a serial protocol, although the protocol is a bit different from the ShiftBrites. The compact form factor was perfect for a specific project I had in mind, which was an edge-lit picture etched into clear acrylic.

Etching The Picture

halftone-reverseThe idea is to illuminate a piece of clear acrylic from the edge and etch the acrylic so that the light reflects forward showing the image. I planned to use the Epilog Laser Cutter at Techshop to etch the image into the acrylic. Since the light entering from the LEDs is the same intensity for all areas of the image, we need some means of getting multiple gradations of brightness. I’ve previously described methods for turning photos into half-tone images and that’s what I did here as well. I took a photo and turned it into a monochrome bitmap using a 45-degree linear halftone.

One important difference in this case is that we want to etch the acrylic where we want light to shine. The laser cutter acts like a printer, and etches wherever there are dark pixels in the halftone image. So dark pixels in the image equates to light shining in the final product, which means I needed to invert the colors in the halftone which is why the picture looks spooky.

Doing anything with the laser cutter starts with finding the magic combination of speed, power and resolution that will give the best results with the material you’re etching. After a few test runs I found settings that gave me reasonable results.

Building The Hardware

I used an Ikea Ribba frame to house the picture. They come in a variety of sizes, but I really like the square ones as they are quite deep and allow you to mount your picture all the way back for a shadow-box like effect. Since I needed to squeeze in electronics, LEDs and a 3mm thick piece of acrylic this was useful.

IMG_2978 IMG_2979

I used a Modern Device RBBB Arduino-compatible microcontroller board for this project, as it’s super-small and fit perfectly beneath the Octobrite in the frame. The Octobrite wants 3.3v for the LEDs but the RBBB had a 5v regulator so you can see I stuck a separate 3.3v regulator on there to power the LEDs.

I used a Dremel tool to cut out a space on the bottom of the frame to house the Octobrite. I hot-glued it into place so that it would be roughly in the middle of the frame. The Ribba frame comes with a spacer insert that I mounted the etched acrylic into with some more Dremel and hot-glue work. I was careful to make certain the exposed edge of the acrylic lined up directly over the LEDs.

final-assembly

Through experimentation I discovered that the edge-lit acrylic is brighter on the smooth side, rather than the etched side. So I mounted the smooth side forward in the frame. Also, the light looks best contrasted against a dark background so I cut a piece of black construction paper and mounted it behind the acrylic. Putting everything together and closing up the frame was the last bit of the physical construction.

Software Light Show

IMG_2999 The final bit was to get the LEDs to do something interesting. The RBBB has a programming header exposed on it so I can update the software using my handy adafruit FTDI cable. As tempting as it was to do something complicated, I discovered that a few subtle fades through some colors looked the best.

They aren’t kidding about the “brite” part – I’m driving the LEDs at about 5% max current and it’s plenty bright. The board and voltage regulator stay nice and cool at this level and it gives enough light that the picture is clearly visible but not overwhelming.

I’ve published the Arduino source code for folks who’d like to adapt it for their use. You can edit the color table section near the top to modify the animation.

Here’s a video of the final result running. The lighting changes confused my video camera so the exposure isn’t quite right. It looks brighter and the animation is smoother in real life, but this gives an idea of how it came out.

 

Tags:   , , ,
Categories:   arduino | atoms | electrons
Actions:   E-mail | Permalink | Comments (2) | Comment RSSRSS comment feed

The Accidental Buddhist

Friday, 17 July 2022 00:55 by yergacheffe

I should probably start by saying I’m not an expert in Buddhist practices or those of just about any other religion. The sum total of my knowledge in this area was picked up from Chinese restaurants, re-runs of Kung Fu and the occasional PBS documentary. Somehow amidst the Honey Walnut Prawns and pledge drives I’ve become aware of an exercise practiced by Buddhist monks that I find fascinating.

Tibetan Sand Painting is an ancient art where monks creating beautiful and exquisitely detailed pieces of artwork with colored sand. It’s a labor-intensive process that can take days to complete, and the results are amazing. But when the art is completed they simply brush the sand away destroying the image. It’s a metaphor for the fleeting nature of life. That’s always seemed intriguing to me – creating something just to destroy it. Now I’m not sure if this next part is true or not, but I recall hearing that they destroy the artwork the instant it is completed. There’s no sitting around gazing upon their work in awe and high-fiving each other. The point of the creation is the destruction and nothing else. So the logical thing to do upon its completion is to immediately trash it. It’s religious meditation as punk rock. Maybe that’s why this idea is appealing to me.

This practice is appealing to me in theory, that is. There are a lot of things I like conceptually but really it’s the idea I like and not the doing. Flying in an F-16, for example, is an incredibly attractive thing that I hope I’m never rich enough to actually do because apparently every non-pilot who has done it has hated the experience. I can appreciate things that others do without actually doing them myself. I don’t actually need to be destitute and living on a diet of White Russians and bowling alley nachos, because The Dude is out there takin’ ‘er easy for all of us. Similarly, I don’t need to destroy my handiwork because The Monks are out there reminding us all of how fragile our existence is while I watch them on my flat-screen TV from the comfort of my couch.

45 Watts of Enlightenment

These thoughts were far from my mind as I started my cutting job on the Epilog Laser at Techshop. It was my first test of my laser-cut paper halftoning technique and I was cutting out a photograph from some cardstock. I created a linear halftone that consisted of a bunch of parallel lines where the thickness of the line varied according to the darkness of the image. Here is a close-up of the vector image I was cutting – if you squint or back up across the room you can see that it’s a pretty good effect.

It’s quite an intricate design that needs to be cut, but fortunately the laser cutter is doing all the work. Several minutes later the Epilog beeped indicating the job was finished and I pulled out the finished work.

Have you figured out where the story is going yet?

I picked up the piece of cut cardstock and for a brief fraction of a second the image of the photograph hung in mid-air before collapsing into a pile of confetti. I immediately recognized my error – each diagonal line was completely separate and thus had nothing to hold them together. I had turned the Epilog into a $30,000 paper shredder. As the pieces of paper fluttered to the floor I was reminded of the impermanence of existence and felt an overwhelming craving for Mongolian Beef. But lunch and enlightenment would have to wait, because I needed to finish my project.

I decided to try a fairly simple fix. In CorelDraw I created a rectangle that was as tall as my image and .02 inches wide. I then duplicated it several times so I had a series of vertical bars and then used the Weld command to join these bars to my image. Finally I trimmed the edges so there weren’t any bars poking out past the edge of the photo. The result looked something like this:

The results came out far better than I expected. The vertical lines were thin enough to not distract overly from the image, but were substantial enough to hold the paper together very well.

 

Lesson Re-Learned

It’s not like you need an advanced degree in topology to avoid a mistake like this. Most of us learned these principles in Kindergarten while cutting shapes from construction paper. It’s obvious in hindsight that the laws of physics apply to a laser cutter just as much as they apply to blunt scissors. But making the mistake is the best way I know to assure you never make it again.

Tags:   ,
Categories:   atoms
Actions:   E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Pictures From Paper

Wednesday, 15 July 2022 15:05 by yergacheffe

One of my favorite toys at Techshop is the Epilog laser cutter. It can cut and etch at resolutions up to 1200dpi. It can cut through things like paper, cardboard, acrylic and thin wood as well as etching into those materials, metal and even food.

Lately I’ve been experimenting with creating pictures by cutting pieces out of colored card stock and stacking them up. The way to think about it is that each layer of paper gives you a single color – it’s like a 1-bit monochrome bitmap that’s either the color of the paper or transparent showing what’s behind it. Newspaper printers figured out ages ago how to deal with a similar set of constraints – a single ink color, but high resolution of ink placement – and approximate multiple shades of color using a technique called half-toning. Here’s how I adapted this technique for paper-cut images.

 

My first test was to see how I could approximate a gradient fill. I started by creating a jpeg image containing a simple black-to-white radial fill (left). Then in my paint program I converted the grayscale image to a monochrome black-and-white image. When you do this in CorelPaint it gives a variety of options on how to do the conversion. One of them is creating a half-tone image, which is what I used. I created a halftone using squares (dots are the ones you see in newspapers) at a 45 degree angle and a very low resolution of 7 lines per inch. The result is the picture on the right.

Now I needed to turn this image into vector outlines so the laser cutter can deal with it. I imported the bitmap into CorelDraw and used the bitmap tracing feature to trace it in line-art mode. Corel’s tracing is fairly flexible and can attempt to trace multi-colored images by creating vector shapes in different colors. Sometimes even if you feed it a simple picture, things like anti-aliasing artifacts can trick it into using a bunch of colors which I didn’t want. Using line art tracing settings gave me a shape containing about 1500 little vector polygons that approximated the half-tone bitmap. I gave the shape an empty fill and hairline outline which tells the laser cutter to perform a cut of the outline rather than a raster-scan etch. The result looks like the image below.

It turns out the hardest part of the project was getting time on the laser cutter. My schedule has been very busy and between travel and working evenings and weekends I’ve only had a few chances to get to Techshop recently. The two laser cutters are very popular so it was almost 2 weeks before I had a chance to try it out. I cut at 600dpi, 100% speed and medium-low power which gave good speed and minimal charring. They call it a cutter, but what it’s doing is burning the paper, so too high a power or too slow a speed will end up with visible burn marks on the paper. A fire in the machine is a possibility as well and before they let you use the cutter you have to take a safety class where they force you to deal with a fire, which is not nearly as exciting as it sounds but still awesome.

I cut it out of dark brown card stock and then placed it on top of a background of red construction paper . The result is a radial ramp from red to brown that looks pretty good. I could have made the squares a lot smaller, but wanted them to be fairly big and obvious. Also, the file took 10 minutes to cut as it is. With a lot more polygons it would have increased the cutting time significantly.

You’ll notice that in the middle the halftone squares got so close they ended up touching and it cut the entire middle out. I didn’t worry about it because this was going to be the background for a picture and the middle would end up being covered. The full finished picture was a picture of a tea drink my daughter likes which you can see below. The additional layers are glued on top of plastic and acrylic spacers to give the whole image depth and the upper layers actually cast shadows on the lower ones.

Tags:   ,
Categories:   atoms | electrons
Actions:   E-mail | Permalink | Comments (2) | Comment RSSRSS comment feed