EEVblog Electronics Community Forum

Electronics => Beginners => Topic started by: Chet T16 on April 07, 2012, 07:10:39 pm

Title: I2C Question (with Arduino)
Post by: Chet T16 on April 07, 2012, 07:10:39 pm
I'm trying to send some data to an I2C slave from an arduino. Maybe a silly question but do i need to have the slave connected to test the output from the arduino? At the minute i have the arduino connected directly to my logic analyser.

This is the data i captured between the master and slave earlier, its the radio and display in one of the cars.

(http://i256.photobucket.com/albums/hh169/chet_t16/rasta/display/i2c_car.png)

This is the arduino code, pin 2 is the MRQ line

Code: [Select]
#include <Wire.h> 
void setup() {
   Wire.begin();
   pinMode(2, OUTPUT);
digitalWrite(2, HIGH);
delay (1000);
}
void loop()
{
digitalWrite(2, LOW);
delay(20);
digitalWrite(2, HIGH);
Wire.beginTransmission(0x94);
digitalWrite(2, LOW);
Wire.send(0xB0);
Wire.send(0x85);
Wire.send(0xAB);
Wire.send(0x62);
Wire.send(0x40);
Wire.send(0x40);
Wire.send(0x40);
Wire.send(0x73);
Wire.send(0x62);
Wire.send(0x67);
digitalWrite(2, HIGH);
Wire.endTransmission();
delay(1000);

And this is what i'm capturing on the logic analyser (note the write to address isn't the one in the code) Any i2c code i try run gives the same output)

(http://i256.photobucket.com/albums/hh169/chet_t16/rasta/display/i2c_ard.png)

So, yeah, i'm a bit confused. Is the arduino expecting a response from the slave? Even if it was i don't get why the address would be wrong. Is there different i2c protocols? I

Any input appreciated!
Title: Re: I2C Question (with Arduino)
Post by: Short Circuit on April 07, 2012, 07:45:55 pm
Yes, you need a device to talk to. When addressed, it will acknowledge it's address and subsequent transfers. Now, the transfer quits because there is no ack on the address.
Title: Re: I2C Question (with Arduino)
Post by: almoehi on April 07, 2012, 07:53:48 pm
Your master ist telleing your slave that he wants to write to him and waits for the aknowledge signal from the slave that tells the master that the slave is listeneing and he can proceed sending data to the slave. As the slave does not send the ACK the master knows that the adressee is not listening and quits his attempmts talking to the lasve.
Title: Re: I2C Question (with Arduino)
Post by: Chet T16 on April 07, 2012, 08:44:45 pm
That would explain the ACK then  ::)

I'll have to connect everything up to the car tomorrow then, i couldn't earlier because i only had 1 usb cable with me and it was either the arduino powered up or use the logic analyser!