0
Offline
Newbie
Karma: 0
Posts: 23
Arduino rocks
|
 |
« on: January 12, 2011, 11:07:08 pm » |
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
|
|
|
|
|
Austin, TX
Offline
Faraday Member
Karma: 41
Posts: 5162
CMiYC
|
 |
« Reply #1 on: January 13, 2011, 12:14:17 am » |
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
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15309
Measurement changes behavior
|
 |
« Reply #2 on: January 13, 2011, 01:04:43 am » |
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
Newbie
Karma: 0
Posts: 23
Arduino rocks
|
 |
« Reply #3 on: January 13, 2011, 01:42:43 am » |
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
Brattain Member
Karma: 279
Posts: 15309
Measurement changes behavior
|
 |
« Reply #4 on: January 13, 2011, 01:49:00 am » |
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
Newbie
Karma: 0
Posts: 23
Arduino rocks
|
 |
« Reply #5 on: January 13, 2011, 02:29:26 am » |
 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
Brattain Member
Karma: 279
Posts: 15309
Measurement changes behavior
|
 |
« Reply #6 on: January 13, 2011, 02:51:33 am » |
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.  Lefty
|
|
|
|
« Last Edit: January 13, 2011, 02:57:07 am by retrolefty »
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 23
Arduino rocks
|
 |
« Reply #7 on: January 13, 2011, 03:11:32 am » |
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
Brattain Member
Karma: 279
Posts: 15309
Measurement changes behavior
|
 |
« Reply #8 on: January 13, 2011, 04:13:47 am » |
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
Edison Member
Karma: 12
Posts: 1800
There is an Arduino for that
|
 |
« Reply #9 on: January 13, 2011, 07:40:42 am » |
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)
Offline
Brattain Member
Karma: 269
Posts: 25392
Solder is electric glue
|
 |
« Reply #10 on: January 13, 2011, 08:56:19 am » |
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
Newbie
Karma: 0
Posts: 23
Arduino rocks
|
 |
« Reply #11 on: January 13, 2011, 02:36:19 pm » |
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
Brattain Member
Karma: 279
Posts: 15309
Measurement changes behavior
|
 |
« Reply #12 on: January 13, 2011, 02:45:26 pm » |
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
Edison Member
Karma: 12
Posts: 1800
There is an Arduino for that
|
 |
« Reply #13 on: January 14, 2011, 07:41:33 am » |
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
|
|
|
|
|
0
Offline
Jr. Member
Karma: 0
Posts: 66
Arduino rocks
|
 |
« Reply #14 on: January 18, 2011, 08:07:16 pm » |
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 
|
|
|
|
« Last Edit: January 18, 2011, 08:08:20 pm by zaphil »
|
Logged
|
|
|
|
|
|