-->
Page 1 of 6

Pull-up (and pull-down) revisited

PostPosted: Sat Mar 19, 2016 6:48 am
by eriksl
There have some amount of discussions about the necessity (or lack thereof) of pull-(down/up) resistors on (un)used pins. To that discussion I would like to add a short story of a real-life experience I had recently. It might change your point of view on this subject.

I have been struggling getting a good connection on WLAN-level since the start. Connection speed always falls down to ~10 mbps very quickly and when I start to send bigger amounts of data (larger packets, quick succession), the connection speed drops even more, to the point where it reaches "0" (according to my access point) and no data is sent or received at all. After some time the esp recovers and it starts all over again.

I have no reason to believe my access points are at fault, they're semi-professional ones and they have no problems with other devices.

Lately the problem has become such that the esp couldn't get a connection at all. Tried "everything", access point configuration (802.11g vs. 802.11n, speed hard wired, channel, etc.), no success. Finally attached the UART for debugging. Immediately got a connection. Coincidence I thought. Another try. And another. Connection, no problem. Removed the UART connection, no WLAN connection. Time after time. Connected the UART again, good WLAN connection, again, time after time. This was no coincidence.

I suspect the power, that the esp would be silently (also) fed by the cp210x. Measured the power, no problem. Added a large capacitor (2200 μF) to be sure, but no difference. Afterwards it appeared I didn't even connect the power line (which is as it should be) so power couldn't be the issue.

The only thing left was the impedance on the GPIO lines. I use my UART connection for programming as well, so it's connected to GPIO0 (boot select), RST, GPIO1 (UART) and GPIO3 (UART). Checked all of these without the UART connector inserted. GPIO0 and RST where already low-impedance, pulled up to 3.3V. That could never make the difference.

The GPIO1 and GPIO3 where high-impedance though (of course, if you think of it, nothing connected). I started with a pull-down. I used 1k for a strong pull but not too strong to damage the driver (1k = 3.3 mA). This made the pin going down all of the time, rendering the UART unusable and also made the esp not boot up. Then changed the resistors to pull-up and voilà, all working again.

Not only was the esp now booting properly, it also connected immediately, every time again and UART was also functioning as it should.

But the biggest surprise was the performance. Now I have a connection of 65 Mbps all of the time (the highest possible on the esp), I can send a flood ping of 1400 bytes sized packets to it with an interval of 5 milliseconds (didn't try less, actually) and none of them drop... The connection speed remains 65 Mbps.

It gets even better. I have an access point on another floor with the same SSID. I turned off the local access point and restarted the esp. I immediately connected to the other access point, also with a connection speed of 65 Mbps and also no packet loss with large packets.

A big mystery solved for me.

Lesson learned: always pull up or pull down I/O pins. Not only the one's you're not using (which I already did), simply every single one of them. The esp has very high impedance inputs combined with quite strong output drivers, so it requires and also can handle quite strong pull-ups.

Cause of the problem? I can never know for sure, but it looks some RF signal was leaking out of the IC over these pins and the unterminated lines were acting as an antenna. Very bad.

Re: Pull-up (and pull-down) revisited

PostPosted: Sat Mar 19, 2016 8:21 am
by martinayotte
eriksl wrote:The GPIO1 and GPIO3 where high-impedance though (of course, if you think of it, nothing connected). I started with a pull-down. I used 1k for a strong pull but not too strong to damage the driver (1k = 3.3 mA). This made the pin going down all of the time, rendering the UART unusable and also made the esp not boot up. Then changed the resistors to pull-up and voilà, all working again.

Did you tried to pulled up RX only while leaving TX floating ?
Because it could be that RX with LOW state is interpreted as Break signal ...

Re: Pull-up (and pull-down) revisited

PostPosted: Sat Mar 19, 2016 8:55 am
by eriksl
martinayotte wrote:
eriksl wrote:The GPIO1 and GPIO3 where high-impedance though (of course, if you think of it, nothing connected). I started with a pull-down. I used 1k for a strong pull but not too strong to damage the driver (1k = 3.3 mA). This made the pin going down all of the time, rendering the UART unusable and also made the esp not boot up. Then changed the resistors to pull-up and voilà, all working again.

Did you tried to pulled up RX only while leaving TX floating ?
Because it could be that RX with LOW state is interpreted as Break signal ...

That's an interesting thought, but doesn't explain how it would interfere with the WLAN RF ;)

Re: Pull-up (and pull-down) revisited

PostPosted: Sat Mar 19, 2016 9:58 am
by AdrianM
What firmware are you using? With nodemcu/lua I find that GPIO3 is has it's internal pull-up enabled by default after a reset (the same is true for all other uncommited GPIO's.

You can determine the state of the internal pull-up on a input pin by connecting it to 0V via a 27K resistor and measuring the voltage across the resistor. If it measures 3V3 (or whatever the supply is) it's obviously not an input after all, but an output set high.

If it's an input with pull-up enabled, then the 27K pull-down will drop the pin to half the supply e.g. it will measure 1.15V across it. If it measures 0V then it might be a fully floating input or an output set low. To check of course you can swap the 27K around to connect the pin to Vdd. If the pin is still at 0V its obviously an output.

One other thing that I noticed was that the supply current only increased by 2mA when bringing an input to mid-supply. With some microcontrollers this can create a drastic increase in supply current but the ESP8266 seems pretty good in this respect. This leaves me puzzled about your findings.