Hello.. many thanks for any help!
I have a brushless motor system being run by three Arduinos. The system has grown from a single Uno as the pulse-controller, adding a 2nd with an LCD and Joystick as a user interface, and finally a Mega w/ ethernet and relay shields. As the system grew, I first used SoftEasyTransfer between the Pulse controller (Slave) and User Interface (Master), and moved over to I2C to integrate the 3rd Arduino (BATManager, 2nd slave)... and now I've hit a wall... being that Tx to the 2nd Slave works perfectly. But I can not get the Master to Tx or Rx from Slave 1 in either direction. My current code has periodic transfers from the Slave, and a push-putton to cause a momentary Tx to the Slave from the Master.
In summary, the system its a brushless motor controller, using A0 to sense a magnet through a sensing coil. When a "threshold" value is reached, the drive coils are charged until the analog input falls below the "threshold". The "threshold" value is the primary variable being passed around, but the EastTransfer data structures have a standard set that may be implemented in the future. Master has pins for an IR LED and IR phototransistor, which make up an optical tachometer, as well as 2 pushbuttons, joystick, and Seeed Studio 16x2 LCD, and 2 LEDs (unused at the moment).
Hardware setup along the I2C bus is 2.2K Ohm resistors to the 5v line, and all Arduinos share a GND. I've read conflicting info about whether the 5v (+) VDD needs to also be shared. Testing with the (+) shared had the same results. The relay shield and LCD seem to overload a common 9v battery, so I plan to power each Arduino with it's own battery. For testing each are powered through the USB cable.
From the research, I've covered the basics... I'm using A4 & A5 on both UNOs and 20/21 on the Mega for SDA and SCL respectively. Shared Ground. Each Arduino has their own I2C ID.
I've added a bunch of Serial.printlns to debug where things are... odd thing is that all three programs run along, no crashes... the BatMan (slave 2) receives fine. Problems are 1) when the Master sends data to the Pulse Controller (slave 1), code makes it as far as receiveEvent() and simply moves on.. the data is not received, no variables updated, keeps on looping. The next time I try to update the Slave 1, it does not make make it to the receiveEvent(). On the Master, the same behavior, in that the receiveEvent() will trigger once, then not again... but the loops keep going. No compile errors.
System seems to run for as long as practical without locking, so I don't think it's a stack-overflow or something like that... I'm curious if I have a type mis-match somewhere/somehow?!? I'm only passing Int's around at this point... seemed simple enough! Interrupt collision maybe? I'm grasping at straws at now.
Master is an UNO R3, Slave 1 is an UNO SMD and the BatMan (slave 2) is a Mega 2560. Not sure what else to add except the code. Questions welcome and thanks again for any suggestions.
Master code: Dropbox - Error - Simplify your life
Slave 1 code: Dropbox - Error - Simplify your life
BatMan (slave 2) code: Dropbox - Error - Simplify your life