Digital Output pin set LOW vs. GND pin?


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

Even if a gate is 1000pf, it will not blow the pin unless you drive it REALLY fast.

IRF510 is rated at 100V 5A and has a gate capacitance <200pF.

Rise and fall times are a few tens of nS.

I've driven these directly from an output pin with not the slightest hint of a problem.

I've driven these directly from an output pin with not the slightest hint of a problem.

You won't have until they fail. A short circuit is a short circuit no matter how brefley it occours and it is exceeds the absolute maximum in the data sheets.

You definitely need a resistor there in case the MOSFET fails. Because they very often fail with the gate short-circuiting to one of the other pins. The result is that your high-power motor or light or heater could be effectively wired directly from high voltage to the Arduino's pin, unless you have a protective resistor.

I've also found I need a gate-source resistor like Retrolefty suggested. Even the brief time a pin is high-impedance during a reset cycle was enough to fry one of my MOSFETS :frowning: And they switch on so much current so quickly it induces spiky voltages all over the place, I had to add some capacitance just to slow the things down.

I'm very jealous of all you people who have them working wired directly! :-[ Mine need at least two resistors and a capacitor...