User avatar
JohnBeardmore
Posts: 206
Joined: Thu Nov 15, 2012 11:03 pm
Location: Derbyshire UK.
Contact: Website

GPIO pull up resisance

Mon Apr 22, 2013 1:30 pm

If you set a GPIO pin to input with pull up resistor e.g. using the wiringPi C library

pullUpDnControl( <pin>, PUD_UP )

call, does anybody know what the resistance of the internal pull up resistor used in the Pi is ?

I've written something to read pulses from electricity meters which triggers an ISR each time it sees a pulse on any of six GPIO inputs.

It works fine, but if you handle the board, you do see some spurious triggering on unconnected inputs, which makes me wonder if I could improve noise sensitivity by using external pull up resistors instead, maybe 220 or 330 ohm.

Not much point in my doing this if the internal resistance is already of this order though.

Cheers, J/.
Author of oBeMS open source Building energy Management System.
Automatic Meter Reading (AMR), Building Management System (BMS),
Building Energy Management System (BEMS), Infrastructure Control System (ICS).
See: http://t4sustainability.co.uk/oBeMS/

User avatar
joan
Posts: 13297
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: GPIO pull up resisance

Mon Apr 22, 2013 1:36 pm

Of the order of 50K ohm from memory. Not sure where it's specified.

techpaul
Posts: 1514
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

Re: GPIO pull up resisance

Mon Apr 22, 2013 1:38 pm

The internal pull-up resistor is fairly high I BELIEVE of the order of 30 to 100k.

So suscepatble to interfrerence. normally 10k or slightly lower is sufficient. The lower the resistance the more current used and I would not go below 1k for switch or similar pullups.
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

techpaul
Posts: 1514
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

Re: GPIO pull up resisance

Mon Apr 22, 2013 1:44 pm

Better to tie unconnected signal inputs to pullups of 10k to 3V3.

Does your board have a long cable with all 26 GPIO pins connected in a cable?

If so and you KNOW none of the signal pins are going to be used for outputs then tieing the FAR end of the cable's unused signal pins to gnd will help as will wiring all gnd pins together at FAR end. This stops the wiring acting as an aerial

Do NOT wire unused 3V3 or 5V pins to gnd
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

User avatar
JohnBeardmore
Posts: 206
Joined: Thu Nov 15, 2012 11:03 pm
Location: Derbyshire UK.
Contact: Website

Re: GPIO pull up resisance

Mon Apr 22, 2013 2:35 pm

joan wrote:Of the order of 50K ohm from memory. Not sure where it's specified.
Hi Joan,

I guess that explains the amount of pick-up then. Maybe I will do something with external resistors then.

Thanks, J/.
Author of oBeMS open source Building energy Management System.
Automatic Meter Reading (AMR), Building Management System (BMS),
Building Energy Management System (BEMS), Infrastructure Control System (ICS).
See: http://t4sustainability.co.uk/oBeMS/

User avatar
JohnBeardmore
Posts: 206
Joined: Thu Nov 15, 2012 11:03 pm
Location: Derbyshire UK.
Contact: Website

Re: GPIO pull up resisance

Mon Apr 22, 2013 3:37 pm

techpaul wrote:

>The internal pull-up resistor is fairly high I BELIEVE of the order of 30 to 100k.

OK, consistent with Joans figure. Thanks.

>So suscepatble to interfrerence. normally 10k or slightly lower is sufficient. The lower the
>resistance the more current used

True, but with a 3V3 supply, 330R only sources 10mA. Even if all six inputs are pulled low at once this is only 60mA. I have a good quality 1000mA supply on the board, RS part number 667-5789, so as there's nothing else except an Edimax USB wi-fi thing connected to the Pi, I hope I can get away with that. (Certainly nothing hoover power out of the HDMI connector etc.)

The inputs get a 100ms pulse every few seconds typically, so if I pull up with a 330R resistor, the average consumption is probably well 1mA per channel - only a tiny fraction of the Pis consumption.

I'd like to keep the average energy consumption low, but the noise immunity high, and if the kit is used in an industrial environment, to some degree I'd like to reduce the risk of damage due to mild EMP from welding kit, switching reactive loads etc.

When the open collector thing that pulls my inputs low isn't active, my wiring is basically tristate baring the effect of the pull up resistors. Essentially it's a badly behaved aerial attached to the SOC. There must be some risk of spikes harming the Pi.

I could use diodes to the supply rails, varistor capacitors etc, but if I can get acceptable noise immunity just by using fairly low pull-up resistors, that would certainly be the cheapest option.

I have a little experience of this sort of thing. We have a multi channel phase angle control light dimmer with TTL inputs connected to switches round the house for dimming or brightening lights. This has the inputs to the TTL 74LS150 mux connected to long wires and 220R pull-up resistors, and it's been running 24/7 for 19 years without problem.

> and I would not go below 1k for switch or similar pullups.

I can't see any penalty except power consumption ? As long as the open collector thing you are connected to can sink the current your input is sourcing of course. We're using the Elseter A100C meters with SO Pulse output (IEC 62053-31). I assume these can sink 10mA. I'm sure I checked at some point, though now I go looking for it, I can't find any documentation to that effect.

>Better to tie unconnected signal inputs to pullups of 10k to 3V3.

Surely pretty much any value will do ? In general I'd agree, but I'm using pull ups on the lines I'm using, and the other GPIO pins aren't connected to external wiring.

>Does your board have a long cable with all 26 GPIO pins connected in a cable?

No. Six pins of the GPIO are wire-wrapped to more pins on veroboard. Screw connectors are soldered on to the veroboard. Some cores in CatV and other manky bits of cable go off from the screw connectors to the three electricity meters that I'm using for testing. At the moment these are all a meter or so from the Pi. In the general case, the lines could be a lot longer.

>If so and you KNOW none of the signal pins are going to be used for outputs then tieing the FAR end
>of the cable's unused signal pins to gnd will help as will wiring all gnd pins together at FAR end. This
>stops the wiring acting as an aerial

Do NOT wire unused 3V3 or 5V pins to gnd

:) Trust me - I've done stupider things !

Thanks both ! J/.
Author of oBeMS open source Building energy Management System.
Automatic Meter Reading (AMR), Building Management System (BMS),
Building Energy Management System (BEMS), Infrastructure Control System (ICS).
See: http://t4sustainability.co.uk/oBeMS/

techpaul
Posts: 1514
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

Re: GPIO pull up resisance

Mon Apr 22, 2013 4:00 pm

JohnBeardmore wrote:
techpaul wrote:The internal pull-up resistor is fairly high I BELIEVE of the order of 30 to 100k.
OK, consistent with Joans figure. Thanks.
techpaul wrote:So suscepatble to interfrerence. normally 10k or slightly lower is sufficient. The lower the resistance the more current used
True, but with a 3V3 supply, 330R only sources 10mA. Even if all six inputs are pulled low at once this is only 60mA.
However it is not recommended to take more than about 50mA from the 3V3 pin so marginal at best.
The inputs get a 100ms pulse every few seconds typically, so if I pull up with a 330R resistor, the average consumption is probably well 1mA per channel - only a tiny fraction of the Pis consumption.
Depends if the line sits low most the time then the average is 9mA, but in reality you need to worry about peak as so near available 3V3 limit determined more by the onboard regulator and its existing on-board load.
I'd like to keep the average energy consumption low, but the noise immunity high, and if the kit is used in an industrial environment, to some degree I'd like to reduce the risk of damage due to mild EMP from welding kit, switching reactive loads etc.
Might be better with 1k.
I have a little experience of this sort of thing. We have a multi channel phase angle control light dimmer with TTL inputs connected to switches round the house for dimming or brightening lights. This has the inputs to the TTL 74LS150 mux connected to long wires and 220R pull-up resistors, and it's been running 24/7 for 19 years without problem.
But runs off a psu with much more spare capacity
JohnBeardmore wrote:
techpaul wrote:and I would not go below 1k for switch or similar pullups.
I can't see any penalty except power consumption ?
For one input no but with limited 3V3 available and many inputs, your are risking other effects on board.
As long as the open collector thing you are connected to can sink the current your input is sourcing of course.
When the open-collector is off you are more than likely feeding a small amount of current to the Pi, instead of when on taking small current from Pi and mainly the resistor. Current flow direction changes.
We're using the Elseter A100C meters with SO Pulse output (IEC 62053-31). I assume these can sink 10mA. I'm sure I checked at some point, though now I go looking for it, I can't find any documentation to that effect.
Not familiar with them myself.
JohnBeardmore wrote:
techpaul wrote:Better to tie unconnected signal inputs to pullups of 10k to 3V3.
Surely pretty much any value will do ? In general I'd agree, but I'm using pull ups on the lines I'm using, and the other GPIO pins aren't connected to external wiring.
Almost any value much higher than 10k and its impedance makes it a weak force, below 1k and multiple lines then you start taking too much current a lot of the time from 3V3 and could exceed safe operation.

If you can shield cables or add extra grounds this will also help.
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

User avatar
JohnBeardmore
Posts: 206
Joined: Thu Nov 15, 2012 11:03 pm
Location: Derbyshire UK.
Contact: Website

Re: GPIO pull up resisance

Tue Apr 23, 2013 12:14 am

>John Wrote:
PaulWrote:

>>...with a 3V3 supply, 330R only sources 10mA. Even if all six inputs are pulled low at once this is
>>only 60mA.
>
>However it is not recommended to take more than about 50mA from the 3V3 pin so marginal at best.

Where is this stated ? See my calcs below.

>>The inputs get a 100ms pulse every few seconds typically, so if I pull up with a 330R resistor, the
>>average consumption is probably well below 1mA per channel - only a tiny fraction of the Pis >>consumption.
>
>Depends if the line sits low most the time then the average is 9mA,

It doesn't. As I said, or to me more explicit, the pulses are low (conducting to ground) for 100ms. I suppose in theory you might get several pulses per channel per second, but certainly not in the currently intended application.

> but in reality you need to worry about peak as so near available 3V3 limit determined more by the
>onboard regulator and its existing on-board load.

Yes, see calc below.

>Might be better with 1k.

I think 330R should be OK. See calc below.

>>I have a little experience of this sort of thing.
>>We have a multi channel phase angle control light
>>dimmer with TTL inputs connected to switches round
>>the house for dimming or brightening lights. This
>>has the inputs to the TTL 74LS150 mux connected to
>>long wires and 220R pull-up resistors, and it's
>>been running 24/7 for 19 years without problem.
>
>But runs off a psu with much more spare capacity

Probably. It's been a while since I looked !

>>I can't see any penalty except power consumption ?
>
>For one input no but with limited 3V3 available and many inputs, your are risking other effects on board.

Let's try and quantify this. Looking at the Pi schematic, there doesn't seem to be anything between the 3V3 regulator and the GPIO 3V3 connector. The track might be a bit thin, but I can't imagine any track struggling with 60mA. The 60mA 'limit' strikes me as a bit arbitrary.

I guess the issues are 1) does the peak current exceed the regulators rated output current (which could kill
it quickly), and 2) with the additional load of the pull ups during pulses, will the regulator overheat with the
heat sink capacity available (which could kill the regulator slowly).

I suspect that given that the Pi isn't plugged in to anything else, we probably won't exceed the rated
output, though it's interesting that the schematic notes by the 3V3 regulator, "Place on Mh 400sq mm Copper Area for pd 800mW".

If the voltage regulator is dropping 1V7, it dissipates 800mW at 470mA. And here we all are buying 1500mA powers supplies... Anyway, it looks as if the NCP1117 itself is rated at 1A.

Web pages like http://www.raspberrypi.org/phpBB3/viewt ... f=2&t=6050 seem to indicate typical current consumptions on the order of 200mA. Even if we allow 300mA to give some headroom, I don't think it looks as if my drawing pulses of up to 60mA for 100 ms will either exceed the max rated regulator current, or the maximum recommended dissipation on the 'heat sink' provided.

USB outputs run at 5V, so hopefully the USB wi-fi doesn't further stress the 3V3 regulator.

>>As long as the open collector thing you are connected to can sink the current your input is sourcing of
>>course.
>
>When the open-collector is off you are more than likely feeding a small amount of current to the Pi, >instead of when on taking small current from Pi and mainly the resistor. Current flow direction changes.

I don't know what semiconductor technology the SOC is, but as you say, it is only likely to sink a small amount of current, and the resistance of the pull-up probably won't change that a lot.

>>Surely pretty much any value will do ? In general I'd agree, but I'm using pull ups on the lines I'm using,
>>and the other GPIO pins aren't connected to external wiring.
>
>Almost any value much higher than 10k and its impedance makes it a weak force, below 1k and
>multiple lines then you start taking too much current a lot of the time from 3V3 and could exceed safe >operation.

As far as I can see from the calc above, even if it was drawing a 60mA current for a high proportion of the time, the regulator max current and dissipation would not be exceeded. (I can't envisage more that 200ms per second per chanel in the intended use though.)

>If you can shield cables or add extra grounds this will also help.

The choice of wire will probably be determined by wiring regs, and the need to run our pulse cables next to chunky mains cable in big electrically noisy conduit, then to terminate them in the quite chunky pulse
screw connectors in the electricity meter. The ideal cables for a channel would probably be a pair of double insulated singe 1.5sqmm cables, though the ideal stuff is hard to find.

Cheers, J/.
Author of oBeMS open source Building energy Management System.
Automatic Meter Reading (AMR), Building Management System (BMS),
Building Energy Management System (BEMS), Infrastructure Control System (ICS).
See: http://t4sustainability.co.uk/oBeMS/

techpaul
Posts: 1514
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

Re: GPIO pull up resisance

Tue Apr 23, 2013 10:36 am

JohnBeardmore wrote:>John Wrote:
PaulWrote:
>>...with a 3V3 supply, 330R only sources 10mA. Even if all six inputs are pulled low at once this is
>>only 60mA.
>
>However it is not recommended to take more than about 50mA from the 3V3 pin so marginal at best.

Where is this stated ? See my calcs below.
http://elinux.org/Rpi_Datasheet_202_Rasperry_Pi_IO in Power section
http://elinux.org/Rpi_Low-level_peripherals in description of pin 1 and pin 17 in table
>>I can't see any penalty except power consumption ?
>
>For one input no but with limited 3V3 available and many inputs, your are risking other effects on board.

Let's try and quantify this. Looking at the Pi schematic, there doesn't seem to be anything between the 3V3 regulator and the GPIO 3V3 connector. The track might be a bit thin, but I can't imagine any track struggling with 60mA. The 60mA 'limit' strikes me as a bit arbitrary.

I guess the issues are 1) does the peak current exceed the regulators rated output current (which could kill
it quickly), and 2) with the additional load of the pull ups during pulses, will the regulator overheat with the
heat sink capacity available (which could kill the regulator slowly).
Yes there is very little spare capacity on those pins.
I suspect that given that the Pi isn't plugged in to anything else, we probably won't exceed the rated output, though it's interesting that the schematic notes by the 3V3 regulator, "Place on Mh 400sq mm Copper Area for pd 800mW".
For heatsink the regulator will need
If the voltage regulator is dropping 1V7, it dissipates 800mW at 470mA. And here we all are buying 1500mA powers supplies... Anyway, it looks as if the NCP1117 itself is rated at 1A.
Only with suitable heatsink and a) the square pad is not enough for 1A power dissipation and b) at that level no doubt the polyfuse will blow. People are using all sorts of power supplies often because they are not doing tests as the PSUs are often chargers not PSUs, they have lossy cables and sometimes really bad PSUs.
Web pages like http://www.raspberrypi.org/phpBB3/viewt ... f=2&t=6050 seem to indicate typical current consumptions on the order of 200mA. Even if we allow 300mA to give some headroom, I don't think it looks as if my drawing pulses of up to 60mA for 100 ms will either exceed the max rated regulator current, or the maximum recommended dissipation on the 'heat sink' provided.

USB outputs run at 5V, so hopefully the USB wi-fi doesn't further stress the 3V3 regulator.
But some of its internal logic runs from 3V3 and internal regulators.

I have given my opinion that 1k will be more than adequate for your purposes and reduction of noise/EMI/etc... What you do is your own choice
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

JRA
Posts: 20
Joined: Wed Jan 17, 2018 10:25 pm
Location: Maryland, USA

Re: GPIO pull up resisance

Wed Jan 17, 2018 10:44 pm

People please. There's complete misinformation here. :| Please understand that an external pull-up or pull-down placed on a GPIO pin setup as an input draws zero current from the Input. Doesn't matter what value of resistance. You can hard ground that pin or tie it directly to 3V3. It's an Input. Veeeery high impedance. As the person wrote they use a 330 ohm resistor and pulse it every 100ms. Fine. That 10mA was supplied elsewhere - from another source of 3V3. The Pi did not have to produce that current. It flowed into the 330 ohm R, created 3.3V at that input pin, zero current flowed into or out of that pin, the Pi power supply was not taxed or affected, and the return 10mA came back to the source via the GND connection. Get it?

User avatar
JohnBeardmore
Posts: 206
Joined: Thu Nov 15, 2012 11:03 pm
Location: Derbyshire UK.
Contact: Website

Re: GPIO pull up resisance

Thu Jan 18, 2018 1:12 am

JRA wrote:

>People please. There's complete misinformation here. :|

Well, let's see...

>Please understand that an external pull-up or pull-down placed on a GPIO pin setup as an input draws
>zero current from the Input. Doesn't matter what value of resistance. You can hard ground that pin or
>tie it directly to 3V3. It's an Input. Veeeery high impedance.

With you so far.

>As the person wrote they use a 330 ohm resistor and pulse it every 100ms. Fine.

I think 'the person' was me. I think I said the pulses were of 100ms duration. They are not regular, but vary in frequency. The measurement taken is the number of pulses per minute.

>That 10mA was supplied elsewhere - from another source of 3V3. The Pi did not have to produce
>that current.

The Pi 3.3 volt regulator has to produce that current, hence the comment "it is not recommended to take more than about 50mA from the 3V3 pin so marginal at best". Nodody was suggesting that the current be souced through a GPIO input, but from the 3V3 rail pin on the GPIO header.

>It flowed into the 330 ohm R, created 3.3V at that input pin, zero current flowed into or out of
>that pin,

The GPIO pin is pulled up by a resistor so that when there is a pulse through a measuring device with an open collector output, the GPIO pin can be pulled to ground, and the activity sensed by generating in interrupt in the Pi.

>the Pi power supply was not taxed or affected,

Are you saying that the 10mA doesn't come from the 3V3 regulator on the Pi ? I deigned the system, and I can assure you it does.

I can also assure you there are 6 of these inputs, and could be more in some circumstances. There is nothing to stop all inputs being pulled low at the same time. Six times ten is sixty, and 60 is greater than fifty. This gave rise to the warning from another poster that "it is not recommended to take more than about 50mA from the 3V3 pin so marginal at best". Seems like a sensible comment to me. It would be embarassing if for example, the Pi crashed when all inputs were pulled low.

>and the return 10mA came back to the source via the GND connection. Get it?

I think we "Get it". The sourse is the 3V3 regulator on the Pi.

For what it's worth, in the end we settled on 120 ohm pull ups to minimise noise pick up by reducing input impedance. We use an additional 3V3 simple switcher power supply where we have lots of pulse inputs. The system works well, and you can explore the sort of data it collects from pule output electricity meters starting from the link below, and using the buttons to navigate. http://t4sustainability.co.uk/cgi-bin/O ... ubBtn=Prev

Cheers, J/.
Author of oBeMS open source Building energy Management System.
Automatic Meter Reading (AMR), Building Management System (BMS),
Building Energy Management System (BEMS), Infrastructure Control System (ICS).
See: http://t4sustainability.co.uk/oBeMS/

User avatar
rpdom
Posts: 12401
Joined: Sun May 06, 2012 5:17 am
Location: Essex, UK

Re: GPIO pull up resisance

Thu Jan 18, 2018 6:47 am

I'm pretty certain that the 50mA recommendation was based on the old 3v3 linear regulator on the original Pi. The newer ones (B+ and later) use a more efficient switching regulator and can supply much more current. I haven't seen an actual recommended maximum, but I believe it can supply over 100mA for external circuits.

User avatar
joan
Posts: 13297
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: GPIO pull up resisance

Thu Jan 18, 2018 8:57 am

rpdom wrote:
Thu Jan 18, 2018 6:47 am
I'm pretty certain that the 50mA recommendation was based on the old 3v3 linear regulator on the original Pi. The newer ones (B+ and later) use a more efficient switching regulator and can supply much more current. I haven't seen an actual recommended maximum, but I believe it can supply over 100mA for external circuits.
I think the 3V3 rail on some Pi models can supply up to 1 amp (based on the chip used)..

Have a look at https://raspberrypise.tumblr.com/post/1 ... power-rail

User avatar
JohnBeardmore
Posts: 206
Joined: Thu Nov 15, 2012 11:03 pm
Location: Derbyshire UK.
Contact: Website

Re: GPIO pull up resisance

Thu Jan 18, 2018 11:52 am

Yes, this April 2013 discussion was back in the days of the original Pis.

At the moment we use the Pi 3 for new systems in the 'field', the Pi 2 for most development, and the Pi 1 is still in use in our original systems, and is still usefully collecting data after more than five years.

Pi 4 anyone ?

Cheers, J/.
Author of oBeMS open source Building energy Management System.
Automatic Meter Reading (AMR), Building Management System (BMS),
Building Energy Management System (BEMS), Infrastructure Control System (ICS).
See: http://t4sustainability.co.uk/oBeMS/

JRA
Posts: 20
Joined: Wed Jan 17, 2018 10:25 pm
Location: Maryland, USA

Re: GPIO pull up resisance

Fri Jan 19, 2018 2:41 am

I apologize for my idiot post. I was dead wrong.

User avatar
JohnBeardmore
Posts: 206
Joined: Thu Nov 15, 2012 11:03 pm
Location: Derbyshire UK.
Contact: Website

Re: GPIO pull up resisance

Fri Jan 19, 2018 2:46 am

Not to worry, we've all been there !

Cheers, J/.
Author of oBeMS open source Building energy Management System.
Automatic Meter Reading (AMR), Building Management System (BMS),
Building Energy Management System (BEMS), Infrastructure Control System (ICS).
See: http://t4sustainability.co.uk/oBeMS/

Return to “Bare metal”

Who is online

Users browsing this forum: No registered users and 6 guests