Arduino Uno Dual Merge MIDI “Shield” – Part 2

I’ve been meaning to have a try at PCB design for a while.  I’d like to add it to the list of things I’m amateurly enthusiastically ignorant about.   I’ve not seen anything like my Arduino Uno Dual Merge MIDI “Shield” available anywhere but it is built of individual designs I am very familiar with, so I thought I’d give it a go.

ArduinoUnoMIDIShield-PCB4-Ger

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

Update:

These are the key tutorials for the main concepts used in this project:

If you are new to Microcontrollers, see the Getting Started pages.

The Basic Process

I’m attempting to reproduce the circuit from my Arduino Uno Dual Merge MIDI “Shield” into a PCB.  Fritzing has a PCB editing view and I have tinkered with it before, but I didn’t really know what I was doing.  Pretty much everyone I’ve spoken to uses KiCad (or an equivalent commercial tool), so I thought I’d take the plunge and see if I could give it a go.

These are the basic steps in the workflow so far:

  • Download and install KiCad.  At the time of writing, this means v6.0.
  • Create a new project – from a template if one exists (there are templates for Arduino and Raspberry Pi).
  • Re-create the schematic in KiCad using the Schematic editor.
  • Assign “footprints” to all the components.
  • Import the schematic into the PCB editor.
  • Align the footprints, add tracks, edit the silkscreen labels, and so on.
  • Create “Gerber” plot and drill files for all the layers.
  • View and check the Gerber files using the Gerber viewer.
  • Upload the Gerber files to a PCB production facility, pay and wait (and hope).

Each step also involved various checks (electronic and manual) and iterating back to the previous step to fix issues or update the design.

One thing I found straight away, is that although I felt I was doing quite a “beginner” type activity – a relatively basic PCB with through-hole components and a few connectors – to do these simple things I still had to get right into the complexity of the tools as if I was designing the most sophisticated board I could imagine.  From that point of view, KiCad isn’t particularly beginner friendly.  But it isn’t totally inaccessible either, so it is worth just getting stuck in.

There are a number of tutorials out there for getting you going on all this (see the links above), so I’m not going to attempt to reproduce all those here.  What I am making a note of though (as my usual “notes to self”) are the various things that weren’t obvious to me at each stage that I think I’ll want to remember for the future.

Create the Project

Having said that I felt a little “in at the deep end” one thing that definitely threw me a “life preserver” was the “Create project from template” option.  This has a whole range of DIY/maker starting points for a range of Arduino or Raspberry Pi projects and really saved me having to completely start from a “blank sheet”.

I selected an “Arduino as Uno – Expansion Board” and found myself with all the header definitions for an Arduino shield read to go.

Re-creating the Schematic

ArduinoUnoMIDIShield-PCB-Sch

The KiCad schematic editor is a much more professional tool than Fritzing, but it isn’t quite obvious how to do “simple” things as a consequence.  Here are my notes to self.

  • Pretty much every “thing” you’d want to add is under the “symbols” icon (an opamp I believe).
  • You can add a resistor by opening the symbol list and typing “R” and a capacitor by typing “C”.
  • To start drawing a wire type “W”.  Wires can be linked all over the place, so just draw away!
  • Make good use of power and ground “anchors” (under the GND symbol icon).
  • Make use of labels (the “letter on a wire” icon) to save having wires all over the diagram.  This was particularly useful to link up to the Arduino template which has a host of labels already added to the connections.
    • Note: I wanted to use D0, D1, D2 which were labelled as follows: 0(Rx), 1(Rx), 2 – so these are the labels to use – exactly as written.
    • You can change any labels just by clicking on them, so I could have changed 0(Rx) to 0 for example.
    • There a number of types of labels, but I just used “net labels” rather than “global” or “hierarchical” labels for this one.  I plan to read about when to use the others at some point…
  • Don’t forget to add decoupling capacitors.  I just created a separate part of the diagram showing power and GND with all the capacitors I needed linked between the two, to save cluttering up the main schematic.
  • Anything that doesn’t need a connection should be linked as “N/C”.  The shortcut Q gives you the “cross” symbol to add in the appropriate places.
  • I didn’t worry about component labels at this point – they can be added later.

When everything appears to be complete, you can run the “Electrical Rules Check” (ERC) to see what you’ve forgotten.

Update: here are a few additional thoughts after having used KiCad for a while:

  • Be sure to do your changes in the schematic view and then “update PCB”.
  • There is an automatic “annotate PCB” options, but if your edits mean you have weird numbering of components now, there is also an option to “reset all numbering”.
  • Updating footprints in the schematic view doesn’t seem to map over to the PCB view.  You have to change them there too.

Assigning Footprints to Components

One thing that surprised me in the workflow is that you add footprints to symbols in the schematic view.  You do this by bringing up the properties for the symbol and then selecting a footprint from the huge range provided.

This is the point, where I must admit I was quite lost for a while.  The following were key to helping me here:

  • Footprints are labelled according to their physical properties, not their electrical ones.  Which makes absolute sense, but when you first encounter them it yields a bewildering number of options!
  • Don’t be afraid to get your ruler out!  Seriously.  You’d think there was some kind of specification for sizes, given how detailed the electrical properties get specified, and if you have a manufacturers datasheet for your exact component, then there is.  But the ultimate check is literally to measure your component and find the footprint that both looks right and has the right dimensions!
  • It tends to remember the last footprint you selected, so it can be relatively quick to add footprints to all components if you do all the same types together.
  • Here are some common through hole components (of the sort you might get in a hobbyist electronics pack):
    • Resistors: You’ll probably want some of the R_Axial_DINnnnn options.  These are labeled with the length, depth and pin-hole distance dimension.  I chose DIN0207 which are 6.3×2.5mm bodies.  In “horizontal” mode there are a number of pin-spacings available.  I went with the smallest, so I chose:
      • Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P7.62mm_Horizontal
    • Capacitors: following similar logic, for this build I just needed a simple ceramic disk type footprint, so I used:
      • Capacitor_THT:C_Disc_D6.0mm_W2.5mm_P5.00mm
    • Diodes: there are a whole range of DO-xxx standard sizes.  DO-41 seems pretty common for common signal diodes.
    • DIP chips: There are some devices specified, but really what you are after is the common footprints for many devices – the best place to start is those labelled Package_.  But even a simple 8-pin DIP package like the 6N138 I’m using has several options. I went with this one (again checking with a ruler):
      • Package_DIP:DIP-8_W10.16mm
        • Update: This was the wrong one!!  In the end the one I needed was: Package_DIP:DIP-8_W7.62mm_Socket
    • Header sockets and pins: This really took me a while, and to be honest I ended up Googling it!  I didn’t end up using them anyway, but for “common” 2.54mm spaced header pins and sockets, the following groups are probably what you are looking for:
      • Connector_PinHeader_2.54mm
      • Connector_PinSocket_2.54mm

There are sub-options for single (PinHeader_1x) or dual (PinHeader_2x) rows of pins, and the number following the “x” says how many pins.  And then options for vertical, horizontal, surface mount, and so on.

For this PCB I also wanted a footprint for a PCB mounted MIDI socket, but whilst there is a symbol for a 5-pin DIN socket, there wasn’t an obvious footprint that I could find.  Thankfully there is a “third party” one I found here: https://github.com/nebs/eurocad that perfectly matches the kinds of sockets I have.

I downloaded the ZIP file from this repository and then had to go to Preferences -> Manage Symbol Library from the schematic editor to import this as a special library for my project.  I used the “Add existing library to table” option and imported the “.lib” as a KiCad legacy library (I think these are v5 libraries).  It converted it over to a “.kicad_sym” as used by v6.0.  This allowed me to select “EurocadLibrary:MIDI_DIN5” as the footprint for my MIDI sockets.

Thankfully I didn’t need to do anything specific for the Arduino elements as they are defined as part of the template.

Once complete I could import the schematic into the PCB editor. If not already done, it will prompt for annotations – i.e. to label and number the components.

PCB Design

Again this is a complex view, but the main elements that we need to worry about right now are:

  • The two copper layers (front and back).
  • The two silkscreen layers (front and back).
  • The Edge cut layer.

The Arduino template has some additional layers that might be useful as part of the design process. The “User.drawings” layer shows the location of the reset switch, USB socket, power socket and ICSP header, but this isn’t required as part of the final production outputs.

Here are the basics that were useful for me to remember:

  • The basic board parameters must be set up before you get stuck in, which can be found in File -> Board Setup.  Note that there are lots of things that can be set up in here, but I think I just needed the following:
    • Constraints:
      • Minimum track width: 0.6mm (this is probably over generous, but it got me started!).
        • Update: Most PCB fabrication will support widths down to 6 mil which is 0.1524mm, so this is a really useful minimum to specify.
      • Minimum clearance: 0.6mm
        • Update: some footprints get very confused with any clearance, so sometimes this can be set to to the minimum 0.1524mm, or even to zero and then just manage it “by hand”.
    • Pre-defined sizes: I added a 0.6mm and 0.8mm track width using 0.6 for most tracks and 0.8 for power.  There are lots of dependencies here depending on your power usage, width of track, “weight” of copper used by your PCB manufacturer, etc, so this is something to look at more carefully, but for low-current, basic operations, these seemed like sensible starting points!  These can be selected later when drawing tracks.
      • Note: pcb manufacturers will ask for a minimum track width and spacing in “mils” not mm, so the cheapest 6mil/6mil settings is 0.1524mm.
      • Update: smaller track widths are required if you wish to route between 2.54mm pin headers. I’ve taken to including a 0.254mm track for such signals too now.
    • Net classes: The Default can be changed to reflect the above widths/clearances/etc too.
  • If you go back and update the schematic (I did this several times) then it can be re-imported into the PCB tool. It will give you a list of what has changed.
  • If you go back and change a footprint, that didn’t seem to get imported back, so I had to do that in the PCB editor too.  There is an option to do a global “find and replace” though, replacing anything with one footprint with a new one.
  • “X” starts drawing tracks. Unlike a diagramming tool, each straight line in a track is treated as independent, but connected to other lines it links too.  This means that whilst you might draw a track with bends and corners, once complete, each part can be treated differently.
  • Prior to using “X” using “V” switches the copper layer being drawn.
  • “R” rotates a component.
  • Connected elements all form a “net”, so it is possible to work on a whole “net” at a time, but I didn’t really explore that very much.  The template has some default nets for power and ground.

I am still bumbling my way through this at present, but when I asked on Twitter about my first attempt (as shown above) I got some really useful tips back, which I’ve tried to summarise here:

  • Don’t bother with the default track widths, they are probably too narrow.  Note that the PCB houses I looked at charged a lot more for smaller than the default 6 mil tracks (like 3 times more at least) but also allowed you to go even thinner, but there really isn’t any point if you don’t need to – as I say 6 mil is 0.1524mm!
  • Avoid tracks joining at right-angles if possible (although this seems to have divided opinions and may be based on out of date experiences?).
  • Avoid tracks joining with angles less than right-angles as solder might be “stuck” there during manufacturing.
  • Use both sides of the board to avoid complicated routes.
  • Try to route through gaps horizontally or vertically rather than at angles.
  • Try to route away from holes/pins.  Sometimes the default route the tool was selecting seemed a bit “close” to me, so I’d often click the “first bend” myself in a more useful place.
  • Capacitors were placed near to their ICs, resistors were moved around to help with routing.
  • Where it made sense to I tried to maintain a “visual grid” that lined up holes and orient similar devices in the same way (e.g. the diodes and optoisolators).
  • I switched layers at the holes rather than adding in additional vias between the layers.
  • In the case of a using template like I’m using here, I didn’t worry about unconnected pins/holes.
  • I had a bit of a “do I, don’t I” moment with regards to adding a ground plane (our discussions on Twitter left the matter undecided). I did produce a version with the whole underside as ground (see above), but when I then wanted to route one additional signal underneath, I abandoned that idea.
    • Update: Adding a GND zone on the underside greatly simplifies routing if you have a number of GND connections.

All of these notes need be caveated with the note that “I have no real idea what I’m doing and I’m largely making things up as I go”.  It was quite an amusing moment when my tweet that stated exactly this, got retweeted by some techie accounts with several 10ks of followers…

Once things seemed to be connected up, then running the “Design Rules Checker” will show up any additional issues to fix.  One that kept catching me out – sometimes clicking a pad created a short, usually invisible “single point” track.  If you select something and get a prompt that shows several tracks but you can only see one, then look for a really short one and select that to see where it is.

Once the electronics side of things seems to be ok, then it is time to think about the silkscreen – i.e. the printing that will appear on the board.  There are many layers that can be associated with additional information on the board.  Component values were on the “Fab” layers, but that seemed like too much for me, so I disabled the “F.Fab” and “B.Fab” layers.

Update: some templates don’t have the “fab” layers present, even if they are in the footprints you’re using, so you need to go to the board options and check the two fab layers.

However one thing I thought would be quite useful is the resistor values, so I edited the properties for all resistors and indicated that the values should appear on the “F.Silkscreen” layer.  This allowed me to position the resistor values in the centre of the resistor boxes on the board to aid assembly. I did wonder about doing the same for other components, but there isn’t the variation in quite the same way, so it is a little unnecessary.  I need to look up what the best practice for using silkscreen vs fab layers is.

Finally I printed out a black/white paper version at 1:1 dimensions which gave me a chance to check the physical dimensions of footprints to components.

You can see some of the earlier versions, including one with the experimental ground plane, above, but the one I ended up actually sending off to be built was this one.

ArduinoUnoMIDIShield-PCB4

Build Outputs – Gerber Files

To get a board manufactured, you need to create the correct “build outputs”, which for most places means “Gerber” plot files and Excellon drill files.  The key thing here is knowing which layers of the board need to be recreated as Gerber files.  The following were apparently required (I turned off all the rest):

  • F_Silkscreen
  • F_Mask
  • F_Cu
  • B_Silkscreen
  • B_Mask
  • B_Cu
  • Edge_Cuts

In addition to these, I created a “combined” drill file – i.e. I selected the option: “PTH and NPTH in a single file”. I wasn’t sure about this.  One tutorial said to merge them, but actually my board could have benefited from non-plated through holes (NPTH) for the Arduino mount points.

However, when looking at the produced layers, the NPTH holes were the “grip” holes for the DIN sockets, not the mounting holes for the Arduino.  As I always tend to solder the mounting holes for DIN sockets anyway, I just merged the two layers and saved everything as a “plated through-hole” drill file and used that.

I did see somewhere that having two drill steps tends to be more expensive, so this is probably what was best for me anyway.

Note: I also enabled the option to create a “job” file.

The end result is 8 files that can be loaded into KiCad’s Gerber viewer (7 can be loaded in one go by loading the “Gerber job” file).  At this point it is well worth turning the different layers on and off in the viewer to check for any oddities in the patterns.

The end result can be seen at the top of this post.

Sent for Manufacture

Once everything is complete, the board needs to be made.  There are many companies that will accept a board’s Gerber files and send you PCBs back in the post.

I’ve looked at the following services (I have no affiliation or support from any of them, and so far have not actually used any of them for my own design):

In the end the prices were all quite similar – approx $5 for ten 68mmx53mm boards, plus around $12 postage to the UK. I went with Seeed this time as I know about their own boards and devices, but I’ll like to try the others too just to see how I get on.  They all had a fairly similar process anyway, basically specify the high-level parameters (stick with the defaults if you can for the cheapest option!), upload your Gerber files as a ZIP file, and go for it.

I put in the maximum size of an Arduino shield. I have an edge file that shows the right shape, but I don’t as yet know if that will happen or not – I couldn’t find any mention of non-rectangular shapes on any of the submissions…

Update: the Edge cuts worked fine and I got a nicely Arduino Uno Shield shaped PCB back in the post.

I was tempted to just order 5 boards (the minimum quantity), as I’m not so bold as to imagine they would come back perfect first time! But the cost for 10 boards was the same as 5 in all cases, so I hopefully (and optimistically) have 10 boards now on the way.

Closing Thoughts

That is the end of this phase of the design process.  It has been really interesting to go this route as it is something I’ve been wanting to have a go at for a while.

Lessons learned so far:

  • Don’t be afraid of jumping in and having a go, but be prepared to “work at it”.  There is quite a lot of things to think about in PCB design even at my most basic level.
  • Don’t be afraid to ask for help or comments. My electronics followers on Twitter were great at giving me suggestions on my very naïve first attempt!
  • Visually check all the different views you have available to you.  Mistakes show up with a different perspective.
  • Use the electronic and design rules checkers all the time – and take the time to setup sensible constraints at the start, ideally constraints that match what you can order from your manufacturer.
  • Take advantage of the fact you can print out a 2D 1:1 scale version to check sizes and locations (and clearances) with actual components.
  • Don’t be afraid to use a ruler!

And finally, the temptation is to keep fiddling with it or just check it “one more time”, but eventually you’ll have to “hit go” on it and then move onto phase 2 where you can find all the obvious issues you should have spotted in design stage, but for some reason only come out once you’ve parted with your cash and enshrined your design in FR4 and copper!

I’ll report back once the boards arrive.

Kevin

Leave a comment