Laying out an AVR board.

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

Ok so I have finished laying out a board. I have an ATMega328P running with a 8MHz crystal. The board has two layers and I have chosen the top layer as the ground plane (GND) and the bottom layer as the power plane (VCC). Following design guidelines, I have kept the trace length between the crystal and the AVR minimal. Take a look at the layout and suggest any improvements if you can and also be sure to point out the faults.

Here is the [PCB](http://i.imgur.com/Un1vAbl.png) as well as the [schematic](http://i.imgur.com/UZDFpuW.png).

 

EDIT: A lot of people online suggested that I should ditch the VCC plane on the bottom and replace it with a full ground plane with a ground pour also on the top, and both of them connected with vias. Also, I should use a limited VCC pour for all the components that need it. I want to hear your opinion on this point.

 

EDIT2: Yes I have added the 100nF decoupling capacitors and also the IDC programming header now, which is not in board layout I uploaded because I added them afterwards.

Last Edited: Tue. Jul 25, 2017 - 06:33 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just checking but you read AVR040 and AVR042 before you did this?

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

AVR042 Yes. But I will take a look at AVR040 now.

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

Off to a great start, a few thoughts:

 

You can embed the images within the post by using the "Mountain range" icon, two to the left of the smilie face icon.

This makes it easier for people to review.

 

Next, and importantly, AVcc MUST be tied to V+.

Next, ALL Vcc pins must be connected to V+.

Next, ALL Ground pins must be connected to Ground.

 

Each Vcc and the AVcc pins should have a by-pass cap, 0.1 uF is reasonable, mounted as close to the pins on the micro as is possible.

These by-pass caps are necessary for reliable operation.

 

Next, depending upon how many circuits and boards you have designed, you might find is worth while to bring a spare pin or two out to a resistor and LED, or just out to spare pads.

This way you can install the LED, or not, but it might be useful for debugging code.

(e.g. Enter the ISR, turn on the LED, etc.  Easy to know your ISR is firing, etc.).

 

A spare pair of pads is also useful, when available, for hooking up an O'scope to check timing issues.

This can be helpful with some projects.

 

(There are those who debug with a logic analyzer, and those that use an LED and an O'scope, your choice!)

 

It is usually worth while to mark a couple of mounting holes on the PCB for later drilling, and mounting.

 

I find it useful to put a PCB name and Version number, and date, on the boards.

When I make, (or have made, these days), a PCB, I usually have several of the boards made.

Over the years one ends up with a pile of old PCB's, and having a project name on them, and a version number, can be very helpful.

 

Over the years there are may quickie projects / tests, that can be run on an "old" PCB, perhaps hacking in a new sensor, etc.

Re-purposing an old PCB is easier when the spare pins have been brought out to pads or a header.

 

For development work I find it very useful to include a Reset\ push button switch on the board.

 

I don't recall your programming header.  Make sure it is included on the board.

 

For the Micro, the programming header, the power input header, and any other headers, be sure to include a pin #1 marker.

(A "+" for the power supply, etc.)

 

Many boards also have a "spare" pad / header for a Ground connection, (for later measurements, voltmeter, O'scope, etc.).

 

For many boards I include a small slide switch for power on/off.

The single throw, double pole, PCB mounted, slide switches are cheap and useful for this purpose.

 

Obviously some of the above comments are for prototypes and one-off projects, and are not needed for a large production run.

 

AVR Application Note AVR042 lists some hardware design & layout considerations.

 

JC

 

Edit: typo

Last Edited: Mon. Jul 24, 2017 - 05:38 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I dunno how long images on imgur last But I've cloned them here:schematicpcb

Paul van der Hoeven.
Bunch of old projects with AVR's:
http://www.hoevendesign.com

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

You sparkies will need to comment, but if I have a two-layer board and one layer is +V and the other is Gnd, then what layer(s) do signals go on?

 

-- I see no bypass caps.

-- I see no ISP header.

-- All Vcc pins (including AVcc) MUST be connected.

-- All Gnd pins MUST (or at least SHOULD) be connected.

-- Each pair should have a bypass cap.

-- Typically, /RESET will have a pullup for robust operation.  And maybe a small cap to Gnd.

-- Does a DS1307 "watch crystal" really have load caps?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

theusch wrote:
then what layer(s) do signals go on?
Signals are routed by "plowing" through the plane layers.

 

Edit: Here is a plane layer with signals:

David (aka frog_jr)

Last Edited: Mon. Jul 24, 2017 - 07:16 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Some extra thoughts, nothing substancial (See docJC / Clawson).

Are you thinking of having this board manufactured i China?

The silk screen text is for free then. You can use it for example to add pin names to all pins on your connectors.

 

I also reccomend to add the voltage regulator, caps and maybe a bridge rectifier to the board.

Note that the layout for the bridge rectifier (for example) can easily be shorted (no diodes, just wires) if you happen to use a DC power pack for your first PCB.

(PCB's from China tend to come in batches of 10).

 

And after studying (not just reading) all the EMC stuff you will probably know you need some inductors in the power circuit.

For more hints see my recent post here:

http://www.avrfreaks.net/forum/a...

 

I also find it handy to add a small pototyping area to my pcb's.

I usually draw a few connectors with about 10 pins (no wires) and place them in a grid next to each other on the pcb.

This can be used for small modifications / additions.

 

Also:

Eagle has been popular for hobby projects for 15+ years because you don't have to pay for the software.

However, that has changed recently, after Autodesk bought Eagle.

The Eagle has crashed, and lots of people are switching over to KiCad.

 

KiCad is open source software, officially free with no artificial limitations on for example board size or pin count.

KiCad is also getting better every year in quite rapid tempo.

You can download it here:

http://kicad-pcb.org/

It also has quite a nice forum, My last post there was answered in 3 minutes.

A part of the open source community is people helping each other to make the whole world a little better.

When starting with KiCad, work through the "getting started guide" in the tutorial section.

Watching some youtube video's might also help:

https://www.youtube.com/results?...

 

I wish you a of fun in your engineering career.

Paul van der Hoeven.
Bunch of old projects with AVR's:
http://www.hoevendesign.com

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

theusch wrote:
-- Does a DS1307 "watch crystal" really have load caps?

Missed that. And indeed. these chip's often dont work anymore if they have load caps

Paul van der Hoeven.
Bunch of old projects with AVR's:
http://www.hoevendesign.com

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

Seven pins to "JP_LCD".  Indeed, it is common to have seven signal pins to/from a character LCD.

 

What about power and ground?  What about the contrast circuit?  (What about a possible backlight?)

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

Pigs have better vision than my hindsight.

Especially when they have glasses.

Paul van der Hoeven.
Bunch of old projects with AVR's:
http://www.hoevendesign.com

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

Next, and importantly, AVcc MUST be tied to V+....for  absolute best results, a series inductor (LC filter) can help reduce noise

 

Vref needs a cap to G N D

 

Put pulldowns on ADC6 & 7 (no internal pullup avail)..pins should not randomly float around town.

 

Add an LED so you know what is going on (blink, power, etc )

 

Add a 10 cent voltage regulator...not having something is rather bad/sad.  A path to destruction.  Reverse protection diode too.

 

Forget about the DS1307Z...put your timer code in the processor...what else does it have to do (unless it will go into low power inactive mode) ?  micro has an xtal, so obviously it can easily keep track of time

When in the dark remember-the future looks brighter than ever.

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

avrcandies wrote:
? micro has an xtal, so obviously it can easily keep track of time

C'mon -- you never turn power off?

Ooops--never mind -- OP doesn't show a backup battery...

 

[hmmm-- aren't there special considerations to wiring up DS13xx >>without<< the backup battery?]

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

robo328 does your CAD program have a design rule check (DRC) facility? If so then have you used it to check that the tracks are connected the same as the schematic?

 

For year I didn't do this, the CAD program I had was old and I didn't know how to use it properly, but my "new" CAD program has it and it saves me many hours visually checking things out.

Now in a few seconds I can be pretty sure that all is well, and if not it will tell me what is wrongly laid out.

 

Of course it only tells me that the schematic and PCB match, if I make a mess with the schematic (like it seems you may have done) it's simply a matter of GIGO.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Ground plane on the bottom. You really don't need a vcc plane. Avoid 'islands' in the groundplane. It should be uninterrupted as possible.

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

 Does a DS1307 "watch crystal" really have load caps?

Just had a look at the datasheet. It says that internal capacitors are provided with the oscillator, so I will remove them first thing.
 

Seven pins to "JP_LCD".  Indeed, it is common to have seven signal pins to/from a character LCD.

 

What about power and ground?  What about the contrast circuit?  (What about a possible backlight?)

See this board is only for the signals that flow to the LCD. The power and ground of both this board and the LCD will be connected to another supply board.

 

Ooops--never mind -- OP doesn't show a backup battery...

The backup battery is included. It was taking up a lot of space so I removed it for now but it will be included in the final design. 

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

The ground side of the main crystal's load caps (C3, C4) are supposed to go to the nearest Gnd pin of the Mega328. They don''t. In fact they could not be taken via a more circuitous (pun intended) path if you deliberately tried.

Ross McKenzie ValuSoft Melbourne Australia

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

valusoft wrote:

The ground side of the main crystal's load caps (C3, C4) are supposed to go to the nearest Gnd pin of the Mega328. They don''t. In fact they could not be taken via a more circuitous (pun intended) path if you deliberately tried.

 

What if I add a ground plane at the bottom layer?

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

If that was my design to fix, I would simply start again. Too many problems on the existing to fix. Sorry.

 

Ross McKenzie ValuSoft Melbourne Australia

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

valusoft wrote:

If that was my design to fix, I would simply start again. Too many problems on the existing to fix. Sorry.

 

 

Yeah I know. I just want to list all the faults so that I don't make them in my new board design.

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

Get the schematic correct first. With the pcb it is easier to remove unneaded components than it is to add them. Basically, if you're unsure if you need a load capacitor on the rtc then add it to the pcb. If you find you don't need it, simply don't load it.

Last Edited: Tue. Jul 25, 2017 - 08:06 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
If you find you don't need it, simply don't load it.

And then document on the schematic that these caps are not to be placed.

You can also change the value from "22p" to DNC (Do Not Connect)

Then it is also automatically documenting when extracting a BOM (Bill of Materials).

But just removing it is simpler for a getting started hobby project.

 

robo328 wrote:
If that was my design to fix, I would simply start again. Too many problems on the existing to fix. Sorry.     Yeah I know. I just want to list all the faults so that I don't make them in my new board design.

 

If you switch to kicad I might even be willing to help a bit with schematic / symbols / PCB layout.

(Hop I'm not promising too much here).

 

Edit / Addition:

This page:

kicad-pcb.org/made-with-kicad/

links to:

jpralves.net/pages/cseduinoworld.html

Which has 4 iterations of a beginner project much like yours.

He starts with vero board (perf board, or how it's called) and his last iteration is a PCB design with a m328p.

Paul van der Hoeven.
Bunch of old projects with AVR's:
http://www.hoevendesign.com

Last Edited: Tue. Jul 25, 2017 - 02:57 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For reasons only the OP can know he appears to have abandoned this thread (with most of the salient detail) in favour of:

 

http://www.avrfreaks.net/forum/l...

 

So to prevent cross posting accidents I'll lock this one.

Topic locked