Idiot check on baisc ATmega328P wiring

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've used pre-made Arduinos, and built up breadboard board versions from kits, but I've never built a circuit for a uC completely from scratch.  The next project calls for the uC to live on a custom board as part of various other things, and I'm wondering if I've designed it correctly.  Schematic attached.  I'd appreciate an idiot check to make sure I didn't miss anything important. 

 

Some notes:  The plan is to be able to program this with either an Atmel-Ice via a 6 pin ISP header or (after installing an Arduino bootloader) via an FTDI Basic board over USB.  Hence hookups for both. 

 

The XTAL capacitors aren't specified as I've not yet picked the particular crystal I'll use.

 

The reset circuitry bears some thought.  As discussed in one of my other threads, this is going into a potentially noisy environment - a high altitude balloon tracker.  So I want maximum noise protection.  Therefore, I'm designing with the capacitor (C6) and protection diode (D2), though I may not actually install them unless needed.  The reset pullup resistor, R4, is set to 10k because I want the option of using debugWire, and the AN2519 note states that this is required (also that capacitor C6 can't be present).  I know that D2 will prevent high voltage programming.  That's fine, I have no need (or equipment) for that.

 

The only outputs of the uC I currently need are PD2-PD5 plus i2c/TWI.  Those lines are routed off this sheet.

 

I would appreciate a sanity check.  Did I leave off something critical?  Do I have something that's unnecessary/harmful/sub-optimal?  This isn't going to be a final version by any stretch, it's an interim development step, but I do want to make sure it works, which means making sure the circuit is right before I go and design the PCB...

 

Thanks!

Attachment(s): 

Last Edited: Sat. Feb 3, 2018 - 10:11 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

First glance, I would use caps on each of the power pin pairs (pins 3 to 4, 5 to 6, and 18 to 21).

 

David

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

frog_jr wrote:

First glance, I would use caps on each of the power pin pairs (pins 3 to 4, 5 to 6, and 18 to 21).

 

Makes sense.   Done.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you would like to use the Arduino IDE on the PC to program the AVR through the bootloader, then change one of the grounds on the J3 connector to the DTR signal that comes from the FTDI module board.  Then have a 0.1uF capacitor between the DTR  pin on J3 and the reset.  A jumper or a pair of close pads for a solder jumper could isolate this cap from the reset line when the Arduino IDE is not being used to program the AVR.  

  The Arduino IDE on the PC pulls the DTR low to reset the AVR at the beginning of the upload from the sketch's hex file.  The 0.1uF cap causes this low level on DTR to become a short pulse on the AVR's reset line.  This reset activates the bootloader on the AVR.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For noise immunity the PCB layout is an important factor.

Keep traces short and above a GND plane.

 

R4 and R5 form a voltage divider on the reset pin.

If you move R4 to the side of the switch it is no voltage divider anymore.

Then you can also use a higher value for R5 (Better noise immunity) but I'm a bit nitpicking here.

 

If you have unused pins, route them to a pad.

That makes it a lot easier to make modifications, or for re-use in another project.

Maybe consider ESD protection series resistos between all connector pins and AVR pins.

2k2 for I2C pullup resistors seems a bit low, but still ok.

 

If you want to put the thing in a metal can, it's pretty easy to make one custom size from an aluminimum soda (or beer :) can.

You can design it on a pc, print on paper, glue it to a can, cut it out with a knife or normal scissors, and fold it into shape.

Optionally you can put some normal staples throug it.

Some time ago I made a little parametric sketch for this in FREEcad.

The squares should not be cut out, but be folded to the inside of the box.

Then fold the flaps on the outside over the squares to make a relatively sturdy box.

Attachment(s): 

Doing magic with a USD 7 Logic Analyser: https://www.avrfreaks.net/comment/2421756#comment-2421756

Bunch of old projects with AVR's: http://www.hoevendesign.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Simonetta wrote:

If you would like to use the Arduino IDE on the PC to program the AVR through the bootloader, then change one of the grounds on the J3 connector to the DTR signal that comes from the FTDI module board.  Then have a 0.1uF capacitor between the DTR  pin on J3 and the reset.  A jumper or a pair of close pads for a solder jumper could isolate this cap from the reset line when the Arduino IDE is not being used to program the AVR. 

 

Not the IDE, but I _was_ going to use avrdude to upload via bootloader, so you are absolutely right, I need to connect the DTR pin.  Missed that.  Thanks!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Paulvdh wrote:

For noise immunity the PCB layout is an important factor.

Keep traces short and above a GND plane.

 

Yup.

 

Quote:

R4 and R5 form a voltage divider on the reset pin.

If you move R4 to the side of the switch it is no voltage divider anymore.

Then you can also use a higher value for R5 (Better noise immunity) but I'm a bit nitpicking here.

 

Note sure I follow.  I can see the voltage divider you mean, although with 10k and 330R, the voltage at reset would be about .1V, which I'd think would be enough to reliable trip the reset? 

 

But I don't quite follow the fix.  Do you mean tie the bottom end of R4 between R5 and SW1?  That would certainly resolve the voltage divider issue.  Where would C6 and D2 tie in?  Same place they are now, or where the new R4 goes?  If the latter, will they provide the right protection through the 330 resistor?

Quote:

Maybe consider ESD protection series resistos between all connector pins and AVR pins.

 

Again, I don't quite follow.  Just place a resistor in every line that goes to a jack, like, say MOSI or RXI?  What value resistor?  And won't that interfere with the signals?

 

Quote:

2k2 for I2C pullup resistors seems a bit low, but still ok.

 

That was based on the datasheet formula and a rough estimate of capacitance.  4k7 is certainly more common, and I don't imagine much capacitance in this application (it's a single run on the same pcb to a single other chip, probably less than 1" traces, and both are SMD).  So might bump them up.

Quote:

If you want to put the thing in a metal can, it's pretty easy to make one custom size from an aluminimum soda (or beer :) can.

You can design it on a pc, print on paper, glue it to a can, cut it out with a knife or normal scissors, and fold it into shape.

Optionally you can put some normal staples throug it.

Some time ago I made a little parametric sketch for this in FREEcad.

The squares should not be cut out, but be folded to the inside of the box.

Then fold the flaps on the outside over the squares to make a relatively sturdy box.

 

Appreciate it, and will take a look, but I'm a long way from enclosure design.

 

Thanks!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

About R4 & R5

With a residual voltage of 100mV you can of course easily reset your AVR and you can use your circuit as in the schematic.

But if you wanted to use a stronger pullup for "extra noise immunity" (for example 1k) and you also wanted to use a higher value for R5 (Let's also assume 1k) then your reset pin would not get pulled further down than half of your Vcc.

jgalak wrote:
Do you mean tie the bottom end of R4 between R5 and SW1?
Yes, that is exactly what I mean.

Both R4 and R5 get pulled to GND by the switch. There is no voltage divider anymore.

 

This would also allow you to "simplify" your design ( a little bit) for mass production.

Instead of 3 different resistors, you could just use the same value resistors for R2, R3, R4, and R5. (One reel in the SMD Pick & place machine instead of 3).

C6 and D2 stay where they are. Close to the AVR. and "away" from the outside world (your switch).

 

jgalak wrote:
Again, I don't quite follow. Just place a resistor in every line that goes to a jack, like, say MOSI or RXI? What value resistor? And won't that interfere with the signals?

ESD protection is a combination of a lot of different factors.

AVR's have ESD protection diode's on their inputs, but these can only handle a limited amount of current (energy).

If you put a resistor in each conductor between the connector pins and the AVR pins a part of the energy of the ESD event is dissipated by the resistor, and your circuit can survive bigger ESD events than a bare AVR could.

Using these resistors is a very common practice.

If you look at the schematic of the original USBasp:

http://www.fischl.de/usbasp/

You see R1 and R2 series resistors (68 Ohm) to the USB connector and you see R4, R5, R6, R7 (270 Ohm) to the ISP connector.

I am a bit surprised that Thomas didn't use series resistors in the inputs to the AVR. (RxD and MISO).

Apparently his main goal was short current / overload protection.

 

Bus Pirate uses 2k series resistors on digital inputs:

http://dangerousprototypes.com/d...

 

If you do a web search you can get plenty of info about series resistors uded for ESD protection:

https://duckduckgo.com/html?q=es...

http://www.machinedesign.com/tec...

 

The ESD diodes are enough to be able to use your AVR in an ESD protected environment, but not enough for the outside world.

The value of these resistors is a compromise, because they do interfere with the signals.

In the machine design link above they state that even a 10 Ohm resistor halves the ESD peak current. Higher values provide more protection.

So it depends what your circuit can tolerate.

Combined with cable capacitance these resistors also give a bit reduction on EMI.

 

=======================

You mentioned high altitude balloons.

There are quite some collectors of Radio sondes who get hunted down as the descent back to the earth.

Better hobby than geocaching I guess...

Here Mike tears such a probe down ( Vaisala RS92-SGP ).

https://www.youtube.com/watch?v=...

Quite a bunch of websites about these things, from teardowns to museums.

http://radiosondemuseum.org/the-...

With a bit of searching you can probably find complete schematics, detailed PCB photographs and a lot of other info of these things.

It's almost impossible to invent anything new.

It's all been done before.

Hunderds or thousends of times.

Often more...

Doing magic with a USD 7 Logic Analyser: https://www.avrfreaks.net/comment/2421756#comment-2421756

Bunch of old projects with AVR's: http://www.hoevendesign.com