Arduino Forum

Using Arduino => Networking, Protocols, and Devices => Topic started by: macegr on Jan 30, 2011, 02:33 am

Title: Updated Centipede Library (MCP23017 I2C 16-port I/O expander)
Post by: macegr on Jan 30, 2011, 02:33 am
In response to a customer request I finally added internal pullup support in the Centipede Library ( for either the Centipede Shield or DIP MCP23017 chips).

Link: http://docs.macetech.com/doku.php/centipede_shield#code_example

Bonus tip: the MCP23017 supports up to 1.7MHz I2C speed, though the Arduino does not. However, the Arduino does support 400KHz I2C operation. For 16MHz Arduinos, simply add TWBR = 12; in your setup() function after Wire.begin();
Title: Re: Updated Centipede Library (MCP23017 I2C 16-port I/O expander)
Post by: kg4wsv on Jan 30, 2011, 06:43 pm
Quote
the Arduino does support 400KHz I2C operation. For 16MHz Arduinos, simply add TWBR = 12; in your setup() function after Wire.begin();

If you really want to make your library friendly, include code that does that automatically, for all the arduino variants.  Oh yeah, and put the control registers back the way you found it, so I can use my XYZ device at whatever speed, and use the MCP23017 as fast as possible.

Thanks for sharing your code!

-j
Title: Re: Updated Centipede Library (MCP23017 I2C 16-port I/O expander)
Post by: macegr on Jan 31, 2011, 07:43 am
Yeah I might add support for it...you are correct that the TWBR register transparently and instantly changes the I2C speed. The prescaler registers work the same way. It would be interesting to write an I2C library that automatically negotiates to the highest speed that doesn't exhibit communication problems...could be very handy for long distance I2C without extra driver hardware.