Pages: [1]   Go Down
Author Topic: Will there ever be a SoftI2C Library?  (Read 1460 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 11
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Since there is a soft serial, is there any plans for softI2C?
How difficult/important is it to bit bang the I2C protocol? I have seen applications where it is needed, eg. to utilize 2 wiimotes, where changing the address is difficult. I have a few other applications but I was wondering if it is the community's list of priorities.
Logged

Bonn, Germany
Offline Offline
God Member
*****
Karma: 2
Posts: 903
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hm.. i am not quite sure about this, but have you ever looked into the twi.c? as far as i understand it there the pins for the twowire protocol are defined, maybe by copying the library and doing the neccessary changes one could add a second or maybe a third i2c portpair to the arduino.. but i am more than unsure about it...
also i stumbled upon a library (http://jump.to/fleury) for I2C on an Atmel.. maybe this may help you about this whole subject.
Logged

Believe me, Mike, I calculated the odds of this succeeding against the odds I was doing something incredibly stupid[ch8230] and I went ahead

Seattle, WA
Offline Offline
Jr. Member
**
Karma: 1
Posts: 81
Arduino rocks my socks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

twi.c and Peter Fleury's library both use the hardware module.  I'm currently trying to sniff some i2c traffic, and was planning on writing a softi2c kind of library when I got a chance.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 11
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK I am Interested in writing the softI2C, I would would liek to know who assisted in the actual I2C or anyone who has knowledge to help me bit bang it. People with Soft Serial knowledge would also be great. Any takers?
Logged

Seattle, WA
Offline Offline
Jr. Member
**
Karma: 1
Posts: 81
Arduino rocks my socks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The atmega168 datasheet has a pretty good explanation of the physical protocol.  I have my sniffer working, but it uses the hardware SPI module and an INT pin - not exactly SoftI2C.

Do you just need master mode, or will the Arduino be addressed as a slave too?
Logged

Ohio
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is an app note and project source from Atmel on how to implement software i2c in assembly.

http://www.avrfreaks.net/index.php?func=viewItem&item_id=75&module=Freaks%20Tools

take it for what its worth
Logged

0
Offline Offline
God Member
*****
Karma: 1
Posts: 588
LumiNet rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Do you need I2C master or slave in software?
What devices must this software-I2C-lib talk to?

I guess that a TWI master is very easy, simply create the START condition with two pins, then use shiftOut(dataPin, clockPin, bitOrder, value) to write the 7bit address and r/w bit, followed by 8bit data and then create the STOP condition on the two pins...

Receiving data is another topic.
Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 40
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

There's a TWI bit-banging master in my Ports library, at:
   http://code.google.com/p/jeelab/source/browse/trunk#trunk/libraries/Ports
Look in Ports.h and Ports.cpp for the PortI2C and DeviceI2C classes (you can define multiple devices on one Port).

The PortsBMP085.* files contain an example of their use as described here:
    http://jeelab.equi4.com/2009/02/19/hooking-up-a-bmp085-sensor/

Not sure it's of any use, but feel free to use/re-use/alter as you like.

-jcw
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 58
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't know what exact features you need, but I posted a modified i2c (master) library here, which might be easier to hack. It still uses the hardware i2c module though :
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1175112203/10#10
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 11
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

My purpose for soft I2c is actually just master, I am building a robotics kit that may use multiple sensors with similar non-modifiable i2c addresses. In fact it is the Lego Mindstorms NXT robotics kit sensors - primarily the Ultrasonic sensor for now. So hopefully this I2C master should do the trick!
Having a slave would be pretty interesting as to the capabilities i would be able to do hmmmm - chain robots - communicating over I2C smiley-razz
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 40
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

FWIW, the links in my March post have changed to:
    http://code.google.com/p/jeelabs/source/browse/trunk#trunk/libraries/Ports
and
    http://news.jeelabs.org/2009/02/19/hooking-up-a-bmp085-sensor/

(so much for trying to maintain valid links all over the web...)

-jcw
Logged

Pages: [1]   Go Up
Jump to: