Go Down

Topic: Current from I/O PIN (Read 6341 times)previous topic - next topic

franceslup

Oct 25, 2012, 11:22 pm

Each of the 54 digital pins on the Due can be used as an input or output, using pinMode(), digitalWrite(), and digitalRead() functions. They operate at 3.3 volts. Each pin can provide (source) a current of 3 mA or 15 mA...

So... If i want to use a LED that needs 20mA (i use to do it with arduino uno) there is risk (maybe is sure) to broke The board???

Grumpy_Mike

#1
Oct 26, 2012, 01:02 am
Quote
If i want to use a LED that needs 20mA (i use to do it with arduino uno) there is risk (maybe is sure) to broke The board???

Yes, that is what a current limit means.
If you want 20mA then use a transistor.

franceslup

#2
Oct 26, 2012, 09:15 am

Quote
If i want to use a LED that needs 20mA (i use to do it with arduino uno) there is risk (maybe is sure) to broke The board???

Yes, that is what a current limit means.
If you want 20mA then use a transistor.

Is required a particular bjt for example???
Arduino Du gives 3mA... If i use a classic 2N222?

franceslup

#3
Oct 26, 2012, 09:42 am
Another question... Which is The pin at 3mA, and which is at 15mA?

#4
Oct 26, 2012, 09:54 am
Here's a somewhat badly formatted and unverified list of the pins

Code: [Select]
`Pin Port     Func0   PA8          RX01   PA9          TX0                    152   PB25         Digital Pin 23   PC28         Digital Pin 3          154   PA29 and PC26   Digital Pin 4       155   PC25         Digital Pin 5          156   PC24         Digital Pin 6          157   PC23         Digital Pin 7          158   PC22         Digital Pin 8          159   PC21         Digital Pin 9          1510   PA28 and PC29   Digital Pin 10      1511   PD7          Digital Pin 11         1512   PD8          Digital Pin 12         1513   PB27   Digital Pin 13 / Amber LED "L"14   PD4          TX3                   1515   PD5          RX3                   1516   PA13         TX217   PA12         RX218   PA11         TX119   PA10         RX120   PB12         SDA21   PB13         SCL22   PB26         Digital Pin 2223   PA14         Digital Pin 23         1524   PA15         Digital Pin 24         1525   PD0          Digital Pin 25         1526   PD1          Digital pin 26         1527   PD2          Digital Pin 27         1528   PD3          Digital Pin 28         1529   PD6          Digital Pin 29         1530   PD9          Digital Pin 30         1531   PA7          Digital Pin 31         1532   PD10         Digital Pin 3233   PC1          Digital Pin 33         1534   PC2          Digital Pin 34         1535   PC3          Digital Pin 35         1536   PC4          Digital Pin 36         1537   PC5          Digital Pin 37         1538   PC6          Digital Pin 38         1539   PC7          Digital Pin 39         1540   PC8          Digital Pin 40         1541   PC9          Digital Pin 41         1542   PA19         Digital Pin 42         1543   PA20         Digital Pin 4344   PC19         Digital Pin 44         1545   PC18         Digital Pin 45         1546   PC17         Digital Pin 46         1547   PC16         Digital Pin 47         1548   PC15         Digital Pin 48         1549   PC14         Digital Pin 49         1550   PC13         Digital Pin 50         15   51   PC12         Digital Pin 51         15  52   PB21         Digital Pin 5253   PB14         Digital Pin 53         1554   PA16         Analog In 055   PA24         Analog In 156   PA23         Analog In 257   PA22         Analog In 358   PA6          Analog In 459   PA4          Analog In 560   PA3          Analog In 661   PA2          Analog In 762   PB17         Analog In 863   PB18         Analog In 964   PB19         Analog In 1065   PB20         Analog In 1166   PB15         DAC067   PB16         DAC168   PA1          CANRX69   PA0          CANTX                1570   PA17         SDA171   PA18         SCL1                 1572   PC30         LED "RX"73   PA21         LED "TX"74   PA25         (MISO)               1575   PA26         (MOSI)               1576   PA27         (SCLK)               1577   PA28         (NPCS0)              1578   PB23         (unconnected)        15USB   PB11         ID                  15USB   PB10         VBOF                15  `

The "15" indicates a high-current pin.

HC pins can source 15mA and sink 9.
LC pins can source 3mA and sink 6.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

franceslup

#5
Oct 26, 2012, 10:04 am

Here's a somewhat badly formatted and unverified list of the pins

Code: [Select]
`Pin Port     Func0   PA8          RX01   PA9          TX0                    152   PB25         Digital Pin 23   PC28         Digital Pin 3          154   PA29 and PC26   Digital Pin 4       155   PC25         Digital Pin 5          156   PC24         Digital Pin 6          157   PC23         Digital Pin 7          158   PC22         Digital Pin 8          159   PC21         Digital Pin 9          1510   PA28 and PC29   Digital Pin 10      1511   PD7          Digital Pin 11         1512   PD8          Digital Pin 12         1513   PB27   Digital Pin 13 / Amber LED "L"14   PD4          TX3                   1515   PD5          RX3                   1516   PA13         TX217   PA12         RX218   PA11         TX119   PA10         RX120   PB12         SDA21   PB13         SCL22   PB26         Digital Pin 2223   PA14         Digital Pin 23         1524   PA15         Digital Pin 24         1525   PD0          Digital Pin 25         1526   PD1          Digital pin 26         1527   PD2          Digital Pin 27         1528   PD3          Digital Pin 28         1529   PD6          Digital Pin 29         1530   PD9          Digital Pin 30         1531   PA7          Digital Pin 31         1532   PD10         Digital Pin 3233   PC1          Digital Pin 33         1534   PC2          Digital Pin 34         1535   PC3          Digital Pin 35         1536   PC4          Digital Pin 36         1537   PC5          Digital Pin 37         1538   PC6          Digital Pin 38         1539   PC7          Digital Pin 39         1540   PC8          Digital Pin 40         1541   PC9          Digital Pin 41         1542   PA19         Digital Pin 42         1543   PA20         Digital Pin 4344   PC19         Digital Pin 44         1545   PC18         Digital Pin 45         1546   PC17         Digital Pin 46         1547   PC16         Digital Pin 47         1548   PC15         Digital Pin 48         1549   PC14         Digital Pin 49         1550   PC13         Digital Pin 50         15   51   PC12         Digital Pin 51         15  52   PB21         Digital Pin 5253   PB14         Digital Pin 53         1554   PA16         Analog In 055   PA24         Analog In 156   PA23         Analog In 257   PA22         Analog In 358   PA6          Analog In 459   PA4          Analog In 560   PA3          Analog In 661   PA2          Analog In 762   PB17         Analog In 863   PB18         Analog In 964   PB19         Analog In 1065   PB20         Analog In 1166   PB15         DAC067   PB16         DAC168   PA1          CANRX69   PA0          CANTX                1570   PA17         SDA171   PA18         SCL1                 1572   PC30         LED "RX"73   PA21         LED "TX"74   PA25         (MISO)               1575   PA26         (MOSI)               1576   PA27         (SCLK)               1577   PA28         (NPCS0)              1578   PB23         (unconnected)        15USB   PB11         ID                  15USB   PB10         VBOF                15  `

The "15" indicates a high-current pin.

HC pins can source 15mA and sink 9.
LC pins can source 3mA and sink 6.

______
Rob

Thankyou di D you find it on The datasheet from atmel?

#6
Oct 26, 2012, 10:10 am
Yes. As I said though not verified, nobody else has checked it.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

franceslup

#7
Oct 26, 2012, 10:25 am

Yes. As I said though not verified, nobody else has checked it.

______
Rob

I think that we have to know this from Arruino.cc before we can completely use the board... If i Connect a led on a wrong pin( we don't know The wrong pin xD) i could damage the arm!

Far-seeker

#8
Oct 26, 2012, 04:51 pm

Is required a particular bjt for example???
Arduino Du gives 3mA... If i use a classic 2N222?

For the pins that only output upto 3 mA I would use FETs (like MOSFETs) instead of BJTs.  This is because FETs are always controlled by voltage level, rather than current level, on their gate.  You could still use many BJTs, like the 2N2222, but you'd have to make sure the BJT is biased so it is controlled by its base-emitter voltage, and not the base-emitter current (which you'll have to limit to below 3 mA).

Grumpy_Mike

#9
Oct 26, 2012, 05:47 pm
Quote
but you'd have to make sure the BJT is biased so it is controlled by its base-emitter voltage, and not the base-emitter current

So do we ensure this by rewriting physics?

A BJT is a current controlled device, you can't do anything to change that. A typical small signal BJT has a gain in the region of 200, so for 3mA you can switch up to 600mA.

Far-seeker

#10
Oct 26, 2012, 07:21 pmLast Edit: Oct 26, 2012, 07:47 pm by Far-seeker Reason: 1

Quote
but you'd have to make sure the BJT is biased so it is controlled by its base-emitter voltage, and not the base-emitter current

So do we ensure this by rewriting physics?

Two words: "Voltage buffers".  In that type of circuit the current (while still necessary to operate the BJT) can be set arbitrarily to a fairly small level and VIN determines VOUT. Unless you think a NPN common collector circuit requires non-standard physics...

Edit: Perhaps I overstated things a little by using the words "have to" instead of "should, and Grumpy_Mike is certainly correct that 3 mA can control a current hundreds of times larger.  However, it is entirely possible to use a BJT so that one voltage controls another without violating the known laws of physics!

Grumpy_Mike

#11
Oct 26, 2012, 09:49 pm
Quote
However, it is entirely possible to use a BJT so that one voltage controls another without violating the known laws of physics!

Now from that link I suspect you are not suggesting using an op amp.
The whole point of a BJT is that it is driven by current, not voltage. That current might be small but it is current never the less because it is current that makes the transistor work. FETs on the other hand are voltage devices and draw negligible current apart from the initial charging of the gate source capacitance. All three configurations of the transistor are called a voltage buffer on that page.

Lets look at each in turn:-
1) Common emitter - the normal way I would recommend, base current determines collector current

2) Common base - note the page says this is not suitable for a TTL voltage buffer, it has a low gain and typically I use this for video coupling.

3) Common collector better known as an emitter follower. - This has no voltage gain but a current gain, you do not need a base resistor because of the feedback on the emitter keeping the emitter / base voltage stable. However this is 0.7V so this means when you use it as a voltage buffer you loose 0.7V. Used with the Due that will reduce the voltage output from 3V3 to 2.6V. When lighting an LED this will not be high enough for blue and white LEDs although it is enough for red and green. Again I would not recommend this due to the voltage drop that it produces.

franceslup

#12
Oct 26, 2012, 10:07 pm
thank you guys...
I tryied a configuration On pspice.. if i use an 2N222 NPN BJT in common emitter mode, with 10K resistor on base (on a pin of arduino 2 so 3.3v).... the current on the base is less then 1mA... i don't remember the value of the Vcc on the led... maybe was 5v...
So i think i can use a BJT

Grumpy_Mike

#13
Oct 26, 2012, 10:14 pm
Quote
the current on the base is less then 1mA

In fact it is a lot less than 1mA it is 0.26mA.
Remember at 3V3 the 0.7V base emitter drop is a lot more significant. So you use the voltage across the base resistor of 3.3 - 0.7 = 2.6V for your calculations.
You can afford that base resistor to be down at 1K and still be within the limit.
I would use 4K7 - (0.5mA)  force of habit really.

Far-seeker

#14
Oct 26, 2012, 11:29 pm

The whole point of a BJT is that it is driven by current, not voltage. That current might be small but it is current never the less because it is current that makes the transistor work. FETs on the other hand are voltage devices and draw negligible current apart from the initial charging of the gate source capacitance.

I never stated that a BJT could work without current!  I originally recommended using FETs over on the 3 mA pins because I know the difference on how they operate.

Lets look at each in turn:-
1) Common emitter - the normal way I would recommend, base current determines collector current

2) Common base - note the page says this is not suitable for a TTL voltage buffer, it has a low gain and typically I use this for video coupling.

3) Common collector better known as an emitter follower. - This has no voltage gain but a current gain, you do not need a base resistor because of the feedback on the emitter keeping the emitter / base voltage stable. However this is 0.7V so this means when you use it as a voltage buffer you loose 0.7V. Used with the Due that will reduce the voltage output from 3V3 to 2.6V. When lighting an LED this will not be high enough for blue and white LEDs although it is enough for red and green. Again I would not recommend this due to the voltage drop that it produces.

Although you are correct that I should have stated, "common emitter" and not "common collector".  I... wasn't in a frame of mind conducive to self proof-reading when I wrote it.  I took your comment in a way you probably didn't mean, and furthermore let it irritate me more than I should have even if you did.

Regardless, with NPN a common emitter circuit the voltage difference between the base and emitter will be the VIN.  Since VOUT can be expressed as follows VOUT = AV * VIN; how is VIN not effectively controlling VOUT?  Yes, I intentionally didn't mention that the current will be amplified as well and that is fundamental to the operation of the BJT.  However, in my mind at least, it wasn't necessary because the maximum current is so low and all the pins except DAC0 and DAC1 are either outputting digital or PWM signals. So it's just easier when biasing the circuit to concentrate on the voltage, either setting it up to be an actual voltage amplifier or a switch, and only address the current in the context of ensuring it doesn't go above 3 mA.

Go Up

Please enter a valid email to subscribe