UC Berkeley, EECS Department B. E. Boser EECS 40 Lab LAB5: PCB Layout

Enter the names and SIDs for you and your lab partner into the boxes below.

Name 1 SID 1 Name 2 SID 2

Printed Circuit Boards The advantage of prototyping boards is flexibility: we can quickly wire up and test a circuit, and easily make changes if something does not work as expected. But flexibility comes with several drawbacks. Circuits built with prototyping boards easily stop working because of a wire or component falling out. Prototyping boards are also large, and time consuming to assemble. You certainly would not start production using prototyping boards. Printed circuit boards (PCBs) such our microprocessor development system overcome these problems. The loose wires are replaced with copper traces. Solder joints ensure reliable electrical conduction between the leads of the components and the PCB copper traces and mechanically hold the components in place. In this lab we design a custom PCB for the solar meter prototyped previously. Fabricating the boards will take a few weeks (express service takes as little as a day, at extra cost). When they are back we will solder the components to the PCB and test the circuit.

Parts Table 1 on page 3 shows a list of parts used for the project. In addition to a description of each part, the table shows the part names used for simulation in LT Spice and Eagle Layout, the PCB layout tool we are using. Both programs are available on the instructional cluster and also as free downloads from • http://www.linear.com/designtools/software/ltspice.jsp and • http://www.cadsoft.de

Grading The capability to design, build and implement functional electronic circuits is the ultimate proof that you suc- ceeded in EE40. In this project you will get a lot of guidance to help maximize your chances for success. Never- theless, you will have to make many decisions and work carefully to get everything working. You will be graded by your results in each step, and the final result. Despite best efforts, you may make mistakes. A non-working board does not automatically mean a bad grade. If something goes wrong and your design does not work you will be asked to find the error and repair it if possible or document it otherwise.

PCB Layout After verifying your circuit design in a prior lab, you are ready to layout the . We use a tool called Eagle CAD for this task (http://www.cadsoft.de). You can either use the tool on the instructional cluster or on your own computer. Use the instructional setup if you run into problems. First we learn how to layout a PCB. A good source are the Sparkfun tutorials, available at http://www.sparkfun.com (click “Tutorials” in the header and then choose “Beginning Embedded Electronics”). Although we won’t be ready to solder for a couple of weeks, start with Tutorial 6, The basics of through hole soldering. The pictures of PCBs in the tutorial give you a good idea of the final result. Although you do not need all the information presented in the tutorials to complete this lab, the material gives you a much better understanding of the process that will help you better understand elements of the design and manage your own projects.

1 Figure 1 Touch sensor interface. The touch sensor behaves electrically like a . When a finger is placed over it, its capacitance increases. The micro- controller detects this capacitance by measuring the RC charging and discharging delay.

Schematic Capture PCB layout starts from the circuit schematic. Unfortunately Eagle cannot read the schematics from LT Spice1. Our first step is therefore to enter the schematic of our design into Eagle. Sparkfun Tutorial 8, Getting started with Eagle PCB and capturing a schematic, explains how. In the Tutorial you learned that you need a parts library with symbols and footprints for all components we are using. For your convenience and to minimize the chances for errors we have collected these devices in a library, ee40.lbr, which you can download from the course website. Make sure to use the parts from this library when entering the schematic to be sure that the PCB will match the physical shapes of the components we are using. The opamp component is bit special: inserting it into the schematic adds three symbols, one for each opamp and one for the power connection. Left click three times to place opamp A, B, and the Vdd and connections in your schematic. Then wire all three of them. Ground the inputs of the unused opamp. Our design is based on the solar meter designed and tested in a prior lab. On the board, power comes from single CR2032 Lithium battery. We also need to add a power switch. Of course many mechanical switches are available, but to add a special design feature, we use a capacitive touch sensor instead. The sensor consists of a few copper traces on the PCB (preferably placed near the edge where a finger can easily get to) and a . The rest of the happens inside the microcontroller. Figure 1 shows the circuit including the opamp which is powered from port P2.7. We will write the program code after the boards are back from fabrication. Enter the complete circuit including the microcontroller, display with series , light sensor and ampli- fier, and the touch sensor with charging & discharging resistor. In addition add the following elements to your schematic:

a)A FRAME-LETTER. This is for annotation only: add your names, the project title, and the revision number and date to the text block in the lower right corner of the page. b)A BOARD3X3 pseudo device. Place this component anywhere in the schematic. When you layout the PCB, this components sets the dimensions of the board to 3 in by 3 in, the size we will be using for this project. The component also includes mounting holes and adds descriptive text to the board. c) BS-7 holder for the CR2032 battery.

d) Two 100 nF ceramic and one 100 µF electrolytic decoupling capacitor between Vcc and ground. In the PCB layout these will be placed as closely as possible (to minimize parasitic series inductance) between the supply pins of the microcontroller (the electrolytic and one ceramic capac- itor) and the opamp (the other ceramic capacitor). Remember to connect the opamp supply (and its decoupling capacitor) to P2.6 rather than Vcc. e) To aid debugging, place a 3-pin header like the one found in the lower right corner of the micro- processor development system close to the edge of the board. Tie the leads to Vcc and ground. The header is convenient for debugging the board (e.g. connecting an oscilloscope probe) or to power the circuit from an external supply rather than the battery. f) Ground the inputs of the unused opamp. Some components draw excessive current from the supply when their inputs are left floating.

1Advanced layout tools are available that integrate schematic capture, simulation, and PCB layout. Unfortunately these tools have a steep learning curve.

2 Description Part LT Spice Eagle Layout MSP430G2231 MSP430G2231 (socketed) N/A MSP430G2231 CR2032 Battery CR2032 battery voltage N/A CR2032 Holder BS-7 N/A BS-7 Power header N/A HEAD3 Opamp LMC6482 opamp2 LMC6482 Photo (Solar Cell) Osram BPW34 current source BPW34 100 nF capacitor (2x) capacitor CAP01 100 µF elco capacitor ELC01 Resistors 1/4 Watt resistors resistor RES04 Touch sensor N/A capacitor TOUCH 7-segment display 7 SEG7

Table 1 Part list and names in LT Spice simulator and Eagle PCB layout tool.

Once you have entered the complete schematic into Eagle, run the electrical design rule checker (ERC). You will be getting a warning, POWER pin OP1PWR VDD connected to P2.6 (or similar). You should not be getting other warnings and no errors. Check that all required components are in the schematic and properly connected. If you work in a team of two it is a good idea to have your partner do the check. Ask the instructor if you are unsure about anything. Then check one more time: an extra hour spent here can save you hours debugging and repairing a faulty PCB.

Show printouts of your LT Spice and Eagle schematics to the instructor.

Board Layout Work through Sparkfun Tutorial 9, Eagle PCB Layout to learn how to layout the board and hand a printout of your layout to the instructor at the beginning of the lab. Use 0.05 in wide traces for power and ground, and 0.016 in wide traces for signals. Leave a 0.1 in margin at the border. This is to make it easier to cut the boards, which are fabricated in large panels, apart. The auto router can be a mixed blessing. While it can speed up work, in some situations it generates poor layouts with longer connections than necessary or extra vias (connections between the top and bottom layer of the board). The resulting extra parasitic series resistance and inductance of the copper traces can cause demanding circuits to malfunction. Check the result from the auto router and rework poorly routed connections. Often components can be rearranged or reoriented to improve the layout. Sometimes it is faster to just layout the board manually and not use the auto router at all. Now layout your board. Delete the automatically generated board outline and move the lower left corner of the BOARD3X3 outline with the mounting holes in the corners to coordinates 0,0. Everything must fit inside the 3 × 3 inch box. Place a text string (silk screen, layer tPlace) with the course, lab section, and your names near the border. E.g. UCB EE40 Spring 2011, Lab Tu 3, Einstein & Obama. You can place the components anywhere on the board, but some arrangements are preferable since they result in shorter interconnections and fewer vias. Do not place components too close together or they may not fit or be difficult to solder. The leads of decoupling capacitors (especially the ceramic capacitors) should be as short as possible, and the touch sensor should be close to the edge of the board (where a finger can easily get to) and not more than a few millimeter from the microcontroller (to minimize interconnect capacitance). Do not route signals underneath the touch sensor. After finishing your layout produce a zip file with Gerbers using ee40-gerb274x.cam from the course website. Follow the instructions in the tutorial and avoid the mistakes discussed there. Once again it’s time to check your work. Follow the procedure from the tutorial. Update the trace width and spacing and run the design rule checker. The only errors you should be getting are overlap errors in the TOUCH component2. Visually inspect the layout on the computer screen and a printout and verify that all component footprints match the size and orientation of the actual components. This is important since Eagle has a very large library of different footprints; if you inadvertently selected an incorrect one the part may not fit in the fabricated board. As always, if you are not sure, ask! Online services such as http://www.batchpcb.com have more sophisticated error checkers that catch problems Eagle misses. Create an account and submit your design; you will get results back by email.

2These are not real errors—the software only thinks there is an error while actually there is not. Nevertheless it still would be preferable to get rid of them. Whenever there are fake errors, there is a risk of inadvertently overlooking a real error. Please let me know if you know how to fix the TOUCH component so it will no longer generate DRC errors.

3 Finally, have the instructor check off on your work and send him the zipped Gerber files. Name the zip file EE40_lab_name1_name2, where lab is your lab session (e.g. Th8) and name1 and name2 are your and your partners name.

Now we get a break from working on the solar meter until the PCB is back from the fab.

What Have We Learned?

In this lab we learned about printed circuit boards and how to lay them out. This is a very useful skill to have for any (electrical) engineer. Custom PCBs open many new opportunities for projects including (wireless) sensor networks, robots, the perfect guitar preamp, and of course the possibility to participate in interesting research projects waiting for your skills as professional circuit designers. Who knows, perhaps your first job will require you to design a PCB? Good to already know how!

4