Project

Build a Thermocouple Amplifier and Custom KiCad Libraries

August 10, 2015 by Patrick Lloyd

Building on skills developed in the introductory KiCad tutorial, this article will focus on creating custom parts and adding them to a local library, expanding the default libraries to include community repositories, and contributing parts back into the open source ecosystem. The end product will be a MAX31855 K-type thermocouple amplifier which can be used for a huge array of temperature sensing projects.

Recommended Level:

Intermediate

What's the Big Idea, Anyway?

As we continue the journey into open source hardware development, we eventually will have to leave the comfy confines of the standard parts libraries for schematics and footprints and branch out into more uncharted terrain. This tutorial will cover some of the aspects of custom part creation and also how to get involved with the KiCad community and contribute your custom parts to the official open source repository. This is going to assume some familiarity already with the program so go back to the introductory tutorial if you get tripped up.

This article will focus on building a breakout board for the Maxim MAX31855 K-type thermocouple amplifier, which will come in handy for several projects down the road. I'm basing my schematic off of one of Andy Brown's subcircuits from his awesome Android reflow oven project. If you aren't familiar with thermocouples, they're really cool temperature sensing devices that rely on the Seebeck Effect. The "type" (K-type in this case) refers to the metals used in the junction which influence the thermoelectrical properties of the sensor. Unlike some of the more popular breakout boards on the market for the MAX31855, this one will be able to accommodate two kinds of connectors: a standard 0.1" two-pin terminal and an ANSI standard K-type mini PCB-mount thermocouple connector.



This is what the final board will look like viewed with KiCad's snazzy 3D rendering system.

 

What you need to complete the tutorial:

  • Any computer with the latest development build of KiCad

Update KiCad

Since KiCad is under constant development, it is recommended to update it to the latest testing build. If you are using the helper script provided by KiCad that we worked with in the intro tutorial, open a terminal in the location of the script and type

./kicad-install.sh --install-or-update

 

This will pull the latest updates from the KiCad code repository and recompile the software suite. As a small side note, I found that sometimes when updating from the script the build process fails. If that occurs, you may have to run make clean in the KiCad sources build directory. To find the directory specified in the install script, type: 

cat kicad-install.sh | grep "WORKING_TREES="

 

which will produce something like:

<kbd>WORKING_TREES=/home//.opt/kicad/kicad-sources</kbd>

 

Change into that directory and then type:

cd kicad.bzr/build/
make clean

 

Change back to the directory with the helper script and try again.

 

Build a Standard Library Schematic

Begin by opening KiCad and creating a new project. Then open Eeschema and create the following schematic using parts from the standard libraries:

 

I used the following parts:

  • 1x MAX31855KASA (Cold Junction K-type Termocouple Interface, SPI, SO8)
  • 2x INDUCTOR_SMALL, value changed to "FERRITE_BEAD"
  • 1x C (Unpolarized Capacitor), 100nF
  • 1x C (Unpolarized Capacitor), 10nF
  • 1x R (Resistor), 10K ohm
  • 1x CONN_01X02, value changed to "STD_HEADER"
  • 1x CONN_01X05

 

This schematic as it is now will get you to a functional breakout board. However, many thermocouple devices use a ANSI standard keyed connector and it would be a shame to have to cut it off and strip the wires just because we don't have a proper receptacle for it on our board.


Here is that special TC connector in all its glory...
 

Thankfully, several manufacturers make PCB-mountable female sockets that can be used to interface with the thermocouple. I couldn't find one on DigiKey, which is my preferred distributor, but Farnell had some from Newport Electronics. I managed to find them through Octopart's search engine which was one of the recommended parts locations from Dan Romanchik's Five Places to Find Part Info Online.


It plugs into this lil' thing right here. This is a generic stock image from the supplier website so not what ours will look like. For starters, ours will have a "K" instead of an "E".

Getting into the Schematic Library Editor

Now that we have our connector picked out, we need to put together a schematic symbol that can be incorporated into Eeschema. This is done through KiCad's Schematic Library Editor. Find this button and give it a hearty click:

This will pull up a blank schematic editor window. Find the "New Component" button and click on that too: 

This will bring up the new component properties menu where you can set some basic information about your new part. I set mine up like so:


PCC-SMP-K for the manufacturer's part number and P for the REFDES since it's a plug

 

After we have a new component, navigate to the button that looks like a little book without lines on the pages to save this component in a new library:

 

I generally save it in the project folder with the schematic and board files it's not that crucial. Just remember where you put it since you have to manually tell KiCad to use this library. To do that, find the Component Libraries option from the preferences toolbar:


Why isn't there a hotkey for this?!

 

The Component Libraries selection window will let you choose which libraries to search for parts in and prioritize their order. Select the Add button next to the "Component library files" window and find your recently saved library. 

 

Now that our new library is on the search path, we need to make it that active development library. This is important if we want to add more than just one symbol to it. Find the other open book icon, but this time it has lines in it (brilliant icon choices, right?)

From the library selection dialog that opens up, find your newly created library and select OK. 

 

If you wanted to add some more detailed information about the part, you can select the Part Properties button which is indicated by this:

And add some more details that make searching for the part a little easier.

 

Phew. That should take care of the "behind the scenes" schematic symbol work. Now we can finally make the symbol!

 

Using to add pins, M andto move and grab, R to rotate, and then the circle and line tools on the right toolbar, I made the following part. The stuff near T+ and T- is the symbol for thermocouple, just to make things a bit clearer. I also explicitly included the retaining bar as a pin so we can either ground it or leave it disconnected in the project.

 

After everything is saved, you can add the part to your schematic in Eeschema just as simply as anything else. Here is the finished schematic:

Footprint Library Editor

Okay so now what? How does KiCad know what the darn thing is supposed to look like on a PCB? Well, we have to go through a similar process with the Footprint Editor and create a library. Find the Footprint Editor button either in Eeschema or the KiCad home screen:

This will present a boring looking blank screen akin to the schematic library editor. There is a similar level of behind the scenes rigmarole to go through to get to the actual creation of the footprint. Find the  button which will create a new footprint. I named mine PCC-SMP-K like the schematic symbol. 

 

The next step is to save this new footprint to a new library. Find the  "book without any lines" icon and use that to save your new schematic into the project folder. 

 

KiCad uses a folder with a ".pretty" extension to represent each footprint library. Those folders then contain a .kicad_mod file with the corresponding footprint. To add this new library to the search path so we can associate it to the schematic part later, use the Footprint Libraries Wizard located in the toolbar at the top:

 

 

Select the "Library on my Computer" option and navigate to where you saved the ".pretty folder". You can either make it a global or a local library for just that project. Up to you on that one. This wizard also allows you to install KiCad libraries directly from the swiftly growing KiCad Github repository, which is pretty slick. The Footprint Libraries Manager shows you the installed libraries and gives you some more control over your parts:

 

Now we can select our library as the one for active part development by locating the  icon and selecting ours. The last "under the hood" aspect of the footprint creation is to edit some of the information about the part itself and link the documentation file. Find the following button and use it to configure the footprint: 

 

 

You can modify clearances and 3D part information if you want to integrate this with a mechanical enclosure but that's out of the scope for this particular tutorial. There's a ton of stuff that KiCad can do and It's important to keep in perspective that KiCad is a really powerful piece of software.

 

Now for the guts of the footprint. This relies very heavily on the information provided in the the datasheet for the PCC-SMP-K so I've tossed in an excerpt from it detailing the land patter and mechanical dimensions. According to the recommended layout, it needs four equally sized 70 mil holes with slightly asymmetrical spacing:

 

There is a bit of art and freeform design in this stage. For example, the datasheet specifies diameter for the hole but not the amount of area we should leave for solder. Since we expect to jiggle this connector a bit when occasionally replacing thermocouple probes, it would be wise to add a healthy solder pad area to make a really solid connection to the PCB. I made my holes like so:


70 mil hole and 110 mil total solder area

 

After placing four of these holes, I used the text and line tools to annotate the part and draw on the silkscreen layer the outer dimensions of the connector. That way I don't get confused when plugging in probes or placing components later. After laying everything out, my final footprint looks like this:

 

Note: Pay attention to the pin numbers. These will correspond to the pin numbers that you assigned to your schematic library. Also, since the retainer bar on top is basically just a piece of copper, they are the same node electrically. The layout editor allows for you to represent a single node with multiple pins. 

Building a Board

Now with both our footprint and schematic libraries built and on KiCad's search paths, we can start the workflow to building a PCB. That workflow is as follows:

  1. Build and annotate the schematic with Eeschema
  2. Run CvPcb to associate the schematic symbols with their footprints. Don't forget to save the associations!
  3. Generate a netlist file.
  4. Open Pcbnew.
  5. Import the netlist file.
  6. Lay the parts out, route the board, and generate Gerber files for manufacturing.

For reference, these are my CvPcb associations:

Now you can spread out and route the parts. All the parts except for the headers and connectors are surface mount so I decided to place those underneath the main thermocouple connector to make a really nice compact design:

 

I then added a polygon pour on the top and bottom copper layers and connected them to GND and slapped an Open Source Hardware logo on there for good measure. Here's the final product - pretty, rendered, and ready to be manufactured:

Getting this Board IRL

If you are interested in putting this board together yourself and actually using it in your next project, you can find all the design files as well as Gerber files, datasheets, and a bill of materials (BOM) in the lib-intro.zip file attached here:

lib-intro.zip

I generally like to use OSHPark to manufacture boards. They charge by the square inch and are pretty darn cheap if you're just looking for a simple two layer board. This one in particular costs $5.20 for three (they only sell in multiples of three) which is pretty snazzy. You can find this project's board here.

 

What it All Means

KiCad isn't a perfect program yet, and I'm not ashamed to admit it. But what it lacks in polish, it more than makes up for with its community of incredibly passionate designers, programmers, engineers, physicists, and hackers all working together to make a fantastic tool that is already capable of awesome things. CERN very poignantly captured this idea on their contribution page:

We think that KiCad can do to PCB design what the GCC compiler did to software: ensure that there are no artificial barriers to the sharing of information, so that design and development knowledge can flow more freely.

So if you can, get involved: Donate a couple bucks, start developing, or contribute your awesome new footprints to the official repository. The whole motivation for using KiCad and participating in the open source movement in general is that through free tools like these (free as in beer and as infreedom), you have more power, flexibility, and freedom to design and build the devices of the future. Happy hacking. 

Give this project a try for yourself! Get the BOM.