Thursday, September 5, 2013

PCB Design Process

My Raspberry Pi Temperature Monitor Project was pretty cool, and I was getting some neat data from it, but I wanted to take it to the next level. This included using modern temperature sensors and building a printed circuit board (PCB) to replace the breadboard in the old project. In this post I will discuss my PCB design process.

First schematic

I started by converting the entire old project schematic to KiCad, a free and open-source PCB design program. I used Quick KICAD Library Component Builder to design a library file for the MCP3208 and KiCad Library Search Engine to get the library file for the 13x2 header. 

Choosing footprints for schematic components

After the schematic is finished it's exported into a netlist, which is then opened in CvPcb (still part of KiCad). In CvPcb the physical footprints are chosen for the components in the schematic. I chose the lying-down resistor style (R3) for the resistors and the standing up resistor footprint (R1) for the thermistors. The 13x2 header has a footprint: pin_array13x2. For the MCP3208 I chose the DIP-16__300_ELL footprint which is the standard DIP-16 footprint but with elongated solder pads.

Trying to fit the parts on to the PCB

Then the netlist is imported into PcbNew, the KiCad PCB layout editor. This is where most of the designing happens. The basic goal is to fit all of the parts on to the smallest board possible while having all of the connections. 

First complete board layout

After some tweaking I managed to connect everything on one board. I measured the board at 2.2" by 2.75", which seemed pretty small. 

Gerber plot settings

Drill file settings

I intended to use OSH Park to have the PCB made when I was done, so I exported Gerber and Drill files for that. All of the files have to be in one .zip before OSH Park will accept it. Then it is uploaded for processing and a price estimate is given. OSH Park charges $5 per square inch. 

First board on OSH Park

Suddenly my "small" board was going to cost $26! Now I focused on reducing the size of the board.

Second PCB design

I pushed all of the components closer and resubmitted to OSH Park. Surely this board would be much cheaper.

Second PCB on OSH Park

The second board would have cost $20 to print. Cheaper, but I knew I could do better. 

Third PCB design 

I realized eight ADC channels was probably overkill, and cut it to four channels by switching from the MCP3208 to the MCP3004. I also realized that I could use bigger traces where I had room for them. 

Design rules for the PCBs

Finalized third PCB design

I was really happy with the third PCB layout. I managed to make it much smaller, used larger traces where I could, and even figured out how to type on the back silkscreen layer (mirrored for production). 

Third PCB on OSH Park

The third PCB would cost $8.30, $17.70 cheaper than the original board. I was ready to order now, keeping in mind that I would have to order new parts to build it. 

Third PCB rendered in KiCad's 3D render mode

Although I was really happy with the third PCB and planned on ordering it, I wanted to wait a bit to see if I could improve it. Of course, an hour later I wanted to try to make it even smaller.

Fourth PCB design

For the fourth PCB, I wanted to see how small I could make it if it was all surface-mount components (all the PCB's before this were through-hole). Then it occurred to me that if I could make the header smaller I would save a lot of room on the PCB. I changed the MCP3004 and the resistors to surface-mount footprints, and changed the header to a 5x2 by using the 3.3v on pin 17 instead of pin 1. 

Fourth PCB design on OSH Park

The price for the fourth board was $3.90, a significant reduction of $4.40 from the last design and $22.10 cheaper than the original! 

Fifth PCB design

I couldn't stop thinking about it though. The big breakthrough was the new header design. I wanted to see how small I could make my original board using a smaller header and new techniques but otherwise with the same parts.

Fifth PCB rendered by OSH Park

The fifth was 1.20x1.29 inches, or $7.74. While this is more expensive than the fourth PCB, it is still $18.26 cheaper than the first one. Not bad. 

New schematic design

I went to sleep that night trying to decide between the third and the fourth PCB designs. However, when I woke up I realized I had been doing it all wrong and neither of them were useful! For some reason I was still designing PCB's to use thermistors instead of modern linear temperature sensors like the TMP36 or LM35. I started all over again with a new schematic using a MCP3004, 5x2 header, and four TMP36 sensors in the TO-92-3 package. 

Sixth PCB

Now I was making progress. I had a small PCB that used modern temperature sensors and didn't waste any room on resistors. 

Sixth PCB on OSH Park

This new PCB would cost $6.26 to have produced. The sensors cost $1.42 each, but it is a small price to pay for high accuracy sensors. 

Seventh PCB

If you guessed I wasn't done yet, you are right. Eventually it occurred to me that I didn't really need four temperature sensors and could get by with just two. This meant that I could use a two-channel ADC, the MCP3002, which is only a DIP-8 package. 

Seventh PCB on OSH Park and ordered

After seven designs and many hours, I finally had one that I liked. The price was $2.90, the cheapest board so far! I also saved money on temperature sensors by only using two and some on the chip by using a smaller one. 

I ordered the parts and the PCB on the same day. The parts took about three days to be delivered, while the PCB took about two weeks. This gave me some time to test my new sensors. 

TMP36 sensor readings. When did it get so cold?

Of course, they didn't work properly. 

Every time I tried to get the temperature the readings were way too low.

After a long time looking at datasheets and some help from google I discovered the problem was the output current of the TMP36, only 50 μA. Apparently the MCP3002 needs more current than this to get a correct reading, so all of the values were coming in low. 

The TMP36 can still be used through an op-amp, but this would make the PCB I designed and ordered useless! 

I decided instead to use another sensor, the LM35. The LM35 has a 10 mA output current, 200 times the TMP36 and enough for the MCP3002 to read it. It also had the same package and a similar pin-out with one exception: the power and ground pins were reversed, which means the sensor has to be installed backwards to the PCB silkscreen. Not a big deal. 

PCB's with a centimeter ruler

After a long two weeks, the PCB's showed up in a purple envelope. The first thing I did was verify several connections with my multimeter, then I went to soldering. 

Header pins soldered in

MCP3002 and LM35 soldered in

After I had it all soldered it was just a matter of plugging it in an testing it out. I only soldered in one temperature sensor to start.

Plugged into ribbon cable

Ribbon cable origami not required but helpful

Accurate readings from the PCB

It works! All that effort paid off and now I don't have to deal with a bunch of wires and breadboard just to log some temperatures. Hopefully next time I can start with the seventh PCB. 

If I was going to redesign this PCB again, I would probably add a ground plane (copper fill) to the bottom of the board, but the current design works fine. 

  • OSH Park sells PCB's in a minimum quantity of 3, so all of the prices I've listed are actually for 3 boards. Divide the price by 3 to get the actual cost per board. 
  • OSH Park prices and posts guidelines in imperial units. Although I hate using them, I used them in the design process and in this post because that's what OSH Park takes. 
  • Eventually I started to not plot module texts and values to gerber files and just insert them myself on the silkscreen. This worked a lot better for me.
  • Library's are added to KiCad in the schematic editor under Preferences > Library > Add
  • The header came from Carlolib-dev.lib
  • The TO-92-3 came from transistor2.lib
  • The final design files are available:
  • Or you can order the board straight from OSH Park:
  • I used KiCad 2012-apr-16-27-stable for Linux

No comments:

Post a Comment