bedesda
Posts: 7
Joined: Sun Jun 07, 2015 4:30 am

switches resistance

Sat Jul 04, 2015 2:30 am

Hey guys,
In one of my project I have 10 switches under the control of the PI, I know that logically we have to use resistors for each ones. I decided to use pull up ones and also I'm considering using the internal resistance of the chip. I was wondering how viable was this solution. And also instead of using the resistance in the python code of my program, using what I read on this page ( https://www.raspberrypi.org/documentati ... uration.md ) which would if I understood well, use the pull up resistance of the chip as soon as the PI boot up no?
Then the circuit should look like this

pin 3 (with internal resistor)--------Switch ---------------------- Ground
pin 5 (with internal resistor)--------Switch -----------|
pin 7 (with internal resistor)--------Switch -----------|
pin 9 (with internal resistor)--------Switch -----------|
pin 10 (with internal resistor)--------Switch ---------|
....

Please correct me if I'm wrong and thank you for reading so far.

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

Re: switches resistance

Sat Jul 04, 2015 7:34 am

Pins 3/5 (gpios 2/3 SDA/SCL) have hardwired pull-ups to 3V3 and will be fine.

Pin 7 (gpio 4) defaults to a high pull and will be fine.

Pin 9 is a ground pin so unusable.

Pin 10 (gpio 15 RXD) defaults to a low pull so will not be any good.

bedesda
Posts: 7
Joined: Sun Jun 07, 2015 4:30 am

Re: switches resistance

Sat Jul 04, 2015 7:13 pm

Thank you for your answer. So I am wondering how many pins have pull-ups to 3V3? Or if there's only the pin 3 and 5?

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

Re: switches resistance

Sat Jul 04, 2015 7:27 pm

bedesda wrote:Thank you for your answer. So I am wondering how many pins have pull-ups to 3V3? Or if there's only the pin 3 and 5?
All the gpios have internal pull-ups to 3V3 and pull-downs to 0V which can be individually selected in software. Only pins 3 and 5 have external hard-wired 1k8 ohm pull-ups to 3V3 on the Pi board.

At power up gpios 2-8 default to internal pull-ups to 3V3, gpios 9-27 default to internal pull-downs to 0V. The internal resistors are of the order of 50k ohm.

bedesda
Posts: 7
Joined: Sun Jun 07, 2015 4:30 am

Re: switches resistance

Sat Jul 04, 2015 7:46 pm

joan wrote:
bedesda wrote:Thank you for your answer. So I am wondering how many pins have pull-ups to 3V3? Or if there's only the pin 3 and 5?
All the gpios have internal pull-ups to 3V3 and pull-downs to 0V which can be individually selected in software. Only pins 3 and 5 have external hard-wired 1k8 ohm pull-ups to 3V3 on the Pi board.

At power up gpios 2-8 default to internal pull-ups to 3V3, gpios 9-27 default to internal pull-downs to 0V. The internal resistors are of the order of 50k ohm.
Then I should be able to connect my 10 switches to 10 gpio pins and the common ground (with the pulls down activated thanks to this config? https://www.raspberrypi.org/documentati ... uration.md).
But then it would be dangerous to press the buttons when the Pi is booting no and the settings aren't configured right?
And if configured with the page I just showed you, would I still have to activate the pulls down in the c++/python code?

I'm sorry to bother you that much, I don't want to burn my PI :oops:

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

Re: switches resistance

Sat Jul 04, 2015 7:58 pm

bedesda wrote:
joan wrote:
bedesda wrote:Thank you for your answer. So I am wondering how many pins have pull-ups to 3V3? Or if there's only the pin 3 and 5?
All the gpios have internal pull-ups to 3V3 and pull-downs to 0V which can be individually selected in software. Only pins 3 and 5 have external hard-wired 1k8 ohm pull-ups to 3V3 on the Pi board.

At power up gpios 2-8 default to internal pull-ups to 3V3, gpios 9-27 default to internal pull-downs to 0V. The internal resistors are of the order of 50k ohm.
Then I should be able to connect my 10 switches to 10 gpio pins and the common ground (with the pulls down activated thanks to this config? https://www.raspberrypi.org/documentati ... uration.md).
But then it would be dangerous to press the buttons when the Pi is booting no and the settings aren't configured right?
And if configured with the page I just showed you, would I still have to activate the pulls down in the c++/python code?

I'm sorry to bother you that much, I don't want to burn my PI :oops:
That's the situation at power-up. All sorts of software (device tree, loaded modules and drivers) may reconfigure the gpios during boot.

You will only be absolutley safe if you set the pull-ups/downs yourself in your own software (or add your own stronger hardwired pull-ups/down) and only enable your hardware once that is done.

bedesda
Posts: 7
Joined: Sun Jun 07, 2015 4:30 am

Re: switches resistance

Sat Jul 04, 2015 8:13 pm

Thank you so much for your answer, I think I'll just add 10k ohm resistor between the switch and the pin, to be sure I won't have troubles, thank you again for your help! :)

Return to “Beginners”