How to test an atmega (arduino) i2c network

First of all sorry for my bad English and for this "theoretical" question on how is the best way to do things. I'm just out from university and no-one ever told me how problems can be resolved in a practical way.

I'm trying to develop a network of 4 atmega (I'm using Arduino platform), 1 master and 3 slaves. they are communicating via i2c.

I'm looking for a smart way to test it. right now my debug is happening via serial protocol: i have some

Serial.println(...);


and I'm reading them plugging the Arduinos via USB and reading serial incoming messages with serial monitor in Arduino IDE.

What i am doing now is:

1. Coding slaves having a test program (one for each slave) in the master (powered with a normal power supply).
2. When I'm "sure" that the slave is OK, unplug the USB of the slave, plug the master, coding the master.
3. Do this for each slave.
4. Pray.

This workflow has a lot of problems; it is a blind communication. When I'm working on the master, I don't really know what is happening on the slaves, and vice-versa. Then, if one Arduino crash causes the master to crash (because the I2C protocol does not provide for the fact that one slave does not respond or it is switched off) and I have to reset all slaves (I'm doing that by switching off the power supply of all slaves).

One more problem: Some slaves need real-time operation with stepper motors, and if a motor is running and some interrupts of I2C protocol library Wire.h occur (and this is happening each time the master require some message from the slave, I think), it eventually can happen while the motor is running and this cause the motors' movement (that must be as linear as possible) to be "trottered". To avoid this, I have only one-way communication: The slaves only receive commands. I don't know if this is the best solution but seems to work.

The blind one-way communication, the repeated plugging and unplugging of USB, plugging and unplugging the power supply and pressing reset buttons is making me feel stupid. Until now, I have done software development with IDE (Eclipse) that provides debug. If I have a some threads to be synchronized, I can have prints or whatever that make life simpler, and with software I'm doing unit testing that gives me a good tool for isolating the bug. Now with the Arduinos net, when something goes wrong, I don't have any idea how to find where is the problem. This is my first hardware network, and it is frustrating.

I need some advice on figure out a smart workflow, having a nice way to test my system, and to feel myself a coder.

-
Why unplug and replug? Why not just leave them all plugged in and read debug data from all four devices? –  Jim Paris Oct 16 '12 at 18:17
Did you create this network or are you just testing it? The only reason I ask is because atmega devices can be connected via SPI with the configuration you are talking about. You need to use a pin to enable/slave select each slave when you want to talk to it. The slaves are able to talk back over MISO. –  Hair_of_the_Dog Jan 14 '13 at 22:22

You can probe and monitor the bus using BusPirate. This way you can see what is happening on the bus and will help you debug the issues.

Here is a video demonstrating i2c bus scan.
It can also be used as a I2C analyzer as demonstrated in this video.

-

Plug all of the arduino boards into a usb hub?

It's fine to have the slaves only receiving, but then you have no guarantee that commands were successfully received. Some sort of ACK is probably better.

-
If he's using I2C, then the protocol itself assures that the message was received. –  Nick Johnson Oct 17 '12 at 9:05