Week 10

Output Devices

Assignment:

1) Add an output device to a microcontroller board you've designed, and program it to do something.

I chose to make a board with a servo motor. I started with Neil's example servo board, and added a button and an FTDI header.

Neil's HelloServo board:

My modified Servo board

I routed my servo connections to PA6 and PA5, unlike Neil's board which uses PA6 and PA7. This is so that I can potentially plug in two servos and program them using the hardware PWM, rather than the software PWM.

As per usual, this week was a one-step forward, three-steps back process. Most of my excess time was spent cutting my board.

I had to plan in a few jumpers because I couldn't route traces under my J1 header, because (as I later found out) I had selected the right footprint but the wrong part in Eagle. When I milled my board, the traces were coming out way too thin.

It turns out that the trace width in Eagle was set at a default 6 mil, which is thin. The traces actually did mill and hold together, but they would have been difficult to solder. The endmill wasn't able to mill small enough to separate two traces on the upper right side of the board.

I remade my board with wider traces and clearances of 18 mil. This yielded a better result. However, in my eagerness to examine my better board result, I lifted it off the MDX-20 and then immediately realized I hadn't yet cut the outline. Now, I wouldn't be able to match up the board to its original position in order to cut the outline. I out the board back and tried to approximate where the outline would be cut by setting the mill to do a test-cut in the air above my baord. This is however an inexact process and I cut into my board, ruining it.

I also had to photoshop out the airwires that were left over so the MDX-20 wouldn't try to cut along those lines.

I made a new board, but due to photoshopping work I'd done to fix export issues from my Mac retina display, my board outline wasn't quite perfect. I had to do some emergency aborts to avoid cutting into my board.

Stuffing the board was perhaps the easiest part of this week. The Flux pen and some experience is starting to show. To make a 22 uF capacitor, I stacked two 10 uFs and two 1 uFs, which was a new thing and a little tricky. If I do this again I'll just stack two 10 uFs because apparently that's close enough for this purpose.

When I was about to program the board, I had an unecessary detour into re-doing a part on the board. Another student had wired the regulator incorrectly (he'd used a part in Eagle that didn't line up with the part in the shop inventory). Since I used the same part, the ZLDO1117 1amp regulator, I removed the part from the board using the heatgun-while-grabbing-the-part-and-suspending-the-board technique. It turns out that my part was correctly placed all along, because I'd already checked the part's datasheet before I had initially soldered it. I soldered it back into place.

Final stuffed board, with jumpers.

Programming the board

I first tested Neil's program to make sure my board worked. Since I was only using one servo plugged into PA6, the pin that's the same between my board and Neil's board, I didn't need to change the pin designation in the program. I did have to run the program fuses command, since we need to tell the program to use the external 20mHz resonator rather than the microcontroller's built-in clock.

While programming the board, I set the desktop power unit to 9 volts and 100mA. The regulator on my board will keep the voltage to 5V or under. Apparently it's not a good idea to plug the board directly into my laptop for power, now that we are working with more voltage and current. We don't want anything to backfire and harm the computer. Here's what the setup looks like:

And here's how my board is plugged in:

After programming the board, I unplugged my laptop and increased the current to 500 mA, because the servo needs to draw more power.

It works!

Next, I modified the program to include instructions for the button to turn on the servo. This meant defining terms for my button, and writing a bit of code into the main program loop to make the servo move to a specific position when the button is on, and move to a different position when the button is off.

I programmed this program onto the board, then tested it. It worked as well.

That's all for now