Arduino Forum

Using Arduino => General Electronics => Topic started by: jeanpaulsc on May 12, 2018, 11:28 pm

Title: can I safely ground 12v (vcc) to digitalWrite(pin, LOW);
Post by: jeanpaulsc on May 12, 2018, 11:28 pm
I would like to ground an NPN emitter to the pin adjacent to it's base. Is this a bad idea? The NPN's function is to open a 12v solenoid.
Title: Re: can I safely ground 12v (vcc) to digitalWrite(pin, LOW);
Post by: avr_fred on May 13, 2018, 12:40 am
Bad idea? That impossible to say as this statement:
Quote
I would like to ground an NPN emitter to the pin adjacent to it's base.
makes no sense. While it is correct that that you ground the emitter in a typical npn switch circuit, what pin and base are you referring to?

Perhaps a photo to explain?
Title: Re: can I safely ground 12v (vcc) to digitalWrite(pin, LOW);
Post by: Wawa on May 13, 2018, 01:23 am
I think OP is asking if you can use a digital output pin as ground pin for the emitter of an NPN transistor that drives a solenoid.
The answer to that is NO.
Because all the solenoid current will then flow through the Arduino pin, which has an absolute limit of 40mA.
Leo..
Title: Re: can I safely ground 12v (vcc) to digitalWrite(pin, LOW);
Post by: ReverseEMF on May 13, 2018, 01:44 am
It sounds like you might be talking about this:

(http://forum.arduino.cc/index.php?action=dlattach;topic=547110.0;attach=257525)
And if so, then the way to language this is: The Arduino Digital Output, tied to the Base of the NPN Transistor, through a series [current limiting] resistor, Grounds the 12V connected mystery thing, when D? is HIGH, and un-grounds it when D? is LOW.  D? can be any of the Arduino Digital Outputs. 

A Bipolar Transistor is a Current Amplifier.  In other words, a small current flowing from the Base to the Emitter, controls a larger current flowing from the Collector to the Emitter.

You need the transistor because the Arduino Output mustn't go higher than 0.5V more than VCC.  If the Arduino has a VCC of 5.0V, then the output pins mustn't go higher than 5.5V.  If an output is connected to something that goes to 12V, then, when the output is HIGH, there is the danger of that 12V source pulling the output higher than 5.5V

Also, Transistor selection depends on what it is that you want to switch.  How much current will it draw?  Is it just going to 12V or is there more to the circuit?  We very much need more information to properly answer this question, so if you can provide a schematic or good photo or something that would allow us to know what it is you are trying to do, that would be a BIG help ;)

UPDATE:  I missed that the "Mystery Device" is actually a solenoid, so I added a protection diode to the schematic diagram (above).

Also, if that solenoid draws more than 200mA Max, use a MOSFET.
Title: Re: can I safely ground 12v (vcc) to digitalWrite(pin, LOW);
Post by: RIN67630 on May 13, 2018, 05:03 am
I would like to ground an NPN emitter to the pin adjacent to it's base. Is this a bad idea? The NPN's function is to open a 12v solenoid.
Yes, that IS a bad idea.
If you ask, then you probably have got no experience with DC solenoids, which are is one of the weirdest thing in electronics.

If you don't know how to drive them, go for the safe way and use a relay shield.
Title: Re: can I safely ground 12v (vcc) to digitalWrite(pin, LOW);
Post by: Southpark on May 13, 2018, 09:05 am
I would like to ground an NPN emitter to the pin adjacent to it's base. Is this a bad idea? The NPN's function is to open a 12v solenoid.
Draw a circuit diagram for clarity. Draw the transistor, and add some text and arrow to point to the terminal that you want to 'ground'. The title of your post is unclear. In general, we want to avoid connecting 'Vcc' to 'ground'.
Title: Re: can I safely ground 12v (vcc) to digitalWrite(pin, LOW);
Post by: jeanpaulsc on May 13, 2018, 11:54 pm
This is what I had in mind:

(my image was here, but I cannot seem to attach to an edit. Image in 5 min)

It certainly can't draw power from the pin, though it draws very little, but my question was really can I safely ground to a pin set to LOW.

I don't see why not. If not, is there a danger grounding to a GND pin?
Title: Re: can I safely ground 12v (vcc) to digitalWrite(pin, LOW);
Post by: Wawa on May 14, 2018, 12:03 am
Image doesn't work.

Setting a pin HIGH connects the pin internally to VCC (5volt) with a mosfet switch with an absolute max current rating of 40mA.

Setting a pin LOW connects the pin internally to GND with a mosfet switch with an absolute max current rating of 40mA.

So you can't 'drain' more than 40mA to ground through an output pin.
Leo..
Title: Re: can I safely ground 12v (vcc) to digitalWrite(pin, LOW);
Post by: jeanpaulsc on May 14, 2018, 12:04 am
This is the image (attached).
(Not intuitive. Do I really have to upload it to an arbitrary site?)

Regarding the current limits, does the GND pin have the same limit?
Title: Re: can I safely ground 12v (vcc) to digitalWrite(pin, LOW);
Post by: Wawa on May 14, 2018, 12:06 am
The full solenoid current would flow from collector to emitter through the pin to ground, likely blowing the pin.

The base of an NPN transistor NEEDS a current limiting resistor.
Base current for full saturation of the 'switch' should be 5-10% of the collector current, depending on the transistor.
If that's more than ~20mA, then you should switch to a darlington or mosfet.
Leo..
Title: Re: can I safely ground 12v (vcc) to digitalWrite(pin, LOW);
Post by: jeanpaulsc on May 14, 2018, 12:15 am
The base of an NPN transistor NEEDS a current limiting resistor.
Base current for full saturation of the 'switch' should be 5-10% of the collector current, depending on the transistor.
If that's more than ~20mA, then you should switch to a darlington or mosfet.
Enlightening. Thank you.
Title: Re: can I safely ground 12v (vcc) to digitalWrite(pin, LOW);
Post by: Wawa on May 14, 2018, 12:19 am
A TIP120 is a good choice for a solenoid.
It still needs a base resistor, but base current for that darlington is 1:250 for saturation.
Note the higher BE voltage (~1.5volt) when you calculate the base resistor.
Don't forget the back-EMF diode across the solenoid.
Leo..
Title: Re: can I safely ground 12v (vcc) to digitalWrite(pin, LOW);
Post by: ReverseEMF on May 21, 2018, 12:54 am
A TIP120 is a good choice for a solenoid.
It still needs a base resistor, but base current for that darlington is 1:250 for saturation.
Note the higher BE voltage (~1.5volt) when you calculate the base resistor.
Don't forget the back-EMF diode across the solenoid.
Leo..
The thing about a Darlington Transistor is the fairly high Emitter Collector saturation voltage.  A MOSFET is a much better choice.
Title: Re: can I safely ground 12v (vcc) to digitalWrite(pin, LOW);
Post by: Wawa on May 21, 2018, 01:07 am
The thing about a Darlington Transistor is the fairly high Emitter Collector saturation voltage.  A MOSFET is a much better choice.
Not much difference if you power a solenoid with 11.25volt (darlington) or 11.95volt (fet).

Different story if you switch a LED strip.
Then a 1volt drop could have a light power reduction of 40%.
Leo..
Title: Re: can I safely ground 12v (vcc) to digitalWrite(pin, LOW);
Post by: ReverseEMF on May 21, 2018, 02:34 am
Not much difference if you power a solenoid with 11.25volt (darlington) or 11.95volt (fet).

Different story if you switch a LED strip.
Then a 1volt drop could have a light power reduction of 40%.
Leo..
Try more like 10.8V, but I get your point -- it's probably a trivial difference [though, with the right MOSFET, that voltage could be closer to 12V -- not sure where you get 11.95 -- but even so, still, probably, trivial], BUT, there is another parameter to consider: Power Dissipation.  With a higher voltage drop across the switch, there will be greater Power Dissipation.  Whereas, with a MOSFET, the Power Dissipation can be nil in all but the most extreme cases.  There is no way to get the Emitter-Collector voltage down on a Darlington -- it will always be at least 1.2V, and probably more like 2V for higher currents.
Title: Re: can I safely ground 12v (vcc) to digitalWrite(pin, LOW);
Post by: Wawa on May 21, 2018, 03:09 am
Fairchiled TIP120 datasheet, Figure 2.
A TIP120 has a CE saturation voltage of ~0.6volt@1Amp, and ~1volt@3Amp.
Assuming a collector/base current ratio of 1:250.
Leo..
Title: Re: can I safely ground 12v (vcc) to digitalWrite(pin, LOW);
Post by: ReverseEMF on May 21, 2018, 03:36 am
Fairchiled TIP120 datasheet, Figure 2.
A TIP120 has a CE saturation voltage of ~0.6volt@1Amp, and ~1volt@3Amp.
Assuming a collector/base current ratio of 1:250.
Leo..
That's if the transistor is running hot.  More like 0.8V at room temp.  But, you're right, for currents that low, the VCE(sat) is much lower than I stated.  But, we really don't know what current that solenoid is going to require, and since we haven't heard from the OP for a while, we may never know ;)