Download Lab Report Guideline - Computer Organization and Assembly Language Programming | ECE 375 and more Lab Reports Electrical and Electronics Engineering in PDF only on Docsity!
Copyright © 2004 Oregon State University School of Electrical Engineering & Computer Science
This document is the property of Oregon State University and the School of EECS. Limited use is allowed according to the following criteria: materials are free to use except for cost of reproduction but must bear this statement. Materials created using this information may not be labeled as TekBots materials without the prior written consent of Oregon State University and the School of EECS.
ECE 375 Lab Book ◊ ii
Table of Contents
Table of Contents.................................................................................................................................. ii How to use this manual ..................................................................................................................... v Important Symbols ............................................................................................................................ v
- Lab 1..................................................................................................................................................... Lab Structure..................................................................................................................................... v
- Introduction to AVR Development Tools ...............................................................................................
- Objectives..........................................................................................................................................
- Prelab ................................................................................................................................................
- Procedure..........................................................................................................................................
- Wiring Your TekBot........................................................................................................................
- Looking at some AVR Source Code ..............................................................................................
- Write Up ..........................................................................................................................................
- Additional Questions .......................................................................................................................
- Challenge ........................................................................................................................................
- Lab 2...................................................................................................................................................
- C → Assembler → Machine Code → TekBot .....................................................................................
- Objectives........................................................................................................................................
- Prelab ..............................................................................................................................................
- Procedure........................................................................................................................................
- Looking at C Code and the CodeVision Studio............................................................................
- Compiling C Code and Downloading ...........................................................................................
- Your Own Code ...........................................................................................................................
- Write Up ..........................................................................................................................................
- Additional Questions .......................................................................................................................
- Challenge ........................................................................................................................................
- Lab 3...................................................................................................................................................
- Data Manipulation and the LCD Display .............................................................................................
- Objectives........................................................................................................................................
- Prelab ..............................................................................................................................................
- Introduction......................................................................................................................................
- Initialization......................................................................................................................................
- LCD Driver User Manual .................................................................................................................
- LCDInit.........................................................................................................................................
- LCDWrite .....................................................................................................................................
- LCDWrLn1 ...................................................................................................................................
- LCDWrLn2 ...................................................................................................................................
- LCDClear .....................................................................................................................................
- LCDClrLn1 ...................................................................................................................................
- LCDClrLn2 ...................................................................................................................................
- LCDWriteByte ..............................................................................................................................
- Bin2ASCII ....................................................................................................................................
- Data Manipulation............................................................................................................................
- Writing Your Name ..........................................................................................................................
- Write Up...........................................................................................................................................
- Additional Questions........................................................................................................................
- Challenge ........................................................................................................................................
- Lab 4 ...................................................................................................................................................
- Large Number Arithmetic ....................................................................................................................
- Objectives........................................................................................................................................
- Prelab ..............................................................................................................................................
- Procedure ........................................................................................................................................
- Assignment......................................................................................................................................
- Write Up...........................................................................................................................................
- Additional Questions........................................................................................................................
- Challenge ........................................................................................................................................
- Lab 5 ...................................................................................................................................................
- Simple Interrupts .................................................................................................................................
- Objectives........................................................................................................................................
- Prelab ..............................................................................................................................................
- Introduction......................................................................................................................................
- Interrupting a TekBot .......................................................................................................................
- Write Up...........................................................................................................................................
- Additional Questions........................................................................................................................
- Challenge ........................................................................................................................................
- Lab 6 ...................................................................................................................................................
- Extremely Simple Computer (ESC) .....................................................................................................
- Objectives........................................................................................................................................
- Comments .......................................................................................................................................
- Prelab ..............................................................................................................................................
- Specifications ..................................................................................................................................
- Data .............................................................................................................................................
- Registers......................................................................................................................................
- Memory ........................................................................................................................................
- Data Memory ............................................................................................................................
- Program Memory ..................................................................................................................... ECE 375 Lab Book ◊ iv
- Instructions...............................................................................................................................
- Assignment......................................................................................................................................
- Test Program Description ............................................................................................................
- Write Up ..........................................................................................................................................
- Challenge ........................................................................................................................................
- Lab 7...................................................................................................................................................
- Remotely Operated Vehicle v2.0 ........................................................................................................
- Objectives........................................................................................................................................
- Prelab ..............................................................................................................................................
- Problem ...........................................................................................................................................
- Specifications ..................................................................................................................................
- Write Up ..........................................................................................................................................
- Challenge: Freeze Tag ....................................................................................................................
- Appendix A:.........................................................................................................................................
- Parts Lists ........................................................................................................................................... - Parts List......................................................................................................................................
- Appendix B:.........................................................................................................................................
- Schematics .........................................................................................................................................
- mega128.2 ......................................................................................................................................
- avr-isp..............................................................................................................................................
- Appendix C: ........................................................................................................................................
- Suppliers .............................................................................................................................................
How to use this manual
During this course, you will work with components and circuits that you will use in your own engineering careers. The objective is to show the non-electrical engineer how electronics is important to other engineering fields. You will be designing sensors and sensor circuits to measure real phenomena—not just arbitrary circuits. Everything learned in lecture has relevance and is useful in later courses and future careers. As various tasks are performed in these labs, pay attention to how lecture material relates to the tasks. Understanding how the lecture material is used and applied will greatly improve understanding of the topics.
Important Symbols
This symbol indicates an important note that should be remembered. Paying attention to notes like these will make tasks easier and more efficient.
This symbol designates information that must be followed. If caution is ignored the task may appear impossible. Ignored caution symbols can lead to damaged systems.
This symbol represents something that should not be forgotten. Reminder symbols are used to make sure an important step has been completed before continuing.
The innovation symbol indicates an opportunity to advance beyond what is required. These sections will give more insight into the what, why, and how of a certain topic. Use these to learn more or get ideas for nifty innovations.
Lab Structure
Section Overview
The section overview will describe briefly what will be learned in the section and what will be done.
Procedure
The procedure portion of each section contains all of the tasks to be completed. All tasks are related to lecture. Keeping this in mind will help in better understanding the lecture and lab material.
Lab 1
Introduction to AVR Development Tools
Section 1: Introduction to AVR Development Tools
ECE 375 Lab Book ◊ 8
Objectives
- Connect your AVR microcontroller board to a TekBot.
- Create a new AVRStudio4 project.
- Download and compile the sample AVR Assembly source code.
- Understand how to run and operate PonyProg.
- Upload and run the sample program on the TekBots AVR microcontroller board.
Prelab
In labs to come you will be required to complete a prelab for each lab. The prelab will cover concepts and knowledge that is required for the lab. The prelabs are due at the beginning of your lab section each week. If you do not have your prelab done at the beginning of the lab period, you will receive no credit for the prelab. Prelabs are to be submitted on paper, not by email.
For this lab, no prelab is required.
Procedure
Wiring Your TekBot
- The first step is to look at the wiring diagrams available on the TekBot webpage. To make the wires for connecting your TekBot boards together, you will need to use the ribbon cable that came with your kit with male headers soldered to the ends and a bit of heat shrink tubing on the connections. There is a short tutorial on the web that explains this process in detail.
- Because we are working with a modular programmable AVR microcontroller board, you can connect the whisker inputs and motor controller outputs to any pins on any port on the board. But for the demo lab to work properly, these cables need to be connected in a certain way. This configuration should be used throughout the course. They were chosen more for their alternative functions rather than their primary functions. As the course progresses, you will learn what both of these functions are. Table 1 shows the proper pin connections below.
Section 1: Introduction to AVR Development Tools
ECE 375 Lab Book ◊ 10
(Optional) If the IDE is not already installed on the computer, or if you are doing this lab from home, read through and follow the steps in Section 2.1.1 of the AVR Starters Guide to download and install AVRStudio4 on your computer.
- Follow the steps in Section 2.1.2 in the AVR Starters Guide to create a new project. In most IDE tools, a project is the base starting area to your program. It consists of all files you use and any settings for the program. When following this tutorial, you’ll want to use the AVR assembly source code you downloaded from the web in step 1.
- With the current project activated in step 4, follow the Project Simulation tutorial in Section 2.1.3 of the AVR Starters Guide to learn how to compile and simulate your program. By the end of this step, you should know how to successfully create an AVR project from scratch and be able to compile it into usable program hex code.
- When assembly source code is compiled, it creates a binary program file (called a HEX file with a .hex extension). This HEX file contains the actual binary instructions that are used by the ATmega128 and is what needs to be uploaded onto the AVR Microcontroller Board. Unfortunately, AVRStudio4 does not have the ability to program the actual chip. To do this, you will need to run the program PonyProg. This is a freeware program that can upload the AVR HEX programs to the various AVR microcontrollers.
- Follow the tutorials in Section 3 of the AVR Starter to install PonyProg and upload the AVR program into the ATmega128. Use the HEX file that was generated by AVRStudio4 from the previous steps. HINT: When testing and debugging a program, it is useful to keep both AVRStudio4 and PonyProg running at the same time. Load only the HEX file the first time you start PonyProg. If you make changes to the code, simple recompile and then ALT-TAB over to PonyProg and hit the Reload files button. This will update the HEX file within PonyProg to reflect any changes made to the program. Then upload the code to the chip again.
Section 1: Introduction to AVR Development Tools
- With the program uploaded into the microcontroller, unplug the TekBot from the computer and turn it on. Observe the behavior; the TekBot should be operating in the similar BumpBot fashion. Demonstrate your TekBot to your TA.
TA Initials: __________
Theory of Operation for Lab 1 AVR Assembly Code.
- Initializes key components of the ATmega
- Starts the TekBot moving forward
- Polls the whiskers for input
- If right whisker is hit o Backs up for a second o Turns left for a second o Continues Forward
- If left whisker is hit o Backs up for a second o Turns right for a second o Continues Forward
Write Up
For this lab, there will be no write up. This lab is simply for familiarization and introduction to AVR Studio and PonyProg. You will automatically get 20 points for this lab for obtaining the TA’s initials as indicated.
For all other labs, you will write up short summaries that detail what you did and why, explains any problems you may have had, and answers some questions that are specific to each lab. The hard copy of write up, along with your code should, be submitted to your TA by the beginning of class the week following the lab. NO LATE WORK IS ACCEPTED.
The write up should be typed. It should be neat and free of misspelled words. Be sure you have used sufficient comments for ANOTHER STUDENT to be able to understand your code. Code that is not well documented will be penalized severely.
Lab 2
C
Assembler
Machine Code
TekBot
ECE 375 Lab Book
Objectives
•^
Look at a sample C program
-^
Write a sample C program for the AVR microcontroller
-^
Compile the code using the CodeVision IDE and compiler
-^
Download this code to your AVR board and verify its function
Prelab Remember—no late prelabs will be accepted. Write a pseudo code program for making your TekBot the way it did in Lab 1. Your robot shoulddetect objects using its whiskers, reverse, and turn away from the object. Procedure
Looking at C Code and the CodeVision Studio 1.
Download the sample code available on the web page. This is simple assembly code that iswell commented and ready to compile. All code that you produce should be as wellcommented as this code. Save this code where you can find it in your UNIX file share networkdrive (commonly called drive Z:) There are two different programs on the web; be sure to getthe correct one for your TekBot.
Open the CodeVision Integrated Development Environment (IDE) and select ‘
New Project
You have two options here, either run the ‘Wizard’ or not. The wizard for CodeVision willquickly generate values to be stored in specific places in the AVR to setup peripheral deviceslike the A/D converters and the serial port. We don’t need to do this, so don’t use the wizard.You are asked to name your project. Put the project file in its own directory with the sourcecode you got from the web. CodeVision creates a lot of files so you don’t want to put it justanywhere. After you have named the file, a short ‘selection’ screen pops up, as shown inFigure 1. Click ‘
Add
’ and add the code you downloaded. Click the top tab called ‘
Compiler
’ to
bring up the compiler options.
ECE 375 Lab Book
Figure 2: Compiler Settings
Figure 3 shows the ‘
After Make
’ settings. You want to program the chip after make, and you
don’t want to verify erasure. DO NOT MESS WITH THE FUSE BITS. Your AVR board canbecome unusable if you write to the wrong fuse bit without knowing what you are doing.
Figure 3: ‘After Make’ Settings
Click
OK
, and CodeVision should open the source file. Examine this file so you understand
what is happening. It is written in ‘C’ (you should have learned C in CS151 or elsewhere). Ifyou are having difficulties, check the web and teach yourself or ask for assistance from yourTA.
Pseudo Code for Lab 2 ‘Dance’ C Code.
•^
Initialize Port(s)
-^
Loop Forever
o
Forward for 500mS o
Reverse for 500mS o
Right for 1000mS o
Left for 2000mS o
Right for 1000mS
Compiling C Code and Downloading 1.
Now that you understand the code and have connected your TekBot as expected, you willwant to compile and download your code to your TekBot. This is where the beauty of an IDE
Challenge
Modify your TekBot so it can move objects across a table top. Your TekBot needs to pushobjects that it touches a short distance. An example of how your TekBot should work is:
a.
TekBot hits object. b.
TekBot continues forwards for a short period of time. c.
TekBot backs up slightly. d.
TekBot turns slightly towards the object. e.
TekBot repeats steps a through d.
There are several ways to approach this problem, but you must accomplish it by revising yourfirmware (change the C program or rewrite it). To get credit for this challenge, you mustdemonstrate the operation of your TekBot to your TA and submit a copy of the code used.
ECE 375 Lab Book