Go Down

Topic: Arduino going into Hang Mode using I2C (Read 2785 times) previous topic - next topic

asmughal

http://www.smacula.co.uk/2011/12/communicating-between-arduino-boards.html

I have just written this as a case study for what I am trying to achieve.

I am communicating between two Arduino boards, using a bus extender, and using optical isolation.

Once I configured it properly before the isolation state, it worked perfectly.

However, after I added the optical isolation in the circuit, the system seems to hang every now and then when you disconnect the hardware.

Has anybody else experienced this? And has anybody solved this? Is this a time out issue?

I did see an I2C master library out there, http://dsscircuits.com/articles/arduino-i2c-master-library.html, which seems to promise to sort similar problems but A, I cannot apply it in my application, and B, I am not entirely sure if that is the problem I am facing.

Any help is appreciated.

The code, and the circuits are explained in the link I gave.

Thank you!

wayneft

The lines appear to be very noisy on both the SDA and SCL lines which is probably what's causing the system to hang.  According to the data sheet, the Arduino will filter out noise spikes shorter than 50ns so you may want to measure the width of some of those spikes.

I know you said the other library won't work for your application but you may want to at least try it anyway because I wrote it so that it would have a better chance at recovering from bus lockups and report back more error codes to help define where problems are happening.

asmughal

Thanks for your prompt reply... got busy with the Xmas break and all, so first of all let me wish you a merry Xmas!

So how should I use the write() command? I do not know a register address in the other Arduino to write to?

Thanks!

wayneft


Thanks for your prompt reply... got busy with the Xmas break and all, so first of all let me wish you a merry Xmas!

So how should I use the write() command? I do not know a register address in the other Arduino to write to?

Thanks!

...and a very Merry Christmas to you! 

It complicates it a little because the way the library is written it's looking for an address.  But if we look at how the communication works there really is no difference between sending 6 bytes with no address and sending an address followed by 5 bytes...it's all received by the slave the same. So with that being said assigning the address to outgoingByte[0] and sending the next 5 bytes should suffice.  So the below code should work.
Code: [Select]

I2c.write(2,outgoingByte[0],outgoingByte+1,5);

asmughal

Once again thanks for the reply.

I shall try and implement it and give it some tests/scope.

However, just one further question, the hanging of the Arduino, is that definitely a TIME OUT issue? Or could there be any other explanation that I have missed out?

Thanks!

wayneft


However, just one further question, the hanging of the Arduino, is that definitely a TIME OUT issue? Or could there be any other explanation that I have missed out?


Can't say that it's definitely a timeout issue but the library will give you the error code where it's hanging which will help narrow down the problem.

asmughal

Hi Wayne,

I have tried your library after some discussions on your blog as well, and it seems to be working very well.

I'll keep you posted about any updated information.

Thanks again for your help throughout!

wayneft


Go Up