behind the scenes: ATMEGA TQFP32 centric smd prototype pcb - Page 1
Forum section: electronics / projects

author: JohnnyBerg
author_rank: Frequent Contributor
timestamp: February 23, 2015, 06:59:31 pm
content: I like doing development work with a ATMEGA in it. And I have been looking on how to do that without to much hassle.Of course I tried the breadboard with the breakout boards. Nahh .. not reliable. Moving the breadboard results in loose contacts, and different behavior. Tried numerous breadboards, did not like that.I tried a different approach:Hmm .. that's better. But still a lot of hassle. I can do better than thatIn this thread I want to show how I got to this:I'll show each step involved in the designing and production of this pcb.Please bear with me, English is not my native language.So I'll do a lot of pictures. After all, 1 picture says a lot more then 1000 wordsp.s. I try to figure out whats best for the pictures, and how to get good quality.

author: JohnnyBerg
author_rank: Frequent Contributor
timestamp: February 23, 2015, 07:29:30 pm
content: It all starts with the schematic. I use KiCad to design the schematic and the PCB. KiCad is open source and available on Windows, Mac OSX and Linux.I use it on a Windows 7 machine, and occasionally on a Macbook pro.I use a fairly recent version, (build BRZ 5376) and found it superior to the "stable"build.Nothing revolutionary going on here. A ATMEGA328, with most of its pins broken out. There is a 6 pin header for the In Circuit programmer.Notice that there are 2 crystalsOne is the PTH version, and one is the SMD version. In the design they fit nice on each other, so the user of the board has can choose either version.The same applies to the reset switch. There is room for a PTH and a SMD version.There are also PWR_FLAG on the power lines. That is a thing of KiCad. When doning a DRC (Design Rule Check) KiCad complains that the power lines are not fed with juice. By putting the power flags in the schematic, KiCad DRC stops complaining.The pin out follows the "Arduino convention". Most of the time I put the Arduino bootloader in the chip, and use it as a Arduino clone. More on that later.This is how this part of the schematic looks on the pcb:Stay tuned, more to come

author: JohnnyBerg
author_rank: Frequent Contributor
timestamp: February 23, 2015, 09:57:15 pm
content: Every pcb needs some connectivity and power. First of all, USB. I thought it would come in handy as the decoupling capacitor and a LED were already on the board.Furthermore, I put a DC Jack on the board, and a SOT223 device with the decoupling capacitors already in place. That gives a lot of possibilities to make some kind of power supply. Or perhaps a FET or transistor in SOT223 with a resistor from gate top ground. Who knows?This is how this parts look on the board:

author: JohnnyBerg
author_rank: Frequent Contributor
timestamp: February 23, 2015, 10:27:27 pm
content: There is no point in re-inventing the wheel, what one needs is some kind of killer feature. I like to power my designs from a single LiPo battery, and I need a charger for that. Charging a LiPo battery is complex, and until now I used 2 devices for that. The MCP73831 and the TP4056. I do not want to use much space on the board, but I want to be able to use one of two devices. So I placed the TP4056 on the backside of the pcb. Later I will show has that is done.LiPo batteries have a fixed connector, so my board has to have that to. Connecting it the wrong way will destroy the charge IC.With a lot of smokeThe schematic looks a bit wierd, of course. That is because the TP4056 and the MCP73831 are connected in parallel. But only one is used!The POWER_FLAG's are for the KiCad DRC. RProg is dependent on the choosen battery capacity. The TP4056 can charge up to 1A.

author: zapta
author_rank: Super Contributor
timestamp: February 24, 2015, 03:11:10 am
content: Arm Pro Mini is a good starting point for prototyping with ATMEGA328P and it's available on ebay for $4 shipped. It's a bare bone design with output pins for a USB/Serial (e.g. FTDI Basic).

author: JohnnyBerg
author_rank: Frequent Contributor
timestamp: February 24, 2015, 08:51:16 am
content: Some other breakout stuff:Double crystal and switches again, as I want to have both SMD and PTH version available. The LED section is prewired with a 0805 resistor. 4 SOT23 transistors/mosfets/regulators will de devided in 2 and placed on differrent areas on the board.Did I say that the size of the board is 100 x 50 mm ?The power lines need some special care. I want to have plenty of decoupling on it, and on the backside a as large as possible gound plane. Also, the power lines must be a bit ticker.

author: JohnnyBerg
author_rank: Frequent Contributor
timestamp: February 24, 2015, 09:45:16 am
content: At this point in the design it is wise to stop working on the schema, and start thinking how the pcb will look like. I choose 100x50 mm, because many pcb makers have good deals on a size like that.We can open the pcb design of KiCad and see how far we are with our layout. We put the parts that we have on the pcb, and if there is room left, we add it to the schematic. We make a couple of round trips, until the pcb is full, and we are satisfiedI first draw the outline of the board. Then I put some dimensions in, always handy.In the end I decided to make the hight 49mm, that gives me an opportunity to panalize two boards to 100x100mm. For cutting there is then 2mm left. PCB makers also have good deals on 100x100mm boards

author: JohnnyBerg
author_rank: Frequent Contributor
timestamp: February 24, 2015, 10:55:24 am
content: Lets talk about footprints. There are some huge collections out there. And I see people "collect" large footprints libraries. Well, I don't. I only use a very small subset of footprints, well tested and of parts that I have "in stock". I'll keep a 3D version with them so my 3D rendering of the PCB will be as realistic as possible.I learned some tough lessons on using someone else's footprintsIn KiCad there are two ways to assign footprints to parts. First is with the CvPCB tool. I find that a real pain in the ass. Sometimes a use it to verify if my footprints are all assigned.The second way is to assign a footprint in the schematic. That is quite easy. Move to the part and press F. Then assign the footprint. My library of schematic parts is also very small, only my "preferred" items list (parts that I have in stock)Most of my parts already have the correct footprint assigned in the library, or have a very narrow selection in the footprint filter. Assigning footprints this way becomes a no brainer.

author: JohnnyBerg
author_rank: Frequent Contributor
timestamp: February 24, 2015, 02:49:47 pm
content: Before we can start with the PCB itself, we have to set the design rules. Most PCB manufacturers can do 6 mil traces. and 0,3mm hole via's, 6 mil copper around the hole. Of course, pushing things to what a PCB maker can do, will increase the odds on getting faulty PCB. I always try to build in some room for error.Most pcb makers give track with and clearance in mills (being 1/100 of an inch or 0,0254mm) and drill sizes in mm. So, wen setting the global design rules, I first set the minimum track with and clearance.Then switch to metric and set via size and drill size.Leave the micro via's at their default, I never used them.

author: JohnnyBerg
author_rank: Frequent Contributor
timestamp: February 24, 2015, 03:31:59 pm
content: We are almost done to do some tracks on the pcb .. finallyBut first we have to run the DRC (Design Rule Check). Lately I hangout on a forum, and there was this guy who said to ignore DRC errors. I never do that. I try to make my symbol library as perfect as possible, and I am very keen on resolving all errors.When running the DRC for this design, I get 1 error:Hmm .. oh yes .. KiCad is warning me that I have connected two power output pins to each other. Very good. As I am using one of the two IC's this is not a real problem. It's more that something very special is going on here.Notice pin 9 of the TP4056. I've marked that as not connected. It's my way of saying "hey DRC, I know that it is not connected!"

author: JohnnyBerg
author_rank: Frequent Contributor
timestamp: February 24, 2015, 07:07:48 pm
content: Finally, the routing of the PCB can begin. For display purposes I've simplified the schematic to the ATMEGA centric part, as shown in post #2. DRC is OK, PCB is defined and the design rules of the PCB are set.Footprints are assigned.From the schematics I generate a netlist. In this file all connections are described. The file is human readable. Sort ofThen I run Pcbnew, and import the netlist:The result is somewhat intimidating, but after a global spread out all footprints (this was quite different in the stable version), it looks a bit better:The white lines are component connections. They are called the ratsnest.Now I start dragging and rotating footprints ..For demonstration purposes, I did not place the double crystal and reset switch on top of each other.I set the grid to 50 mills. Later I use a smaller grid, but this is a good start. I use the mousewheel a lot to zoom:stay tuned, more to come

author: Rick Law
author_rank: Super Contributor
timestamp: February 24, 2015, 08:42:24 pm
content: Interesting!You have some of the similar modules I "encapsulated". I certainly will keep an eye here.

author: JohnnyBerg
author_rank: Frequent Contributor
timestamp: February 24, 2015, 09:09:42 pm
content: Quote from: Rick Law on February 24, 2015, 08:42:24 pmThanks !I intent to finish it as far as building a Arduino Nano with some extra stuff on it. So also the smd soldering. But also choosing a pcb manufacturer and looking at gerber files before sending them out.Tomorrow, when I am in the lab, I'll do some more pictures and text.If you have any questions, don't hesitate to ask.

author: JohnnyBerg
author_rank: Frequent Contributor
timestamp: February 25, 2015, 11:24:13 am
content: At this time in the design, its a good idea to see what we have:Next step is to put all the parts in the presumed position and start layouting. I've done some routing by hand:I do no like that. Mostly I'll route power lines and critical stuff by hand, and for the rest I use the autorouter. KiCad's autorouter sucks!. But there is a very good alternative called Freerouting.I export the pcb to route to a spectra design DSN file. It can even be a partial route, or a few traces. Then Freerouting picks up the DSN file and routes the pcb, according to the given design rules.After a few minutes and some optimalisation, it looks like this:Not bad, only 1 viaUsusaly this means I've taken to much space on the board. I have to do some iterations, to get the most out of it.Now I export a Spectra Session File, and KiCad picks that up.stay tuned, more to come!

author: Rick Law
author_rank: Super Contributor
timestamp: February 25, 2015, 07:52:49 pm
content: I think it may be good to size a carrier board for Nano/Mini as well.I used to focus on the 28-pin dip ATMEGA328P-PU because when I do blow the MCU, I can replace the MCU easy. The Nano can be had for $4 and the mini at $3. Buying the DIP or the TQFP package is going to be more than that.I personally like Nano for those that can work at "common ground" and mini for those that cannot. The mini gives me an opportunity to isolate the USB with either a Bluetooth connection or optically isolated RS232.

author: JohnnyBerg
author_rank: Frequent Contributor
timestamp: February 25, 2015, 08:05:56 pm
content: Quote from: Rick Law on February 25, 2015, 07:52:49 pmI'll think about that.QuoteIHMO is the nano not very complete. It lacks a reference, to do accurate ADC measurements. And I like to power it from a LiPo battery, so it needs a charger on board. And I want to measure the LiPo status, and detect if USB is plugged in. Did I mention that the original Nano lacks reset control?Thats why I designed my own NanoLipoStandby current is 130 nA when running direct on the LiPo. It has also a possibility to run with a 3.3V regulator, standby current 7 uA.It is the smallest I made until now, a lot of 0603 stuff

author: Rick Law
author_rank: Super Contributor
timestamp: February 25, 2015, 08:42:27 pm
content: Quote from: JohnnyBerg on February 25, 2015, 08:05:56 pmI didn't know that (Nano doesn't have a voltage reference)! Learn something new every day...After playing around with the on board ADC (Uno with P-PU DIP), I decided to go with the 3.3V whenever I can. The variation with USB supply makes the 5V reference iffy, whereas, with the 3.3V, I can get a (comparatively) solid reference even when I switch PC (different USB voltage). On one of my older PC (4.8V USB out), the 3.3V reference was still working ok whereas the 5V reference went far south.

author: JohnnyBerg
author_rank: Frequent Contributor
timestamp: February 25, 2015, 08:49:26 pm
content: I use a 2.495V reference, on board on A6. When reading from the ADC I first read the reference and then the port (A0 for example). Then calculate the resolution (reference value / 2.495)That way, I am independent of VCC, I even can measure it!IMHO this is the only way to use the 10 bit ADC within reasonable accuracy.And I can turn of the reference, to save power