Week 9

Input Devices

Assignment:

1) Measure something. Add a sensor to a microcontroller board that you have designed and read it.

I chose to work with a temperature sensor this week, the NTC thermistor that Neil used as the example temperature sensor. I got a little ambitious and decided to also build some output devices into my board, so that based on the temperature sensor reading, you can instruct the board to do something. What I envision is a person placing their finger on the temperature sensor, and if the temperature is above a specific value a light will turn green. If it's below that value, a light will turn red. Still in the Halloween spirit, I am calling this a Vampire Detector to sense out cold-blooded people.

Here is my schematic drawn in Eagle:

And here is the corresponding board design.

To make the board design, I started with Neil's "Hello temp" board. Then, I swapped in an ATTiny44 for the AtTiny45 so that I would have more pins available to add my LED lights. I added a green LED and a red LED, each connected to a resistor. I also checked to make sure everything (VCC, RST, etc.) was routed correctly to the ATTiny44 as some of the pin positions have changed. Because I was going to be both transmitting and receiving, I would need to use both TX and RX (Hello Temp only uses Rx).

It was really difficult to route my board. Ultimately, I couldn't find a way to make all necessary traces connect, so I left three disconnected and planned to add jumper wires to connect them when I stuff my board.

I exported my board, then resize it down by 50% given that I have a Mac Retina display and this is a known glitch that would otherwise make my board too large. I also make my board in the shape of a skull, because vampire detector. Next up, milling the board on the Roland MDX-20.

My board is (deliberately) rather large and there aren't big enough copper boards for it, so I get some full size boards and cut them in half to get large baords. Unfortunatley, the milling is a disaster. All of my traces come out too small or demolished. I check all the settings and try again. It's 1am on a Saturday night so I call it quits for now. Only the next morning do I realize that it's quite possible I was using the wrong size endmill.

Trying again on Sunday with the right-size endmill and all the settings carefully checked works perfectly, and now I have a nice looking board.

I gather all my parts, and stuff my board.

Another student introduced me to the Flux pen, which makes soldering the baord SO. MUCH. EASIER. It's like a performance-enhancing drug. Every solder is now your best solder. You mark the surface you want to solder with the pen, and then the solder will magically flow there. It's lovely.

This is my first time making jumpers. The toughest part about it is that the metal wires at the core of the jumper wire fray, making it hard to solder them together. The bigger problem is that the insulated casing of the wire melts instantly when it gets anyhere near the soldering iron...which it has to be to make the solder connection. Switching to a smaller-gauge solid core wire helped, because it at least eliminated the fraying problem.

Completed jumpers:

Now that the board is ready, it's time to plus it into my laptop and program it. I connect the ISP header and the FTDI header. Because my Mac only has ONE port, this gets messay (Thanks, Apple). I program the board using the AVRISP programmer.

Some adjustments need to be made to the Hello Temp files so that they will run on my board. First, I change references to "AtTiny45" to "AtTny44" in the Hello Temp makefile, the c file, and the python file. I also change the pins and ports and the data direction registor to be correct with regard to the ATTny44, so that they match up with my Eagle schematic of how my board is wired. I also need to change the clock speed and baud rate to 8Mhz (not 20Mhz) and 9600 baud, since this align's with ATTiny44's clock speed and is apparently better for serial communication. I'm not entirely sure how to think about baud rates and adjust them so it's a thing I've bookmarked to read into later.

Huge thanks to Sam for his saintly patience in helping debug this thing, as we encountered multiple RC=-1 errors and "file or directory not found" errors, as well as just random things not working. Finally though, the LEDs turn on!

Notice anything funny? It's that blue LED. My schematic called for a green one, and I stuffed my board with a green one, so it was quite a surprise to see it light up blue. I had double-checked all my components when stuffing my board, so maybe someone had misplaced a blue LED in the green LED box. Anyway, I don't see a need to replace it since it's similar enough to green in my concept. The red one is the one that mattered more for my design.

It's nice that the LEDs turned on, but the assignment this week was to get the temperature sensor working. There is some mathematical maneuvering behind how the temperature sensor converts from analog to digital, which Sam identified, and which I will need to look into later so I can better understand it.

In the main loop of the C program, I added some instructions. This code tells says that if the temperature first digit reading is below 100, turn on the red LED and turn off the blue one. If the temperature first digit is above 100, turn off the red LED and turn on the blue one.

We chose 100 because we noticed that the temperature reading of a person's finger seemed to dip above or below that number, so it seemed a good cut-off point for a sensor. We could see this when running the python script that gave us both a visual and numerical reading of the temperature sensor.

The code works! When some people place their finger on the temperature sensor, they getting a reading of Human (blue light) and when I place my finger on the sensor, I get a reading of Vampire (red light)

I've got plenty to work on from here: better understanding clock speeds and baud rates, and how the temperature sensor operates, and how to get it to display Farenheit vs. Celsius.

That's all for now