Page 1 of 1

RGB module not working once leostick joins i2c bus..

Posted: Thu Nov 01, 2012 12:54 pm
by r23d
Hi folks,

I'm a bit stuck on something and need help! :?

I have an RGB module attached to a leostick which is slaved to an arduino duemilanove on an i2c bus.

I'm having a few issues with this setup, namely :

1. Once the Duemilanove (master) joins the bus, the RGB Module seems no longer to respond. (it works fine when not attached, or when I comment out wire.begin() on the master).
2. While I can send messages from Master to slave, I can't seem to request and receive data from the slave leostick.
3. The Piezo on the Leonardo makes an audible hum (sounds like 9600Hz) when the I2c is running. :shock:

I'm new to i2c and the RGB module, so it could be something simple, but I'm tearing my hair out here...

My sketches are attached...

Any ideas? :geek:

cheers,

Richard Allen
Melb, Australia

Re: RGB module not working once leostick joins i2c bus..

Posted: Fri Nov 02, 2012 5:02 am
by r23d
Sorted problem :)

Basically I figured out a few things about the I2c bus :

1. You don't have to have a master-slave setup, a master-master setup is possible and works much better for my case. I was sending requests for data from the slave leostick out from the master duemilanove every program loop (crazy I know). I thought this was the only way to get data back from the slave as soon as an event happens there. Of course, with the slave now a master, it can send it's own data when it happens interrupt-style.

This was why my piezo was so noisy - all those messages! Plus I guess the poor leostick was so busy processing interrupts, the messages to the RGBLED didn't stand a chance of working. Now it's happy.

2. If you have 2 masters on I2c, and you want one to send a message to another, and get a reply message sent back immediately, do the second wire.Write() (the reply) outside the first wire.Receive event, otherwise the i2c bus won't cope.

Hope this helps someone out there...

code attached FYI. The actual project is a work in progress, so don't expect any amazing stuff from the code just yet except working i2c and RGBLED examples...

cheers,

Richard