Thierry88
Posts: 9
Joined: Sat Mar 12, 2016 9:18 am

Maximum current draw GPIO pins?

Mon Mar 28, 2016 6:00 pm

Hello,

I'm building a python script to control 16 different GPIO outputs with PWM.
each pin is connected to a 1N4148 diode then connected to MOSfet IRLB8721 and they drive white and rgb led strips on 12V.
with 4 outputs on at the same time it works fine, but is it safe to turn 16 on at the same time? (i havent tried this yet...)

Also i noticed when i have a very low brightness setting using PWM the leds flicker and blink when the CPU is doing something.
Does anyone know any answer for this?

Greetings,
Thierry de Bakker.

gordon77
Posts: 3746
Joined: Sun Aug 05, 2012 3:12 pm

Re: Maximum current draw GPIO pins?

Mon Mar 28, 2016 6:37 pm

It's quoted as 16mA per pin, 51mA total.

User avatar
GTR2Fan
Posts: 1601
Joined: Sun Feb 23, 2014 9:20 pm
Location: South East UK

Re: Maximum current draw GPIO pins?

Mon Mar 28, 2016 6:52 pm

Thierry88 wrote:I'm building a python script to control 16 different GPIO outputs with PWM.
each pin is connected to a 1N4148 diode then connected to MOSfet IRLB8721 and they drive white and rgb led strips on 12V.
with 4 outputs on at the same time it works fine, but is it safe to turn 16 on at the same time? (i havent tried this yet...)
The GPIO pins aren't designed to drive capacitive loads directly. As MOSFETs exhibit some capacitance across the gate and source, I'd be inclined to put a 1k5 resistor in series with the gate. It is only a tiny capacitance and you'd probably get away with it, but better safe than sorry. Having resistors in place also means that you can calculate the maximum likely GPIO pin current instead of having to pure guess it.
Also i noticed when i have a very low brightness setting using PWM the leds flicker and blink when the CPU is doing something.
Does anyone know any answer for this?
That may be due to the unnecessary diode in series with the gate of the MOSFET that's allowing the gate to float when not being driven high. If that is the reason, removing the diode should fix it.

Another problem becomes fairly obvious when reading the datasheet for the IRLB8721. It states a turn-on voltage of 4.5V, so you're never going to be able to turn them fully on with a 3.3V signal. That may not matter a great deal unless the LEDs are pulling significant current, but it's probably best to keep an eye on the temperature of the MOSFETs to make sure their internal resistance isn't making them too toasty running your specific load.
Pi2B Mini-PC/Media Centre: ARM=1GHz (+3), Core=500MHz, v3d=500MHz, h264=333MHz, RAM=DDR2-1200 (+6/+4/+4+schmoo). Sandisk Ultra HC-I 32GB microSD card on '50=100' OCed slot (42MB/s read) running Raspbian/KODI16, Seagate 3.5" 1.5TB HDD mass storage.

Thierry88
Posts: 9
Joined: Sat Mar 12, 2016 9:18 am

Re: Maximum current draw GPIO pins?

Mon Mar 28, 2016 7:08 pm

Thank you for your reply.

I forgot to mention that i have a 10k pull down resistor on the gate of the mosfet so it cannot float.
i have tried connecting the ledstrip directly to the 12v source and it's the same brightness as when i drive it with the raspberry at 100% dutycycle so i do think that the mosfets are fully on.
i just thought that putting the diodes in line with each pin would be a safety if for what ever reason the MOSfet meltsdown.
and i have had the strips on for a long time and even without heatsink the mosfet stays dead cold, and i am planning to put a heatsink on anyway just to be sure but that's pure overkill.

so would you suggest to put a 1k resistor in series with each pin to limit the current?
also don't you think the diode is a good protection?

User avatar
Burngate
Posts: 5720
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Maximum current draw GPIO pins?

Tue Mar 29, 2016 9:15 am

GTR2Fan wrote:Another problem becomes fairly obvious when reading the datasheet for the IRLB8721. It states a turn-on voltage of 4.5V, so you're never going to be able to turn them fully on with a 3.3V signal.
According to the IR datasheet I've just downloaded from AdaFruit, the gate threshold is 1.35v min, 1.80v typ, 2.35v max. Even with a diode in series (0.7v) the Pi should begin to turn it on, though only just for the top end of the range.
On the same datasheet, there's a nice graph.
irlb8721.png
irlb8721.png (11.71 KiB) Viewed 1619 times

Thierry88
Posts: 9
Joined: Sat Mar 12, 2016 9:18 am

Re: Maximum current draw GPIO pins?

Tue Mar 29, 2016 10:21 am

So that means that i can use this setup?
Or remove the diode and replace with 1k resistor?
Or leave the diode in place and also add the resistor?

User avatar
GTR2Fan
Posts: 1601
Joined: Sun Feb 23, 2014 9:20 pm
Location: South East UK

Re: Maximum current draw GPIO pins?

Tue Mar 29, 2016 12:36 pm

Burngate wrote:I've just downloaded from AdaFruit, the gate threshold is 1.35v min, 1.80v typ, 2.35v max.
That's the gate threshold voltage, not the saturation voltage.

From the same datasheet...
Very Low RDS(on) at 4.5V VGS
It depends how 'on' you need it to be.
Pi2B Mini-PC/Media Centre: ARM=1GHz (+3), Core=500MHz, v3d=500MHz, h264=333MHz, RAM=DDR2-1200 (+6/+4/+4+schmoo). Sandisk Ultra HC-I 32GB microSD card on '50=100' OCed slot (42MB/s read) running Raspbian/KODI16, Seagate 3.5" 1.5TB HDD mass storage.

Thierry88
Posts: 9
Joined: Sat Mar 12, 2016 9:18 am

Re: Maximum current draw GPIO pins?

Tue Mar 29, 2016 5:02 pm

Thanks for all the help.

@GTR2FAN:

Time for some measures:
My Supply outputs 12.81V
When pwm output is at 100% dutycycle,
I measure 3.62V directly on the GPIO pin, after the 1K resistor its 3.31V, and after the 1,5K its 3,15V
The mosfet gives me 12.31V on the ledstrip with the 1K or 1,5K (doesn't make a difference) and it's very bright, i don't see any difference between direct supply and mosfet supply, so that works perfectly.
Unfortunatly it looks like i can't measure any current between the GPIO and MOSfet, but i think that's because i still use the same cheap multimeter as since i was 11 haha (28 now btw.. so lots of years of abuse :twisted: ), so i think its time for a replacement.
Also i discovered that the leds get brighter with the 1K/1,5K resistor instead of the diode, (resistor drops only 0.30v/0,45v while the diode dropped 0.7v)

so i should remove the diodes and put the 1K or 1,5K in place?
Could it be smart to take an even higher value? the highest possible resistor before it would drop under 12V?

User avatar
GTR2Fan
Posts: 1601
Joined: Sun Feb 23, 2014 9:20 pm
Location: South East UK

Re: Maximum current draw GPIO pins?

Tue Mar 29, 2016 5:20 pm

I'd go with replacing the diode with a 1k5 resistor. The 10k resistor between the gate and source could happily be increased to 47k or so if you want to reduce the potential divider effect it's having with the other resistor.
Pi2B Mini-PC/Media Centre: ARM=1GHz (+3), Core=500MHz, v3d=500MHz, h264=333MHz, RAM=DDR2-1200 (+6/+4/+4+schmoo). Sandisk Ultra HC-I 32GB microSD card on '50=100' OCed slot (42MB/s read) running Raspbian/KODI16, Seagate 3.5" 1.5TB HDD mass storage.

Thierry88
Posts: 9
Joined: Sat Mar 12, 2016 9:18 am

Re: Maximum current draw GPIO pins?

Tue Mar 29, 2016 5:23 pm

ok i'll do that, thank you very much for the help.

Can you explain that second part a bit?

Return to “Other projects”