Electronics Design and Production
Many of my tutorials for electronics can be found on the fab website of the Center for Bits and Atoms at the MIT Media Lab. I'd encourage you to look at the Electronics Production, Electronics Design, and Embedded Programming pages of that site for more tips and troubleshooting techniques.
This small tutorial will show how to create a milled circuit board with soldered components to assist in programming arduinos.
The design of the circuit board was provided to us as .pngs generated from Eagle, a Printed Circuit Board (PCB) software design tool. It consisted of traces for both the interior and exterior part of the board. The purpose of the project was to gain comfort with a mill and produce a board that will be used later in the semester. The milling of the board was done using a Modelo mill and the board was stuffed by hand.
1. Before starting, ensure that you have the Modela instructions, mod_defaults, and both the trace and contour on the Ubuntu shop computer. 2. Open a new terminal, and follow the Modela instruction readme file, until your terminal says "listening to server." Minimize the terminal window and navigate to mod.cba.mit.edu. 3. In the module, lead the mod_defaults file. If successful, you should see a "read mod_defaults" prompt appear. 4. Pick "image (.png)" for the first column, "Roland MDX-30 (.rml)" for the second, and "PCB traces (1/64)" for the third column. The circuit board image should load and the right side parameters should automatically populate.
5. As a sanity check, input a xmin and a ymin and click "move to xmin,ymin." The Modelo should move the tool to the new origin you specified. If it moved, click the View button on the Modelo to make the base area accessible. 6. Obtain a copper plate and use double sided scotch tape to secure the plate to the base. Try and leave a little bit sticking out; It will make removing the plate later easier. Be sure not to overlap the scotch tape! Press down firmly. Press View on the Modelo to return it to the xmin and ymin coordinates.
7. Use the Up/Down buttons on the Modelo to control the tool height. Manually adjust xmin, ymin to get tool to the bottom left of a board. You should be able to fit three boards on one piece of copper! Write down the xmin, ymin coordinates! You will need them later. 8. Place a 1/64 end mill into the Modela tool by loosening both screws on the tool using an allen wrench. Place the end mill almost all the way up inside the tool. Tighten both nuts on tool (do not overtighten!). 9. Using the Up/Down keys on the Modelo, lower the tool. Given that you placed the end mill almost all the way up, you should not be able to touch the copper. Instead, leave about a cm gap from the lowest the tool will go. While holding the end mill with one hand, loosen the nuts and gently place the end mill on the copper. 10. Finally, hold down the end mill onto the copper (so it does not move) and re-tighten the nuts. For security, press the down button on the Modelo once or twice to ensure penetration. 11. Now, go back to the module on the lab computer. The png should still be loaded. Click "Calculate path." You should see a stencil image of where the Modelo will mill. Black lines and arrows indicate the direction the board will be milled. Red lines indicate when the tool is raised. Check for any discontinuities or clearly visible milling offenders. Else, ensure the Modelo machine is clear, the copper plate is ready, and press "Send Path."
12. When completed, press View Mode on the Modelo, use a shopvac to clean the area, and ensure the piece is okay. 13. IMPORTANT: If you are going to continue and make the exterior contour, refresh mod.cba.mit.edu. Bug tends to keep the size of the previous image. 14. Repeat steps 4-12 using "PCB outline (1/32)," manually inputting the same xmin and ymin, using the same copper plate, and replacing the end mill.
15. Once both the interior and exterior traces have been milled, press View on the Modelo. Shopvac or Dust Bunny the area. Remove the copper plate by pulling on the excess double sided tape. If you need to, use sand paper to smooth out the board in case the end mill you used was dull. 16. Congratulations! Buy yourself a F'real, you earned it!
Finally, we have a circuit board! Now, we have to stuff it with components. To start, ensure you have all your tools available. Although the only thing you need is solder and a solder hand piece, I recommend obtaining a heat gun, copper quick braid, tweezers, a stand to hold your board, and flux.
Also, given that all the components are smaller than my love for onions (and I really hate onions), it is a great idea to make a checklist of all the components you will solder on. Using the board diagram provided, I made a checklist of all the components I needed, added some double sided tape to the checklist, and as I obtained new components, I tapped them to the checklist.
To solder components onto the board, begin with the smallest and most complex piece. This is the piece that requires the most room to work, so it is a good idea to do it first. Use a stand to hold the board down; You WILL need both hands to solder. Work your way down the checklist until all components are soldered. Be sure to fix any mistakes right after you make them, as it is more difficult to fix errors after all components are on the board.
1. Start with applying flux to the area of the component you will solder. Flux helps the solder spread, which is particularly useful for components with many small leads close together, like the mini USB connector. Flux can come in either a pen or brush. Either way, apply liberally. Flux tends to rust copper, so be sure to remember to wash your board after you are done soldering all the components. 2. Apply solder. The best way to do this is to hold the hand piece tip on the area you want to apply solder to for 3 to 5 seconds to heat the copper. Then, bring the solder wire to in between the hand piece and the copper. You will have to experiment with the angles of both the hand piece and the solder wire, but once the wire melts, it should easily spread a into a thin film over the copper. 3. Using tweezers, place the component (be sure to check orientation, particularly of diodes and micro controllers) over the thin layer of solder. Use the tip of the tweezers to hold the component down, and gently touch the hand piece tip to the layer of solder. This should melt the solder enough to adhere to the component. 4. Now that you have two hands free (and the component is semi-attached to the board), use the handpiece and solder wire to add more solder to the ends of the component to create a smooth film from the component to the copper.
5. If you find that your component's leads are connected from too much solder, breath. You can use the copper braid to remove some. Lay the copper braid over the solder you want to remove. Place the end of the hand piece on TOP of the copper braid. Hold until the solder UNDER the copper braid melts. Quickly remove both the hand piece and braid. The melted solder will stick to the copper braid. Genius. I know. 6. If you find you placed a component crooked, or cannot fix the connected leads using the copper braid, you might want to just remove the component all together and start over. To do this, use a heat gun. Hold the top of the board vertically (so the components would fall if they were not soldered on). Use the heat gun to apply heat to the components you want to remove. Hold the gun for a few seconds until the solder holding the component melts and the component falls off. Word of caution: Use this only on isolated components, else you might loosen components that are nearby. 7. Repeat steps 1-6 for all your components.
Soldering is an technique that takes a lot of practice, but is fairly easy to learn. To prove it to you, below is a picture of the two boards I made. The top board has many imperfections. The trace mills are thick, the components are crooked, and there is a lot of solder on the board. In contrast, the bottom board (the second board) is much cleaner. In particular, the solder on top of the mini USB and of the micro controller is thinner, and smoother. The resistors are all aligned with the copper paths on the board. The traces themselves are also more defined since I sanded the board down more. Basically, by making a second board, I was able to improve a lot.
A personalized board with a button and an LED.
To design the board, I used a free (sorta) software called Eagle. It is pretty straightforward, especially when you have a library populated by past MAS.863 students for components. Eagles has two big views; Schematic and Board View. Before starting, get the library from the class repository. The Fab library has all the components you will need. Finally, before you start, get familiar with all the Eagle buttons. The hardest part about Eagle is all the ridiculous amounts of buttons that are necessary to do simple tasks.
In schematic view, you link all pins of all components using a "net." A "net" is a visual link between pins that provides guidance when you go into board view. You can also add labels to nets. Nets with the same labels are automatically linked (not necessarily visually in schematic, but definitely in board view). As you add components from the library, right click to rotate the component by 90 degrees before placing it. When the "net" is active, right clicking with make turns on the path. Also, once you connect a net to a component, when you move the component, the net will move with it.
Below is my schematic. It has a a button (switch), ATTiny44a, an AVRISP, a 1uF capacitor, a 20 mHz crystal, two LEDs, 3 10 KOhm resistors, 1 0 ohm resistor, and one FTDI header.
First of all, to get here, press the button on the top horizontal toolbar, not on the left toolbar. In general, when working in board view to design your board, you want to group things close enough to not waste material printing/milling, but far away enough to be easy to solder. Remember to give enough clearance between end mill paths. The Modelo machine has a 1/64 inch end mill (15.625 mil), so use at least a 16 mil clearance.
The main point of the board view is to use the route tool to remove the yellow lines (electrical connection) and replace them with routed (red) lines. Generally, space out your components how you would like them, and then start routing pins together. Remember that you can route lines in between leads of components.
Finally, before finalizing your board, use design rules. The fab library has a design rule library. To use it, the button is on the bottom left. Along with some other things, it will check distances of end mills and tell you if the board is millable.
The outer line you see is just the dimension layer, not actually the physical circuit board layers. Dimension layers just control what you are exporting. To create the millable area, click the "rect" button, then select the milling layer (layer 46), and create a rectangle around the entire circuit.
To finally export, go to layers and only show one layer at a time. For the traces, show only the top layer ("display none top"). Go to file, export, select image, be suer to select monochrome, use at least 500 dpi, and then click ok. Do the same thing for the exterior trace (use "display none mill" to display that layer).
In order to create the board, I followed the steps from one of my past weeks on Electronics Production. As in before, you start with a checklist. However, this time, I accidentally used a 1/32 inch bit for my traces because someone left a 1/32 bit in a 1/64 box. Being the noob that I am, I did not notice haha. It wasn't until 2 hours and 3 iterations of spacing my routes out later when I switch the end mill because it was not sharp anymore that I compared the two and realized this.
Anyways, I was finally able to mill my board and stuff it with components. I accidentally scratched my board at one point, so I used a voltmeter to ensure all routes were still continuous. Turns out they were all good.
And finally, the final board!
Talking to a Board, with an Interpreter
The best way to understand what is going on during this week is to draw it. I want to start by thanking Matt Edwards for his help and patience when I put on a confused face after he said things like "AVR fabISP GCC FTDI," and countless other acronyms that I am still not all too familiar with. The following image shows exactly what is happening when I say I programmed my board. This image also helped me debug when, of course, my board did not work. The following tutorial is assuming you are using a Windows 7 64-bit machine.
To get started with Arduino, first install the Arduino IDE from http://arduino.cc. Then, you will need to add ATtiny support to the Arduino IDE. The best way is to follow the directions from http://highlowtech.org/?p=1695, a great tutorial from the MIT Media Lab.
Also, in the meantime, let us add drivers for both our FabISP and for the AVRISP MkII. The FabISP driver (USBTinyISP) can be downloaded from http://mightyohm.com/blog/2010/09/fixed-usbtinyisp-drivers-for-64-bit-windows-7/. The AVRISP MkII USB driver for Arduino can be downloaded from http://www.visualmicro.com/post/2014/01/17/AvrIsp-MkII-Usb-Driver-for-Arduino.aspx.
The hardware setup is best explained with the schematic above. You will need a computer with two USB ports that has the drivers in the Software Setup section installed. You will then need an ISP (In-System Programmer). The point of the programmer is to interpret the compiled code in your computer and translate it into something your target board can understand. To connect the ISP to your target board, you will have a 2x3, six end connector. The off-the-shelf AVRISP MkII has one attached. However, if you are going to use your previously made FabISP, you will have to make this cable yourself.
For power, you can either create an external power source (3-5V) to power your board, or you can use an FTDI cable, like the one seen above. The FTDI cable is used to move information from your target board to your computer, but for the time being, I will use if to power my board. A third way to power your board is to use your FabISP. I tried this, by removing only one 0 ohm resistor. However, I couldn't get it to work =/. Finally, you will need a target/circuit/LED board. Just a heads up; I will use these three names interchangeably for this tutorial. If you have all this, you are ready to program your board!
Programming Your Board
Arduino IDE has built-in examples that you should use. I used the "Blink" and the "Button" examples. Be sure to change the pin number on the example to the pin associated with your LED or button. Caution! Pin numberings on Arduino don't always match the physical order on the chip. The image below show the physical order (inside) and the Arduino pin number (Not in parenthesis, next to the pin drawing).
Once all hardware is connected and you have changed the pins on an example Arduino program, follow these steps to get programs onto your board.
1. First, select the appropriate board and timing source. If you followed the steps in Software Setup above, you should be able to pick "ATtiny44 (internal 1 MHz clock)" from board submenu under the Tools menu. Although you have likely put a 20 Mhz crystal on your board, start with 1 MHz to ensure it is working properly. 2. Then, select the appropriate programmer. If you are using an off-the-shelf AVR MkII, pick "AVRISP MkII" under the programmer submenu under the Tools menu. If you are using the FabISP you build earlier in the semester, pick "USBtinyISP." 3. Then, select "Burn bootloader" to set the fuses and get timing right. Even if you have a crystal, again, I suggest starting with an internal clock, just to be safe. 4. Finally, select "Upload using programmer" to upload your program.
Congratulations! You programmed a board! If it didn't work for some reason, read through the tips on the side.
SETUP 1: Arduino + AVRISP MkII + LED Mark I
The first setup I tried was using the Arduino IDE, an AVRISP MkII programmer, and my LED board (Mark I) from Electronics Design. And of course, it did not work the first time. I was sure the AVR MkII and FTDI cable were fine since they were purchased and used by others before me. My six lead connector was also fine, so it must have been my LED board that was acting up.
Fixing the LED board
After not finding out what was wrong with my board using a voltmeter, I tested my setup with Richard Li's board. I was able to successfully program his board to blink. Richard inspected my board and was able to find a flaw! I accidentally connected a trace from the power supply in my FTDI connector, through my two LEDs (and resistors), and ending at VCC of my 6 pin connector. Essentially, the pins never lit up because they were not connected to ground. Well then, I tried connected them to ground haha. I used an xacto knife to cut the trace and soldered a wire from my LED to the ground connector of my 6 pin connectors.
Did it work?! No. What do you think this is?
Redesigning the LED board
So I decided to simplify my board. I ended up using only one LED and one button, cleaned up some traces, and checked design rules in Eagle. I milled the board, and stuffed it with components.
SETUP 2: Arduino + FabISP board + LED Mark II
Fixing the FabISP board
I tried removing just one 0 ohm resistor, to power my LED board through the FabISP board, but it did not work. So I resoldered the second 0 ohm resistor, and reprogrammed my board following the tutorial by Anna France.
I was successfully able to program my LED to turn on and off depending on the state of my button using my own FabISP! #FeelsGood