Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: BuddingContraptionist on October 17, 2008, 08:27:45 PM

Title: I2C...resistors?
Post by: BuddingContraptionist on October 17, 2008, 08:27:45 PM
I bought this rangefinder (http://www.robotshop.ca/home/products/robot-parts/sensors/ultrasonic-range-finders/srf02-ultrasonic-range-finder.html).  It lets you communicate via either I2C or Serial, and I want to do I2C (because it uses a 3.3v serial signal, and i don't want to build a 3.3-to-232 converter).  I've read this awesomely informative primer (http://www.societyofrobots.com/member_tutorials/node/35), and I have a question.  Page 4 says that because the SCL & SDA lines are bi-directional, the "open drain thus must be pulled up with resistors."

I have an axon (http://www.societyofrobots.com/axon/images/axon3D.jpg) which has that I2C bus in the upper right center of the board.  Can I wire straight from my SCL & SDA lines on my rangefinder directly to these pins on the axon, or do I need resistors?
Title: Re: I2C...resistors?
Post by: fendi on October 19, 2008, 10:39:18 AM
i think maybe you should check first ,
if in SDA and SCL pin has a conection to resistor like pull up circuit. no need to add pull up resistor again.
Title: Re: I2C...resistors?
Post by: Admin on October 21, 2008, 12:02:39 AM
From the SRF02 datasheet:
Quote
The SCL and SDA lines should each have a pull-up resistor to +5v somewhere on the I2C bus. You only need one pair of resistors, not a pair for every module.

There are no hardware resistors on the Axon I2C bus, but you can activate pull-up resistors in software.

Here is an i2c.c snippet from AVRlib:
Code: [Select]
// functions
void i2cInit(void)
{
// set pull-up resistors on I2C bus pins
// TODO: should #ifdef these
sbi(PORTC, 0); // i2c SCL on ATmega163,323,16,32,etc
sbi(PORTC, 1); // i2c SDA on ATmega163,323,16,32,etc
sbi(PORTD, 0); // i2c SCL on ATmega128,64
sbi(PORTD, 1); // i2c SDA on ATmega128,64

On the Axon, SCL is D0, and SDA is D1.