Assignment 4: PCB design

PCB design seemed intimidating to me. Circuit boards look complicated, and analog electronics holds many mysteries. Amy's help session cleared up a lot of things for me, and I came away with a better understanding of the Hello World board, and of how the LED and button circuits should work.

So after that I embarked on using cad.py to modify the hello world board. I was glad at this point that I had already played with cad a bunch. I was a little stumped at first though on how to route everything- the IC seemed trapped. Then I remembered you can use a resistor or LED as a "jumper," and that helped. Amy's explanation that we could use the pins that were connected to the programming connector (since normally when the program runs that connector is disconnected) helped too.

One thing that was a little frustrating was not realizing sometimes when I had made a syntax error and the thing would fail to render or render incorrectly. The nastiest one was when I was adding the LED, and cad rendered the name in red correctly, but no pads! I eventually realize I had put in x and y coordinates, but not added in z. Later, I had a magical moment when I realized I needed to shift everything upward to make room for the extra components. But how do I move... everything? I realized that since all the positioning is relative, and the tiny45 IC is positioned first, if I just moved that up, everything else would move too. I rediscovered this later when I was helping Caitlin with cad and she had the same question.

So I got my board designed. I was a little worried that everything would really work as planned (it does seem a little crazy to print a circuit board without breadboarding first... but maybe that's the way of things when printing boards is so easy!). But my circuit looked sane (though a bit tightly packed). Here's my layout:

Here's the cad file

I had some frustration with milling this time around. First, I watched Siggi battle with the mill, as he tried to cut from a png and couldn't get it to cut deep enough, leaving shiny traces cut partway through the copper. He eventually fixed that by editing the cam output file manually. When it was turn, I had a similar problem- some (but not all) of my traces weren't cutting deep enough. I tried debugging several things:

Unfortunately, I made three attempts, and all of them had the same problem. I didn't have a camera in the lab to take a picture of these failed attempts, but basically in each case, some of the passes made by the mill resulted in cuts only partway down through the copper. The problems were scattered around, not all in one place. Some tips from Amy and Amon led me to try these two things:

So I tried both of these things, and my board came out nice and clean (albeit cut rather deep, so the traces stand out). So I don't know which of the two changes in the process contributed more.

The soldering mostly went well. I did accidently bridge two pads on one of the connectors, though. Forrest showed me the solder-sucker and the braid, but recommended just using the iron to pick up the solder by letting it flow back onto the tip. That actually worked pretty nicely.

I loaded the hello world code onto my board, and hooray! It worked.

At this point I was technically done, but I couldn't help at least poking around in the code. I really wanted to at least light up the LED. So in my circuit, the LED is connected to VCC, so the pin would have to be set low to turn it on. I looked at the data sheet, and it looked like cbi ("clear bit immediately") was what I needed. This instruction is used in the putchar routine, but it looks backwards there (the comment is "send a one"- maybe the whole thing there is inverted- anyway I decided to ignore this for the moment, trusting that clear really does mean low). So I defined my pin (.equ led_pin = PB1; led pin) and cleared it (cbi PORTB, led_pin). Of course, I compiled and downloaded this, and it didn't work.

Jay Silver, from LLK, had been helping me out, and at this point he helped me through the debugging process. We probed various points on the board using a volt meter, to make sure things looked roughly correct. Eventually we realized that, in fact, the pin was not getting set low. Going back to the code, we saw that we needed a "data direction" instruction, to tell the LED pin that it needed to be an output pin. So I just modified the code ("sbi PORTB, led_pin" and "sbi DDRB, led_pin"). It worked! The LED is not incredibly bright, but it's on. Well, that's enough for now.