20140402 (W) ASETNIOP Keyboard


Pull-up resistors are tricky to understand at first.  They seemed counterintuitive to me but now they’re just a regular part of hardware programming.

The first thing to understand is that if you don’t do something to bring a pin to ground or voltage it just “floats.”  Bringing a pin to HIGH or LOW is called biasing.  Floating does not produce reliable results.  You can solder a resistor in place for each pin and the resistor will hold it HIGH or LOW so you always know what to expect when you read that pin.  That would be troublesome so inputs come equipped with the ability to hold themselves HIGH with a pull-up resistor.

For example, if you set all of your inputs to use the pull-up resistors but didn’t connect any switches you would always read a HIGH state on those pins.  This is good because now you have a reliable way to check that there is nothing happening on that pin.  However, it’s a little confusing because, if you’re like me, you expect there to be a HIGH value when something is happening on the pin.  To make that pin go LOW you install and close a switch between that pin and GROUND.  The path to ground overpowers the resistor and the pin will read zero volts.

Conversely:
Pull-down resistors are not built into the chips I’ve worked with but you can easily install them yourself by putting a high value resistor between the pin you’re working with and ground.  Then you close a switch between the pin and a voltage the chip can accept and it goes HIGH when you press the switch.  Pull-down resistors work the way most people expect a switch to work because you get a HIGH value when the switch is closed.  In this case a high value resistor would be 20KΩ to 11MΩ.

Enough background.
----------
More examples of code written with the standard Arduino Wires library were studied to see how others have approached the communication between an Arduino and the MCP2308 chips.  It seems that there does need to be a command to the MCP23008 which designates the pins as inputs.  There may need to be a second call which designates the pins should have their internal pull-up resistors activated.  According to the datasheet this is done through the GPPU (0x06) register.

The code currently repeats the data from the chip but doesn’t specify if the data is new.  This means that there is no definitive proof there is continued communication.

To do:
• Establish communication with MCP23008
• Follow programming agenda

 Journal page

Comments