Let's Make Robots!

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).

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

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 


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?

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 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.


i2c is not an EEPROM, but an EEPROM can be i2c... Right?

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 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

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 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 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.

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!