Monday, February 20, 2012

Dymaxion Auto-Matic Buckminster Fuller

This ought to lay to rest the persistent ugly rumours that everything I make is somehow useful.


Presenting the Dymaxion Auto-Matic Buckminster Fuller. It's a retro-futuristic black and white screen mounted into a 1950s (or so) radio chassis, which generates and displays text that American luminary R. Buckminster Fuller might have said if he were a piece of software.

The Basic Ingredients

The genesis of this project is difficult to explain. In thrift stores or back alleys or Free Geek I'll come across something that catches my eye, take it home, and let it incubate until some other piece of junk marches into my brain and sets up shop alongside. This might be months or years later. As you can probably imagine, this makes my apartment a dangerous place to walk around with the lights off.


For this project: the first piece I got was the radio. I purchased it dead several years ago, gutted it, and threw it into a closet. It was briefly part of an abortive attempt to make yet another mp3 player, then spent another year in the closet.

What really kicked this project into gear was the arrival of Coleman's worst piece of camping equipment ever. I found it at Popeye's Sailors Exchange -- a venerable marine junk shop in North Vancouver. (It appears that they used to have a website at www.popeyesailorsexchange.com but have since moved it to www.popeyescatalogshop.com -- see if you can figure out why.)

Coleman's story is a little bit like that of Radio Shack. Coleman used to make half-decent camping gear -- stoves, tents, etc. -- as Radio Shack used to be a reputable electronics shop. In the 1990s each declined sharply. Radio Shack turned from the proud Tandy dealer and HAM radio operator favourite into the awful plastic-toy wasteland of recent memory. Coleman got into weird gimmicky camping gear that was generally fine as long as you didn't take it outside or get it wet. When I saw this at Popeye's I knew I was looking at Coleman's Edsel moment.


This is a three-mode torch, an AM/FM radio, an emergency weather radio, and a black and white television. Around the back it has two additional fluorescent tubes that can be positioned like slug antennae. It contains a battery pack and can also be powered from a cigarette lighter or domestic power. Witness the convenient shoulder strap allowing the fetching model to hike over hill and dale without leaving the comforts of civilization behind. I hope that one day a horror movie will be filmed that features this monstrosity in the obligatory unreliable-flashlight scene.

This television screen roughly matched the dimensions of the radio chassis' tuning gauge. At this point I had enough to start working.

Mounting the Screen

I took the television monstrosity home and gutted it. Here is what I saved:



...and here is what I chucked...


In order to get the screen to fit the radio chassis, I had to do some drilling of some of the internal chassis structure:


Notice the paperclips positioned in three corners of the cutaway. I epoxied the paperclips down, then epoxied some cotton fiber over top of the paperclips to give them additional strength where they met the chassis. This allowed me to mount the CRT securely to the chassis without having to drill holes through the exterior. I used this technique numerous times in this project with a lot of success. Here it is with the CRT in:


I tensioned the corners of the CRT against the front of the chassis with twist ties. Hey, it works, and it's pretty solid. Here it is from the front:


To get the circuit board to fit without sticking too far out the back, I had to cut the tops off the knobs:


I also had to extend some of the wires to the CRT itself:


So now I have a pretty cool-looking black and white television with a few quirks. First, it has no video input, so I'm limited to analog broadcasts (which I believe are going to cease even for CBC sometime this year). Second -- oh yeah -- everything is going to show up sideways, since I had to mount the screen on its side to get the proper fit.

Arduino Work


The project so far has a definite style going for it -- if I'd landed a fancy colour LCD display it would've been a lot easier to mount and nicer to watch, but it would have looked incongruous in the old radio chassis. I wanted to stick with the weird retro feeling the ensemble had so far. It had a few characters from the pantheon of 20th century technology -- television and radio -- and I thought it would be interesting to add a computer to the mix. But to keep the aesthetic I wanted something with a really vintage look to it.

I did some research to it and found that the Arduino platform has a video output library. If you haven't come across Arduino, I'll try to explain briefly: it's the greatest success story so far of the fledgling open hardware movement. It's a small, inexpensive circuit board with a very simple computer and an assortment of input/output tools to allow it to communicate with pretty much anything -- sensors, switches, motors, etc. It's simple enough to use that it's rapidly become the most popular platform for tinkering with embedded systems. You no longer need to have a lot of electronics experience or resources at your disposal. For example, to get rudimentary video output from an Arduino, all you need is two resistors. Here's the circuit:

http://code.google.com/p/arduino-tvout/
Here's what the video output looks like:


It's chunky, it's black and white, it's like stepping 40 years back into the history of computing. Perfect! I soldered a couple of resistors together and wired up an RCA jack:


Incidentally, a word on video control circuitry. Any modern computer has quite a bit of dedicated video hardware. The reason this two-resistor circuit is possible is because the Arduino's CPU, an Atmel ATmega168 chip at 16MHz, has to do all the work.


A quick word on how televisions like this one work. They draw each frame of the moving image on the screen the same way we write on a page -- from left to right for each line, gradually moving down the page. At the bottom, it jumps back up to the top left corner and starts again with the next frame. Instead of a pen, the tube has an electron gun at the back that shoots a stream of electrons through a magnetic field which aims towards a target on the surface of the screen, where they hit a coating of phosphors, causing them to illuminate. The screen is redrawn totally 60 times a second, with each of those 60 frames involving around 480 individual horizontal lines. That's a lot of waving the pen around. Luckily the Atmel chip is able to spare enough brain space to still manage a few other things while it's not actively drawing.


As I mentioned before, the television was only designed to pick up signals from broadcast stations. To get a composite video signal into it, I picked up a modulator from Craigslist ($5); this basically acts like a miniature TV transmitter to get a signal into a TV that can't take it directly from the wire. Think of it like one of those little FM transmitters used to get music into a car stereo. Here's how it looks, shelled of its plastic case:


I hooked it all together and ran the TVout demo code on my Arduino -- still sideways:




You can see there's a tremendous amount of distortion due to the modulator. This didn't bother me much at first because it fit in with the retro feel.


So now -- what to do with it?


Markov Models


I've been tinkering occasionally with computer-generated text. It's fun -- you give one of these algorithms a body of text to analyze, then ask it to generate more text, and off it goes blathering in a way that looks plausible at a glance but is totally incomprehensible if you try to read it. I've generated new Nickelback songs, for example, that are generally better (and dirtier) than the originals:

i finally know just what you know that if it goes right
you'll never find out
you can tamper with the pretty pink thong
time to put the brakes on, doesn't matter when you never see
Since I'm also due to become a father in a few months (!!!) I also tried generating some new baby names: gender mishmashes like Curtenay, Briobby, Kathony, and Gabia all the way up to tongue-twisters like Jeanetribernacionian, Darodriandsa, and the exquisite Shondrendacillexantalijamundis. (I wasn't able to secure consensus on any of these.)


The way this algorithm works is by taking a look at the sequences of symbols with a certain horizon in mind -- let's say each symbol is a word (as opposed to a letter, as you would use to generate baby names); let's use a horizon of two words. If the algorithm has already generated the words "This is", it then looks in the corpus of text it's been given to see what might follow; then it rolls the dice to choose amongst the possibilities. There's a high likelihood that it'll generate "the" next as that sequence probably appears frequently. The horizon now becomes "is the" and the algorithm continues along the same lines.


Enter Buckminster Fuller


Buckminster Fuller used to be a household name but his celebrity is probably much diminished since his death in 1983, or more likely, since his prime in the mid-20th century. He is probably best known for the term "Spaceship Earth" or the geodesic dome. He was born in 1895 and witnessed the popularization of the telephone and radio, the invention of flight, television, and the computer; he lived through two world wars, and bore witness to the dawning of the nuclear era. He was an inventor and futurist who wrote and spoke in a hyperbolic, stylized manner using a lot of language of his own devising. To pick a sentence that typifies this:

We find no record as yet of man having successfully defined the universe -- scientifically and comprehensively -- to include the nonsimultaneous and only partially overlapping, micro-macro, always and everywhere transforming, physical and metaphysical, omni-complementary but nonidentical events.
(From "Operating Manual For Spaceship Earth", available at http://www.futurehi.net/docs/OperatingManual.html.)

Riiiiiiiight. (I mock with the greatest respect. His would've been a marvelous brain to pick.)

This corpus suits algorithmic generation well in that his computer-generated counterpart is only occasionally more inscrutable than the real McCoy. Compare:
Possession is becoming progressively burdensome and wasteful and therefore they ought to be synchronizably-tuneable within the vast ranges of the physical and metaphysical know-how on the land for repairs.
Hmm.

More Arduino Work

Here I ran into a limitation of the Arduino platform: it doesn't have a lot of space for storage. For the program and the data it requires, there's around 16KB of space. The original Buckminster Fuller text I wanted to use was about ten times that much, so I needed some other way to store data. Flash storage is cheap and plentiful, and once again the Arduino forums came to the rescue -- one more simple circuit, this time to interact with an SD flash chip (a sort that's commonly used in digital cameras):

SD interface from http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1206874649
I zipped down to Main Electronics for the resistors and a card-edge connector, which can be hacked into a cheap socket for the SD chip. Here's the chip and the card-edge connector:


Cut it down to size and jam the SD card in, and it's a serviceable (if slightly finicky and not at all elegant) socket:


Here is the Arduino with both the video and SD interfaces assembled:


With all of this put together, I started trying to write software for the Arduino. Here I hit a second hurdle -- I couldn't get the SD card interface and the TVout library to coexist happily. Being pretty new to the Arduino platform, I tried asking for help -- see my plaintive post on the subject -- and then eventually figured out a way to continue -- see my own follow-up. (I mention this as testimony that I'm not the kind of tinkerer that farts rainbows and never makes a mistake. Every completed project is a particular exit from a maze of false starts, dead ends, and pulled hair. But in editing the story of the "making of" down to size it often ends up looking like a well-followed plan. That is far from the case.)

The work-around I ended up using was to avoid using some of the more powerful features of the SD library, as they cost too much RAM. Once I started using the SD card directly as a block device, instead of loading a file from a FAT filesystem, I could cut down the RAM usage and the TVout library came back to life.

The snow and interference I was seeing on the screen was starting to get to me. If I moved the project for any reason -- for example, if I should want to eat a meal on my kitchen table like a real human being -- I would later have to find the channel again, which would sometimes take a lot of effort nudging the tiny tuning capacitor with cramping fingers. Eventually I lost it entirely and got to thinking that there must be some way to bypass the modulator and the TV's tuner and feed the composite signal directly into the television.

Googling around I found this video:

This refers to the KA-2915 chip that is used in a lot of televisions. Mine didn't have the same chip; mine was a CD5151CP. I was able to find a data sheet for it -- not very helpful, as you'll find if you follow the link. The breakthrough was finding this PDF with the central chip labeled "CD5151 (2915)" -- implying that the CD5151CP and KA-2915 might be interchangeable, compatible parts. It was a risk I was willing to take, so I cut the "Video Out" trace on the motherboard and patched the Arduino's video signal in instead.

Success! The improvement was spectacular.


As you can see, I also began working on rotating the output of the TVout library so that I could stop craning my neck while I was coding. In the above picture, the text is still being written top to bottom but I've successfully rotated each letter in the font by writing a quick PHP script to read the source code and dump out a modified, rotated source. (I write PHP for my day job, so it's my current utility language of choice.)

Markov Chain Implementation

The major pieces are now all assembled and it's time to write some code.

If I was generating text using a Markov algorithm on my desktop, I'd write a quick PHP script. It would be a couple of dozen lines of code slapped together without much thought, and it would work just fine. That approach isn't possible for this kind of thing on the Arduino.

Writing code for the Arduino is very much a leap 30 years back to the days when resources (storage, CPU cycles, RAM) weren't basically unlimited for all but a few tasks. You had to write code carefully.

With an SD chip attached to an Arduino, storage space isn't a problem -- 2GB is positively oceanic for a tin cup of a chip like an Arduino. However, speed is a limitation, both for the chip and the SD interface, and RAM is definitely a limitation at 1024 bytes (and that much already proving a limit for the SD and TVout libraries alone).

It was clear that I would have to break the Markov algorithm in half -- as much as possible of the crunching would happen on my desktop, which could store some helpful indexes and tables on the SD card. Then the Arduino could use those to do the rest.

I took a couple of cracks at this. The first worked but was glacially slow due to all the time the Arduino chip had to spend sifting through the SD card for the piece of data it was looking for.

After some determined forehead-wrinkling I found an ideal solution. For each generated word, the new algorithm needs to read 28 bytes from the SD chip, which gives it enough information to know exactly where to go for the next 28 bytes. The memory usage is likewise fixed at 28 bytes. That's about the lowest-overhead Markov chain implementation I can imagine. It makes use of 3 different tables, which together take up 265KB on the SD card. That's about .01% of the space available on the SD card -- which just goes to show how cheap flash memory is nowadays.

Final Cosmetics

All that's left is to mount the rest of the guts and work on the aesthetics a little more. The Arduino was mounted to the ceiling of the chassis with more of the paperclip-and-epoxy technique I've become so fond of:


And if you'll excuse a slightly blurry photograph, here is how it looks with everything installed:


The Arduino is a little cock-eyed, but it's firmly installed; I just didn't bother shortening some of the paperclip mounts to level it off.

As the back of the CRT is deeper than the cabinet, I had to cut a hole in the back panel. I took a cap from a can of shaving cream, spraypainted it black, and epoxied yet another paperclip into it:


I'm particularly happy with this detail -- old televisions used to have exactly the same little cup. Here's how the back of the device looks, fully assembled:


Just like an old-school television!

Here's how it looks in operation.


This is one of my favourite projects so far because it's fully realized and consistent. I make these projects mostly with the things I have lying around and they often come out looking somewhat mutant. I'm also very good at getting 80% of the way there and losing interest. The only thing I have planned for this -- well, besides maybe a few minor tweaks -- is a silk-screened diagram and model number on the back.

Thanks for reading! If anyone's interested I can post source code. [Addendum: here's the source code in a separate post.]

14 comments:

  1. Nicely done :)

    I have an '42 radio running mpd but this tops it off :)

    ReplyDelete
  2. blogger_author, got pics or a write-up? That sounds like my kind of project.

    ReplyDelete
  3. Yeah, I'd love to see the source code for this. Your project is quite inspiring! I've messed with the TVOut lib before but didn't have a good reason to make anything from it. I've got some ideas now...

    ReplyDelete
  4. I'd enjoy seeing the code too. This is such a delightful project! Just the right combination of history, whimsy, and sturdy engineering that I try to have in my own projects. I'm definitely nicking the paperclip trick :)

    Also, any tips or comments on working with Bakelite? That stuff can do some unexpected things when one is accustomed to modern plastics...

    ReplyDelete
  5. JT and Jake, thanks -- I've just posted the source code. (See the end of the blog entry for the link.)

    Jake, you've got some pretty impressive projects. Steampunk is a terribly abused idea these days but I do particularly like the projects that go beyond the aesthetic and dig into the technologies -- the steam-powered mechanical television is a particularly good one. I hope it's still occupying an active corner of your shop.

    I haven't worked much with Bakelite, and if I did I would probably rage around with power tools until stopped by injury, destruction of materials, or success. Careful craftsmanship is not my strong suit. This particular chassis wasn't Bakelite but it was some strange kind of early plastic, luckily fairly forgiving.

    ReplyDelete
    Replies
    1. "Steampunk is a terribly abused idea these days" Couldn't agree with you more. Tasteful project you have here. thanks for sharing.

      Delete
  6. Really nice. The only thing I'd add is an occasional brief fade-in-fade-out of white noise to increase the sensation of other worldliness =)

    ReplyDelete
    Replies
    1. Not a bad idea! It would be very easy to mix a little bit of snow in from the tuner; I was also thinking of coding it up to beep the text simultaneously in Morse Code.

      Delete
  7. Very Nice!
    You could scrap the rotation algorithm alltogether and maybe simply swap the x and y outputs in the TVout Library instead, so text is fed out sideways(therefore correctly for the rotated television).

    ReplyDelete
  8. Hey R Reddig, I looked into that but it's not so simple; sprite blitting isn't done a pixel at a time. There's a lot of performance to be gained by keeping things this way. The best suggestion was the one at Hackaday -- simply rotate the coils on the back of the TV tube 90 degrees. Wish I'd thought of that...

    ReplyDelete
  9. Well done Sir... On a whim, I picked up a Magnavox BH3907 tiny B&W for like $4. I was hoping to use it for my Raspberry Pi, but had no true sense of what todo. then I found your post and it had everything. This is awesome!! Even the 5th pin trick worked for the AN5151N IC.

    ReplyDelete
  10. John, great! Write it up and send me a link. I take no credit for that AN5151N trick -- the Youtube video linked in the article gets full credit.

    ReplyDelete
    Replies
    1. Here it is:
      http://boxedlunches.tumblr.com
      Maybe not Tumblr next time?...
      I'm still working on cleaning the signal, but this is amazing to me; thanks again

      Delete

Note: Only a member of this blog may post a comment.