As described on the previous page, the Magic City pinball machine shipped without the fountain color wheel feature that designer Norm Clark had imagined.
The motivation for this project was to try to recreate the effect that Norm had in mind after being reminded of its omission by a brief discussion on an online forum.
The key to this project is the widely available addressable RGB LED strip. Each LED on the strip is actually a small square package that contains three separate LEDs (Red, Green and Blue) along with a tiny processor. When instructed to show a certain color, the processor figures out how to drive each of its three LEDs so that their colors combine into the requested color. For example, if the requested color is purple, the processor makes its Red and Blue LEDs bright while keeping the Green LED relatively dim.
Each processor receives instructions from its upstream neighbor and passes instructions on to its downstream neighbor. (Note the arrow printed on the strip.) To set each LED in the strip to a unique color, the instructions are passed along from one LED to the next, bucket brigade style, from one end to the other until each LED has received its color instructions. Then the command is sent to turn on the color and all the LEDs change at once.
The strip can be cut to include an arbitrary number of LEDs as long as the cuts are made straight across the copper solder pads as shown by the straight lines printed on the strip. When reassembling strips into a new configuration, the connections must be restored by soldering wires to the copper pads that were cut in half. Care must be taken to preserve the direction of the instruction flow, so the DO (Data Out) pad of an upstream strip must connect to the Din (Data In) pad of its downstream neigbhor. +5V and GND connections must also be restored between cut strips.
The first step of the design process was to map out the area that the color wheel would need to cover. The backglass has many translucent areas defined by a mask layer that lets light from the many bulbs shine through from the back. The translucent area for the fountain looks like this:
Light can pass through the white and light blue areas but is blocked by the black areas.
The next step was to map out where the LEDs should be placed behind the fountain. I used Sketchup to create a model of a single LED strip element and loaded an image of the fountain. Using actual dimensions, I was able to see how the LEDs and the fountain related to each other. I went through several iterations of LED layouts using various ring and grid configurations. Factors that ended up being important were the spacing between LEDs to allow for even coverage of the whole area, the amount of soldering that would be required to connect them all together and how easily the LEDs could be manipulated by the software that I would have to write to drive them. In the end I settled on this layout:
The LEDs on the strip I purchased are standard 5050 (5mm x 5mm) surface mount LEDs with a viewing angle of 120 degrees. The image on the left shows the placement of the LED strips under the fountain and the image on the right adds an estimate for each LED of the area it would illuminate given the distance from the LED to the back of the backglass.
The layout places the LEDs not on a square grid, but on a hexagonal or honeycomb grid. Each LED has six neighbors that are all equidistant from each other. I thought this layout would produce more even lighting than a square grid and would allow the colors from each LED to blend more gradually.
With the layout complete, the next step was to build the LED array. I needed something to mount the LED strips to that was stiff but thin since there was very little room behind the backglass. I ended up cutting a piece of sheet metal from a large rectangular olive oil can, flattening it out and painting it black to minimize any reflections from the back side of the backglass. I scribed a few guide lines into the paint and carefully laid out the self adhesive strips to match the layout.
The LED strips were laid out to minimize the wiring required to preserve the Data Out to Data In relationship between strips, so the data travels up the first (or leftmost) strip, down the second strip, up the third strip and so on. The +5V and GND connections can be made in any order, so I split the strips into two groups to reduce the worst case current running through any one strip.
A dab of hot glue anchors the wire bundle that leaves the board, and a resistor before the first Data In connection adds extra protection to the microcontroller. Not shown are the microcontroller required to drive the LED array and the 5 volt power supply.
A microcontroller is required to drive all the instructions into the LED array, and fortunately there are some excellent open source libraries out there to do the heavy lifting. I used the FastLED library and learned a fair bit about color theory in the process.
The commonly used RGB color scheme defines each color as a combination of levels of Red, Green and Blue. Values for each of the three colors can range from 0 to 255. For example (255, 0, 0) is bright red (maximum red, no green, no blue), while (255, 255, 0) is purple (maximum red, maximum blue and no green). In theory, the RGB scheme lets you specify over 16 million unique colors since there are 256 different levels for each of the three colors. Whether or not your monitor, your LED or your eyes can resolve 16 million unique colors is another matter.
Sweeping through all the colors to make a color wheel might seem like a straightforward process since all the colors can be represented numerically. However, sweeping through the RGB colors doesn't produce an even color distribution because your eyes don't resolve the colors evenly. In fact in the RGB scheme, a lot more colors resolve to green or greenish than the numbers would indicate and relatively few colors resolve to yellow. This is similar to the non-linear way we hear sound. Music played at a certain level doesn't become twice as loud when twice the power us used to play the music. In fact, it takes a lot more than twice the power to make it sound twice as loud.
So producing a color wheel effect that appears to have all the colors in equal proportion is tricky with RGB. Fortunately, the FastLED library supports another color scheme called HSV that compensates for our uneven color perceptions by laying out the colors to be visually proportional.
With the FastLED library it was easy to code up something that looks like a rotating color wheel. It turns out that the HSV color scheme in the library is laid out like a color wheel so that each color is essentially assigned one of 256 points around a circle instead of the more familiar 360 degrees. To get the initial colors for the LED array, it was just a matter of measuring the angle of each LED relative the center point (using the Protractor tool in Sketchup) and scaling the angles onto the 256 HSV colors (or hues in HSV parlance). So for example an LED directly above the center point would be at 90 degrees from the X axis but would scale to 64 (90/360 * 256) on the HSV scale. Each LED was initially assigned a color based on its HSV scaled angle.
To get the colors to rotate, each iteration of the main loop adds 1 to the color value assigned to each LED. The aforementioned LED at the top starts with color 64 in the first loop iteration, then get 65 in the 2nd loop iteration, and so on. As each color reaches the maximum value of 255, it wraps back to 0 and continues incrementing in subsequent loops. It takes 256 steps for the colors to make one complete revolution.
On the left is the illuminated LED array and on the right is what it looks like when illuminating the backglass. Note that the colors shown in these photos and videos are somewhat subdued. To keep the camera from saturating the colors generated by the LEDs, most of these images are intentionally underexposed.
Instead of coding the color wheel with colors rotating in a strictly radial pattern (in pie shaped wedges), I opted to add a subtle spiral effect. Rather than a given color projecting in a straight line from the center of the fountain, each color spirals out from the center, like the arms of a galaxy. This was done by adding an extra bit of rotation angle to each LED's color based on its distance from the center of the fountain. The effect is most noticeable on the top half of the fountain which changes color from bottom to top. I thought the effect was more interesting than having the entire top half of the fountain use the same color while still being in the spirit of being something that could be done with a simple color wheel in the 1960s.
I initially thought this project would be pretty straightforward, but I did learn a few things along the way. The first had do do with power supplies. I thought that I'd be able to power the microcontroller and LED strips with a simple power supply using the 6.3VAC lighting circuit already built into the game. After some simulations, however, I realized that the worst case current requirement of the LED strips (~3.6 amps) would make a 6.3VAC based supply cumbersome if not totally impractical. I could have used the 24VAC relay and solenoid supply in the game as the basis for a power supply, but I bailed out and ordered a cheap 5VDC/5A power supply instead.
The bigger lesson is that color is tricky. I was aware of, and thought I understood some of, the subtleties of color theory, but it's a much bigger topic than I had handle on. Visual perception and the issues of RGB color were new to me. I also ran into trouble with the HSV color scheme while trying to make color and color temperature adjustments to make the results look more like they were from warmer incandescent bulbs than cooler LEDs. More often than not these adjustments threw off the balance and made things disproportionately green or muted.
At this writing the color wheel works but is still very much in a prototype stage. There is some work to be done to package it more ruggedly and likely to insulate it from the EM (electromagnetic, not electromechanical :) noise generated by the game. I have noticed some unexpected behavior in the color wheel while playing the game so some shielding, isolation, filtering caps, etc. may be required. I encountered similar issues in the low voltage components while developing the Atomic Pinball Clock.
With a generic LED array now working there is certainly potential for adding features including:
Whether these would be a respectful homage to Norm Clark's original intention or shameless eye candy is up for debate...
There has been some interest in producing more color wheels. This one was made as a proof of concept and is strictly a somewhat janky prototype. Although I have no production plans at the moment, I have ideas that would make it more suitable for production and might be convinced to give it a try. If you have interest in a color wheel for your Magic City please use the Subscribe page to receive updates by email.
Changes and revisions made since this initial build details blog was written are covered on the next page.