Pages: [1]   Go Down
Author Topic: is my schematic all correct? I dont want to fry my new ATmega328!!!!  (Read 1572 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.5 KB - downloaded 50 times.)
Logged

Värmland, Sweden
Offline Offline
Sr. Member
****
Karma: 9
Posts: 262
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17302
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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..... :-(
Logged

Fort Lauderdale, FL
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6144
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
what about the gyro?

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

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.c

Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 137
Posts: 6788
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.)
Logged

Fort Lauderdale, FL
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6144
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.c

Left Coast, USA
Offline Offline
Sr. Member
****
Karma: 7
Posts: 499
Sometimes I just can't help myself.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

...Why don't you just connect your gyro directly to the I2C pins (Analog 4 and 5) ...
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.
« Last Edit: April 11, 2011, 12:01:16 am by davekw7x » Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 :--<
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 137
Posts: 6788
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.)
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

davekw7x:

Quote
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


* Screen shot 2011-04-14 at 1.25.53 PM.png (68.92 KB, 651x681 - viewed 21 times.)
Logged

Left Coast, USA
Offline Offline
Sr. Member
****
Karma: 7
Posts: 499
Sometimes I just can't help myself.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

...

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.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: