Pinball Machine

Hi All,

I am creating a pinball machine project for year 7 students. I want to use 12V solenoids and light bars (LED strips lights), controlled by relays. It also has a 16x2 LCD screen to show the score and an MP3 module to provide sound. Turns out doing something like this is (to me) super complicated. I can do the coding stuff and create the switches etc but what sort of relays do I need to control the solenoids and light bars and what sort of components (diodes and transistors) do I need to ensure it all works? I was hoping to control the 12V with the relays but it doesn’t appear to be as simple as that.

Thanks
Mark

1 Like

Hi Mark.

I was just browsing and came across this.

Why not. Relays can be used to switch anything you want (within reason, be wary of 240VAC mains).
There is no reason you can’t switch 12V as the contacts are completely isolated from anything else. It is the driving of them that may be tricky. Relay current capability is important.
Cheers Bob

1 Like

Hi Bob,

Yeah so I sort of understand what you’re saying. Is it that I need some transistors to make the solenoid fire and a diode to make sure the current doesn’t end up back in the circuit where I don’t want it to go?

Obviously not an electronics expert!

Ta
Mark

Hi Bob,

I found your schematic diagram on another core electronics article. I am definitely going to use a 12V power supply to drive the solenoids. I can’t see how you could ever achieve that without blowing up the arduino. That is why I was going to use relays to turn them on and off. If I am using relays to send 12V to the solenoid, do I need a transistor? My understanding is that the transistor can produce greater current than the power supply and so I still need them. Which one would you recommend?

I had planned on using the same power supply to power the arduino as well. Can this be done? I was just going to hook that into the Vin/VCC pin on the arduino. I’ve done that before and it is has been fine but haven’t done it with a solenoid.

It seems as though you have a GND for the solenoid power and a GND for the arduino power. Would I be right in saying that they are all the same thing? If I am powering the arduino with the same 12V power supply, does it matter where I hook the GND up to?

I know these may sound like stupid questions. For that I apologise. My student is a high achiever but she doesn’t have the experience to work out an issue like this and clearly I don’t either!

Ta
Mark

Core has an excellent tutorial on using relays:
Relay Operation and the Arduino Uno - Tutorial Australia (core-electronics.com.au)

The relay will switch the +12V supply to the solenoid. The other connection to the solenoid will be to the negative of the solenoid supply, so when the relay closes the circuit will be completed and the solenoid will operate. For DC projects this negative side of the supply will often be a Gnd, and will often be the same ground that the MCU uses. But the relay switch is quite separate from any other part of the circuit, and it is not necessary that the solenoid supply negative is the same as the MCU ground.

If you choose a relay module (as distinct from a bare relay device) then you will choose one that can be safely driven from the output of the MCU - this is accomplished with the ‘transistor’ that you are thinking that you need. It’s usually an opto-isolator plus a transistor and few other bits.

Hi Mark
I don’t know which schematic you found, there are several.
I reproduce one here.
image

The CE04538 is a little Freetronics module with a Mosfet and a couple of required resistors mounted on it, very convenient.

For the solenoids you don’t need a relay as you can drive them directly. This circuit is fine for solenoids or relays. Your choice.

A transistor (or Mosfet) cannot generate current, they can only operate with the current you supply to them. I have used a Mosfet here as they have a lower ON resistance (and as a result produce less heat) than a transistor. I think the inference with that statement is they can CONTROL more current than the switching device (Arduino etc) and you possibly mis interpreted the information.

It can but not via the Arduino. The output from the Arduino is 5V and anyway has not got enough current capability to operate solenoids or most relays. Always safest to use external power.
It think this depends somewhat on the flavour of Arduino. I believe models like UNO R3 etc can be powered with 12V into VIN or the barrel jack but 12V is considered maximum or risk overheating the on board regulator. You would have to investigate your version.

Don’t do that. Even if they are the same power supply it is cleaner and tidier to connect the Arduino separately.

Yes. All grounds should be connected. Try to avoid a “rats nest” as it will not only be messy but is more prone to mistakes.

All together and eventually to supply negative see “rats nest” above.
Cheers Bob
PS: There are some 5V and 12V relay boards around which might be a bit more convenient if relays are required. One is similar to the circuit above with on board misfit to drive the relay but does require a 1k resistor in series with the “EN” connection (mosfet gate) from Arduino.

2 Likes

Hi Mark,

For a beginner I’d recommend going with a relay module as that simplifies some of the circuit design considerations and you can instead focus on integrating modules that should work with each other.
We’ve got a category for Relay Modules on the site with a selection.

I personally would recommend something like this one if you need to drive a 12V device from an Arduino and aren’t comfortable soldering.

@Robert93820 's diagram covers what the relay module is doing on the inside. So it’s true you could do away with the electromechanical relay and just use a MOSFET instead to drive the solenoid, but there’s more design considerations to be made with that path.

2 Likes

Hi Trent

That is the one I was referring to. I think this one requires the 1k resistor in series with the gate or “EN” connection. While you are on board here has Pololu offered any explanation as to why a resistor is not fitted here on the board. That Freetronics module I sketched has this fitted. As the Mosfet gate is a short to source at switch on I think this resistor is required as a current limiting resistor to protect the Arduino or whatever driver I/O from accumulative damage.

Eh!!! Don’t quite see that when you are completely doing away with another set of contacts and the relay coil etc. Everything else is the same
Cheers Bob

Hi All
Add on
As this is primarily an education exercise would it not be better to examine all options. Relay and direct switching.
Cheers Bob

Hi Guys,

Thanks for all the advice. Great stuff!

I did find a video that used a tip102 transistor and a IN4001 diode to control a solenoid. The pinball project is a major design project that is supposed to be scaleable i.e. some schools will choose to do it with no electronics at all whilst others may want 4 bumpers, 2 light bars, electric flippers, scoreboard and sound. It all depends on how much cash they have to spend on each student project. A website will be created to sell the different components and then students can decide what they want to put on their machine. I am designing the circuit on fusion 360 and I will be getting the PCBs made on pcbway. I understand that I could just use a relay module to control the solenoid / light bars but as more and more things are added, it will become a mass of relays and wires. I have used 10 pin JST connectors to connect the boards so that you just need to clip in a few plugs rather than a mass of wires everywhere, trying to eliminate the need to troubleshoot when the student plugs it in incorrectly. Each servo / solenoid / light bar have JST connectors on them. I have one PCB with connectors on it that all of the light bars and bumpers etc can connect into. That will connect to the main board that I am creating via the 10 pin JST connectors. The main board will be a ‘shield’ for the Arduino Mega and have the connectors on it wired to the correct pins. If I use tip120s instead of a relay module, I will be able to fit them on the main board and I won’t need to run wires everywhere. I will test with the tip120s before I create the boards. If that works, I will go with that, just to save space and wires. I think they are also cheaper. I got the tip120s of ebay for $0.50 and they are even cheaper off Ali Express. The diodes were $0.20 each.

If I test it and it works without getting hot and it works for a solid amount of time then I’m happy with that.

Thanks again,
Mark

2 Likes

Hi Mark

Don’t forget you gets what you pays for. Especially in this business. Personally (that’s just me) I prefer to purchase name brands as distinct from very cheap Chinese copies. Less problems that way.

If the diodes are being fitted across the solenoids they probably should be schottky but you might get away with 1N4001. No guarantee though, they are pretty slow.

If the students are just going to buy a handful of bits to plug together they are not going to learn much are they.

This is starting to smell like a commercial venture. If that is so leave me out of it. I have expressed concern previously about the pitfalls which could occur by getting involved commercially. OK for Core if they stick to just selling the bits.
Cheers Bob

1 Like

Hi Bob,

It is a ‘psuedo’ commercial venture. The idea for her major project is that it is a pinball machine project designed to be sold to schools although it never actually will be. There is no way you could ever make it work as a business venture. There wouldn’t be enough people involved in making it worth your while.

We are just trying to create a major project that she can get 60/60 for. She needs to investigate everything about the project, comparing the different parts available to what is required and also taking quality and durability into account. She needs to investigate things like mass production and how you would bring a project like this to market. The end goal is a website with parts that you could buy to put together, however it will never actually be ‘live’. Without injection moulding, you’d need to be 3D printing for the next 1000 years to make a go of it.

Your responses here are excellent for her folio as this is the type of research that needs to happen to get the project into the upper range of marks. She should really be experimenting with the different components, including the cheap chinese ones and the ones from reputable suppliers. She may have time to do that but not for all of them. There are too many to do that.

I did see someone else mention the schottky diodes. They will be something we try if the ones we bought fail. In terms of the kids’ learning, they are studying engineering design in Year 7 so they need to look at the forces applied by the bumpers, the effect of the location on the ball, rotational forces, gravity, current etc. We won’t have time to look at the coding of the system as it will be a bit complicated but they do that in some of our other units.

The reason we are making it plug and play is that when the whole thing doesn’t work because something hasn’t been plugged in somewhere, it is difficult to find the issue, particularly when untrained teachers are teaching the unit. I will have a line up of kids from other classes outside my door asking me to fix their pinball machine if that’s the way we go. They are getting worse at following instructions!

Thanks again for your help,
Mark

2 Likes

Hi Mark.
That sounds better. A lot less “commercial”.

They should be schottky. The diodes won’t fail but the transistor/mosfet that is driving them and any other electronics in the chain WILL fail.
The reason:
When the solenoid is turned off the collapsing field will generate quite a large voltage in opposite polarity than the voltage applied to it. This voltage will be effectively in series to the supply and add to it and be applied to the transistor/mosfet driving device. This voltage could be quite large and easily exceed the maximum for the transistor/mosfet thus destroying it over time. The diode is there to short out this generated voltage and should be heavy enough to absorb the expected currents which at a minimum will be the same or more as the value required to operate the solenoid. The power rectifier type of diode such as the 1N400X series are relatively slow in operation and will not catch the generated voltage spike before it appears across the driver device. Schottky diodes are very much faster and are better equipped for this job. A popular one as used in most brushed motor speed controllers is the MBR20100CT. This is 2 diodes in the one package with I think common cathode (might be common anode) and usual practise is to connect the 2 diodes in parallel which provides a capability of 20A.
Cheers Bob
PS Unfortunately you will be paying a lot more for the schottky diodes but you will gain in the long run.

1 Like

Hi Bob,

I don’t have an answer for why a series resistor wasn’t included in the design and if Pololu recommends an external series resistor be added when integrating that module. I’ll reach out to them and see what they recommend and let you know their response.

Hi Trent
Thanks for that and I will be interested to see the response. I believe along with many others that a resistor here is required. Although I think the gate capacitor in this mosfet is relatively small and the charge time small in proportion the fact is it is still a short circuit at switch on.

in fact if you research mosfet switching circuits switching higher currents you will see this resistor as low as 10Ω to decrease the time to as short as possible which decreases heat build up in the mosfet itself. In these cases the gate is driven by a PNP/NPN pair of transistors to provide this gate current which could exceed 1A. There are quite a number of dedicated ICs to do this job also. Google “mosfet gate driver” for more info.
Cheers Bob
A pretty good explanation of drivers and why they are needed here
https://diyodemag.com/education/mosfet_drivers_why_you_need_them
Also some pretty good reasons for switching hard on instead of pussyfooting around with 3.3V on 5V devices in the same article

1 Like

Hi Bob,

I’ve received a response from Pololu which I will include as a quote below:

Thank you for your inquiry. The EN pin on our relay carrier boards
should not need an external in-line resistor since the input capacitance
of the FET is only 50pF. If the customer wants to be extra safe though,
adding a resistor should not hurt. Something around 1k should be fine
for an Arduino pin.

It seems the decision point to include the series resistor is really a judgement of how much input capacitance is too much and Pololu has made the decision that with the MOSFET they’ve selected the resistor isn’t required.

1 Like

Hi Trent
Thanks for the reply. As for me I would always include this resistor and I will always advise using it.
50pF or 500pF is still a short circuit at switch on and damage of this nature tends to be cumulative.
It will be up to the end user if they take my advice or ignore it. But don’t complain if something fails due to this damage down stream a bit.
It would probably cost 5C or so to fit one.
Cheers Bob

2 Likes

Hi All,

Just an update on the pinball machine design.

I have created a system with 4 bumpers, LED strip lights, MP3 module and LCD screen. Each object is working in isolation. Just need to code it now.

I have no doubt that there are improvements that can be made to it. This is a school project after all but if it works, even for a short time while the markers are marking it then I’ll be happy!

The board was designed using Fusion 360 and printed at pcbway.com . Given this is a first attempt, I’m amazed it worked!

Thanks for your help guys. Couldn’t have gotten it working without this forum!

If I find any bugs with it, I’ll be sure to ask for advice again.

Cheers,
Mark

1 Like

Looks cool. Have you designed an enclosure for the PCB?

Not yet. My student is quite good at modelling in Fusion so I think she will come up with an enclosure. The boards are 100 x 100mm and she put holes in the board so we can use some stand offs to support the board within the enclosure. Could be a challenge given that the transistors are higher on the board than the connectors. It is possible that the connectors could be on a piece of veroboard rather than wired into the PCB itself to make them easier to access. Will have to think about the pros and cons of that one.

Cheers,
Mark

1 Like