Master Slaves and sensors

Hello all.

I'm working on a project that involves multiple ATMEGA2560. I plant to have 1 set as master and 10 as slaves. These are all communicating over I2C. My question is with regards to the slaves using a digital potentiometer MCP4551-103E/MS or MCP4131-103E/SN "Microchip Technology". The communication on the pot is over I2C or SPI. How would I setup the ATMEGA so that they all communicate with each other and each ATMEGS also communicates with its pot?

Thanks

How would I setup the ATMEGA so that they all communicate with each other and each ATMEGS also communicates with its pot?

Use the SPI version of the pot as you use the I2C bus for the inter-Arduino communication. And they will never communicate with each other, they will only communicate with the master and even that will happen only if the master explicitly asks for it. Also keep in mind that the maximum length of the I2C bus is about 1 meter at standard speed. If your Arduinos are more spread you should consider another communication channel (RS-485 might be a good choice).

Maybe you should tell us more about your project. Why do you use a separate Mega2560 for each pot? Sounds like an overkill but you might have reasons for it.

You can purpose one of the USART's (2560 has 4) as a master-mode SPI device and run SPI digital pots on that.

SPI howto and libraries for master, slave and serial port full speed master mode only SPI.

Getting a 2560 to run as both slave and master... well it's 2 different ports, you have 8K RAM (can add more) and you can make it so that only 1 bus is running at a time. Default SPI clock means read and write the port register every 32 cycles, dealing with 1 port at a time may be a good thing.