Pages: [1] 2   Go Down
Author Topic: Digital Output pin set LOW vs. GND pin?  (Read 12778 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?  :-?
« Last Edit: January 13, 2011, 12:09:13 am by Joeinator » Logged

Fort Lauderdale, FL
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6144
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.c

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17303
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: January 13, 2011, 01:06:03 am by retrolefty » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17303
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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: http://pdf1.alldatasheet.net/datasheet-pdf/view/175434/ONSEMI/TIP122G.html)
« Last Edit: January 13, 2011, 02:34:28 am by Joeinator » Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17303
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.  smiley-wink

Lefty
« Last Edit: January 13, 2011, 02:57:07 am by retrolefty » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17303
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

France
Offline Offline
Faraday Member
**
Karma: 39
Posts: 3627
There is an Arduino for that
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: January 13, 2011, 07:41:03 am by fdufnews » Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 637
Posts: 34584
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17303
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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
Logged

France
Offline Offline
Faraday Member
**
Karma: 39
Posts: 3627
There is an Arduino for that
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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
« Last Edit: January 14, 2011, 07:43:04 am by fdufnews » Logged

Right Here!
Offline Offline
Jr. Member
**
Karma: 0
Posts: 66
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley
« Last Edit: January 18, 2011, 08:08:20 pm by zaphil » Logged

Pages: [1] 2   Go Up
Jump to: