I2C LCD backpack and multi master

by smithr on Sat Feb 09, 2013 3:00 pm

I am using an arduino as a PC fan controller. I use the I2C bus to read temperatures from the motherboard's temperature sensors.

This is working very well for me at the moment. I decided that I wanted to add an LCD screen to display various information so I bought a 20x4 LCD + the adafruit I2C backpack. This works great for the most part but after a short period of time the screen starts to become corrupted.

I think that the problem is that the motherboard is also using the bus at the same time. This shouldn't be a problem as both the Arduino and motherboard I2C controller are able to operate in multi master mode, but I am seeing Speedfan report trouble accessing the sensors only when the screen is active so I strongly suspect that this is the problem.

I'll be investigating this further myself but I wanted to post the issue here in case anyone can offer any advice and save me some trouble.

If I really can't get it working I guess I will have to use SPI instead. I guess alternatively I could manually implement another I2C master using an additional two pins.
smithr
 
Posts: 4
Joined: Sat Feb 09, 2013 2:33 pm

Re: I2C LCD backpack and multi master

by adafruit_support_rick on Sat Feb 09, 2013 4:49 pm

You may be seeing a voltage problem on the I2C data lines. I'm going to guess that the I2C lines on the motherboard run at 3.3V. When you connect the arduino alone, this isn't a problem because the arduino does not pull SDA and SCL up to 5V, and it is comfortable with 3.3V signals on those lines.

However, the backpack has pullup resistors that bring the signal lines up to 5V, so when you add that you are putting 5V into the motherboard's I2C circuit.

Hopefully, you haven't damaged the motherboard yet, but it's likely that you will if you continue to do this.

I think that what you want to do is to get one of these level-shifters, and connect to the PC motherboard through that.
User avatar
adafruit_support_rick
 
Posts: 8583
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY

Re: I2C LCD backpack and multi master

by smithr on Sun Feb 10, 2013 2:57 pm

Ok, I've put a scope on the motherboard's SMBus line's and yes they are running at ~3V.

With just the arduino connected to the motherboard it is also around 3V like you said, and with just the arduino and backpack it is 5V.

Since they are banned I will add a logic level converter. I think there may be more to the problem than this though so I may end up using the SPI or software I2C instead.
---------------------------------------------------------------------------------------

The datasheet for the MCP23008 states:

Data is written to the MCP23008 after every byte
transfer. If a STOP or RESTART condition is
generated during a data transfer, the data will not be
written to the MCP23008.


I'm wondering whether this is corrupting the data received by the LCD. If this is the case I'm unsure how to solve it except perhaps by modifying the library to read the registers to check that they have been written correctly.
---------------------------------------------------------------------------------------

I thought that I'd found a potential problem but it hasn't made a difference. The datasheet for the MCP23008 shows the I2C read sequence as writing the address of the register that we want to read, then sending a RESTART condition and requesting the data from the register. I think that the code in the library is sending a STOP condition:

Code: Select all
uint8_t Adafruit_MCP23008::read8(uint8_t addr) {
  Wire.beginTransmission(MCP23008_ADDRESS | i2caddr);
#if ARDUINO >= 100
  Wire.write((byte)addr);   
#else
  Wire.send(addr);   
#endif
  Wire.endTransmission();  // LINE 8
  Wire.requestFrom(MCP23008_ADDRESS | i2caddr, 1);

#if ARDUINO >= 100
  return Wire.read();
#else
  return Wire.receive();
#endif
}


I think that line 8 of the code above should be:

Code: Select all
Wire.endTransmission( false);


I changed this in my library though and it had no effect so I guess it's not important.


Thanks for the help btw, you may have saved me a lot of trouble.
smithr
 
Posts: 4
Joined: Sat Feb 09, 2013 2:33 pm

Re: I2C LCD backpack and multi master

by adafruit_support_rick on Sun Feb 10, 2013 4:09 pm

I wouldn't bother trying to debug anything until you get the voltage levels straightened out. I think that's going to turn out to be your problem.
User avatar
adafruit_support_rick
 
Posts: 8583
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY

Re: I2C LCD backpack and multi master

by smithr on Mon Feb 11, 2013 7:25 am

Ok, I'll try that first.
smithr
 
Posts: 4
Joined: Sat Feb 09, 2013 2:33 pm

Re: I2C LCD backpack and multi master

by smithr on Tue Feb 19, 2013 4:07 am

I received my logic level converter yesterday and it has solved the problem.

Thanks for the help.
smithr
 
Posts: 4
Joined: Sat Feb 09, 2013 2:33 pm

Re: I2C LCD backpack and multi master

by adafruit_support_rick on Tue Feb 19, 2013 8:45 am

Groovulent! :D
User avatar
adafruit_support_rick
 
Posts: 8583
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY