Solenoid Control Via Arduino Mega and Shift Out Register

Hi there, new to Arduino so inevitably I have some questions. This isn't the full circuit (the final circuit will have more solenoids and switch inputs) but hopefully my drawing illustrates my goal. Im using two TDK Lambda AC to DC power converters for power (5V for the Arduino/Shift Register and 48V for the two solenoids, which are flippers for a pinball machine). Here is my first question:

  1. I've read about the different ways one can power an Arduino (USB, Power Jack and VIN Pin). From my understanding, using the USB will limit you to about 500mA of current. The power jack requires more than a 5V input (something like 7-12V) because this power is regulated, but you can use a power jack which can supply more current (such as 1A). But what if you use an external power supply? Is it correct to connect the positive lead to the VIN pin and negative lead to the Arduino ground pin? Also is there any restrictions on this power supply, as in, is there a current limit or voltage tolerance for connecting an external power supply in this way?

As you can see in my drawing, I'll be using a 74HC595 shift register to control (as of now) 2 MOSFETS, consequently controlling the two solenoids.

  1. Does it matter which digital pins from the Arduino I use to connect the 74HC595 ShiftOut Register to? I saw a similar setup from another diagram where DS (Serial Data Input) of the Shift Register was connected to a PWM pin on the Arduino. Is this a requirement? What about the other pins?

My last question just has to do with basic wiring.

  1. Does my wiring look safe and correct? Am I correct in connecting the negative leads of my two power sources to a common ground shared by the other components?

Thanks in advance for your replies. Any advice is appreciated.

Hi, welcome to the forum.

Why are there 20 ohm resistors to the mosfet gates ? Could you make it 150 ohm ?
With 150 ohm, the 74HC595 can be powered by the Arduino 5V pin.
Which mosfets do you use ?

You can use any pin for the shiftOut() function.
https://www.arduino.cc/en/Reference/ShiftOut

Never ever use a capacitor on the clock signal. I know that you can find that on the internet, even in a Arduino tutorial, but that is so wrong :stuck_out_tongue_closed_eyes:

The power jack is almost the same as VIN, only the power jack got an extra protection diode.
If you apply 5V to VIN, that is still before the voltage regulator, and the microcontroller won't run at 5V.
About 7.5 ... 9V to the power jack or to VIN is the best.

You must be aware of ground current and how to connect the grounds.
The best option is a single point to which all grounds are connected.
Since the 48V is the most dangerous, follow the current from the 48V to the solenoids, to the mosfet, to ground and back into the 48V power supply. That current may not go through the Arduino board, and may not lift the ground level of the mosfet too much.

Thanks for your in depth reply. I'll try to answer all of your questions/concerns:

I didn't really know what value the two resistors going to the mosfet gates should be, all I know is that the resistor helps reduce an effect called ringing. I was told on another forum to use between 10 and 33 ohms. Why should it be 150 ohms?

This is only a sample of what my final circuit will look like. This will be part of a pinball machine I'm making, this schematic is for controlling the solenoids (such as flippers and slingshots). Not included is the LED lights matrix, Scoring display (7 Segment LED displays), switch matrix and possibly sound. I thought it would be best to use the 5V supply from TDK Lambda to power all of these, not the Arduino, or is this not necessary/make sense? I'm a little confused on what you mean by this question. Do you mean that the Arduino can supply its own power supply to the shift register?

The Mosfets that I will use are FQP30N06L N-Channel 60V 30A Mosefts from Sparkfun.com (here's a link N-Channel MOSFET 60V 30A - COM-10213 - SparkFun Electronics).

Just like you said, I copied the capacitor idea from a similar online circuit. Why is this incorrect?

So you are saying I must use a higher voltage supply (such as 9V) in order to power the Arduino at 5V? Is there any way of using an external supply of 5V (not through the power jack or USB)to power the Arduino?

I'm still confused about the ground connections. Perhaps a diagram could help, but thanks again for the information!

With 150 ohm, the peak current is less. A gate is like a small capacitor, and when it is set high or low, a short peak current occurs. You can safely use up to 1k for the gate resistor.

A capacitor at a digital output pin is always bad. When using a 74HC595 with an Arduino there is no need at all for such a capacitor.
I think this shows how to do it : ExempleDémultiplexeurNumérique74HC595 @ Arduino @ t-o-f

That mosfet is okay, but the 45V is very close to the limit of 60V of the mosfet.

A voltage of 7.5V or 9V is normal to the power jack or VIN, and then the Arduino 5V pin can be used to power the 74HC595.
About using 5V to power the Arduino, I wrote this a few days ago about powering my projects with 5V : Mega R3 doesn't show up in device manager, not even unrecognized device - #6 by Peter_n - Installation & Troubleshooting - Arduino Forum

You can power the Mega with 5V thru the USB connector. 500mA limit.
You can power the Mega with 5V thru the 5V header. Add a diode from 5V (anode) to Vin (cathode) to avoid reverse driving the regulator too much and damaging it. Connect 5V/Gnd in parallel to whatever circuits you are driving.

Peter_n:
You must be aware of ground current and how to connect the grounds.
The best option is a single point to which all grounds are connected.
Since the 48V is the most dangerous, follow the current from the 48V to the solenoids, to the mosfet, to ground and back into the 48V power supply. That current may not go through the Arduino board, and may not lift the ground level of the mosfet too much.

Then what is the GND pin on the Arduino for? Don't I need to have a GND connection the Arduino to make sure everything has the same reference point? Any info would be very helpful, I am pretty confused about this.

Did you understand to follow the current path of the 48V through the relays ? That current may not disturb the Arduino. It may certainly not go through the Arduino board.
If you just connect ground wires as in the schematic, there might be no obvious path that the current will take.
This can be avoided by a single point to which all ground wires are connected.

You could do this:
Make that single GND point. Connect the -V of the 48V power supply to it. And connect the source of the mosfets to that. Also the Arduino GND to that single point.

The 5V power supply is on its own, since it is only for the Arduino (and the 74HC595). You can use it to power the Arduino board via the usb connector or in an other way. But you can use the single ground point also for the 5V power supply. In that case connect the -V to the single ground point and the +V to power the Arduino.

Did I explain it better ? Keep asking if you don't understand :stuck_out_tongue:

Peter_n:
Did I explain it better ? Keep asking if you don't understand :stuck_out_tongue:

Yes I understand now, thanks for not giving up on me :slight_smile: You're saying that instead of having all these different connections to the ground wire at different positions along the wire, connect all of the wires leading/connecting to ground at a single point. This is because, according to my diagram, it is possible that the current path could bypass the Arduino GND pin. Just looking for confirmation.

Also since I'll be working with different gauge wire, what is the best method of soldering and or joining two varying gauges of wire together?

One last question, what alternative is there to using veroboard (as 48V will destroy the board)? Since the Mosfets are through hole mounting I want to use some sort of board. Is this possible when 48V will be passing through it? Thanks.

With 'bypass' you mean that the ground current could take an other router ? Then that is what I mean.
Ground currents are funny things. They prefer sometimes thin wires over thick wires (if for example if the positive wire is next to the thin wire with the returning current). The high frequency currents are even worse. But those will also be very minimal with a single point to connect all grounds.

To connect two wires, I keep the wires straight and overlap them about 5mm to 10mm and solder that. I don't twirl them. Then one or two heatshrink tubes over it.

When it is a mains cable and there will be a lot of stress on that cable, then I bend the wire back with the loops in each other. I might even use thin copper wire to wrap it around the ends. Then I solder everthing.

Veroboard is fine. I see no problem with 48V.
When a wire is soldered to a board, I use hot glue ("hot snot") to fix the wire to the board. That prevents that the wire will break.

CrossRoads:
You can power the Mega with 5V thru the 5V header. Add a diode from 5V (anode) to Vin (cathode) to avoid reverse driving the regulator too much and damaging it. Connect 5V/Gnd in parallel to whatever circuits you are driving.

Correct me if I am wrong, I thought the "5V" Pin could only be used for outputting 5V, not for inputting 5V. If you can do this like you say you can, must you assign the 5V Pin as a particular input in setup?

Look at the Arduino schematic - 5V is the power bus, either driven from USB, from the 5V regulator, or from an external supply. No pin setup is needed.