Microcontroller course

As I mentioned in my last post, nearly six months ago, I taught an “Embedded Development” course in the Computer Science department at the University of Mississippi. It was a highly practical course, and the Arduino was our hardware platform of choice. The “brain” of the Arduino is an Atmel AVR ATmega328P microcontroller with 2kB of RAM and running at 16MHz. Instead of using the Arduino language and development environment, we used C and Eclipse.

We started out learning to blink LEDs, to calculate the value of current limiting resistors, and the difference between sinking and sourcing current. We then learned how to use the hardware timers on the AVR to time events (interrupts) and output Pulse Width Modulation signals to vary the brightness of LEDs and create simple sounds.

Four digit, seven segment display setup

Four digit, seven segment display setup

Next, we learned to use a four digit, seven segment display from Sparkfun. This is a fairly common display, and there are lots of examples of how to use it on the Internet. However, I wasn’t happy with any of them. They either ran the display at low currents (resulting in low brightness) or used standard shift registers at higher currents than they were designed for. I came up with a design that used a TPIC6C595 power shift register to control the segments and four 2N3906 transistors that switched power to each digit. I was quite proud of my design, as I’m definitely a programmer, not a hardware guy. We also learned how to convert numbers into binary coded decimal (BCD) for display on the seven segment display.

For their assignment, the students added a rotary encoder and created a countdown timer. The time to count down from was chosen by turning the rotary encoder. The countdown started when the button built into the encoder was pressed. The time remaining was displayed on the display. When time was up the display flashed and an alarm was sounded on a small speaker we had used for a previous assignment. It sounds simple enough, but it presented plenty of challenge for the students. I had given them example code for all of the various interfaces, but integrating it all together proved to be difficult for some of them.

Next, we used the AVR’s UART hardware to communicate with a computer via USB. This is one area where the Arduino’s library makes things much easier, but we stuck with it and did it all in C.

Then we used the AVR’s analog to digital converter to get temperature from an LM335 temperature sensor. The students used it to build a “thermostat” that had all the features of your standard thermostat.

We then looked at I2C and SPI using an EEPROM and a real-time clock, respectively. We also spent a little time playing around with infrared LEDs, and one student did a TV-B-Gone clone for his final project.

At the end of the course each student had to do a final project of their own choosing. Several of them used a Nokia 5110 graphical LCD display, which I had recently demonstrated in class. It has an interesting interface and is a nice display for $10. A couple of the students used analog joysticks in their projects, like the ones on the Playstation 2 controllers. One student created a “Breakout” clone that used an accelerometer as the control interface. Overall I was very pleased with their final projects.

We covered a lot of ground in the class, and I think the students learned a lot. I know I did. I would have liked to have covered a little more ground, and had time to add in a couple more assignments. I spent a ton of time writing up examples. My PhD research went absolutely nowhere during the semester because I was spending so much time on the class.

I should mention that the materials for the class were completely funded by the department, which made things much easier on me and the students. I hope to teach the course again in a year or so, but we’ll have a new chair by then, so all bets are off on that.

I hope to find an academic conference to which I can submit a paper about the class. I think it’s pretty unique, especially in computer science departments. I haven’t made any headway on that yet, though.

In the fall I’ll be teaching a C/C++ course, which I taught last fall. Hopefully it’ll require much less time to prep for.

Leave a Reply