Friday, January 1, 2016

PCB For Polysix OTA Overdrive

Before today, I had made exactly one PCB.  It was a very simple design, yet it was still a painful experience.  I am not an expert -- that's for sure.  Yet, here I'm going to give it another go.  I'm going to dive in and design myself a custom circuit board.  This PCB is going to host my OTA Overdrive Mod for my Korg Polysix.  It'll contain an Arduino-controlled digipot, including my own Arduino as part of the same PCB.  Given my inexperience, this is pretty bold stuff.  I'm nervous and I'm excited.  Can I make it work?

Here's the PCB design that I made using Fritzing.  It's only a two layer board, but it looks awfully complicated for a newbie such as myself.  Does it have any chance of working?

Laying the Groundwork:  Over the last several posts, I've been figuring out most of the elements of this modification, including the digipot and the Arduino.  I know that I want to put all of those elements onto one board and fit it inside my Polysix.  My biggest remaining unknown is how to physically attach my components to the Polysix's circuitry.

Use One of the Built-In DIP Sockets:  A good trick is to re-use one of the DIP sockets that a used throughout the Polysix circuitry.  This is the same trick that I used when installing my mod to add velocity sensitivity to my Polysix.  For this OTA Overdrive Mod, I'm going to use the DIP socket that the OTA itself lives in (ie, IC20 on the KLM-368 "Effects" PCB).

DIP Socket and DIP Connector:  As shown in the picture below, I'm going to pull IC20 out of its DIP socket and I'm going to insert a pinned DIP-style connector in its place.  My PCB will solder to this pinned connector.  To reconnect IC20 into the circuit, my PCB will include its own DIP socket (and associated wiring).  My PCB will include the wiring to connect IC20 back into the Polysix's circuitry via the pinned connector.

I'm going to attach my PCB via the DIP socket for IC20.  It's great that the Polysix came with so many socketed ICs to enable this kind of hack.

Circuit Block Diagram:  Before diving into PCB design, it's important that I understand what it is that I want to do.  The block diagram below shows my overall approach for this PCB.  It shows the DIP connector and DIP socket, it shows the digipot that controls the overdrive, and it shows the Arduino-style microcontroller that controls the digipot.  It also shows the headers that I'll used to program the Arduino ("ICSP" and "FTDI") as well as a bunch of pins and headers that'll let me be flexible in how I choose to connect the various audio and synth control signals that I might wish to manipulate.

Here's a block diagram of what I'm hoping to build.  I want to include lots of pin headers so that I have plenty of flexibility for modifying my own circuit once it's built.

Which PCB Layout Software?  In my previous attempt at a PCB design, I used CadSoft Eagle This is the PCB layout software common throughout the Maker community, probably because there is a free version that is pretty capable.  Both Sparkfun and Adafruit seem to think that it's a good choice for their open source designs.  I didn't like it, though.  I thought that it was hard to learn and didn't promote self-discovery.  I felt like trying a new tool instead.  I almost went for a cloud-based software tool like Autodesk's 123D Circuits, but at the last moment I ended up downloading and trying Fritzing.  I found Fritzing to be very approachable, and unlike 123D Circuits, it's been around long enough for the forums to have a good number of threads for me to learn from.

To layout my PCB, I tried Fritzing.  It seemed much more approachable than CadSoft Eagle.

Parts then Schematic then PCB:  One should only start a PCB design when you already have a good idea about what you want to build.  That's why I started with the block diagram shown earlier and that's why I spent so much time breadboarding the key elements of my circuit in previous posts.  Once you know what elements are going to be in your circuit, only then should you start with the PCB design software.  PCB design software generally follows a three-step process: (1) choose the parts for your design, (2) draw your schematic using your parts, (3) layout your PCB based on your schematic.  OK, here we go...

Step 1A: Choosing my Parts.  Looking back at my block diagram, my major parts are the LM13600 OTA, the AD5262 dual digipot, and the ATMega 328P microcontroller.  For minor parts, there will be a bunch of resistors and capacitors, some pin headers, and an oscillator/clock for the microcontroller.  Fritzing is already well stocked with parts for me to use for these minor components.  So, it's the major components that I need to focus on.  Lucikly, Fritzing already has the version of the ATMega 328P that I want to use (the surface mount TQFP package).  What Fritzing doesn't have is the LM13600 OTA or the AD5262 digipot.  I needed to make these two parts myself.

Step 1B: Creating the Missing Parts.  Making parts is often the hardest part of using PCB design software.  It's such a pain.  I figured it out through a combination of the Fritzing documentation plus lots of trial and error.  The key to making any progress is that Fritzing already had built-in components of the right size.  They weren't the correct part, but they were the correct size (they already had a TSSOP-16 like my digpot and they already had a DIP-16 like my OTA).  As a result, my task was simply to copy the existing parts and re-name the pins.  Through a combination of the built-in part editor (see screenshot below) and a text editor (to change the labels on the SVG graphics), I was able to create my two parts.  If you're interested, I've shared my Fritzing library on my GitHub here.

One of the hardest part of designing one's own PCB is creating models for the parts that don't come in the standard library. Here, I'm making a model for the AD5262 digipot, which is a TSSOP-16 package.  I also did this for the LM13600 OTA, which is a DIP-16.  This process always seems harder than it should be.

Step 2: Create the Schematic.  With my parts created (go me!), I started creating the schematic.  My final schematic is shown below.  In the upper left, you can see a block corresponding to the DIP connector that'll be used to connect this PCB to the Polysix's KLM-368 PCB.  You can see that most of the pins of the DIP connector get routed down to a DIP socket that I'll put on my board to host the LM13600 OTA chip itself.  You can also see that I've broken out few of the LM13600 pins so that I can manipulate the signals (ie, enable overdrive) with the other parts of my circuit.  The rest of the schematic shows the other elements of my circuit -- in particular, you can see the block for the digipot (bottom left) and the big block for the ATMega 328P microcontroller (center).  The critical connections for the 328P (such as the reset circuit) I copied from the Sparkfun Arduino Pro.  That Sparkfun design is also where I learned the layout for the two programming headers (the FTDI and the ICSP headers).

This is the schematic of all the elements that will go into my PCB.  This defines all the connections between the different circuit elements.

Make it Hackable.  As already mentioned, this design breaks out extra Arduino pins, includes some unconnected "spare pins", and includes a second set of pins for both pots in my digipot.  All of these extra access points are to enable future hacking of my own PCB.  I wanted to include flexibility the design of my PCB so that I can make different connections between the OTA, the digipot, and the Arduino.  Who knows what kind of mods I might dream of in the future?!?  With these extra pins, it'll be easier to have fun explorations.  You've got to be prepared to be spontaneous!

Step 3: Layout the PCB.  With the schematic complete, I started the PCB layout process.  I placed my components onto a notional PCB and started laying wires ("traces") between them.  Below is a screenshot showing all of the parts on a notional PCB outline.  I've got about 2/3rds of the traces complete.  To make a trace you simply choose which side of the PCB you want (top or bottom) and then right-click on one of the "air wires" to create the actual trace.  Because the default trace is pretty thick, I would click on the trace and, in the "Inspector" window pane on the bottom right, choose a thinner size like 12 mil.  Finally, click and drag points on the trace to manually route the trace where you want it.  If a trace needs to jump between layers to avoid existing traces, you create a "via" between the layers by right-clicking on the desired spot on the wire.  This is easy!

This is the PCB layout view in Fritzing.  I'm about 2/3rds complete in laying out the board.
Surface Mount vs Through Hole:  I'm not very experienced with surface mount parts (though I have soldered this TSSOP digipot before), so most of my parts in this design are through hole parts (PTH).  The only two surface mount parts (SMT) are the digipot and the ATMega 328P.  In laying out the PCB, the main issue with mixing PTT and SMT parts is that the grid size (which helps keep your traces orderly) really wants to be different for the PTT components vs the SMT components.  For the PTT parts, grid sizes of 0.1", 0.05" or 0.025" all work well.  By contrast, the TQFP package for the ATMega 328P works better with a 0.8 mm (0.0315") grid.  Annoyingly, for the TSSOP package for the digipot, the best grid size is yet a different value (0.0254").  It gets very tedious manually switching between the different grid sizes.

Finishing the PCB:  Once I got all the traces where I wanted them, I started adding text to the PCB so that I could know where to connect my different signals.  I also put a name and date on the board so that I could know which iteration of he board I was using (surely, I would need to iterate the board to fix errors).  Finally, on the bottom layer, I told Fritzing to do a "copper fill".  This is a common technique to try to reduce unwanted noise that may be transmitted between closely spaced circuit boards (such between this PCB and the Polysix KLM-368 that'll be right underneath it).  A screenshot with my final PCB is shown below.  I shared my Fritzing design files on GitHub here.

Still in Fritzing, I have finished my PCB design, including a big copper fill on the bottom for the ground plane.

Design Rule Check:  Throughout the PCB layout process, I would periodically use the software's built-in tool for confirming that my traces were not overlapping with anything else on the board.  The traces on a PCB can get pretty convoluted, so using an automated tool is a great benefit.  This tool is called the "design rule check" (DRC) and is included with almost any PCB design software.  In Fritzing, when I'd run the DRC, I'd get a big pile of error messages like shown in the window below.

The "design rule check" (DRC) gives lots of errors for my design when using the default DRC rules.

Shrinking the Keepout Distance:  When I would try to find these errors in my PCB, I often saw no issue.  The traces (especially around the SMT components) may have been close, but they were not interfering.  I was confused.  The answer is that the default rules used by the DRC algorithm were too tight for my small SMT components.  When I changed the DRC "keepout" distance from its default 0.01" value to a smaller 0.008" value (see screenshot below), almost all of my errors went away.  The remaining DRC errors were legitimate problems, which I found and fixed.

With such small SMT components, you need to reduce the "keepout", thereby telling the DRC algorithms that it is OK if the traces are close together.  I dropped the keepout from 0.01 inches to 0.008 inches.

Shrinking the keepout (plus fixing some actual errors in my PCB) eventually lets me pass the DRC.

Export for Production:  Once my design was complete and the DRC results came back clean (see screenshot above...I was so happy when I saw this message!), it's time to export the design so that it can be sent out to be printed.  The exported production files are often called "Gerber Files".  In Fritzing, I chose to export to "Extended Gerber Files".  It created a collection of files that define the top and bottom copper traces, the drill locations for the vias and the PTT components, the top and bottom solder mask, and the top and bottom silkscreen (ie, text and graphics).  These are the files that the printing company need to make the PCB.

Tailor for Your PCB Print Company:  Unfortunately, every PCB printing company is a little different in their requirements for the Gerber files.  As a result, the Gerbers may have to be tweaked specifically for different printing companies.  For me, I chose to use OSH Park to print my board.  Looking at their requirements, the Fritzing Gerber files were all fine, except I had to change my drill file to end with ".xln".  That's all I had to do!  My Gerber files are zipped up on my GitHub here.

Send to Printer:  I uploaded my zipped Gerber files to OSH Park.  Their automated system interprets the files and then shows you illustrations of your design so that you can confirm that they interpreted your files correctly.  In my case, the top and bottom views of my board are shown below.  They look pretty good.

Top and Bottom View of my PCB as Generated by OSH Park.  $21.75 for three.  Let's get it printed!

Order the PCB:  In general, the cost for PCBs is driven by the number of layers (a two-layer board is cheaper than a six-layer board) and by the area of the board (a smaller board is cheaper than a large board).  I tried to make my board pretty small.  I was hoping to get under $20, but I only got it down to $21.75.  Given that OSH Park sends you three copies of your board for that price (plus free shipping!), I'm still pretty happy.  Anyone can order my board from OSH Park here.

Waiting:  So, now I wait for the board to get printed and sent to me.  It generally takes 2-3 weeks.  I'm so excited to get it.  Waiting is agony!