GPIO drive strength.

Cellie
Posts: 45
Joined: Sat Feb 27, 2016 9:47 pm

GPIO drive strength.

Postby Cellie » Tue Jan 29, 2019 5:14 pm

I read about the increased maximum drive strength on GPIOs and went looking for an example.
Could not find one and just tried some code on a MH-ET LIVE minikit.
The code compiles and the esp did not blow up!

Code: Select all

void setup()
{
  pinMode( LED0_PIN, OUTPUT );
  pinMode( LED1_PIN, OUTPUT );
  pinMode( LED2_PIN, OUTPUT );
  pinMode( LED3_PIN, OUTPUT );
  pinMode( LED4_PIN, OUTPUT );
  pinMode( TFT_BACKLIGHT_PIN, OUTPUT );

  pinMode( I2C_SCL_PIN, INPUT_PULLUP );
  pinMode( I2C_SDA_PIN, INPUT_PULLUP );

  gpio_set_drive_capability((gpio_num_t)LED0_PIN, GPIO_DRIVE_CAP_3);
  gpio_set_drive_capability((gpio_num_t)LED1_PIN, GPIO_DRIVE_CAP_3);
  gpio_set_drive_capability((gpio_num_t)LED2_PIN, GPIO_DRIVE_CAP_3);
  gpio_set_drive_capability((gpio_num_t)LED3_PIN, GPIO_DRIVE_CAP_3);
  gpio_set_drive_capability((gpio_num_t)LED4_PIN, GPIO_DRIVE_CAP_3);
 ...
...
I dont have a scope atm and wanted to know if it is really that simple.
The above project uses mosfets on the outputs and increased drive strength would mean I could lower the gate resistor value.
Atm I use 330R and this means I could got to 100R?

Which brings the total current to 165mW but I could not find any data to tell me that is a safe value.
Anyone?

ESP_Sprite
Posts: 9709
Joined: Thu Nov 26, 2015 4:08 am

Re: GPIO drive strength.

Postby ESP_Sprite » Wed Jan 30, 2019 3:58 am

I think the datasheet nowadays gives the specs for the I/O currents. You should be safe (not sure why you'd need a gate resistor anyway, to be honest), if any, anecdotically speaking, the ESP32s output pads are incredibly robust. We had a setup here with all GPIOs driven to high and externally shorted to ground, and the ESP happily kept working.

Saakje
Posts: 1
Joined: Fri May 01, 2020 6:14 pm

Re: GPIO drive strength.

Postby Saakje » Fri May 01, 2020 6:19 pm

If you are using MOSFETs then the "drive" should be irrelevant. A MOSFET if used properly, has a very high gate resistance and will not use any current. If used properly, you can get rid of the resistor completely without increasing the drive.
If you are using an NPN power transistor, then yes, you will need a resistor and you will pull current into the base.

Cellie
Posts: 45
Joined: Sat Feb 27, 2016 9:47 pm

Re: GPIO drive strength.

Postby Cellie » Sat May 09, 2020 6:03 pm

If you are using an NPN power transistor, then yes, you will need a resistor and you will pull current into the base.
Hi Saakje.
I am using IRLZ44N mosfets so a gate resistor should be includeed in my opinion. While testing I drove the mosfets a while without gate resistors and no bad things happened then.

bobtidey
Posts: 43
Joined: Mon Jun 18, 2018 2:24 pm

Re: GPIO drive strength.

Postby bobtidey » Sat May 09, 2020 8:52 pm

As has been pointed out a series gate resistor does very little when using a MOSFET driver. The only possible benefit would be to add a degree of protection to the GPIO pin if there was some catastrophic failure in the MOSFET device. These tend to be very reliable devices and I do not add a series resistor.

There can sometimes be a case for a resistor from the gate to 0V if you want to guarantee the device is off when the GPIO is an unknown state at power on. A value like 10K would be suitable.

As an aside the IRLZ44N devices are not guaranteed to be turned hard on with 3.3V logic. Typically they are OK but they are only specified at a gate voltage of 4.0. A high current device that is specified (at 2.8V) is the IRF3708. For lower current applications the surface mount AO3400 is also specified at 2.5V

Cellie
Posts: 45
Joined: Sat Feb 27, 2016 9:47 pm

Re: GPIO drive strength.

Postby Cellie » Thu May 14, 2020 9:10 am

@bobtidey
The resistor (I use 20K) gate -> ground is present.
Thanks for the tip about IRF3708, I think I will buy and test some of those.

@Saakje
If you are using an NPN power transistor, then yes, you will need a resistor and you will pull current into the base.
Do you maybe have some background info link on that?

ESP_Sprite
Posts: 9709
Joined: Thu Nov 26, 2015 4:08 am

Re: GPIO drive strength.

Postby ESP_Sprite » Thu May 14, 2020 1:40 pm

Cellie wrote:
Thu May 14, 2020 9:10 am
@Saakje
If you are using an NPN power transistor, then yes, you will need a resistor and you will pull current into the base.
Do you maybe have some background info link on that?
It's basic knowledge. The base->emittor connection of an NPN/PNP transistor is effectively equivalent to a diode, that is, the transistor will always have a voltage drop of 0.7V over it. If you connect a GPIO directly to an NPN which has its emitter at Gnd, it will pull enough current out of the GPIO until it drags down the GPIO to a level of 0.7V, which can be quite an amount of current and that is not good for the GPIO or the transistor. Hence a base resistor to limit the current.

Who is online

Users browsing this forum: No registered users and 95 guests