# Week 5: Electronic Design, or 9+ Hours of Expasperation
Back to Home
## Lessons Learned
* Don't blindly use design rules that someone else gives you
* Always double check your traces after milling for unwanted connections
*And now, the story of how I collected these lessons...*
We went back to electronics this week, except instead of just milling and soldering, we had to design the circuit from scratch(ish). As it turns out, it was still the milling (curse you, Roland) and the soldering (bless you, ray gun) that turned the last day of the long weekend into a rather sad occassion.
## Designing the Board
This was actually pretty straightforward and fun! We were given a skeletal schematic for the echo hello-world board (some device that can communicate with a computer through FTDI pins (?)), and tasked with re-drawing the board to mill and solder. I chose to design the board in Eagle.
The hardest part of this was probably figuring out the components, which were luckily all included in the fab lab library; unluckily, the names on the schematic didn't all correspond to the component names in the library, so there was some deduction involved. The "XTAL" is a crystal resonator, "t44" is the ATTiny44 microcontroller, and "ISP" is the AVRSIP pin header. We also had to add a button and an LED to the circuit, controllable from the microcontroller. I used the "6MM_SWITCH" component, which is an Omron switch, and "LEDFAB1206", which I intended to be a blue LED. I connected them to the pins that were most accessible when routing traces on the board.
The schematic was easy enough to draw, though my efforts didn't turn out particularly neat:
Instead of adding ground and voltage source components, I drew paths out of all the GND and VCC leads and labelled them respectively with the "name" command. This connected all the respective grounds and voltage sources together. The board is powered overall through the FTDI from the connected computer.
The switch does not need a resistor because the microcontroller has an internal resistor to enable it to control other pins. The LED I chose, part 160-1889-1-ND in the Digikey catalog, has specs of 3.3V forward bias and 20mA maximum current. The voltage from the FTDI would be 5V (according to Zach), so this meant that the current-limiting resistor needed to be (5-3.3)/20mA = 85ohms, but to be safe I went with a 499ohm resistor.
I uploaded the design rules provided in the Gitlab repo. I routed the traces (in Layer 1: Top) by hand instead of using the autorouter so that I wouldn't have to fix any overlaps the autorouter generated. I then drew the outline for the PCB in the Milling layer with the polygon tool (I tried GIMP, and Paintbrush...it didn't really work well). I didn't want to just have a rectangle, but I also didn't have the time or energy to come up with something really aesthetic. Since part of the reason I was only doing this the day before class was because I was binge-watching the new Netflix show *The Dragon Prince* the night before, I thought it only appropriate to pay homage to it in some way.
To export properly, you have to hide all other layers except what you want to export, then go to File->Export->Image and check Monochrome, export as PNG. I used a DPI of 500, which seemed to work fine; others used higher.(Though on second thought...could that be the source of the missing milling that led to merged traces?)
## Milling
As before, I used the Roland miller. Not as before, Roland gave us quite some trouble this week, to which the only solution was repeated turning on and off the miller, closing and opening mods and the modserver.
For some reason, images saved from Mac computers are twice as large as they ought to be when imported into mods, so I had to double the DPI to 1000. Everything else was pretty standard.
A couple of false starts (e.g. my traces and outline files were not the same size at first) and much pleading, a board was milled.
## Stuffing (not sure why that's the name for soldering components)
I had to solder/re-solder my ATTiny44 THREE bloody times. The first re-solder because I realized too late that what were supposed to be two traces didn't get separated in the milling process. I had to re-solder again when I had thought all was done when I realized that all the leads on one side were connected to the ground trace running under the ATTiny44. (How did I realize? I connected the FTDI to the computer and the LED lit up.) This is when I came to doubt the provided design rules. Also, longer pads would have made soldering the resonator a lot less stressful.
After saying goodbye to my chances of eating dinner at anything approaching a normal time, manually cutting away copper with a razor, and adding a jumper wire to reconnect what I had to disconnect, I finally had my board.
## Programming
I was nearly done, but the struggle was not over! I followed the instructions provided with the make files provided. Some modifications I had to make:
* instead of "program-usbtiny-fuses" and "program-usbtiny", I replaced "usbtiny" with "avrisp2" because my programmer wasn't working (Mac didn't register it as a USB), so I had to use the AVRISP programmer
* the term.py script requires the "serial" module, so I had to pip install pyserial first
* my board wasn't connected at the ttyUSBO port; to find it, I typed "ls /dev" in my terminal to see what was available, and Ben helpfully recommended trying tty.usbserial-FT9P30, which worked! Upon which I fled home for a late, late dinner and commiseration with roommate and boyfriend.
## Open Questions
* Why does my programmer not work?
* Why does term.py not reset what I've typed when I restart the script?