Evil Mad Scientist
July Linkdump
- Archives of The Amateur Scientist (from Scientific American), brought to you by Bill Beaty
- LiquidMac
- Cat Herder game.
- The Tetris Wiki has a surprising amount of interesting content.
- Klein bottle!
- Otterpops vs. Fla-Vor-Ice... in which a shocking secret is reveal'd!
- We love these Science Shirts
- Electric Field Toy
- Malevoz Rolling ball clock
- The Wurst rug
- Matrix multiplication really is beautiful.
- Godzilla makes fractal cookies.
- Many Different Dice
- Another dicebag
- Paper Rulers to print out and enjoy. (See also: note about numberless rulers.)
- "Who *doesn't* need a jar of eyeballs?!"
- CNC PBJ!
Resurrecting Tennis for Two, a video game from 1958
In the year 1958-- fourteen years before the 1972 debut of Pong-- a physicist named William Higinbotham demonstrated a remarkable video game called Tennis for Two.
Higinbotham, head of the Instrumentation Division at Brookhaven National Laboratory, designed his game as an exhibit to improve what was an otherwise lackluster visitors' day at the lab. Tennis for Two presented a tennis court-- shown from the side-- on an oscilloscope screen, where handheld controllers allowed the two players to toss the ball to each other. Each controller had two controls: a button and a knob. With the button, you could hit the ball at any time of your choosing when it was on your side of the net, and with the knob you could choose the angle at which the ball was hit.
The game was based on the best contemporary technology: analog electronic computers built out of op-amps, relays, and the occasional transistor. It took Higinbotham and his technicians several weeks to design and build the game. Of course, some things have changed over the last 50 years. Using convenient modern electronics, we have designed a functional and playable replica of the original that can be put together by a hobbyist in a couple of evenings. You can watch the video of our recreation on YouTube or embedded here:
So, the next question you might ask is, "How do you build this?" And, if that is in fact what you're asking right now, you're in the right place. The quick answer is, "with an oscilloscope, an AVR microcontroller, and a digital to analog converter." Ready to get going?
Before we start, let's be clear that this is not a tutorial in how to build an oscilloscope. Tennis for Two is supposed to display on a 'scope, so beg, borrow, or buy one if you don't have one handy. Older low-end analog scopes like mine (a Hameg!) usually go for $50-$150, and if nothing else, you can always make a Scope Clock out of it later.
There are three parts to the electronics that we're building. First, there is the AVR microcontroller-- the brains of the outfit. The specific variety that we're using is the ATmega168, the same chip used in (for example) the Arduino platform. Secondly, there are two handheld controllers that connect to the ATmega168 microcontroller. Each handheld controller has a knob and a button. Third, there is the digital to analog converter that takes the output from the AVR and uses it to drive the scope.
First, let's look at the handheld controllers:
There two controllers are identical little project boxes that each have the button and knob, as well as a cable going back to the other electronics. The controllers themselves are built from 3x2x1" plastic project boxes with aluminum lids, e.g., Philmore #PB140 or Radio Shack #270-1801. Let's take a peek inside.
Inside each controller we have a 10k single-turn pot (Jameco #286206) and pushbutton (Jameco #26623). The knob on the pot is a fancy machined aluminum type for extra snazz. (Jameco #138482). The pot is used to vary an output voltage (that controls the firing angle) between 0 and 4.5 V, and the button, when pressed, pulls one of the inputs from 4.5 V down to 0V. (We use an external 10k "pull-up" on the pin to make that happen.) The circuit diagram for one of the controllers looks like this:
To simplify the wiring, we used some old Cat-5 (ethernet) cable as the cables for the controllers. Inside Cat-5 cable are four color-coded twisted pairs: orange, green, blue, brown. For each of these, we stripped and twisted the two conductors together to make four effective (but thicker) color-coded wires. We used orange (+4.5 V) and green (ground) for power, and the other two for signals: brown for the analog knob output and blue for the button switch output.
Next, let's look at the AVR microcontroller:
(This is admittedly messy but it will make sense in a moment. )
To use an AVR microcontroller, we need to provide it with power and ground-- usually 3-5 V-- and we also need to be able to hook it up to a programmer (at least once). How do do that is described in this article about "minimal target boards" for AVR microcontrollers. I took the easy way out and just used one of our business cards which takes care of the power and programming connections. (The cards are available here), Power for the board comes from a 3xAA box (4.5 V output). I use a usbtinyisp programer (See review); there are other neat ticks like using an Arduino as a programmer.
Let's look at a diagram for what else is connected to the microcontroller:
We've already discussed how the power and programming pins come into play. The other two things to notice are the connections for the handheld controllers and the digital outputs. The blue and brown lines from the two handheld controllers hook up as shown, and the power and ground (orange and green) lines to the handheld controllers also get hooked up to the power and ground pins on the AVR, or anywhere on its target board.
The remaining pins labeled on the diagram of the microcontroller are the 16 digital output lines: PB0 - PB7 and PD0 - PD7. These two eight-bit output ports will be used to control the output that goes to the scope-- the "PB" outputs will control the "X" position and the "PD" outputs will control the "Y" position of the oscilloscope beam. But, the scope takes analog outputs and these signals are digital. So, what we need next is a digital to analog converter (DAC).
For our DAC, we used a very simple and forgiving topology, the so-called R-2R scheme with 8 bits of resolution. When compared with the other (cheap) method of making a DAC on an AVR, the advantage of this scheme is that it has higher frequency performance-- a big plus for drawing clean dots on our scope screen. On the down side, it is a little more tedious to build and has only 256 resolvable levels. Still, a 256 x 256 grid turns out to be just fine for playing games on the scope screen. (See also this article about building a R-2R DAC on an Arduino Protoshield.)
Each of the R-2R chains is composed of nine 10k resistors and seven 5k resistors. (Note the name "R-2R"-- you can actually vary the values a bit as long as you keep the ratios and locations the same-- e.g., nine 20k resistors and seven 10k resistors should also work fine.) To actually hook this up, we brought the PB and PD signals over onto a new piece of perfboard with a couple of ribbon cable segments, so that we'd have room to set up all of our resistors:
The output of each R-2R chain goes to a BNC cable that hooks up to the scope. Because we actually need two BNC inputs to the scope, we used one single BNC cable, cut in half and stripped. Be sure to hook the shielding braid of the BNC cables up to the ground of your circuit.
And then as the last hardware step, hook the two BNC outputs of the R-2R chain up to the scope and put the scope in X-Y mode.
The firmware for the AVR is being released under the GPL. You can download it here (6 kB .ZIP file) and install it through your favorite interface.
That's it-- you should be good to go. You will need to adjust the X and Y offsets and scales on the scope so that the court and ball show up where they are supposed to. And, if you are so inclined, there are plenty of parameters and routines to mess with in the source code.
Finally, special thanks to Grow-a-Brain where we first heard about this wonderful game. We wouldn't have built it if we hadn't found out about it in the first place. :)
digg_url ='http://digg.com/gaming_news/Resurrecting_Tennis_for_Two_a_Video_Game_from_1958';MetaBlog links for this story: [ del.icio.us | technorati ]
Technorati tags: electronics, video games, diy, how to, circuitry, howto, fun, history, oscilloscope, avr, make
Bakery Machinery is Awesome
The Peggy Strikes Back
Today we have an update on our Peggy 2.0 Light Emitting Pegboard project, with (1) a new and improved version of the Peggy2 Arduino library, (2) links to several awesome examples of Peggy hacks-- including a full-motion video hack, and (3) a new GUI application example that lets you display an image on the Peggy without writing a single line of code. Let's start with the hacks!
- 1. Art Dahm has written a digital clock application, an animated "Invader" sign, and an interrupt-driven Arduino display library for Peggy 2.0, all with posted code. These are definitely worth a look! [LINK]
2. Geoff Harrison has turned Peggy into an animated analog clock, that keeps time even when the power is off. And, Honest Abe shows up in Peggy form too. Nice! [LINK]
3. Aubilenon, zsazs, and leviathan wrote a neat demo called "Ledtro" on their Peggy-- Whoa! (Updated: New link with code posted!) [LINK]
4. Taking this to the next level, Julien Gachadoat and Michaël Zancan of 2Roqs sent in this awesome video of animations on their Peggy. They were also kind enough to let us incorporate some of their code into the new version of the Peggy2 Arduino Library. The 3d rotating wireframe cube in the video is one of our new code examples! [LINK]
5.And, taking the cake, Jay Clegg hacked a hardware serial port onto his Peggy, mashed it up with Quartz Composer (!) and managed to get scrolling text and is the first person to get real-time live-motion grayscale video running on his Peggy-- direct from a webcam(!!). He's posted a complete how-to, including videos-- go take a look: [LINK]
And now the Arduino Library update:
Today we're releasing a new version (0.30b) of the Peggy2 Arduino library, which now includes 12 example sketches. The biggest change from the last version of the library is that we have incorporated a line drawing routine contributed by Julien Gachadoat and Michaël Zancan. This lets you draw a line on the Peggy by using commands of the form Line(x1,y1,x2,y2), or by commands like MoveTo(x,y) and LineTo(x,y). We've also included example code for the new functions, including (as we mentioned) a version of the 3d rotating wireframe cube that's in his video.
You can download the latest version of the Peggy2 Arduino Libary on this page, and the gory details about what the functions are and how to use them are spelled out here. This is an open source project. Your code contributions, hacks, and suggestions are welcome indeed.
Lastly, we have a new GUI application example to show off.
One of the outstanding issues with microprocessor-based systems like the Arduino and the Peggy 2 (which shares the same AVR-based architecture) is that they require at least a little bit of programming to do much of anything. While the programming for these systems is about as easy as it gets (for C-like systems) it's still quite a barrier for some people to get past. For example, to turn on a specific set of LEDs on the Peggy 2.0, you might run an Arduino program that has a bunch of commands like this:
- frame1.SetPoint(5,8);
frame1.SetPoint(14,8);
frame1.SetPoint(10,10);
which would turn on the LEDs at (x,y) locations of (5,8), (14,8), and (10,10), assuming that you set up the program correctly-- don't forget your semicolons, initialize the frame buffer, clear the screen when you are supposed to and refresh the display. To those of us who program things, that's nothing out of the ordinary or remotely intimidating. However, for everyone else, it's almost too much to ask.
We would like to reduce the barriers to entry so that more people can enjoy playing with microcontrollers and LEDs, so here's another approach. We have written a graphical application in the Processing environment that generates a complete Arduino sketch as its output. The program is called PeggyDraw, and the output is a complete Arduino program that you can use to put a simple picture on the Peggy 2. You can download PeggyDraw.zip from the Peggy page on Google Code.
To use PeggyDraw, you'll need both the Processing.org and Arduino software packages installed. These are free cross-platform development environments. (I have Processing 0135 and Arduino version 11.) When you open PeggyDraw from within Processing and run it, you'll see a window like this one. It looks like the Peggy display, and you can click to draw or erase the dots on the screen. (This is a bit like the Peggy Planner except that it's oriented towards figuring out which LEDs you want to light up, rather than where you want to put which LEDs of different colors.)
PeggyDraw has only one other I/O method-- a button marked "Save." When you click it, it generates a subdirectory called "PeggyProgram" within the directory where PeggyDraw is located. Inside this folder is the PeggyProgram.pde file, which you can open from within the Arduino environment and directly install onto your Peggy.
Doing this, you can program an image onto Peggy-- like so-- without ever touching code.
As implemented thus far, it's a very simplistic program. However, we think that simple programs like this one that automatically generate useable Arduino code may be an interesting approach to further reducing the barriers to entry-- And it certainly leaves plenty of room for improvement!