ENGIN 2223 – Microcontrollers
This is an introduction to the structure of microprocessors. The topics include architecture, instruction set, assembly language programming, assembler directives, input/output operations, C language programming for an embedded device, timers, analog-to-digital conversion, interrupts, and timing analysis.
Following are resources for each of the microcontrollers labs. Each page contains a link to the lab file (if it is different from the version in the published lab manual), a list of related equipment videos, helpful links, modifications that should be made to the published lab manual, and other tools that will help you to be successful when doing the labs.
Note: Labs 14-17 were written for the duration of the spring 2020 semester in which we were required to work off-campus. They are not included in the lab manual but are included here in case the schedule requires us to do any remote labs, or if students are simply interested in learning more about other topics.
- Lab 1: Introduction to the Arduino Uno and ATmega328P
- Lab 2: Digital and Analog Input Devices
- Lab 3: Displays
- Lab 4: Sensors and Sensor Calibration
- Lab 5: External Interrupts
- Lab 6: Timer/Counters and Timed Interrupts
- Lab 7: Pulse-Width Modulation and Motors
- Lab 8: Proportional and Integral Control
- Lab 9: SPI: Serial Peripheral Interface
- Lab 10: Power Consumption and ATmega328P without Arduino
- Lab 11: Transmitting and Receiving a Secret Message
- Lab 12: Ultrasonic Sensor
- Lab 13: Introduction to Assembly
- Lab 14: USART: Universal Synchronous/Asynchronous Receiver/Transmitter
- Lab 15: Pointers and ADC in Assembly
- Lab 16: Interrupts and WDT in Assembly
- Lab 17: >8-Bit Math in Assembly
ATmega328P Datasheet -This datasheet is probably the most useful resource that you have access to for learning more about the AVR microcontroller. This datasheet contains information on virtually every topic that we cover in class.
AVR Instruction Set Manual – This document contains every instruction allowed on AVR microcontrollers. We cover many of these in class, so this becomes a very useful guide.
Fuse Calculator – Use this online tool to determine fuse settings when programming the ATmega328P chip.
AVR Interrupts – This website has the name of every interrupt vector. Sometimes the name of the same interrupt vector is different on different microcontrollers. In case you are using something different from the ATmega328P, you may want to reference this if your interrupt isn’t working.
Arduino Uno Schematic – A complete pin-by-pin look at the Arduino Uno and how it interfaces with the ATmega328P microcontroller.
Arduino Board Pin Reference – Explains all of the pins on the Arduino Uno board.
Cheater Functions Explained – This website explains the C code behind all of the Arduino “cheater functions” (that you are definitely not allowed to use in class). See how much bloat is included in these functions that we eliminate by using C.
Your Smart Car comes from the SparkFun Inventor’s Kit, but has been modified with slightly different parts. Notably, you will use an Arduino Uno rather than the Redbot Mainboard. Here are the parts included in your box:
- I2C Accelerometer (code will be provided for you on BlackBoard if you wish to use this sensor)
- Bumper (this is a regular contact switch)
- Line Following Sensors
- Geared DC Motors
- Wheel Encoders
Here are the additional parts that you will need to use in your Smart Car:
- Arduino Uno
- 754410 Quadruple Half H Driver (h-bridge motor driver)
Simulation, Schematics & Flowchart Tools
To create schematics for your lab reports, you may use KiCad, Eagle (there is a free download for just the PCB and schematic tool), or Fritzing. As of October 2020, I don’t believe that Fritzing is free to download anymore.
Tinkercad – This online tool allows you to simulate the hardware and software of an Arduino.
draw.io – Use this free website to create flowcharts and block diagrams for use in your design project.
ASCII Code – A full table of ASCII code values in decimal, binary, octal and hexadecimal.
Choosing a Microcontroller Clock – An explanation of different types of oscillators and how to choose the right clock for your microcontroller project.
NAND and NOR Flash – The differences between NAND and NOR flash memory.
How to Use an Oscilloscope – If using a ‘scope intimidates you, check out this reference that breaks it down into simple steps.
A Feynman approach to debugging – This article from embedded.com presents a debugging scenario that may be familiar to microcontrollers students.
If I Only Changed the Software, Why Is the Phone on Fire? by Lisa Simone – Along the same lines as the above example, this book is non-fiction but written in a story-like manner following software developers who have to debug and fix embedded systems projects. Some of the examples should be familiar to you if you’ve ever used a timer/counter ISR or
unsigned char variables!
Guide to Software Commenting – Helpful advice on how to comment your software code.
Microchip Studio – The new version of “Atmel Studio” is Microchip Studio. (Microchip purchased Atmel in 2016.) Download this software onto your laptop if you’d like to work on Assembly code at home. (Note: You can also use this software to write in C on the Arduino.)
AVR Delay Loop Calculator – Want to create a delay in your AVR assembly code and don’t know how? Put in your microcontroller clock frequency and desired delay time and this handy tool will spit out the necessary code to achieve that delay.
AVR Beginners – This is an all-around good resource for writing assembly on AVR devices. (Note: it is not necessarily ATmega328P-specific but discusses AVR in general.)
View Arduino IDE Code in Assembly – If you’re interested in how the Arduino IDE translates your C code to Assembly, follow these steps to look at the output. You’ll see that the Arduino IDE severely bloats your code with a lot of unnecessary instructions that you can eliminate by writing Assembly directly.
Falsehoods that programmers believe in – A lit of many incorrect or problematic assumptions programmers make, and how they can cause software to behave unpredictably or poorly.
Glossary of Electrical Engineering Terms – Definitions of many frequently used EE terms.
How to Read a Schematic – In case you aren’t sure what all of the circuit symbols mean, here is a handy guide explaining the most common circuit symbols.
Sine Lookup Table – If you’ve ever wanted to generate a sine wave using digital values, use this to create a lookup table of numbers. Using the ATmega328P, you’ll need to build an external DAC (such as an R-2R ladder) connected to several digital pins.
Books with Cool Project Ideas
- Make: AVR Programming: Learning to Write Software for Hardware
by Elliot Williams
None of these textbooks is required for this course. However, they make wonderful study guides if you are in need of more resources. Some are available at the COD library.
- Introduction to Embedded Systems: Using ANSI C and the Arduino Development Environment by David Russell
- The Atmel AVR Microcontroller: MEGA and XMEGA in Assembly and C by Han-Way Huang
- AVR Microcontroller and Embedded Systems: Using Assembly and C by Muhammad Ali Mazidi, Janice Mazidi
- Atmel AVR Microcontroller Primer: Programming and Interfacing by Steven F. Barrett, Daniel J. Pack
- Digital Logic & Microprocessor Design with Interfacing by Enoch O. Hwang