Skip to main content

Pinball Solenoid Control


Pinball solenoids come with designations like 23-800.  The first number, 23 in this case, represents the American Wire Gauge (AWG) used.  The second number, and the more important number, is the number of windings which is related to its power rating.  A solenoid with less windings, say 400, is more power and is used for such applications as actuating the flippers.  These solenoids get very hot very quickly, which increases the resistance of the solenoid thereby decreasing the current and therefore the power.  To avoid overheating, these high powered solenoids will have two coils.  One for the main actuation of the solenoid, and another to maintain the position.  The second solenoid will have a smaller wire gauge and more windings.  In example, my flipper 'coils' are 15-411, 15 AWG and 411 windings.  They are quite strong and found in some of the latter Williams pinball machines such as the popular Adams Family machine.  

You can find a lot of good additional information, such as the required voltages (which I wish I had found earlier) for the solenoids from different eras of pinball machines, here at PinballMedic.net.

I happened to buy a bunch of 23-800 solenoids because I was not exactly sure what I was going to use them all for.  If I start running my 32 volts through them and not turn them off, they'll likely get hot, melt something, and most probably catch on fire.  They only have 4 Ohm resistance when cool, and when run on 32V they draw 8 amps of current or 256 W.  That's not good. So if I want control the power, I need to control the voltage.  This way I'll be able to use the 'wrong' type of solenoid for various other tasks. 

A good start to the comprehensive control of the voltage for the solenoids would likely be turning them on and off.  What I needed was a solenoid driver board.  This is a circuit board that takes the 5V logic from my Arduino microcontroller and turns off and on the power to the solenoids using a metal oxide semi-conductor field effect transistor (MOSFET).  This is now the most common type of transistor out there.  Bi-polar transistors used to be common but MOSFETS switch faster and require lower gate voltages, ie. the voltage to turn it on.  


 The switching speed is important because to control the power I used what is called pulse wave modulation or PWM.  A PWM signal is typically a square wave signal that jumps between 0V and say 5V in the case of logic circuits.  Depending on the time between these pulses of 5V you can get an average, lower voltage.  This is only possible because often whatever component you are driving, in this case a solenoid, reacts to the signal a lot slower.  Because the solenoid reacts so slowly to the signal, it only sees an average voltage.  The 'average' voltage can be controlled by changing the duty cycle.  If the PWM signal is at 60% duty cycle, what it is powering will see 60% of the voltage if it cannot react fast enough.

This rapidly changing signal can also be smoothed out using 'filters' so the solenoid does see the average voltage instead of relying on the lagg of the solenoid to average it for you.  Simple filters consist of a resistor is series and a capacitor.  In the case of the pinball solenoids, a series resister is a bad idea as it would fry due to the high current.  I can however, use a large capacitor to smooth out the voltage.  An excellent PWM tutorial is available here.  It is also where I nicked this very fancy PWM animated .gif from. 

I built a basic solenoid driver board using the following components:
- IRF530 Power MOSFET *Note: No longer available

The power MOSFET controls the power to the solenoids.  The AND gate combines the PWM signal and a I/O signal from the microcontroller.  The combined signal is sent to the optocoupler which switches a higher voltage to the MOSFET's gate to turn on the MOSFET.  The higher voltage is required to fully turn on the MOSFET otherwise it would not run at it's max current rating or switch at the required rate for the PWM.  Alternatives for the optocouplers are smaller transistors / non-inverting buffers.
Testing the solenoid driver board using LEDs

Silly me using 3 AND gates when I only have 8 outputs. I was thinking it was a good idea to use a separate one for the flipper controls, but it doesn’t matter! Oh well, had to resolder the board but I at least now have DIP sockets for the chips

It was not working right anyways. As soon as I turned on all the solenoid circuits it would not work. I hooked up LEDs to the circuits to see what was happening.  Now I had some odd occurances happening.  I would place my hand closer to the MC and they would turn on instead of being off or half lit.  The LEDs would actually glow brighter as my hand got closer.  I could touch an optocoupler and it would turn on one light or more.  It was like having a capacitive sensor but not really.
After I had resoldered the board, it still did it and with different AND gates. I checked all my outputs on my MC, made sure none of the pins were floating but I was getting some feedback into the MC from the PWM.  Very not good.   I even took it to one of my coworkers who’s an electrical engineer and he couldn’t figure it out.  Well, that same friend happened to have given me a bunch of electronic parts he was not going to use because he’s all about surface mounted components now and too good for DIP chips anymore!  I took a couple of the AND gates, assuming they weren’t the cheap ones I purchased, and it works like a charm! Guess it goes to show you, you get what you pay for.  For those of you who want to know, the AND gates I had were from Motorola and Texas Instruments.

Testing again but without the extra AND gate and with AND gates that work!

I did have another problem, as at this time I was rather unaware of floating pins.  If an input to an intergrated circuit (IC), such as an AND gate, is not tied to ground or to a voltage it will 'float'.  Floating means that it might randomly change its logic level for fun.  So you could end up with components turning on when you do not want them to.  Whenever I turned on my microcontroller all the mosfets would activate even though I did not apply any voltage to them.  This was easily solved by tying the input pins of the AND gates to ground with a 10 kOhm resistor.  This resistor is called a pull-down resistor because it makes sure that the AND gate inputs are LOW when the microcontroller is turned on.

As a rule of thumb, all unused inputs for every single IC should be tied to a pull up or pull down resistor.  This ensures no floating pins.
To give you a better idea of what is happening I took some photos of my oscilliscope while checking the circuits. Yes, I have one. I only have one because I managed to get it for $25 bucks from a local highschool who were getting rid of electrical equipment for some reason.

Optocoupler Output to the MOSFETS

This photo shows the output of the optocoupler. You can see it laggs behind the real signal which is a square wave.  This means that the optocoupler is actually rather slow.  The PWM signal is generated from the microcontroller and is a rather lower frequency.

The output of the MOSFETs.

The above photo is the output of the MOSFETs.  It is a nice square wave but this is more by happenstance.  The MOSFETS turn off at a low voltage so even though the optocoupler output is slow to come back to ground, the MOSFET does not shut off until the voltage is low.  Because the MOSFETs can switch faster, it results in this nice square wave though the signal stays HIGH for twice as long as the original signal.  This narrows the range of duty cycles for which this setup will work.  Hardly, ideal but at least it works.

Comments

  1. great job! thanks for sharing
    What kind of diode did you associate with the MOSFET?

    ReplyDelete
    Replies
    1. I never thought anyone looked at this. I have not posted in a few years as I changed careers, moved etc. Pretty much you can use any rectifying diode to deal with the flyback across the mosfet, such as the 1N4148. The IRF510 did not have one integrated, but the P40NF10 I ended up using later on does. You should also have one across the solenoid to prevent voltage spikes due to the solenoid de-energizing.

      I did make a mistake and changed my design to analog timing using caps and schmitt-trigger as I wanted to offload the work from my microcontroller as much as possible. However, it has more than enough processing power to deal the switching times. Also, I needed to use higher precision potentiometers to set the timing (20 to 40 ms). Anyways, thanks for posting. Maybe I'll update this thing.

      Delete
  2. answer in your other post 1N4148
    https://mikesprojecttracker.blogspot.fr/2012/04/pwm-voltage-control.html
    :)

    ReplyDelete

Post a Comment

Popular posts from this blog

MOSFET Driver Board

Final version?  I hope so.  I have gone back and redesigned my solenoid driver board several times.  In previous versions I attempted to offload some of the logic from the microcontroller.  For example, I used a Schmitt-Trigger [74HC14] with an RC network to provide a single pulse to the solenoid.  Also, I added in a PWM signal to set the average voltage 'seen' by the solenoid.  This worked but was very limiting to have the pulse length hardwired in and it was difficult to adjust without more expensive precision potentiometers. I chose to simplify my circuit to make it a general MOSFET driver for flexibility.  Since I have more than enough space inside my pinball cabinet, it was not a problem to have the extra boards.  The boards were designed to have 4-channels since by default I would get a minimum of 10 boards for the same price from Seedstudio.  Also, the cheapest board option was restricted to 10cm x 10cm otherwise the price balloons ...

Pinball Cabinet Beginnings

I was getting to the point where I really needed to build on something. I have numerous pinball parts but have nothing to attach them to. I managed to find some pinball plans for a Williams Widebody pinball machine. All the measurements are in mm sadly even though all pinball cabinets are in inches. I converted and change it all to the nearest quarter inch. Well sort of. The guy who measured this was intending on using 45 deg cuts in the corners. My skill saw is too cheap for that so I changed the measurements for butted joints. The interior is set for a 23.5" wide playfield. The length of the cabinet is 51.5" in total. I used 3/4 inch plywood so the bottom would be 50" long for example. You can pretty much dimension the rest from there.  I did get a little chipping of the plywood but I went out and bought a blade with more teeth for finer cuts. It's a 60 tooth saw blade and my skill saw doesn't really have enough power for it so I have...

ATX Breakout Board

Last November, I fried my 'lab power supply' that I made from a computer PSU.  I was testing my solenoids and the stress was just too much for the PSU.  The mistake I made was rapidly turning on and off my solenoid which likely resulted in voltage transients (spikes).  Since the PSU does have a current limiter, it was likely the constant voltage spikes that caused the damage.  There are various methods to suppress voltage transients such as by-pass capacitors and zener diodes.  In particular solenoids and other inductive loads experience these voltage spikes, hence my no longer functioning bench power supply. ATX Breakout Board I could have just rebuilt the same power supply by adding binding posts etc to the PSU housing but after searching the internet an ATX power supply breakout board seemed a popular option.  The main advantage compared to my old power supply was the addition of fuses on the outputs.  The extra safety this provides is perf...