MAQS sensor board PCB layout
Please Log In for full access to the web site.
Note that this link will take you to an external site (https://shimmer.mit.edu) to authenticate, and then you will be redirected back to this page.
MAQS Sensor Board Layout
In ex02 we captured the schematic of a circuit for sensing temperature, relative humidity, and air quality (PM sensor). Now, we're going to layout the board, and get it ready for fabrication.
We'll actually fabricate these and give them to you, meaning that any mistakes you make in your boards, you'll have to live with. You're more than welcome to speedrun this layout, but if you do you'll spend hours fixing your PCB once it's back from the factory - assuming it is even fixable at all. So keep an eye for detail and ask us if you've got questions! We want to make sure you'll end up with working boards - and as the bitter, tongue-in-cheek saying goes, half a day in the lab saves fifteen minutes of layout.
What's a PCB?
A PCB is a Printed Circuit Board, and fundamentally it’s just a flat piece of material that connects electronic parts together. You’ve likely seen them before, but here’s a couple examples of what they can look like:
Those are called rigid PCBs, and they’re made by taking a flat piece of fiberglass substrate, bonding conductive copper to either side, and then selectively etching away the copper to make connections between the components you want. Components mount to either the surface of the board, or they have leads that go through the board and solder to the hole. It’s basically a fiberglass sandwich, and looks like this if you slice into it: m
If you'll notice there's a layer of pretty purple that goes over the copper on the top and bottom of the boards. That's called soldermask, and it keeps solder off parts of the board it shouldn't be on. This will make more sense when we assemble boards, but it only exposes the parts of the copper that are necessary to make solder connections, and protects the rest of the copper from oxidizing. On top of this soldermask is the silkscreen, which is the white line on the board above. This is used for marking up the board, which we'll use to label parts, add version numbers, and a few other things. It's applied in the same way that you'd silkscreen a t-shirt, so it gets the name.
This whole affair is called a rigid PCB, because we're using a rigid, inflexible core, and it's what you'll be designing here. It's the most common type of PCB, but there's plenty of variations. You'll be designing a rigid board with two copper layers in the stackup, hence referred to as a two-layer rigid PCB or just two-layer board. The most common variation on this is a multi-layer board, where we add more layers of copper, separated by insulating fiberglass. Just for clarity, here's what the stackup would look like:
How do we make a PCB?
Making a PCB has a few steps, listed below:
- Circuit Design - where we choose the circuit that will accomplish the desired function within the provided specification.
- Schematic Capture - where we capture our circuit into a digital representation in our CAD tool.
- Board Layout
- Placement - where we choose the location of the parts on the board.
- Routing - where we actually draw the copper wires between components (called traces) and electrically connect them.
- Design Rule Checks (DRC) - where we run some automated checks on the design to look for simple mistakes - unconnected parts, short circuits and the like.
- Gerber Generation - where we make the design files required by the fab, which are called gerbers.
- Gerber Validation - where we double-check our gerbers to make sure they contain the parts they should.
- Fabrication - where we send our gerbers out to be fabricated by a fab house or fab. We'll be doing this part for ya.
We finished the circuit design and schematic capture in ex02, and now we'll run through the rest of the process. There's a lot on this list, but our design is small enough that we'll be able to get our bearings pretty quick.
Board Setup
Stackup and Design Rules
Board Size
I know it's not on the list, but before we jump into layout we'll want to set the dimensions of the PCB we're going to make. To make things easier on the fab we're going to require all of your designs to be 2" x 1.5".
To make things easier for you, we have already made a template pcb with the correct dimensions and design rules. You may download it here. To use it in your project, replace the premade .kicad_pcb
in your project directory with ours. You will have to rename the new file with the original file's name. You will also have to import the settings from this example project file. Download this file, and replace your projects original .kicad_pro
file with it.
Placement
Getting Parts on the Board
Now that our board's the right size, we'll jump into layout by putting parts on our board. But there's no parts on the board right now! Let's fix that by hitting Tools -> Update PCB from Schematics. A little dialogue should pop up, listing all the changes to be brought into your circuit board.
Hit Update PCB. Close the box, and go back to your layout.
Now, all your parts are floating off in space, and its your job to logically place them on the board. We want our parts to be arranged such that components that connect to each other should be physically close to each other. This makes our wires short, which helps with signal integrity, and our parts tightly packed, which helps us not pay the board fab for more board space than we need.
You'll do this by moving and rotating parts as you move them onto the board. The little grey wires are called airwires, and they show what components need to be connected to each other. As you move the part, they'll move with it. And once you draw the connection with a copper trace the airwire will go away.
A good way to start is to move components that are electrically close on the schematic to be physically close on the PCB. So toggle back and forth between the schematic and the PCB. Place the LED and it's current-limited resistor close to each other and to the 3.3V pin on the power connector. Place the SHTC3 bypass capacitors near the SHTC3 IC, and so on. Then, once parts are grouped like this, do final placement, with some tips below.
A few other things
As you're trying to figure out the optimal placement for everything, there's a few things we're going to ask you to think about:
-
Bypass Capacitors: For reasons that we've relegated to footnotes [1^], we put capacitors near the power pin on every chip. Our sensors are physically rather small, so they've only got one power pin, so we'll throw one or two bypass caps on those chips. If we had something larger (like a microcontroller) that had multiple power pins, we'd bypass each of those. But regardless of the number of bypass caps we'll need, make sure to put them close to the power pin they're bypassing.
-
Mounting Holes: Later on we'll design a 3D printed enclosure for MAQS, and we'll need to make sure the board doesn't rattle around inside the case. There's a few ways of keeping your boards retained - plastic clips, 3D-printable tabs, mounting holes, hot glue...the list goes on. You'll get some choice over how you mount your board when the time comes, but as a backup we'll ask you to throw some mounting holes on your board. You can do this by adding a pad to your board (Place -> Footprint), and selecting a
Mounting Hole
footprint. We'll design for a M3 screw. Be logical about the quantity and location of your mounting holes. I'm not saying that I won't be impressed if you draw a wojack on your board out of M3 mounting holes, but that's not quite what we're looking for. -
PM7003 Connector: For integrating the PM7003 connector, ensure it is placed with adequate space around it for the connector housing and any necessary airflow. The connector should be accessible without interfering with other components. For our board, we opted to put the connector on the back of the board in such a way that the PMS7003 sensor would sit nicely within the edges of the PCB. This leads us to our next point.
-
Parts on the Backside: While you can place parts on the backside of the PCB, we advise against it due to potential issues with assembly and mechanical stability. If you choose to do so, ensure critical components are easily accessible and consider the implications for soldering and rework. Remember, this may complicate the assembly process and could lead to a higher risk of errors. You have been warned. To flip a selected component on to the other side of your PCB, press
F
. You would notice (if you had selected an SMD part) that the color of the pads changed from red to blue and were mirrored. Thru-hole parts will also be mirrored but they will stay yellow. -
Access to Ambient Air: While we're thinking about enclsoures, we'll need to make sure that our air sensors have, well, air to sense. And this air should be fresh too - if we were to put everything in a sealed box with no air current over the sensor, MAQS would give us disappointment instead of data. Thankfully though the folks selling us these sensors have done plenty of research on how to mount them in an enclosure for best results, and so they've given us a Design-In Guide for the SHTC3. Think about which side of your board the connectors should go, and on which side everything else should go.
-
Label: It's common to add a label on the silkscreen with what the board is, its version number and when you made it, along with your name and email. The reason for this is so that the end user can contact you if something goes wrong - same reason why you put your name and contact in your source code. Go ahead and add this to the top silkscreen layer by adding text to the F. Silkscreen, or B. Silkscreen layer.
-
Designators: The component designators we assigned during schematic capture are now on the board, and they're how we'll identify which part is which. But to make your boards look pretty we'll ask that all the horizontal/vertial text goes in the same direction (ie, all the vertical text is consistently ascending or descending, and similar for the horizontal font). The default font size is okay - we can go smaller but we don't really have a reason to. It'll just make board assembly more annoying for ya.
-
Pin headers: If you have more than one set of pin headers and wish to make your PCB breadboard friendly, make sure the headers allign to a 100mil grid.
This will likely take you a while - and that's okay! When I'm doing layout I usually spend about 90% of my time on placement, and only 10% on routing. If you do your placement correctly, routing will be super straightforward! As with anything else in this class, if you are having trouble with this please do not hesitate to ask us for help. :)
Routing
In order to route the board in KiCad, you'll begin by drawing copper traces. You can do this by selecting the Route Tracks tool from the toolbar on the left side of the PCB editor window or by pressing X. For this assignment, we recommendyou use 20mil trace width for signals and 30mil width for power. To change the thickness of the trace, you can pre-select a desired size in the Track Width dropdown located at the top toolbar before starting to route. Alternatively, you can adjust the width on-the-fly by pressing W to cycle through predefined trace widths.
Adding vias to route signals through the board can be done by pressing V or by selecting the via tool from the left toolbar. We'll stick with the default via size for simplicity, but you can customize individual via properties or modify the default via size in the Design Rules if necessary.
When wiring the board, it's recommended to first connect all signals excluding the ground. Begin with shorter connections before tackling longer ones. As you complete connections, the corresponding airwires will disappear, indicating a successful route. Routing is often an iterative process; you might need to move parts or existing wires to optimize space.
For ground connections, adding a ground plane is beneficial. In KiCad, you can create a ground pour on the bottom layer by selecting Place -> Filled Zones and drawing a polygon that covers the desired area on the bottom layer. In the Filled Zones properties window, set the Net to GND to connect it electrically to ground. This helps reduce electrical noise and simplifies grounding. You can absolutely have other signals be a plane if desired, but we usually reserve it for very commonly needed nets, in particular your positive and negative ends to your power supply. This minimizes routing difficulties as well as ensures you have minimal ohmic losses on your power supply path wherever possible!
Now, with the ground pour done, you can wire up all your grounds, but starting a wire from a ground pad, then adding a via to the ground pour side. So the grounds will end up looking like little wire stubs + vias. Nice and sweet.
If changes are made to the layout, you'll need to update the ground pour manually by right-clicking on it and selecting Zone -> Fill all Zones (or press B
on your keyboard). It's advisable to route most signals on the top layer to maintain large, unbroken areas in the ground plane on the bottom layer.
Design Rule Check (DRC)
After routing, including all ground connections with vias to the ground plane, proceed to the Design Rule Check (DRC). In KiCad, access this by going to Inspect -> Design Rule Checker and run the check to identify and correct any issues. It's default settings can sometimes be a little conservative, so in addition to catching things that'll definitely break your design (traces you forgot to route, or traces that overlap and short out) it'll also catch things that might break your design. We'll leave it to your intuition to figure out which are which, but ask if you'd like us to have a look! We'll check your work at the end anyway.
Gerber Generation
For Gerber generation, KiCad uses a direct export feature. Navigate to File -> Plot to access the plotting window, where you can select layers to generate Gerbers for and configure other settings. Additionally, generate the drill files by selecting Generate Drill Files in the same window. These files are necessary for manufacturing the PCB.
Ensure to review the generated Gerber files using a Gerber viewer to confirm that all layers are correctly represented. Once satisfied with the design, you could upload the Gerber and drill files to a PCB manufacturer (We will do this for you).
Finally, when you are ready to submit, push your changes to git and submit the following box.
[^1]: The traces on your board act as antennas that unintentionally radiate the signal they're carrying out of the trace, into other traces and the environment. Take a bunch of traces on a board transmitting into and out of each other all the time, and you get a bunch of noise. We don't want this noise getting into the power rails of our chip, because power gets routed to pretty much everything inside the chip, so any noise in power is seen in pretty much the entire chip's outputs. Which is bad. And there's another reasons why we'd want bypass capactiors, but I'm out of space in this footnote.