Need Help Wiring Switches

Thread Starter

7H3LaughingMan

Joined Dec 5, 2012
6
I am working on a breadboard that will allow me to add GPIO pins to any device w/ I2C. It is currently based around the MCP23017 which is a 16-Bit I/O Expander from Microchip.

At the moment I want to be able to configure the 3 Address Pins w/ a DIP Switch, but the problem is that they are externally biased and need to be hooked to either Ground or VDD w/ ground. From my understanding I am going to need to add either a Pull-Up or a Pull-Down resistor so it wouldn't be floating and cause issues. I am confused on the specifics of each application and which would be best for this situation w/ a small footprint.

I am also wanting to add a simple push button for the Reset Pin so thing can be reset internally in case there is an issue, however this is also externally biased and needs to be connected to VDD for normal operations or ground to be reset. I am assuming this will also need either a Pull-Up/Pull-Down but what kind of switch should I use for this case?
 

thatoneguy

Joined Feb 19, 2009
6,359
3x 10kΩ Resistors from \(\small{V_{DD}}\) (+5V) to dip switch, with other connection of each switch to \(\small{V_{SS}}\) (Ground) for the 3 address lines. Connection to the IC is between the resistor and Non-Ground switch connection.

1x 10kΩ Resistor from \(\small{\overline{RESET}}\) to \(\small{V_{DD}}\) to momentary NO (Normally Open) switch to \(\small{V_{SS}}\) for Reset button. Optional series capacitor and resistor with with switch to reduce key bounce if it is a problem. Connection to the IC is between the resistor and Non-Ground switch connection.

2x 4.7kΩ (for 100kHz, 1kΩ for 1.7Mhz) from SDA to \(\small{V_{DD}}\) and same value resistor from SCL to \(\small{V_{DD}}\). No connections to ground.

Power pins should have a 0.1μF cap between \(\small{V_{DD}}\)and \(\small{V_{SS}}\) as close as possible to the pins, with as short of leads as possible. (See sigline on "bypass caps")

More info can be found in The Datasheet
 

Thread Starter

7H3LaughingMan

Joined Dec 5, 2012
6
Well I feel kind of stupid about the fact of not mentioning that VDD is going to be +3.3V, the main MCU I am going to be using is a Raspberry Pi which is a 3.3V system. And since I am going to be using the interrupt pins I would have to step down the 5V to 3.3V to be useable without frying the electronics.

Are the resistors necessary if it is being hooked up to a MCU? I am also confused about the fact of hooking SDA & SCL to VDD since they need to be hooked up to the SDA/SCL of all the other devices that are going to operate on the bus.
 

thatoneguy

Joined Feb 19, 2009
6,359
For 3.3v usage, the connections are the same for address and reset, \(\small{V_{DD}}\) is 1.7-5V for that IC, I just added the typical value in parenthesis for those who get DD and SS confused.

For the I²C Clock and Data lines (SCL and SDA), as long as there are pullups somewhere on the bus, and the connecting wires aren't too long (max length depends on speed of bus, see I²C specification). The pullups need to be stronger when running at High Speed (1.7Mhz), though 3.3V and 5V don't change the requirement for pullups somewhere, as the bus is an open drain connection.
 

Thread Starter

7H3LaughingMan

Joined Dec 5, 2012
6
I did some digging around and apparently there Raspberry Pi has a 1.8kΩ pullup resistor that is built into the BCM2835 chip and is on by default. I am doing some checking to see if they could be disabled and it looks the BCM2835 can change the pins to pullups, pulldowns, or disabled.
 

thatoneguy

Joined Feb 19, 2009
6,359
Leaving them on is fine. As long as there are pullups somewhere on the bus, the bus will work, you don't need to add them to every IC, assuming your bus is < 12 inches total.
 

Thread Starter

7H3LaughingMan

Joined Dec 5, 2012
6
Is something like this what we are talking about for doing a pull-down resistor to the dip switches? One issue I am having w/ Eagle Cad is how do I add a board component to my Ground/3V3, I was wanting to do a pad w/ holes to pull the cable through.
 

Attachments

thatoneguy

Joined Feb 19, 2009
6,359
Is something like this what we are talking about for doing a pull-down resistor to the dip switches? One issue I am having w/ Eagle Cad is how do I add a board component to my Ground/3V3, I was wanting to do a pad w/ holes to pull the cable through.
That will work as well, only the "on" position will be a 0 address, and the "off" position will be a 1 address.
 

ErnieM

Joined Apr 24, 2011
8,377
The MCP23017 has an Operating Voltage Range (V)1.8 to 5.5, so it can run at the same voltage as the Pi, unless you intend to split the voltage to run 5V peripherals.

I2C can run at either 3.3or 5V, but not both without help. I've mixed parts like that using a level translator like a PCA9306.

While I have never used Eagle I do lots of PCBs. (Currently I use Kicad.) I'm not sure exactly what you mean by a the "pad with holes" but generally you can make and add a mechanical symbol for things like board mounting holes. You may also be able to define a custom footprint for these wires where you get a thru hole for the electrical connection, plus a non connected hole for a wire strain relief.
 

Thread Starter

7H3LaughingMan

Joined Dec 5, 2012
6
That will work as well, only the "on" position will be a 0 address, and the "off" position will be a 1 address.
I am confused by this comment, I thought what I wanted to use was a pull-down resistor. Where you have VDD connected to a switch, when then connects to the pin, but between the switch and pin you have a resistor connected with the other end connected to ground. So when the switch is turned on the current will go to the lease resistant path which would be the input pin, which will be set as a 1.
 

ErnieM

Joined Apr 24, 2011
8,377
I am confused by this comment, I thought what I wanted to use was a pull-down resistor. Where you have VDD connected to a switch, when then connects to the pin, but between the switch and pin you have a resistor connected with the other end connected to ground. So when the switch is turned on the current will go to the lease resistant path which would be the input pin, which will be set as a 1.
That is correct. A pull down resistor makes it a
zero with switch open, and a
one with switch closed.
 

Thread Starter

7H3LaughingMan

Joined Dec 5, 2012
6
That is correct. A pull down resistor makes it a
zero with switch open, and a
one with switch closed.
So I am correct but your telling me the opposite, unless a pin that is high is a 0 or a low is 1. My understanding is that a pull-up resistor makes it high by default thus it's a 1 and when the switch is turned on the power goes to ground bringing the pin to a low state being a 0.

A pull-down resistor has the pin normally connected to ground being a 0, and when the switch is turned out on the power goes through it and since ground has a resistor before it then the power goes to the pin since it's least resistant.

So a pull-up makes it high by default unless the switch is activated, and a pull-down makes it low by default unless the switch is activated.
 
Top