How to ground the external power supply

I would like to control a 12V solenoid using arduino. Naturally, the solenoid is powered using a external power source (a DC adaptor). I am using a 2N2222A transistor to control the current flow.

However, I am stuck with grounding. How do I connect the solenoid circuit to the ground? Can I connect the solenoid to the arduino's ground? I have this doubt because, since arduino's voltage and current is limited to 5V and 40 mA per pin, what happens when the solenoid powered by 12v is connected to arduino's ground?

What are the other alternatives?

If you want to drive the circuits and have them work together without an opto isolator you connect the 12V ground to the Arduino ground so that they share a common ground.

Connecting all grounds will mean you create a common level for all of the different circuits.
If you forget this, there's almost no telling of how the different parts will misbehave, but they will for sure.

Alternative is to use for instance optical isolation.
Using an opto-coupler will allow you to control different devices without an actual electrical connection.
This should be considered for instance when you need to control some part that is directly (without a transformer) to mains supply (110 or 230 VAC).
Also optical isolation is a way to comply with certain regulations, but i don't think that is an issue here.

Yes optocoupler is a better solution. However, what if due to certain considerations, the optocoupler needs to be powered by 12v or 24v external supply? Does connecting the 12v or 24v common to the arduino ground doesn't damage the arduino board?

I have yet another doubt. Assume that the Arduino and the solenoid are connected by the same external dc supply (12v - 2A)(connected in parallel), now how does the grounding go. Should I still connect the transistor's emitter to the arduino's ground?

Firstly if you use an opto coupler one have of the couple is in one circuit the other half is in the other and there is no electrical connection only an optical one.

To answer your other question, if all the grounds connected then electrically you can connect the emitter to which ever ground you like. You do need to ensure there is enough collector resistance though, so that you don't put too much current through to burn out the transistor.

If you're going with the non-isolated approach, then use a star-point connection scheme. Just use a separate wire for each ground, then tie the other ends together. This avoids creating a ground loop where one ground is jumpered another in series.

I have attached 3 images for better understanding. I apologize. I should have added it earlier

Question 01: Both the solenoid and the arduino share a common 12v dc external power source. Now, it is still necessary to connect the common (black terminal) coming from the MOSFET to the arduino’s ground?

Question 02: The solenoid is powered by a 60v dc external power. Again, the common from the MOSFET is connected to the Arduino’s ground. However, since the supply voltage is 60v doesn’t this damage the arduino?
The answer to this question has been given by ‘ChilliTronix’ and ‘MAS3’. However, whats the limit of voltage that can be connected to the ground?

Question 03: Here, the solenoid circuit along with its power source is isolated from the arduino using a relay. Does the solenoid circuit still needs to be grounded. If yes, should it be connected to the arduino’s ground?
Can the isolated circuit (even when connected to multiple devices in parallel) be connected to Earth (of the AC mains)(Wan’t to get clarified of ChilliTronix’s and dlloyd’s view)?

And finally thanks everyone for their patient and prompt replies

There is no limit as to what's connected to Ground - it is ground.
With a relay, the two sides are electrically seperated, there is no ground connection between the supplies.
The relay side can connect to what you want.

Question 01:

No

Question 02: The solenoid is powered by a 60v dc external power. … However, since the supply voltage is 60v doesn’t this damage the arduino?

No because there is no connection between the gate of the FET and the 60V.

I think you are lacking some fundamental theory, read this:-
http://www.thebox.myzen.co.uk/Tutorial/Power_Supplies.html

Hello guys,

Since my question is essentially the same of OP, and is basically a continuation of this very discussion, I think its better to post this question here than creating a new topic which necessarily would refer to this post.

So, the last post from Grumpy_Mike recommended reading a tutorial about Power Supplies, which in the end had this schematic as the "standard" recommendation to projects such as the ones OP was asking about:

I do recognize the reasons why the shared ground is important, the tutorial explained them very well.

But still, one doubt remains. ConsiderArduino Playground, from where we can see that the max current rating for Arduino Uno GND pins is 200 mA. Also, consider I want to control a 12V/2.5A solenoid just as OP was initially asking, with a schematic identical to the one from the tutorial.

When I share the UNO's ground with my external power supply, will it potentially damage the Arduino? This question arises from the following reasoning: the 2.5 A current the solenoid will need, from what I understand, will get out from the 12 V power supply, pass through the solenoid, than from transistor collector to emitter, than will sink into ground, which is where my doubt lies.

Wouldn't this 2.5 A potentially damage the Arduino, since its GND pins can only sink up to 200 mA?

Basing on many tutorials and projects online, I think this does not seem to be an issue, since a GND current restriction is never commented. Why is that so?

Thanks for the help!

PS.: I think I am making mistakes with this maximum GND pin current concept... Or with the theory of how grounding works (I cant see why all current would sink into the source GND and not to Arduino GND).

the 2.5 A current the solenoid will need, from what I understand, will get out from the 12 V power supply, pass through the solenoid, than from transistor collector to emitter, than will sink into ground, which is where my doubt lies.

In that diagram there are two circuits, a high current one on the right, and a low current one on the left. The
1k resistor means that only small currents can possibly flow on the left, as there is at least 1k in that circuit
at all times.

I think you are not taking in that the whole circuit determines the current flow, current doesn't just go
where it likes. The left hand circuit controls the right hand circuit, but sees only a small fraction of
the current.

MarkT:
I think you are not taking in that the whole circuit determines the current flow, current doesn't just go
where it likes. The left hand circuit controls the right hand circuit, but sees only a small fraction of
the current.

So, the Arduino GND pin only receives the small current that went out from the digital output pin?

ren1:
So, the Arduino GND pin only receives the small current that went out from the digital output pin?

Yes.

Nice! Thank you very much guys!

Hi,
shapeimage_10e.jpg

Tom… :slight_smile:

The only part of the circuit that sees the LOAD current from the Solenoid AND the return path from the PIN turning on the transistor is the one (node) wire from the transistor EMITTER pin to GND. The Arduino PIN only ever sees the load needed to turn on the transistor.

This is WHY we love transistors. HECK, this is why Transistors got invented... to turn SMALL currents into BIGGER currents.

Thanks Tom +1
Changed the diagram on my web site to reflect this. Hope it helps to clear up any confusion.

This does raise a point however about wiring layout. You do not route any part of the circuit carrying the heavier current through any part of the Arduino. The Arduino's ground is connected to the emitter of the transistor (Source terminal of the FET), not the other way around.

This is particularly important not merely in terms of the continuous current flowing through the switching circuit, but for avoiding transients due to the switching on and off of that current, to be conveyed to the Arduino part. This is a major source of problems we encounter here.

I frequently stress the need to keep the wiring from one part to another together, power wire with ground return; control wire with its return (which return for many common relay modules, is not the ground). The idea is to avoid loops which permit inductive coupling; we are dealing with devices which are operating at HF (3 to 30 MHz) radio frequencies here, electromagnetic transmission is a very real matter.