is my schematic all correct? I dont want to fry my new ATmega328!!!!

Does anyone know if I have everything correctly connected in the attached schematic? I am trying to work out all the pin connections for 4 accelerometers and a gyro, using my new ATmega328, FT232R and 2 multiplexers. I am also not sure about the resister AND capacitor on the ATamega328 RESET pin for an automatic reset. I hear the cap is needed to reset on powerup and uploading sketches but I also hear i need a resister to make sure the chip doesnt reset in the middle of running the code. Not sure if I got this wrong.....

is this the right forum for schematics?

rightHardware?.pdf (494 KB)

The capacitor and resistor to reset are almost correct. The capacitor should be connected to DTR on the FT232R rather than TXD on the ATmega.

It's also considered a good practice to wire two .1ufd bypass caps from Vcc and Avcc to ground and to mount them close to the avr pins.

Lefty

oh cool. i see where I went wrong. what about the gyro? Is that connected correctly, do you know? I couldnt find a schematic for hooking up its pins..... :frowning:

what about the gyro?

You'll need to provide more information. What is the part number?

its the Triple-Axis Digital-Output Gyro ITG-3200 Breakout

what about the gyro?

Based on the pin names (scl, sda), your gyro has a two-wire (I2C?) digital interface, and it is inappropriate to have it connected to an analog multiplexer or analog pins...

RetroLefty mentioned bypass caps for the AVR; it's also a good idea to have one for each other chip as well (and maybe for each sensor, depending on whether the breakout boards already have them or not.)

You are using the ATmega's I2C pins to sample the analog voltages from your MUXes.

Why don't you just connect your gyro directly to the I2C pins (Analog 4 and 5) and the MUX to know of the other Analog Inputs? Then you can eliminate a MUX and you don't have to write the I2C stack in software.

[quote author=James C4S link=topic=58111.msg417978#msg417978 date=1302490983]
...Why don't you just connect your gyro directly to the I2C pins (Analog 4 and 5) ...[/quote]
Some care has to be taken here since the Arduino Wire library, used with I2C devices, enables internal pull-ups (to Arduino VCC, which is +5 Volts) on the ATmega328 I2C pins (Analog 4 and 5). This gyro device will not tolerate 5 Volts.

Option 1: Make a slight modification to the Wire library (or make your own I2C library) that does not enable the internal pull-ups. Use external pull-up resistors (something like 2K7 Ohms) from SDA and SCL to +3.3 Volts. Some breakout boards may have places for these resistors.

Option 2: Use bidirectional level shifters between Arduino Analog Pins 4 and 5 and the I2C pins on the gyro. Gyro-side pull-up resistors go to +3.3 Volts, Arduino-side pull-up resistors go to +5 Volts.

Regards,

Dave

Footnote:
[/begin Opinion]
I don't really understand why the Wire library enables internal pull-ups. The values may be anything from 20K to 50K Ohms, which I personally would not trust to give consistent performance. Since I always use external pull-ups, the internal pull-ups don't help, and in the case of 3.3 Volt peripherals, actually can harm the device.
[/end Opinion]

It's just an opinion. It's worth exactly what you want it to be worth.

James: I didnt include all of my sensors in the schematic- I am hoping eventually to use 27 analog input channels. but that is later after I get the chip working without added stuff...

James & Dave: wow. I didnt know this. Since I am new to the arduino ide and its language, i will just add some pullup resisters to my board to reduce to 3.3....

But now I am a little confused. The gyro still uses analog pins, not digital, right? After a while of poking about searching, I came up with this, for gyro pin settups;

SDA -> A4 (PC4)
SCL -> A5 (PC5)
INT -> D3 (PC3)
CLK -> GND
NO 3.3 POWER connected

Instead of having the three channels SDA, SCL and INT connected to these analog pins on the ATmega328, I can just use 3 analog pins on one of the muxes? And to confirm in either case, I still need to add the pullups to reduce the 5v to 3.3 so as not to fry my gyro? Sorry to be a pain.. I am just so scarred of messing my my new components :--<

The gyro still uses analog pins, not digital, right?

NO! That's the big issue; the I2C interface of the gyro is digital (the gyro has internal A-D converters), and it needs dedicated digital pins to talk to it (preferably the pins that implement hardware I2C on the Arduinoo.)

davekw7x:

Option 2: Use bidirectional level shifters between Arduino Analog Pins 4 and 5 and the I2C pins on the gyro. Gyro-side pull-up resistors go to +3.3 Volts, Arduino-side pull-up resistors go to +5 Volts.

Is the attached what you mean by adding pullup resisters to the IC2 pins on both the gyro and the Atmega328? Again, the gyro is modeule number ITG-3200

fabienLyrique:
...

Is the attached what you mean

No. The net effect of that connection is that each of the pins is pulled up to something like 4.15 volts through a resistance value of 5K Ohms. (Off the top of my head, using the superposition principle and Thevenin's theorem.) You should not apply 4.15 Volts to I/O pins of the 3.3 Volt gyro device.

There are I2C level shifting devices available (Texas Instruments PCA9306, for example). I have also used discrete circuitry described in NXP Application Note 10441 to interface with 3.3 Volt I2C EEPROMs.

The point is to isolate the 5 Volt Arduino I2C lines from the 3.3 Volt I2C device so that no voltage higher than 3.3 Volts is ever applied to the logic pins of the 3.3 Volt device

The whole idea of I2C is that either the master or the slave can pull the lines low (any time they want), but they don't actively pull them high. High state is obtained from passive devices (pull=up resistors).

So: a master or slave can pull the line low or not pull it low. A given device can release the line (stop pulling it low) and then look to see if the other device is pulling it low. The whole protocol is built around that.

Bottom line: Don't pull up I2C lines on the 3.3 Volt device to a voltage higher than 3.3 Volts. (See Footnote.)

Regards,

Dave

Footnote:

Post-bottom-line comment:

Maybe you can consider Option 1. Just pull the lines up to 3.3 Volts and modify the Wire library (or make a copy and modify the copy) so that internal Arduino pull-ups are not enabled.

This requires changing two lines of code in Arduino distribution libraries/Wire/utility/twi.c so that the pullups are not enabled. The Arduino , operating at 5 Volts, will accept 3.3 Volt inputs as logic 1, and it will work without any additional hardware.

Thanks Dave, I'll need to study what you say a bit more to completely understand everything, but I get your point. I'm new to this, so I have never tried to alter one of the libraries - but it sounds like the way for me to go though, with a bit of study. Thanks for clarifying.