Monday, February 29, 2016

Sound Module, Rollover Switches, and RC Time Constants


Over the weekend I experimented with one of my options for sound. The MOL-AU5121 .mp3 module from MDFLY. I've been hard pressed to find a good example for designing a .wav player, or even one that was easily addressable from an outside source, but the board from MDFLY was an easy to use option that is really tempting to stick with. The module reads serial data in, and plays MP3 files stored on the sd card mounted to the back of the device. The documentation for this thing is wrong on at least a couple of things I have found. It states the Baud rate for the SR-232 is 4800 when in reality it's 9600. It also states that the addresses of the files are dependent on what you name them ie. address "01" = "001.mp3". This is however, not true. The addresses for the individual .mp3's depend on the order they are loaded onto the sd card. I'll give them that if were to name them all that way before hand and then load them all at the same time, this should work fine, but if you saved 001.mp3 then 003.mp3 then realized you forgot about 002.mp3, then 002.mp3 would be addressed with "03". There are programs out there that let you specify what order files are loaded onto the cards, so I will have to look into that. I'm thinking I'm going to need three or four of these modules chained together to be able to play multiple sound files at once. One for dialogue, one for music, and one or two for various sound effects. I will have to program in some sort of hierarchy for the audio files to make sure the more important files can interrupt and not be disturbed by less important sounds. 

I ripped the audio in the video from the actual TV show. Unfortunately I got one where Walter says "engaged" instead of "encoded". I have started keeping a notepad file open and recording when and what is said on the show as well as various sound effects I want to go back and take later. I love that research for this includes watching my favorite show.

The switch I'm using is an old leaf type rollover switch used in older pins. I dont think I will be using these. They take up too much room on the bottom of the play field and are also comprised of two separate parts. A more modern switch uses the same curved wire actuator but instead of the leaf switch, it uses a micro switch.

Rollover switch slot from top of playfield.

Older, leaf type rollover switch pieces.

Modern micro switch type rollover switch.

When trying to test this thing using an Arduino, I was having problems with the ball rolling over the switch too fast and the code not catching the signal fast enough. This seamed very odd to me. How could I see the switch close faster than a 16MHz processor? Short answer, I can't. when I was programming the code I tried to get the state of my input inside my if statement instead of storing the state of the input into a variable and checking the variable inside of my if statement instead.


instead of:

bool switchState = digitalRead();

I'm really not sure why it should make a difference at all, but I do know for sure that this is what fixed the problem. I had also thought about using a capacitor  to temporarily store the 5v signal and release it slowly through to the input. I did try this too, I even thought it was working, but it didn't. Out of curiosity, I used my scope on the input and saw that the cap was draining just as rapidly as it was charging. Maybe there isn't enough internal resistance on the input? I will have to try this again later with a 1k resistor or similar going into the input from the cap. 

The 10K resistor is just to keep the input at a logic level low until the button is pressed. A 1uF capacitor draining through a 1K resistor should keep my input around VCC for about 1 second. What I have just made here is what is known as an RC circuit. Resistor, Capacitor circuit. Capacitors charge and discharge in what is referred to as a time constant. Or rather, 5 time constants. The capacitor will be ~63.2% charged after just a single time constant passes. It then takes 4 more time constants for the other 36.8% to charge. So the first one is usually the most important. Calculating the time constant of an RC circuit is easy. Capacitance multiplied by Resistance. So 1uF is .001F and 1K ohms is 1000 ohms. .00 * 1000 = 1 second. So the time constant is 1 second. So after the button is depressed the cap will take one full second to lose 63.2% of its charge holding the input high for that whole time. It is only a function of the 1K that makes our cap drain so slow. Charging the cap is almost instantaneous. When the button is pressed, the capacitor has no resistance to the current charging it. Bad idea? Probably but what do I know. So lets get the time constant real quick for charging. .001F * 0 Ohms = 0 Seconds. Yup, theoretically that capacitor will charge instantly.

Here's some more information on RC circuits and Time Constants.

Friday, February 26, 2016

Where are my Inputs?

I just realized I made a terrible mistake with the EZSolenoid board I just purchased. It has no inputs. I'm using all the IO for outputs to the driver. Now I will have to either use only two solenoids per board and cut the traces that lead to the others, or use the thru-holes of the ATTiny85 to send discreet signals from an external MCU. I'll probably go with the latter. Oh well. I should have thought it through more before sending the gerbers to OSHpark.

On a lighter note, I tested out an unidentified mechanism last night. I'm not sure what it is. It reminds me of an escapement. Escapements are the devices in side clocks that only allow one tooth of a gear to move at a given time. In my industry, industrial automation, we use them on conveyors to release a single part into a machine. This device reminds me more of those. But why would something like this be used in pinball? I have only two possibilities I can think of. One: To gather multiple balls and release them as multi-ball all at once. Possible, but what would the point be of closing off the lane while releasing the multi-ball? Or Two: Placing between two similar lanes and blocking one lane while allowing balls to roll through the other. No matter the purpose it was originally intended for, I don't know if, or what I might use it for on Stargate Command. If anyone has any thoughts on what it might be, please let me know.


The mechanism has a double coil like the flippers do for holding. I'm not sure what happened with the holding coil. I did have it working last night after recording the video, but I didn't actually change any wiring. It seemed to suddenly start working. I'm wondering if maybe the armature needs to be all the way in the solenoid before trying to switch on the holding coil. It would make sense. I will have to test this out later.

Thursday, February 25, 2016

More KiCad

Top Layer

I am becoming more skilled with KiCad and cant seem to stop laying out boards. I designed and purchased this one last night for testing out my solenoids on the test playfield. I am no longer willing to navigate through spaghetti wiring and loose breadboard connections while working. It's so frustrating trying to design something without being able to rely on the robustness of a previously working design. It is always good practice to work on one thing until it works every time without failure, and only then move on to something else. I'm hoping this board will do just that. Each one can independently control 4 solenoids with an ATTiny85, and be mounted on the bottom of the test playfield using the four 6-32 mounting holes in the corner. I can then route the power rails to screw terminals, making disconnecting the power from the playfield quite simple.

Bottom Layer

Silk Screen and Edge Cuts

This is the schematic I drew up originally of the solenoid driver. the 40V is isolated from the logic through an opto. because of the way I have done this the logic to turn the solenoid on is backwards. So when my output is high the solenoid is deenergized and when the output is low the solenoid energizes the problem with this logic is that there is a high probability that the solenoid will stay energized and burn out. So my design tries to counter act this by using a PNP transistor to invert the signal before entering the circuit. This method still doesn't fix the underlying problem though. Keeping the solenoids turned off requires the use of my 5v supply. In the event of my 5v supply failing, every solenoid would fire and blow a fuse, burn out a coil, or worse. So my new design uses an output of the MCU to fire a relay which switches on and off the 40V rail to the coils. Now my coils wont have power until I output a signal. A signal that is not available unless my voltage source is on.

New Solenoid Driver Portion

Monday, February 22, 2016

Solenoids and Slingshots

I disassembled the pop bumpers now that I know they work. Installing them later on the new test board should be trivial. Test Board? Yes, I went to home depot and bought some 1/2 cabinet grade plywood and cut a prototype playfield out. 42" x 20.25" x .5". I found an excellent website called Pinball Makers  that has had a lot of useful data on designing and building a pin. I found a table of many different games and the dimensions of their playfields. There is also a page with CAD drawings and 3D files of many components and layouts. Part of me wants to download all the data I find and tuck it away on my server in fear that the source pages may not be available later, but I think that's just paranoia. I am keeping a small, pocket notebook with me so when I am away from my bench and find an important piece of information I can write it down for later.

I purchased an old slingshot assembly and did my best to mount it to a scrap piece of .5". The slingshots are the triangle thingies above the flippers that bounce the ball on an angle back up the playfield. I also purchased, at the same time, a set of Gottlieb replacement rubbers. Because sometimes you should change your rubbers. I assumed the larges of these bands must be for the slingshots. I spent Friday night drawing the lower part of the playfield in pencil on the prototype. I have seen in pictures that the slingshots start above the shaft of the flippers. So, knowing where my flippers were going to be, I measured from above them back to the start of the inlane guide. After using this measurement to place posts on my scrap board I placed the 4" band on the two posts and pulled the side to the inlane line and more or less had where my 3rd post should be. Now mounting the switches and solenoid assy is what started becoming an issue. I downloaded one of the layouts from pinball makers and snapped some dimensions and printed it. After looking at the measurements it was clear that the slingshot I had a drawing of was much smaller than the one I had just outlined. Ignoring this obvious clue, I attempted to mount all the hardware. It seemed to compact. You know, because my slingshot was too damn big. I was debating purchasing a plastic slingshot cover from an old game and using it to help me lay it all out when I noticed my bag of rubber bands had some documentation I didn't bother to read before. Inside was a detailed layout of the playfield these replacements were for, a chart showing the various band sizes, and a key easily mapping what each one was for. And sure enough, the band I was using was the wrong one. I was using a 4" band instead of a 3".  I will have to layout all the measurements on a new board and have faith the 3" band will work. My guess is it will. I'll have a video up as soon as I test it.

After my agonizing defeat with the slingshot I decided to install the flippers to the Protofield™. This was quite simple and gave me no trouble at all. I just mounted the base, inserted the flippers with new rubber, lined up the flipper and tightened down the shaft.


I find the flippers to be a really fascinating piece of engineering. Before I get into why I think that, let me first explain what a solenoid actually is and how it works. When a current is applied to a length of wire, a small,, weak electromagnetic field builds around the wire. If you were to take this wire and then put a single loop into it, the small electromagnetic field will become larger as a result of the two fields joining each other. Now if we take that same wire and instead put many, many more loops going the same direction to form a "coil", we will have created a much larger, stronger, magnetic field. Perhaps in school the teacher had you loop wire around a nail and pick up paperclips when the coil had a battery connected to it. You created an electromagnet. What the teacher probably didn't have you do is apply more voltage to your coil thus driving more current through and inducing an even stronger electromagnet. If he/she would have done this without injuring the students, the nail could have been pulled out of the coil by hand, and when released, "sucked" back into the coil with force. The strength the coil depends on the amount of current being applied. The more windings a coil has, the less current it will draw, the weaker the field will be. So if you had a coil with 200 windings and a coil with only 100 windings, assuming the same voltage is applied to both, the coil with only 100 windings will be twice as strong and draw twice the amount of current. Ordinarily, a solenoid will consist of 1 coil, a ferrous shaft(steel), and a spring. Voltage is supplied to draw the shaft in, and the spring pulls the shaft back out when the voltage is cut off.

Normally, a solenoid is only switched on momentarily to perform an action and switched off quickly to avoid burning out the coil. The problem with pinball flippers however, is the player will want to hold the button down to catch the ball and hold it. It is possible to reduce the current of the solenoid to the point where the coil could stay energized indefinitely. And that would work for holding the flipper up, but the trade off would be that the flipper would no longer have the power needed to throw the ball at high speeds up the playfield. The solution to this is elegant and the reason I love the flipper assembly so much. The flipper solenoid has two sets of windings. one short and capable of producing higher power, and one long and capable of holding the flipper without drawing high current. These two coils meet together in the middle to form one long coil with a tap somewhere in between the two.
The negative side of the power source is routed through a normally closed switch and then to the center tap of the coil. The outer side of the longer coil(holding coil) is connected directly to the negative side of the power source. When voltage is applied to the outer tap of the smaller coil, a large current is drawn through the coil giving the flipper the high power it needs to drive the ball. When the flipper reaches it's end of stroke, a bracket on the shaft of the flipper opens the normally closed switch, causing the only path left to negative to be through the secondary, longer coil. This immediately reduces the current draw to be just enough to hold the flipper in the up right position.

Stargate Command Kickoff!

So considering this project is going to take so long, I have decided to post updates to this page as I progress. Let me first say, building a pinball machine has been in the back of my mind for a long time. However, I have been very hesitant to actually attempt to build one. I know it will take a while, I know it will be relatively expensive, and quite complex. There are many systems that go into one of these, both mechanical and electrical. I expect to learn many things from this project, and I suppose that's the real point anyway. Some things, right off the bat, I expect to learn doing this.

  • The ins and outs of solenoids
  • Driving a dot matrix display(Hardware & Software)
  •  Editing Audio
  • How audio is actually stored and played
  • Audio amplifiers
  • Mixing multiple voltage supply's
  • Using CAD to design printed circuit boards
  • Object oriented programming
  • Vacuum forming 
  • Creating vinyl artwork
  • Protective Layering
  • Wire forming
  • Patience 

 After countless hours of playing pinball at the arcade and traversing the web looking at pinball hardware and 3rd party parts, I'm starting to get a better understanding of this whole pinball thing.
The first items I purchased were 3 pinballs, used bumper assemblies of various types, and several used targets and switches. I want to start this off with used, less expensive, parts just in case I change my mind about a part or break it in the process of learning all this.


While waiting for the parts to arrive, I designed two IO expansion modules for the micro controller. One 32 point Input module and one 32 point Output module. The input module consists of four 8bit parallel-in shift registers, and the output module consists of four 8bit parallel out shift registers. I designed a library for both expansions using an unsigned long variable for each then using an AND comparison to see the 32 points at the bit level. I have no better way of describing that right this second. If you are still interested, you can look at the code your self. In the video you can see a lot of bad flicker. this was due to me writing a function to see if output 0 was set to zero. If I remember correctly, a for loop was writing a zero into that register whenever it finished its loop. I have since wrote an independent function to turn all outputs off. No more flicker now.

I purchased this old pinball power supply from ebay. It was originally inside of an old pinball machine from the 70's. I thought getting this to work would be super simple. When it arrived and I sat down at my bench with it, I noticed it was a multi-tap transformer with many wires and no indication about which one was what. I couldn't find any documentation on the transformer online. I don't currently have an auto ranging multimeter and didn't want to go to the trouble of probing that big transformer every which way to figure out what was what. In a last ditch effort I searched the transformer part number again and matched it with the keyword "pinball". And bingo, I found out which pin this was originally from. It was from a 1977 Atari Airborne Avenger. One more googe search away and I found the owners manual to the game. There on page 68 was a seemingly hand drawn schematic of the power supply. This was a nicely documented game. I don't know if most machines were like this, but I will certainly strive to document my machine well enough that it can be repaired with relative ease. The drawing had wire colors and everything. I'm not sure if I'm actually going to use this old heavy linear supply or not. I know some people use switching power supplys that were designed for industrial applications, but if I run into no problems with this, then I think it's the way to go. Also, for the smaller voltages I will be using an ATX power supply to run the lights and logic.

Upon going through the drawing and figuring out what is still there I managed to label all the pinouts of the 3 front molex connectors. I purchased the mating molex connectors for the 3 just in case I might need them down the road.


Here's a quick demo of the pop bumpers in action. I do have brighter lights inside now but for some reason the newer video wouldn't upload. perhaps later. Also, I haven't yet figured out what exactly I'm going to do about the lights in the game. These games used to use 12v incandescent bulbs for all the various lights, but recently I have seen them getting replaced with LED bulbs of the same socket type. I purchased some of these 555 socket LED bulbs for the PirateCade cabinet but they seamed to burn out after about a month. I will have to buy several types and experiment to see what I should use for this.

Oh Boy! I'm actually really excited about this one. I have been wanting to actually design a PCB and have it made for a long time. The thought of having to learn new software and screwing something up was just too daunting. But sometimes you just need to pull the trigger and just do it. Just like Shia Labeouf said. It took me no more than 6 hours to make myself comfortable in Kicad(PCB design software) making schematics, part footprints, and routing traces on the board. I actually really enjoyed it. I plotted the gerber files and sent them off to a board house to have my PCB manufactured. I am having it done through OSH Park. They will print pcb's at $5 per square inch of a 2 layered board, and they will send you 3 copies of your board. So, since my board is 1" x 1", my price for 3 boards was $5. Can't wait to see how it will turn out.

They even give you a picture in your order screen of what your particular board might look like. So I guess my board will be barney. The thru holes for the IC worry me a little now that I'm looking at it. They look small. Maybe I entered the data wrong from the datasheet. Oh well. I guess I'll know when it gets here. I heard the turn around rate for them is around 2-3 weeks. Not bad considering the price.
What is my circuit you ask? Well it's just a small ATtiny85 Breakout board with a built in reset switch. It has nothing to do with my pinball game but it was a $5 learning exercise to see if I actually have the hang of this whole thing. So even though this is just a small, almost pointless board, I am really excited about my new found skill and am even more motivated to design the rest of the hardware.

February 19, 2016

I was tinkering last night with my pop bumpers trying to get them to trigger better. I couldn't for the life of me get the switches positioned just right to where an even amount of pressure from all sides would activate the spoon switch. As I was adjusting and setting up the flipper assemblies, I thought the shaft of the flipper looked too low. I got out my calipers and discovered the distance between the bottom of the flipper and the top of the mounting bracket was just over 1/2". This tells me that the playfield this flipper came from was 1/2" thick. The board I have been testing the bumpers with is 3/4". After a quick search I learned the standard thickness of a playfield is indeed 1/2".  I will have to set up my bumpers on a 1/2" board to see what difference it will make. My guess is a lot.

Here's the new video of the lights in the bumpers.