Digital Output pin set LOW vs. GND pin?

What is the difference between the GND pin on the Arduino Uno and a digital pin set as an output and LOW?
I'm trying to use an output pin to turn a darlington transistor on and off to send power to a motor. The transistor is NPN. (TIP122G). Basically, I need to ground the base of the transistor to allow the motor to turn on. If I connect it to a GND pin on the Arduino, the motor turns at the rate I want to. If I connect it to a digital pin and set it to LOW however, the motors barely get enough power to turn. What is a digital pin set to LOW doing that a GND pin isn't? :-?

Are you sure you've set the pinMode() for the I/O pin to OUTPUT?

You should probably measure (or calculate) the amount of current you expect to flow from the base through the pin. In any event, you should still be using a series limiting resistor to make sure no more than 20 or 30mA flows through the I/O pin.

Normally one has to turn an output high if wired to a base (with series base resistor)of a NPN transistor, if emitter is grounded and collector to load and then to positive voltage, so called low side switching. Perhaps if you could post a drawing of your circuitry we might be able to figure it out.

A digital output low is a direct connection to ground as long as the current demand is lower then 40ma, above that damage to the pin will result. A arduino output pin can both sink (when low) and source (when high) current up to the max current rating stated above.

Lefty

I've definitely set the pinMode to OUTPUT. The current seems to only flow through the transistor when I put the base to GND. Is this what should happen?

Is this what should happen?

That depends how everthing is wired up, including the load and external power supply. Without a drawing to see what and how you wired everything we can only speculate. A picture is indeed worth a thousand words in cases like this.

Lefty


Here is what I have wired together. I can't understand why connecting the base of the transistor to pin 2 and setting the output to LOW gives less power to the motors than putting the base to GND. Also, I don't understand why I'm using GND to 'turn on' the transistor. I thought it required power through the base to allow current to flow through the collector and emitter. This seems to be the only way I can get any response from the motor in my circuit... :-[

(Maybe this will help? The transistor I am using is a TIP122G NPN transistor: TIP122G pdf, TIP122G Description, TIP122G Datasheet, TIP122G view ::: ALLDATASHEET :::)

The problem is that your resistor is both the wrong value and wired in the wrong place. Remove that 100k ohm resistor and wire a 200 to 1,000 ohm resistor between the output pin 2 and the base terminal of your transistor. Lastly make sure you run a wire from the battery minus terminal to an arduino ground terminal. All should be fine with those changes made.

However there is a chance that you might have damaged the output pin 2 due to not having a series connected resistor between pin2 and the base. You may have to test using a different output pin.

See I told you a picture was worth many many words. :wink:

Lefty

Thanks for your help. But it's still not working... :-/
Now the the transistor responds to neither 5v or GND on the base, and I've tried using both a 300 ohm and 1000 ohm resistor. Just to clarify, this is what I'm at now:

Well the circuit is now correct as drawn. Now we have to test if the transistor or output pin is defective.

First test: Remove the resistor from pin 2 and plug it into the arduino +5vdc pin. If the motor runs then the transistor is good and we need to test the digital ouput pin2. If the motor doesn't turn on with +5vdc applied to the resistor then you have a bad transistor, or possible you have misidentifed the proper terminals for the transistor, check the datasheet to make sure you know which is base, emitter and collector.

Second test: If motor ran with +5vdc applied to the resistor, then move the resistor to another pin2 and change your software to use that new output pin. Also make sure you are using pinMode(pin, OUTPUT); properly to set the pin to output mode.

Good luck;

Lefty

First test: is controlling the pinout of the transistor
Second test: controlling it is correctly wired.

If you have wired as in your drawing, connecting the base of a NPN to ground had never made flowing current through the collector. So either the transistor is defective or it is uncorrectly wired.

So either the transistor is defective or it is uncorrectly wired.

Or you blew it up with the first wrong circuit you used it in.

Ah! Solved it. You were right. I'd misidentified the proper terminals. I couldn't find it on the datasheet before, but I've located it at the bottom of the page.
I assumed the terminals were (from left to right) emitter, base, collector.
Turns out they are actually base, emitter, collector, for this transistor. But now connecting it to 5V works! Also, I tested it with a script for digital pin 5 and it also works! You've allowed me to continue working on my project and helped me learning! Thanks very much for all your help!! ;D ;D ;D

I assumed the terminals were

A very valuable lesson learned, never assume wiring decisions. Always use references to determine proper terminals of components if you are not 100% sure.

Glad you got it working and good luck on your further progress.

Lefty

Turns out they are actually base, emitter, collector, for this transistor

Well I am very surprised. Are you sure?
I think you have exchanged emitter and collector. If I were you I will double check.

Look here --> http://www.datasheetarchive.com/Indexer/Datasheet-051/DSA0031567.html

Hmmm. B-C-E is quite common and lots of transistors will work (poorly) with the C & E terminals swapped!

Personally I prefer to use a FET - no resistor needed at all then :slight_smile:

Personally I prefer to use a FET - no resistor needed at all then

Me too. My favorite $1 transistor:

All though it is a good safety idea to add a 10k resistor between gate and source, in case arduin power is turn off but device power is still on, that will ensure mosfet stays off.

Lefty

Personally I prefer to use a FET - no resistor needed at all then

Sometimes true... but they can also be a lot more finicky when working with TTL logic levels.

Poor transistors... they get no love anymore. If you talk to them nicely (bias and buffer them them nicely with resistors) they are really quite sweet.

Some good advice: I feel you can never have too many 0.1uF Caps or 1K, 10K, 4.7K resistors, or 2N2222A, 2N2907, 2N7000's in your parts bin.

N-Channel MOSFET 60V 30A

is overkill for nearly everything I do. A 2N2222A with one or two resistors can accomplish so much and do it cheaply.

use a FET - no resistor needed at all then

Except of course to protect the arduino from over current when it charges the discharged capacitor and drives into an effective short circuit for a small fraction of the time. 100R should be enough to keep it safe.

What is the gate capacitance of a mosfet gate?
If its less then say, 0.01uf, i would not worry about the spike too much.

What is the gate capacitance of a mosfet gate?

Depends on the specific mosfet and is given in the device datasheet. Larger current ratings have larger gate capacitance.

Lefty