Go Down

Topic: Looking for macegr and info on his "Centipede shield" (Read 2 times) previous topic - next topic

macegr

You assign addresses by pulling the A0, A1, and A2 lines high or low. If a chip has all three low, it is chip 000 and in the Centipede library is pins 0 through 15. If you set up the chip as address 001, then it will have pins 16 through 31.

There should be no conflict between the RTC and the MCP23017 on the same I2C bus.
Unique RGB LED Modules and Arduino shields: http://www.macetech.com/store

lost_and_confused

Ok,

I shall show my stupidity here:

But obviously the MCP can't have the same address as either the RTC or EEPROM.

How/where in the code do I determin their addresses?

macegr

You'd probably do best to look in the respective datasheets for the parts.

But I can tell you now it's pretty unlikely you'll see a collision.
Unique RGB LED Modules and Arduino shields: http://www.macetech.com/store

lost_and_confused

Well, I am "that much closer" to having it working.

Put in the IC socket and killed a couple of caps (alas) and 1 x 7805 (drats!)

But the voltage on the socket looks good.

Just to check:
I connect the SCL and SDA pins from the Arduino to the pins on the MCP and "voila!"

Do I need to do anything with the address lines on the chip?  For now I haven't connected them to anything.

I shall make it address 0 and hope.

When I have the centipede library installed/included, how would I know I am "talking to it"?

I shall scurry off and look for example sketches.

lost_and_confused

#9
Jul 14, 2012, 09:13 am Last Edit: Jul 14, 2012, 09:45 am by lost_and_confused Reason: 1
Slight update:

Something doesn't work.

I got the example sketch and applied it to my sketch.

When I complied it and sent it to the arduino, it "crashed".  The first line of the display was black, the second clear, the third back and the fourth clear.

I paniced (spelling?) and thought it was the I2C bus.

Luckily when I went back to an earlier version it worked.  So then I realised that the Centipede library and stuff were happening.

I remarked out the lines and it works.

One thing:
I haven't got the 23017 connected yet.

I am (stupidly) worried about it.  When building the veroboard part, I killed 1 voltage regulator and 2 caps.  Well the caps were probably already dead.  Can't be sure.

So I need to work out - somehow - what the RTC and EEPROM addresses are and make sure the 23017 is at another one.

Sketch here:
Code: [Select]

// Example code for Centipede Library
// Works with Centipede Shield or MCP23017 on Arduino I2C port

#include <Wire.h>
#include <Centipede.h>


/* Available commands
  .digitalWrite([0...127], [LOW...HIGH]) - Acts like normal digitalWrite
  .digitalRead([0...127]) - Acts like normal digitalRead
  .pinMode([0...127], [INPUT...OUTPUT]) - Acts like normal pinMode
  .portWrite([0...7], [0...65535]) - Writes 16-bit value to one port (chip)
  .portRead([0...7]) - Reads 16-bit value from one port (chip)
  .portMode([0...7], [0...65535]) - Write I/O mask to one port (chip)
  .pinPullup([0...127], [LOW...HIGH]) - Sets pullup on input pin
  .portPullup([0...7], [0...65535]) - Sets pullups on one port (chip)
  .init() - Sets all registers to initial values

  Examples
  CS.init();
  CS.pinMode(0,OUTPUT);
  CS.digitalWrite(0, HIGH);
  int recpin = CS.digitalRead(0);
  CS.portMode(0, 0b0111111001111110); // 0 = output, 1 = input
  CS.portWrite(0, 0b1000000110000001); // 0 = LOW, 1 = HIGH
  int recport = CS.portRead(0);
  CS.pinPullup(1,HIGH);
  CS.portPullup(0, 0b0111111001111110); // 0 = no pullup, 1 = pullup
*/

Centipede CS; // create Centipede object


void setup()
{
  Wire.begin(); // start I2C

  CS.initialize(); // set all registers to default

  CS.portMode(0, 0b0000000000000000); // set all pins on chip 0 to output

  //TWBR = 12; // uncomment for 400KHz I2C (on 16MHz Arduinos)

}


void loop()

  for (int i = 0; i < 15; i++) {
    CS.digitalWrite(i, HIGH);
    delay(10);
  }

  for (int i = 0; i < 15; i++) {
    CS.digitalWrite(i, LOW);
    delay(10);
  }
}



Go Up