Actions

AVR Microcontroller Class 2009: Difference between revisions

From HacDC Wiki

Line 87: Line 87:


== Class 5: Serial I/O and Interrupts ==
== Class 5: Serial I/O and Interrupts ==
Laptop, meet AVR.  AVR, laptop.  Serial communication (plus serial-to-USB cable) lets you connect your micro to about anything, including your computer.  Interrupts let the hardware (pins, serial port, timers, etc) call run functions for you, with the main body of your code picking up where you left off.  Combine the two, and you can get pushbutton control of an AVR from your laptop keyboard.


[[Media: helloSerial.zip]]
[[Media: helloSerial.zip]]
Line 94: Line 96:
[[Media: class5.pdf]]
[[Media: class5.pdf]]
<br>
<br>
[http://www.jerkpile.com/serialScope.py serialScope.py]
 
And as a bonus, if you run Python, [http://www.jerkpile.com/serialScope.py serialScope.py] provides a helpful debugging tool and an example of how simple USB/Serial code can be on the laptop side.  Coupled with on-chip ADC, it's a (low speed, sideways) serial oscilloscope.  Otherwise, a handy debugging aide.


== Class 6: Serial I/O ==
== Class 6: Serial I/O ==

Revision as of 04:48, 21 October 2008

Syllabus, course material, homeworks, photos, etc from an Introduction to Microcontrollers with AVR chips class can be found here.

Also see (and contribute to) Useful AVR Links


Class 0: Introduction and Setup

What the AVRs are, what all the pins do, what they can do for you. Then the toolchain: soldering together the programmer kits, getting the software up and running.

Labs: building the kit and running a test LED flasher. (Almost all lab today, little talk.)

Resources:

Class 1: Programmer Hookup and Hello World LED Blinking

Lecture on how the programmer works -- simple serial interface basics. Some basics on avrdude / GCC tools. Hook up the programming interface wire-by-wire to the Mega48 chip and flash it with a simple program. The hook up an LED to the output port and watch it blink!

Resources

  • Wiring Diagram: Wiring.png

Homeworks

  • Your kit has 10 resistors and 10 LEDs. If you want, you can solder them together to make [AVR: LED Blinkenlights].
  • If you didn't already, make labels for the signal wires. Think of an easy way to remember which go where (into the 6-pin or 10-pin header). And/or make permanent programmer "pigtails" by soldering the signal wires to a 2x3 header in the correct orientation (headers available in the HacDC hackersmart for pennies).
  • Play around with the delays in the LED_Demo.c code. Make the blinking faster or slower. Experiment with on time and off time.

Class 2: Outputs: Bit Math, Cylon Eyes, and PWM Fading

How to make chips speak to the outside world, pin-by-pin. Enough C bitwise-math operations to make it work. Pulse-width modulation.

Labs: Visualizing bytes, Cylon eyes, and dimming LED's. Extra credit: cross-fading cylon eyes!

Resources

Homework

  • So you can make various lights blink and/or dim. Now what? Cross-fading cylon eyes? Patterns? Something groovy?
  • Note that you've got an 8-bit display if you're willing to read out numbers in binary. Useful for debugging later on, for sure. What else? Binary clock? Simple upcounter? Display "random" numbers?
  • If you could swing it around, you'd be on your way to a POV toy.

Class 3: Inputs: Buttons

Gather data from the world. The lecture ended up being just on digital input.

Labs: One note organ Media: class3.pdf


Class 4: Inputs: Debouncing and Analog-to-Digital conversion (ADC)

This class, we'll get to debouncing our button input, and reading in continuous voltages

For more info on ADC stuff, see this note

Labs: pushbutton organ, light-dependent theremin.

Media: class4.pdf


Media: debouncedMusicbox.zip


Media: lightDependentTheremin.zip

Class 5: Serial I/O and Interrupts

Laptop, meet AVR. AVR, laptop. Serial communication (plus serial-to-USB cable) lets you connect your micro to about anything, including your computer. Interrupts let the hardware (pins, serial port, timers, etc) call run functions for you, with the main body of your code picking up where you left off. Combine the two, and you can get pushbutton control of an AVR from your laptop keyboard.

Media: helloSerial.zip
Media: helloInterrupts.zip
Media: class5.pdf

And as a bonus, if you run Python, serialScope.py provides a helpful debugging tool and an example of how simple USB/Serial code can be on the laptop side. Coupled with on-chip ADC, it's a (low speed, sideways) serial oscilloscope. Otherwise, a handy debugging aide.

Class 6: Serial I/O

Make the micro speak to your computer (and vice-versa). We can also cover other serial protocols (I2C, SPI).

Labs: Basic serial in/out, data-logging light sensor. Maybe SD/MMC cards? Extra credit: ADC + serial output + Python + laptop = ghetto oscilloscope.