At the heart of any pinball machine is some sort of control system that makes the game come alive. As I rather enjoy electronics work I decided to build my own control system from scratch. I designed a circuit board in Kicad, sent the design off to China to be fabricated, and on the second revision I had a fancy custom PCB (Printed Circuit Board). I actually designed two boards specifically for the machine, one for the microcontroller and logic, and another to switch the big noisy coils.
The final machine actually has 4 PCBs and 3 microcontrollers:
- The main control board with an ATMega32 running at 16Mhz. For those electrically inclined, here is the schematic. The control board has the following specs:
- Individual control of 256 LEDs
- Inputs from 64 switches
- Control of 12 solenoids
- My own fancy firmware written in C with the AVR GCC compiler
- The coil board used to trigger the 50V coils such as the flippers, slingshots and pop-bumpers.
- A sound trigger board running an ATMega8. This microcontroller receives UART signals from the main control board and does the interfacing to the SOMO-14D sound modules. This board also does some software debouncing of the slingshots.
- A board to control the moving target, running an ATMega8.
Given that the ATMega32 only has 32 I/O lines, and I wanted to control 256 LEDs, 64 switches and 12 solenoids, I need some extra circuitry. For the LED and switches, I used a matrix configuration. There are numerous descriptions of this method around (Here for example). The light matrix consists of 8 columns which source 12V, and there are 32 rows which sink current to ground. By turning on each column in order I can turn on up to 32 LED’s at any one time. If the columns are cycled fast enough the human eye can’t tell the LED’s are flickering. I found the minimum frequency to be 55 Hz (close to a monitor’s refresh rate) with each LED on 1/8th of the time.
I used 4 x 74HC595 8-bit serial in/out shift registers to store the 32 row states during a cycle. Each shift register was connected to a ULN2803 8-channel driver in order to sink enough current. A column in the light matrix was selected one at a time using a 4028 BCD to decimal decoder (to save microcontroller I/O) connected to a bunch of P-Channel MOSFETS which source current. Diagrams of this are in the schematic.
For the switch matrix I also used a matrix configuration. Most of the switches in the machine are micro switches or leaf switches. By arranging them into 8 columns and 8 rows, I could sample the state of 8 switches at a time. Each switch required a diode in series so it would not affect the other switches in the column. I also added the ability to read in 24 digital (5 V) inputs such as photo-interrupters, by using 3 x 74HC245 Octal 3-state buffers interfaced to matrix.
With some clever software I could then sample the state of all 64 switches every 16 ms and trigger events if a switch changed state.
Other major parts of the electronics include:
- Scores displayed on the backboard, simply using 7 segment LED displays connected to the light matrix.
- A coin mech to accept 20c coins. This is rather simple, the coin mech sends a pulse every time a proper coin is inserted, so I connected it up to a digital input on the switch matrix.
- Sound effects and background music, described here.
- An elaborate and ingenious moving taget.