modify the Wire library to import into my sketch?

is there a tutorial somewhere on how to find and modify the Wire library to import into my sketch? I want to change the internal Arduino pull-ups so they are not enabled.

Apparently this requires changing two lines of code in Arduino distribution libraries/Wire/utility/twi.c, but I cant find this twi.c file.....

Can anyone point me in the right direction? Many thanks in advance, f

What OS are you using? Which version of the IDE? Did you look in the folder where you installed the Arduino software? Did you find the libraries folder? Was there a Wire directory there?

OS 10.6.7 Arduino Alpha 0022 There isnt a folder- just the Arduino app itself in my Applications folder. No, there is no Wire directory anywhere.....

maybe somehow I made an incomplete installation??

Nah, Mac OS obscurity at work. Click the Arduino app, and go to File -> Show package contents (I think). If not that, Control-click the icon and select "show package contents". The library folder should be in there, that's where you'd install or edit any libraries you want to use. I think. I'd almost imagine they'd have a more accessible place to put the library files...

But why would you want to turn off the pull-ups anyway? It kinda needs those to work right... :.

I'd almost imagine they'd have a more accessible place to put the library files...

They do. Library files that are part of the official arduino distribution are located in the application core file folders. Users can also store contributed libraries into a folder one has to create named libraries and placed in the users sketch directory. This allows one to update to a newer arduino IDE release without losing all their own written or downloaded library files.

Here is the structure of my users library on a windows machine:

C:\Documents and Settings\Primary Windows User\My Documents\Arduino\libraries

12 Folders:

Button DS1307 Flash FreqCount FreqMeasure MsTimer2 Playtune Streaming String Tone WString __MACOSX

0 Files:

Here is where the 'official' arduino supplied library files are located:

C:\Documents and Settings\Primary Windows User\My Documents\My Programs\Arduino\arduino-0022\libraries

13 Folders:

ArduinoTestSuite EEPROM Ethernet Firmata LiquidCrystal Matrix SD Servo SoftwareSerial SPI Sprite Stepper Wire

Lefty

Ah, there it is!

Basically I want to get 3.3 volts into a gyro without needing extra hardware. Below is the original thread. I moved it here since it was going off topic....

http://arduino.cc/forum/index.php/topic,58111.msg420722.html#msg420722

In the arduino-0022/libraries/Wire/utilities/twi.c file, starting at about line number 67:

Original code:

  #if defined(__AVR_ATmega168__) || defined(__AVR_ATmega8__) || defined(__AVR_ATmega328P__)
    // activate internal pull-ups for twi
    // as per note from atmega8 manual pg167
    sbi(PORTC, 4);
    sbi(PORTC, 5);
  #else
    // activate internal pull-ups for twi
    // as per note from atmega128 manual pg204
    sbi(PORTD, 0);
    sbi(PORTD, 1);
  #endif

My modification actually changed four lines of code (not two---so sue me) and added a comment:

  #if defined(__AVR_ATmega168__) || defined(__AVR_ATmega8__) || defined(__AVR_ATmega328P__)
    // The original Arduino library code activates internal pull-ups for twi
    // as per note from atmega8 manual pg167
    //
    // From davekw7x: This mod makes sure that internal pull-ups for the I2C pins
    // are NOT enabled.
    cbi(PORTC, 4);
    cbi(PORTC, 5);
  #else
    // activate internal pull-ups for twi
    // as per note from atmega128 manual pg204
    cbi(PORTD, 0);
    cbi(PORTD, 1);
  #endif

Have tested it with I2C EEPROMs operating in a 3.3 Volt circuit.

You will need two pull-up resistors (something like 2.7K Ohms or 4.7 K Ohms or some such thing). One from each of the I2C lines to 3.3 Volts.

In fact I think that, for reliable operation, you should always use external pull-ups even if the internal ones are active. (This is just an opinion---my opinion. It's worth exactly as much as you want it to be worth.)

Regards,

Dave

Footnote:

For boards with mixed 3.3 Volt and 5 Volt I2C devices, I use bidirectional level shifters between each Arduino I2C pin and each 3.3 Volt device I2C signals.

If the level-shifter doesn't have internal pull-up resistors (or if you cobble your own with FETs) you still need external pull-up resistors: One resistor pulled up to 5 Volts on each I2C line on the Arduino side of the I2C line level shifters. One resistor pulled up to 3.3 Volts on each I2C line on the Device side of each I2C line level shifter.