i2c new to me...

Allright Folks,

One of you all's gunna need to explain this whole i2c thing to me. I have done a wiki (which confused me even more) and a few google searches. What I have got so far is it is an extra little storage space that a pic can talk to. I guess there are "packets" of bits and addresses or something like that but really, I have no idea.

Can someone explain this whole i2c thing and include some basic, pratical uses (and how to do it) when being used with a picaxe. --Explain it as if you would explain it to a 4-year-old.

As for me, I am just now playing with a picaxe 40 on a R4 Systems "4-chip board" (it supports and came with an i2c).

I think you mean an I2C EEPROM

I2C itself is a kind of special serial-like protocol for communicating between devices.

An I2C EEPROM is a tiny storage device, which may be accessed via the I2C serial protocol

As for any specifics of the board you are using, I’d find some example code to look at,

like: http://profmason.com/?page_id=106

:slight_smile:

I am starting to get it, a little

Ok, I guess I was right in thinking it was extra space to store stuff. I visited the link (above) which helped a lot -thanks. I am still a little unclear on the read/ write thing and the %10100000 thing. I guess I should ask a pratical question. If I wanted my robot to remember a series of inputs, say I have 4 buttons and I hit each one in a certain patern, how could I use the EEPROM to remember the pattern? --For example, 4 buttons going to 4 input pins, and I hit 1,3,4,2. Now I want the EEPROM to remember that and when I ask it, I want 4 LED’s to blink the same pattern.

Can anyone walk me through that?

Wait, Wait Don’t tell me yet…

Hey folks,

I am still studying all the info found at http://profmason.com/?page_id=106 (thanks Buhatkj) and the more I read, the more it is starting to make sense. I still welcome any info or help you might have, but please don’t give me any full pieces of code. --I wanna figure it out for myself!

–This stuff is cool!

I2C and other devices

I2C is a communcation method between your micro and a number of other devices. Nearly every Devantech device has the ability to receive and send back data over I2C. Sonars, compasses, motor drivers etcetra, in addition to eeproms like above. And all these devices can be hooked up on the same 2 pair of wires (technically 3), so you don’t have to string a bunch of wires to every device you want a central micro to communicate with.

Basically you can have an eeprom, a sonar, a motor driver all connected by their SDA and SCL pins (and a ground connection commmon to all for reference) and only the device that is addressed (by the micro starting I2C comms) will respond. All devices will listen to the initial address sent by the master, but only the matching slave addressed device will respond to the additional info sent by the master next. Data is sent 1 bit at a time, at various data rateds the devices are capable of.

I think I2C means Inter-IC-Communication, and is trademarked by Philips, which is why companies like Atmel refer to their compatible devices as TWI (Two Wire Interface).

It’s a nice convenience, but I actually prefer reading data directly, like analog inputs, PWM, to get a quicker response to more current data.

 

Another piece of the puzzle
i2c is not an EEPROM, but an EEPROM can be i2c… Right?

Right, I2C is just how the

Right, I2C is just how the stuff can be communicated with. Its like Sharp IR needing an analog pin and say a sonar ranger being PWM output or something. Its just a different and maybe easier way to interface to your micro.

Tecnically, i2c is a bus, a

Tecnically, i2c is a bus, a couple of lines where more devices can talk… Something like a small network or lan, of course with the limitation that only the master (usually the microcontroller) can talk to other “nodes” (slaves).

Here’s an example for picaxe, this comminicates with an i2c LCD display:

 

init: pause 500 ’ wait for display to initialise
i2cslave $C6,i2cslow,i2cbyte ’ set up i2cslave for LCD
main: writei2c 0,(254,128,255) ’ move to start of first line
pause 10 ’ wait for LCD to process data
writei2c 0,(“Hello!123”,255) ’ output text
end

Commands here are i2cslave and writei2c. There’s also a readi2c to read from a device. There exists all kinds of components that communicates with i2c: motor controller, sensors, actuators, everything.

I love i2c becouse it cuts down the number of wires you have to have, it gives a “standard” protocol that works for everything and it’s quite easy to use once you get it (well, not as simple as an analog input :P)

the only thing i want to add
the only thing i want to add is: if you are using picaxe then just go for the I2C walkthrough they provide you with. It also gives you nice examples on how to communicate with an EEPROM. I don’t have much time to do that now, because i am already doing IR comunication, but i am also interested in comunicating with EEPROMs, so if you achieve some results tell us!

This board has a Picaxe 18

This board has a Picaxe 18 and a dedicated servo-controller all hooked up together.

The picaxe sends i2C to the controller, to let the controller know how & where any of the 21 servos that the controller can control should be.

That setup tought me to write / write i2C with Picaxe. Which is really really easy, once you get it. I can recomend to get the board, so you have something that works, and can concentrate on learning the i2C - knowledge that you then can transfer… and afterwards you still have a cool board.

In fact I think I have a spare board, if you have somthing we can swap… Look for the topic Frits’s private parts up for grabs in the forum for what I want.

The “Picaxe book” (The green one sold from the picaxe store & amazon (though the book is outdated in many ways) also has good short chapters on the subject.

Man, guys… Thank you!

Well, I have spent the last few days studying this whole i2c and EEPROM thing and I think I really got it now. My main problem was reading too much technical crap about i2c and a bunch of %10010100 stuff. What I really should have done is go straight to the picaxe manual! It’s 3 commands for cryin’ out loud! Readi2c Writei2c and Slavei2c… That simple. I have figured out the address and speed of my EEPROM, found the jumpers on my board to get it and the picaxe talking, and hope to do my first test coding tonight.

Thanks to all who have helped!

 

 

All them techies, confusing!
All them techies, confusing!

something to read about i2c

I have been playing with i2c and arduino. Mainly for robotics.

I have written a small primer on i2c and lcd control, it is running on uchobby.com right now… and also on makezine.com

 

http://www.uchobby.com/index.php/2008/09/16/introduction-to-i2c/

That’s a good primer on i2c, and what all you can do with it.

 

SRF08

the SRF08 sonar uses i2c to communicate. I am using a PICAXE 28x1 ror my first robot and wondering if I should get one? It looks more complicated to programme, which may be a problem as I have no programming experience, but only uses 2 pins to communicate and my 28 pin board has ribbon cable connections for power and ground. the '08 also has a light sensor. the datasheet is here: http://www.rapidonline.com/netalogue/specs/78-1086.pdf

Use what you need for ranging
The SRF08 can range out to 11 meters. Maxbotix sonars can range out to 6.45 meters and woulds require only one line (plus power and ground). I’d get the SRF08 if I wanted to learn more on I2C, or needed the extra range (fast robot) and would get the Maxbotix if I wanted simpler interfacing to the MCU, and a something less costly.