ATMEGA328P footprint and further development

I will tell you how I understand it. My board is same microcontroller with most of the external stuff that supports it. I dont have leds, USB input and USB chip that helps to programm microcontroller with it, reset button. I have quartz, but it is not needed if I will power my bord with less voltage, I have 5V regulator, because I am planning to supply board with voltage more than 6V(As far as i think 12V). I have reset button pulled up, so my microcontroller will not reset unexpectedly. I have capasitors for VCCs, I know that they help to get rid of noice, but in which dirrection fom microcontroller to other devices, or to microcontroller. I made AREF as it is shown in arduino scheme, so I can work with ADC. And I have ISCP, so I can load my programm. And of course drivers and outputs for motors.

I have the one that is staying on arduino, it has capacitors included, watch the scheme!

I pulled up the rst leg of microcontroller, so it is always on, never resets, isn't it enough? It is the same as in arduino nano scheme, but without button.

Probably, and I guess you are right. THAT IS WHY I AM HERE! I know that my scheme and PCB are not the best. Explain me what is bad, why it is bad and how to make better. Thats all! :wink:

If you're using a crystal oscillator, you need two capacitors to go along with it.
If you use a ceramic resonator, it's possible it has the capacitors built into it.
It depends on which specific part you have selected. Your schematic indeed shows in-built capacitors, so it's not 'quartz'.
Anyway, I'll assume from here on you've selected a part with built-in capacitors as indeed indicated on your schematic.

I'd still place it on the other side of the board, away from the noisy motor drivers.

No, supply voltage is not directly related to the question if your oscillator will run and be stable.

But you don't have a reverse diode that prevents a HV spike on RST which can instantly erase your flash. The 328P can be a bit temperamental in this regard. I'd add a diode with its anode to RST and cathode to Vcc just to be sure.
Btw, I'm pretty sure the 328P has its RST internally pulled up; in that sense it's not required to pull it up in the first place - and yet, the Arduino guys do it, too. Sometimes, you want to incorporate a little insurance, simply because it costs next to nothing, but saves you a lot of trouble in case things work out differently than you anticipate.

But you have no way to debug your program. I think that's going to pose a problem later on. It's no fun to work on a board without having an easy way of knowing if your code is being executed the way you intend it to be.

Well, in all honesty, they don't have to be the best. They only have to work well enough for your requirements. Which is why I suggested earlier to just go ahead and have the board built as you have it now and see if it's good enough. If so, job done, congratulations and have fun with it. If not, we can always troubleshoot later.

PS: try not to get angry at the guys trying to help you. What they say makes sense, and they really are trying to help. Receiving criticism is never nice; breathe deeply, run a mile and keep smiling.

30 messages have already explained this to you - and you answer that all this is not important, capacitors are not needed, protection is not required. If you are sure that you understand all this, then go ahead, order the board and try it. Why you waste your time here?

If you want to be helped, you need to be more respectful of other people's advice.

Thank you for your advice.
Bye

1 Like

Lets start from the bottom

It does not make sence. I explained my thought proccess in the first message and asked 3 things: 1)Did i chose right driver? Am I right thinking the way I am?
2)How to place capacitors correctly?
3)Just overall review of scheme and PCB

^^^ Does this answers my questions?

Next yours is good, I am working

^^^ Is this helpfull? I don't want questions to me. I explained in the beginning that I HAVE NO EXPERIENCE. I don't need: "Where are the capacitors for TA6586s?
Are you sure that your PCB design can dissipate the heat from the 4 motor drivers."
I need:
"It seems like there are no capacitors for TA6586s, add them because this and that and that.
Also it might that your PCB design will not be able to dissipate the heat from the 4 motor drivers. Because this and that. Add this!"
So, no help from this message. This message is like giving question on question which is nonsence!

That was the best message so far, even though it is in negative sence.

^^^ not answering my questions

^^^ not answering my questions

Next yours is good

And so on. So you are the only one helping here, thank you!

So, first of all I moved all of my components on the top side and moved my capacitors differently, now lets see


It is the one that is used in arduino nano, probably i named it wrong.
As far as I know, ceramic resonator should be placed as close as possible.

You mean on the bottom? Or further on the upper side?

As far as I know it is, more voltage -> more possible frequncey. So if you power microcontroller from 2 battaries 1.5V, you actually dont need ceramic resonator 16MHz, because microcontroller itself can operate on 8 MHz. Am I wrong?

The question is that I made RST leg as it is made in arduino. The do the same as I did. Doesn't that mean that I am fine without cathode? I am NOT proving you wrong! I just do not undersatnd. Arduino nano has same microcontroller and on the scheme it is visible that there is no cathode there, am i right?
NanoV3.3.sch (arduino.cc)
Why do I need it then?

On data sheet each legs if they are pulled up it is said "with internal pull-up resistors", there is no that line in reset leg info.

What if I know that my code works right? I tested it on prototype. I am expecting that I am gonna load it once and it will work, because I built the scheme according to the prototype and PCB according to scheme. How does actual boards produced? They don't have any USB inbuts or what ever for debugging. I am not doing a hard project, there is nothing to debug. Button pressed motor works thats all.

I have questions to my board that i built now, and I came here to ask these questions. When I find answers, I will definitelly built them.

Yes, certainly. At the same time, it's important to keep it away from noisy parts of the circuit, especially if they involve relatively high currents. You can achieve this by rotating the microcontroller so the oscillator part faces away from the power electronics. You've already started playing with the orientation of the 328; experiment a little further to reach a more optimal layout. Don't hesitate to use vias on the tracks between the 328P and the motor drivers.

It doesn't matter if the oscillator ends up at the top, the left or the bottom of your board - as long as it's as far away as reasonably possible from the motor drivers.

Yes, but that's a different matter from whether the oscillator as such will run stably.

It's an additional insurance I like to include when using Microchip controllers (Atmega, Attiny) after having experienced issues with some of them entering HV programming mode inadvertently. I guess the Arduino Nano circuit avoids this risk.
Feel free to leave out the diode; there's a good chance you don't need it.

In case of doubt, it's always wise to refer to the manufacturer's recommendations. In this case, you'll find them in AVR042 here: https://ww1.microchip.com/downloads/en/appnotes/atmel-2521-avr-hardware-design-considerations_applicationnote_avr042.pdf
Page 6:

The reset line has an internal pull-up resistor. If the environment is noisy, it can be insufficient and reset may occur sporadically. Refer to the device datasheet for the value of the pull-up resistor that must be used for specific devices.

Furthermore:

ESD protection diode is not provided internally from RESET to VCC in order to allow HVPP. If HVPP is not used, it is recommended to add an ESD protection diode externally from RESET to VCC.

What if you want to change it for whatever reason?
What I usually do is include a 5-pin header with GND, Vcc, rx, tx and DTR (which can be connected through a 100nF cap with RST on your 328P). You can then connect any USB-Serial adapter (e.g. FTDI) to your board and program it like an Arduino Nano etc. as well as get Serial monitor output (and input). It's very convenient.

I would at the very least include an LED connected through a series resistor on two GPIO's that you can use for diagnostics. Throw in a power LEd as well fed off of the Vcc of the microcontroller so that you know it actually gets power.

It's these little things that make your life a whole lot easier once you have that board in your hands and start playing with it.

Finally, it's technically not a problem, but the routing of the traces looks a little funny/unorthodox with those crooked angles etc. It won't affect how the board works, but personally, I always try to make it look kind of nice, too. Make of that what you will.

1 Like


Oh, one more thing - don't forget to add those decoupling capacitors to the motor driver chips. You may have to space them a little further apart, and/or re-orient them to make it all fit nicely.

Got it, i'll do that

got it I'll add a diode

But it is for AVR042. Here is ATmega328P ATmega328P (arduino.cc)
Page 4: you can see that if it is internally pulled up, it is written "with internal pull-up resistors (selected for each bit)", there is no such thing in Reset pin

So I will leave my pull up resistor on rst leg

So, what are my thought on this point. Honestly, I wanted even to avoid having ISCP. Wanted to solder proper legs ISCP programmer, load program and unsolder. But I thought that probably it will be VERY troublesome for me. So I convinced myself to have ISCP inputs, so it will be not that difficult to load program. I just see other cirquit boards and i don't see there any input for loading the program and I want to do the same. Most likely we are planning to sell the stuff that we are duing and it seems to me that it is not good to have an easy access to the programm of a microcontroller. I am not making this for fun, or to play with that or whatever. It is not my project. It is project that I was "ordered" to do, so I need to make it as close as possible to how it is actually in various tools. So I don't want an easy to use Arduino Nano. I want to load programm and there will be no more changes or experiments with that.

Is it actually done on actual production boards?

Ha-Ha-Ha, it is actually....Yeah....
I read somewhere that there must be no sharp turns on main power lines, so since I understood that "sharp turns" is ">=50 degrees", this is my way of avoiding it. If 50 degrees is not considered as sharp turn, then I would definitelly love to make it beautiful. XD

If you look at production boards from many sources, you'll find a lot of not-installed components; some will be options not chosen, some will be debugging features left in simply because it takes design time to remove them; and, there's always the risk of inadvertent change. There's little added cost to real estate generally. Components often get left out for that reason.
When you've designed your 50th board, you'll understand this. Time is fleeting, so designing-in features you don't actually use is sometimes time saving, curiously.

Until you get into fitting 10 lbs of stuff in a 5lb bag - that's when you earn your design chops; no insult intended, but you're not there yet.

1 Like

Got you! That make sence!


Since you don't provide a way to reset your circuit, you could disable reset altogether by programming the proper fuse bit.

I understand your confusion, although you could have saved yourself from it by reading the first few sentences of the document. It explains it's an application note that applies to AVR microcontrollers. The 328P is part of that family.

Such application notes are supplementary information that can (should) be consulted in addition to the datasheets. They provide information on the proper use of the parts. You'll find that microcontroller manufacturers often have (1) datasheets explaining the capabilities and partial implementation details of devices, (2) reference manuals that offer insight in how to program or use the devices, and (3) application notes that cover specific aspects of embedding/using the devices in a practical context.

Of course, it's fine to keep your pullup resistor.

I can sort of understand that, although the question is how legitimate the concerns really are. But that's a different discussion.
What I'd like to warn you against is becoming the first (and worst) victim of your own safeguards. You're about to manufacture a board that despite its virtually unsurpassed simplicity will be a nightmare to work with for you.

To turn the problem into a solution, how about this: design the board with the UART broken out to a pin header (in addition to the ISP you already have) so you can enjoy the convenience of programming and debugging the board like a regular Nano etc. Then for the production version, remove whatever you feel is superfluous - or simply leave certain parts unpopulated. That way, you can have the best of both worlds.

I would advice against trying to make this a "first time right" kind of thing. Consider the first board (your first ever PCB, as I understand!) a prototype. Verify that it works and/or resolve the problems it has, then make a second version (or third, fourth etc) for series production. This is also the way it's done in any other professional context, so you'd find yourself in good company.

See @b707's comments above - yes. Have a good look at whatever consumer electronics you can crack open and marvel at the multitude of unpopulated footprints, test points, pogo pin pads, pin headers etc. It's in fact extremely common to find pin headers that are blatantly obvious an UART connector intended for debugging. For high volume production, you'll see that such headers aren't populated to save cost and create a bit of a barrier for people (esp. competitors) to tinker with their equipment, and you'll find that UART output is disabled or only occurs upon some kind of 'magic touch' (i.e. a certain key press combination, a GPIO pulled low during startup etc.), and that the flash is read protected so it won't be able to download it.

Yeah. Well, two 45 degrees also make a 90 degree turn, so there's that. Besides, PCB manufacturers today are pretty good, even the cheap ones. If you like to design your traces with 330 degree corners, they'll just chuckle and hand you your perfectly made boards. Just have a look at some commercially made boards to see how they resolve layout problems; it's very educational.

You've been given advice in this thread you've taken to heart, and some, from grizzled veterans, that you seem to discount because their reasons seem wrong to you, or aren't given. Remember, they may not even remember the smell of "burnt fingers" that taught them some of these lessons, so there's that. There are a lot of good advice tips that are 'soft', i.e. there's no magic reason for doing them, but there's also no reason for not doing them; sometimes, common sense isn't obvious.

One of those is making serial available. For a few pads on the board, why not? They don't even need to be organized into a header, you can fly wires to them if you suddenly have a need. Same with I2C, if you are aware of it. I haven't done a Nano project yet where I haven't brought the I2C out to a connector, and yet again, yesterday, I found myself repurposing one of those boards for another project, specifically because I only need to add an MCP23017 and a Neopixel string and the project is 95% done.
Go ahead and make your board however you choose, but do expect to do it again. Whatever you do, don't order a large batch, unless they'll be repurposed as drink coasters.

And how many locate vias on solder pads. My guess will be zero.

Soldering a component lead on a via stresses the via and causes them to fail. Your project will fail and you won't know why until you perform a continuity test. And even then you may not find it.

1 Like

Overall, I highlighted multiple points that I would love to implement in my project. They are:

1)The positioning of Ceramic resonator - close to MC, but further from drivers.

2)Add diod for reset button.
There is a question at this point. In manual it says

To protect the RESET line from further noise, connect a capacitor from the RESET pin to ground. This is not directly required since the AVR internally have a low-pass filter to eliminate spikes and noise that could cause reset. Using an extra capacitor is an additional protection. However, such extra capacitor cannot be used when DebugWIRE or PDI is used.

Do I need capasitor also in addition to the one that is standing for UART?

3)Add 5 pin header for UART

Question: 100nF capasitor closer to headers or rst pin? I guess RST pin

4)LED on pin, LED on power

5)Add capasitors on motors.

6)Move vias. That is understandable.
7) And I also added some input connectors for joystick, button etc. So now everything is closer to reality.

When I was making this board I decided to turn all my thought processes off, just turned on the music and went for it. It makes me feel weird that there is a lot of unused space, but lets see what you will say, so this is how everything looks now.



Now extra questions that I came up with:
1)I came back to the driver's datasheet and came up with an idea that i probably misunderstood everything. So, here I am coming back to this phrase.

So basically I am choosing driver according to the input voltage, peak current and average current of driver and motor. And I need it to be based on mosfets, because power sourse is battaries. Motor's stats are: Rated Voltage - 6~12V, Rated Current - 0.07A, Stall Current - 1A. So to make motor work on full power I need to give it 12V. I thought that the driver I chose can supply my motors with 3-14V with continuous current of 5 which suits me. But it seems that it is not giving out 3-14V, am I right? So it is not that good for me. So probably I need to change drivers.
I found interesting to me DRV8871. Is this one better? At least it has a better datasheet. It says:

Wide 6.5-V to 45-V Operating Voltage

Does this mean that it can handle 12V motor? Max output current is 3.6 and I don't see countinuous output current, but I think it is fine since I need only 1A max. And it is written that it is a mosfet driver. So basically, if this one suits and is better, I just make all the external stuff as it is in documentation and live a happy life.

2)About capasitors size... All the capasitors, resistors and so on that I use have the size 0805, how do I calculate what size do i need? And that would be great to understand where does this magical number of capacity comes from.

3)You said before that I also need a 470uF bulk capacitor, I just need to place them on parallel to ceramic caps near driver? How do I understand when I need to use bulk capasitor and when I don't? And just to verify the idea of placement of a decoupling capasitor, so I can create some kind of self rule in my head. I should place decoupling capasitor on every VCC leg of every chip and that's all, am I right?

4)Now I have both UART and ISCP. If UART helps me both to load and debug programm, why not to get rid of ISCP? @camsysca said to add I2C. If I am right, it is another communication protocol, do I need to add this also? Three tools for the only purpose of loading and debugging the programm seems weird. I can understand that for big cirquit boards, but for mine. It is kindergarden board, nothing special. Even considering the PCB that I am creating right now as a prototype of my final prototype of my final PCB.

5)And of course. What can go wrong? What would you add? What would you change? But I need explanation, why is the thing you want to add/change needs to be changed and how would you change it.

I2C is not for that purpose. Rather, I2C is a low level communication tool for controlling peripheral devices such as IO expanders, LCD displays, keypads, etc. as an alternative to using the dedicated IO on the processor. Since you haven't provided access to any other unused pins, I2C would be an alternative.
However, you've spent way too much time on this. At some point, 'learn by making mistakes' is better than iterating endlessly to perfect this board, particularly as you seem intent on demanding perfect answers before doing anything.

Order it, make it, figure out what works and what doesn't.

I'm moving on. Best of luck.

But thats the point I don't want to do thing because I was told to. I want to understand and implement stuff, because I understand that it is needed, so when I make another board, I will not go on the forum again begging people for help. Some of the advices are not on the topic, and that is a struggle for me, because I need to spend my energy not on googling the answer and understanding stuff, but on describing and pursuading people that I don't have time, or that I need PCB. The fact that I write the post on the forum telling that I have no experience tells that I am not educated, I have not read books, and I don't have time to look for an answers by myself. And when I am asking question, for example "How do I divide 18 by 9" I do not expect answers like "Oh, you need to start going to school, get the understanding how addition and subtraction works, then come back here" or "Read this book and you will undertand that". Maybe I read that book and went to school, but I still don't understand and I am looking for another way to help my self and getting these answers. Oh, I love that r "Oh, I know how to do that, but i think that you will not get my explanation". Why would you even type that? Maybe it is your problem that you can't explain properly? I came here knowing my problem, that I don't know stuff. Why should I care for someone's problem of not being able to explain stuff. And after that people think that I am rude and too much angry. I don't want to spread negativity and want to leave it there. I am very gald that behind all of those that I described, there are people who are trying to help, and even though I am stubborn and dump, they still do not give up on explaining stuff to me. Thank you!!!

The issue is, some answers are easy, and require only one line justifications. But some are built on years of experience, or years of education, and are best explained in a forum like this as "trust me, this is a better way". I do understand, you have no way of validating the 'behind the scenes' knowledge that others have when they respond here, just as we have no way of assessing your ability/interest outside of the words you use.

Remember, as well, that nobody's getting paid to do the question answering here. Answers are often short and sweet because to explain the issue properly will take many paragraphs, explanatory diagrams, and what have you - that consumes time to pull together; often, extensive web browsing will be required to find 'just the right' evidence. More often than not, doing that effort and presenting that info, is met with a shrug, or silence, or, 'well, I'm not doing that anyway', so the helper is left feeling he/she has wasted their time on yet another newbie.

Just another free opinion, which you are free to discard. Good luck!

Fair enough, I have a lot to say, but I'll leave it there. Thank you for your help!

1 Like