Custom PCBs

From iRobotics Tech Wiki
(Redirected from PCB Design)
Jump to: navigation, search

Circuit Design

Required Circuits

Make a list of all the circuit or elements that you will need to meet the design criteria. For example to control a motor you need the Motor, so add that to the list. Then repeatedly go over the list and add elements/circuits that are needed to allow each item on the list to work. So a motor needs a motor driver, so add that to the list. Continue this process until you come up with items like a power regulation circuit, a speed control circuit, a low battery warning circuit, and so on.

Common Sub-Circuits:

  • Power Delivery / Regulation
  • Battery Management
  • Battery Alarm
  • Protection Circuits (Reverse polarity, over-current, etc)
  • Signal Level Shifting Circuit
  • Power Control Circuits using Relays / MOSFETs / Transistors
  • Status Indicator Circuits
  • Power Smoothing (capacitor banks)

Conceptual Circuits

After creating the required circuits list, think about how they will be implemented depending on the use:

  • Off the shelf circuit boards
    • These are generally cheaper in small quantities
    • Often smaller compared to hand soldering all the passive components
  • Integrated Circuits (ICs) that require some passive components like resistors
    • Allow you to pick out exactly the component specifications you need
    • Gives you more flexibility to choose the interface to control the IC
    • Allows you to control the mode the IC is in for devices like motor controllers that allow for different types of motor braking and acceleration
  • Discrete components (MOSFETs/Transistors)
    • Can be the cheapest option, but is the most complex.
    • Very easy to implement simple control circuits for LEDs, and small motors
    • Can be extremely complicated if you want to do any logical operations
    • Takes up the most physical space for operations that an IC could do like motor driving

Initial Circuit Creation

Once you have decided the way you will implement the required circuits, start drawing up basic circuit diagrams with generic components like "MOSFET," "High Value Resistor," "LED Resistor," "Solder Connection." For now, just get the general idea down of how the circuit will function, and get an idea of what types of passive components you need to make it work (Google is a fantastic resource for finding example circuits and how to implement different boards and ICs).

Resistor Value Side-note

One side note, when looking for resistor values it isn't normally extremely critical to get a specific value. For logic components that need to have pull-up or pull-down resistors to allow button presses or similar functionality, I generally use 10KΩ resistors but for 5v logic stuff you can often (but not always) use anywhere from 1kΩ to 100kΩ without issues. For controlling transistors and similar components again it does not have a huge effect normally, but for low-current control I use 1kΩ resistors to drive them. For an idea what value resistors to use, just search for the circuit/component online and there are often tons of circuits that can give you an idea of what value you should try to get.

But don't worry too much about getting the exact value you need since it only adds complexity. In most cases a resistor that is close enough is much better overall than trying to make a set of resistors in parallel and series have the exact resistance you want.

Computer Schematic

Schematic Designer Program

To create the schematic, I prefer to use a free online service EasyEDA which allows you to simplify the process of creating the entire circuit all the way to having it manufactured. This is what I will be specifically referencing throughout the computer design section of this article.

There are probably better options, but this is by far the most powerful one with a pretty easy learning curve, unlike some of the more professional design options (not to mention this is free and has integration with their PCB Manufacturing service).

Place Components

To start, I create a new project and start to import all the parts I will need for the circuit I am working on currently.

The passive components like resistors and capacitors can be found under the "EELib" tab on the left, and make sure to use the drop down on the bottom left of each component to specify the size that you will be using (this is so later for the component layout, the board has the right solder pads).

For the other components, click the "Libraries" tab and search for the component name you are using (also make sure the "SCH Libs" is selected under "Types"). Verify it is the correct component and pin layout according to the preview on the right of the window, and then click "Place" and click to place as many as you need for the circuit.

Organizing Components

After placing all the components in the schematic, move them around into a orientation that makes sense to easily see how everything will connect (avoiding wire connections that cross over each other if possible).

A good layout often would not require the wire connections to be drawn in order to understand what components connect to what. This is not possible when getting into more complex circuits with many components, but it is a good thing to think about and will help make your schematics easier to follow and troubleshoot when the circuit inevitably acts unexpectedly.

Good Schematic Layout
Good Schematic Layout Line up components as much as you can, and make the flow from one connection as easy to follow as you can.
Bad Schematic Layout

PCB Component Layout

One of the really helpful features of EasyEDA is the ability to convert a schematic to a PCB. This will copy all your components over to a PCB file and automatically uses the correct "footprint" for the device so you can solder the part on. Additionally, it adds "ratlines" that shows which pins and pads of each component needs to connect to other pins and pads of all the other components. This allows you to simply lay things out and visually see where your connections can be routed.

Convert Schematic To PCB

To lay out the components in the PCB, try to originally follow the schematic you drew. If your schematic was laid out nicely it should be easy to rotate some items in order to compact the layout. As a general rule, try to make the distances between the pins small and laid out in a logical way, like having the power circuits on one side and the logic on the other side. This helps to keep the different sub-circuits apart so it is easier to troubleshoot and reduces the overall size of the PCB.

Another thing to keep in mind is that you have two sides to route wires, so you can have some wires that connect on the top surface, and another wire directly underneath it carrying a different signal. This can also help in reducing the size of your board and allowing all the components to fit together more tightly.

Finally, remember you have to have wires between components so just be thinking about where you want the wires to go and leave space for them if possible.

PCB Routing

EasyEDA has a built in "Auto-Router" which can connect all the components together... theoretically. In practice most auto-routers are not going to be as efficient as taking the time to manually lay out everything. I personally always manually route the wires because it helps to keep the wires shorter and it allows me to notice if I need to move a component to fit wires, where an auto-router will just make the wire really long to go all the way around the component, making the PCB excessively large and increasing the wire resistance which leads to power losses.

The best way to get better at laying out the board is to do it a few times to learn how everything works, and then to start working on a more final version of the routing. I often use the "Clone" option to test different ways to route the board. To find this make sure your file is saved and then go under the "Project" tab on the left, make sure your project is selected, and then right click your PCB File, and then "Clone." Then save it under whatever name you want and preferably the same project as the original. Then you have the original component layout and can shift parts around and experiment with routing different ways.

One thing to keep in mind is that you need to have large enough traces to handle the current you want to carry. To determine how large the traces need to be, use an online calculator for "Trace Width" like this calculator. Set the current you need to handle (always make sure it is at least a bit above what you are expecting to normally have), and then set the thickness (Typically 1 oz/ft^2 for the cheaper option, or 2oz/ft^2 for a significantly more expensive option) of copper, and you can get a value for the width of the trace (For a 2 Layer PCB, you use the "Results for External Layers in Air" result from the calculator I linked). After you have the trace width you need, set the "Routing width" value on the right of the screen in EasyEDA.

Trace Width.PNG

Final PCB File Checks

Prototype Circuits

I always prototype the circuits on a breadboard to ensure there is no issue with my design. It is much easier to get the components before the PCB and test them with a breadboard than it is to buy the PCBs and then realize the are wrong, and need to either throw them away or use cutters to break some traces and add extra wire to the top of the PCB in order to make it work. Long story short, prototype your circuits before ordering the PCBs!

Schematic Check

I usually print out a copy of the schematic and PCB design; then I go over both at the same time highlighting every wire in the schematic as I highlight the corresponding trace in the PCB design. If all the connections are made and they match up with your tested schematic, you can move on to the next step, otherwise fix the PCB design and go over it again.

Check Pin Connections

This step is simply to ensure none of your traces got accidentally combined, which could result in a short circuit in your final PCB. I go through the different pins of all the components and make sure I didn't accidentally merge two connections together. EasyEDA does have a warning that pops up if you try to connect two pins that are not connected in the schematic, so if you are sure you did not get any warnings like that pop up, likely there are not any issues here.

EasyEDA DRC Errors

EasyEDA will check all your connections and traces to ensure there aren't any that are too close or accidentally crossing over each other. To check your design, click the "Design Manager" tab on the left, and expand the "DRC Errors" folder (also click the reload icon next to the folder if nothing shows up) to see if there are any issues. If there are issues, click on the issue and it will highlight where the issue is on your board so that you can check it and possibly fix it.

Once you have checked all the errors and fixed them or spent a very long time ensuring there isn't actually an issue you can move on to the final check.

Final PCB Check

Before I order the PCB, I always look over the entire board, understanding every connection and what it does, and why it is there. This ensures there aren't any accidents you may have missed on earlier checks; hopefully after all these checks there will only be very minor issues, which all can be solved without major modifications.

Ordering Custom PCBs

I export the PCB as a "gerber" file which contains all the layer data needed to manufacture the board. All PCB Editors I have seen can export as this type, but it is much easier to do this in EasyEDA as it allows you to export directly to the PCB Manufacturing side of the same site/company. They have very good prices ($2 + shipping for 10 two-layer PCBs under 100mm by 100mm as of writing this) and I have not had a single quality issue with the 25 boards I have ordered so far of three different designs.

To order directly from the EasyEDA editor, click the "Gerber" Button on the top menu

Export Gerber Button

If you have any DRC errors, you will get a warning. If you have verified they are not actually errors or are non-important, you can click ignore.

DRC Errror Warning

You will now have these options:

  • Gerber View: This allows you to view the generated gerber file, with different colors for the different parts of the PCB to verify the copper is exposed where you want and to verify it looks as you expect
  • Generate Gerber: Exports the PCB as a Gerber file if you would like to have the boards made with another service or if you want to manufacture them yourself.
  • Order at JLCPCB: This allows you to easily order these PCBs through their own manufacturing process, which automatically generates and uploads the gerber file, and gives you the option to view the gerber file before manufacture. Additionally, after submitting the order, JLCPCB manually reviews the file to ensure there are no major issues that would make it unable to be manufactured (they do not check if your circuit will work however).
Purchasing PCB Options

Testing Manufactured PCBs

After the manufactured PCBs arrive, I print out my up-to-date schematic and use a multimeter on continuity mode to check every connection.

To test a connection, I like to use alligator clips if possible to clamp one probe to one side of the connection, and I use the other probe to check everything else it should be connected to according to the schematic. After verifying this, I leave the one probe clamped and use the other probe to check that it is not connected to any other nearby traces that it should not be connected to according to the schematic.

PCB Soldering Tips

Through-Hole (TH) Components

I press the pins through the correct holes, and add a small amount of solder to one pin, then after straightening and align the part and, if necessary, hold the component in place while I add solder to another pin until that connection is fully soldered. Then I go back to the first pin and finish adding solder until it makes a nice joint. For any other pins that the component may have I only have to add solder as the component is held in the right orientation by the first two pins I soldered.

Surface Mount Components

I use a very similar technique for through hole and surface mount, placing the component on top of the pads, and then using either tweezers or my finger (depending on the size and how quickly it heats up) hold the component down while I solder one pin to the corresponding pad on the PCB. Then I reheat the joint while gently pushing the component into place. After it is in the right orientation I solder an opposite pad and continue working my way around all the pads until they are all soldered

General Tips

Soldering Technique

I use a small conical soldering iron tip (Ensuring it has a small amount of solder/flux on it to help heat transfer), and place it just between the pad and pin. Then I wait for a second or two while the joint heats up and then I add solder to the side of the pin opposite from my soldering iron tip.

Holding the component

For items with many pins, I use a small amount of thermal adhesive I bought on amazon, but any thick non-conductive paste/liquid underneath the component can greatly help holding it in the right orientation while soldering down the first few pins.

The best alternative (For Surface Mount Only) to this non-conductive thermal adhesive is to place a small amount of solder on the pad it is being soldered to and then push the component into place with tweezers while heating the pad with solder to hopefully solder that pin down. After getting that pin down you can heat it up a bit and use the tweezers to carefully rotate and move the component into place.

An alternative is to use a bit of tape over the component that leaves the pins exposed, but this has the chance to melt and can damage a soldering iron and possibly the joint if not careful.