i2c questions

chris-s

New Member
I've only dabbled a little with i2c, but my current project looks like I'm going to have to split the code into two parts and run 'control processing' and 'ui processing' on a separate chips. This actually suits me since I can mount the 'ui display & keypad' separate from the other parts.

The circuit involves a couple of other i2c devices, DS1307, an i2c lcd driver and potentially a 24LC32.

Originally I was only going to use a single picaxe, but moving to multiple chips opens up new possibilities that I haven't thought thru fully yet. So, is it possible, providing I implement some form of 'locking' mechanism for an i2c bus to have more than one master device, so for example, could I read a DS1307 from two separate master picaxes providing only one at a time?

Can a picaxe running as an i2c slave read other i2c slave devices?

What sort of distances does i2c work over, couple of feet?

What if I want to go further, say 20 to 30 feet how could I do that? Copper or optic?

Finally, the project includes several DS18B20 sensors which I'm reading using the 'readtemp12' functions. These devices also have some in-built nvram available that would be really useful to store 'calibration' info in since that will then stay with the sensor if it gets relocated. Is it straightforward to access this using a picaxe and retain the 'readtemp12' function, ie, anybody got any pointers or code snippets?

Hope thats not too much for one post!

Cheers

Chris
 

Technical

Technical Support
Staff member
1) you can have two masters as long as they only 'talk' one at a time, so some handshaking is required.
2) using hi2csetup you can swap between master and slave modes. however it might give you some programming headaches keeping track of which chip is doing what!
3) i2c is designed for use on pcb tracks, not long lengths of wire. reducing the 4k7 to 2k2 helps give a longer length
4) P82B715 chip from NXP is an i2c extender
5) owin/owout commands can access the nvram. There is no isssue using readtemp in the same program, in fact readtemp is just a pre-programmed sequence of owin/owout commands.
 

BCJKiwi

Senior Member
This site http://www.i2cchip.com/ (among others) has a wealth of information on i2c. The discussion on bus length is best looked at there. There are a number of issues/options to lengthen the Bus.

There can only be one master on the bus. This controls bus timing etc and manages all the arbitration etc. A slave can only respond to a master.
A PICAXE can be a master or a slave.

It would be much simpler (from an i2c point of view) to have one master and that one of the PICAXES be a slave.

There are some memory devices that have two separate i2c buses that allow two different i2c systems (i.e buses) to share a common memory, again, see http://www.i2cchip.com/. Maybe this is the simplest way to share data between two PICAXES as both could be masters on their own bus. Data that needs to be exchanged could be written to that shared memory.
 
Top