Skip to content

Instantly share code, notes, and snippets.

@edunham
Created March 3, 2015 05:38
Show Gist options
  • Save edunham/aeff7ead6094b26f6cb5 to your computer and use it in GitHub Desktop.
Save edunham/aeff7ead6094b26f6cb5 to your computer and use it in GitHub Desktop.
% template created by: Russell Haering. arr. Joseph Crop
\documentclass[12pt,letterpaper]{article}
\usepackage{anysize}
\marginsize{2cm}{2cm}{1cm}{1cm}
\begin{document}
\begin{titlepage}
\vspace*{4cm}
\begin{flushright}
{\huge
ECE 375 Lab 5\\[1cm]
}
{\large
IR Remote Control Robot
}
\end{flushright}
\begin{flushleft}
Lab Time: Tuesday 5-7
\end{flushleft}
\begin{flushright}
Emily Dunham
\vfill
\rule{5in}{.5mm}\\
TA Signature
\end{flushright}
\end{titlepage}
\section{Introduction}
This lab requires us to create a remote controlled tekbot capable of playing
freeze tag. Since I had access to two lab boards (a friend took this class
last year) and didn't want to work with a partner or a robot on wheels, I
modified the task slightly so that the slave/"robot" board will light up a
labeled LED instead of performing a drive action, and its buttons will provide
the whisker interrupts.
In the remote controller, I added the feature that it should light up a
labeled LED each time it recieves a button press, so that the person
controlling the robot gets visual confirmation that their instruction was
sent. I also added a "cheat freeze" feature to the remote for testing
purposes, so that I can test what the robot does when it recieves the freeze
signal.
\section{Internal Register Definitions and Constants}
\subsection{Robot:}
\begin{verbatim}
; assorted variables, counters, and scribble registers
.def mpr = r16 ; Multi-Purpose Register
.def timesFrozen = r17 ; stop permanently after 3
.def waitctr = r18
.def input = r19
.def temp = r20
.def action = r21
.def status = r22
.def innerloop = r23
.def outerloop = r24
.equ WTIM = 100 ; time in wait loop
; the commands specified in the lab handout
.equ MovFwd = 0b10110000 ;Move Forwards Command
.equ MovBck = 0b10000000 ;Move Backwards Command
.equ TurnR = 0b10100000 ;Turn Right Command
.equ TurnL = 0b10010000 ;Turn Left Command
.equ Halt = 0b11001000 ;Halt Command
.equ SendFreeze = 0b11111000
.equ Frozen = 0b01010101
; constants for output (simulated move actions)
.equ fwdlights = 0b10000000
.equ backlights = 0b01000000
.equ rightlights = 0b00100000
.equ leftlights = 0b00010000
.equ stoplights = 0b00001000
.equ freezesendlights= 0b00000100
.equ frozenlights = 0b00000001
; identity
.equ BotID = 0b01000000 ; must match remote
\end{verbatim}
\subsection{Remote:}
\begin{verbatim}
;added the led register to store what the lights should be displaying
.def mpr = r16 ; Multi-Purpose Register
.def led = r17 ; Light combo
.def cmd = r18 ; which command to send
.def temp = r19 ; and some scribble room.
; Use these commands between the remote and TekBot
; just write them out so they won't change if somebody pokes
; a seemingly arbitrary value elsewhere in the code
.equ MovFwd = 0b10110000 ;Move Forwards Command
.equ MovBck = 0b10000000 ;Move Backwards Command
.equ TurnR = 0b10100000 ;Turn Right Command
.equ TurnL = 0b10010000 ;Turn Left Command
.equ Halt = 0b11001000 ;Halt Command
.equ SendFrz = 0b11111000
;
.equ BotID = 0b01000000 ; chose this arbitrarily since IDs weren't
assigned
\end{verbatim}
\section{Interrupt Vectors}
\section{Robot:}
\begin{verbatim}
\end{verbatim}
\section{Remote:}
\begin{verbatim}
\end{verbatim}
\section{Program Initialization}
\section{Robot:}
\begin{verbatim}
\end{verbatim}
\section{Remote:}
\begin{verbatim}
\end{verbatim}
\section{Main Program and Subroutines:}
See attached printouts, since the code is rather long.
\section{Additional Questions}
None given in handout.
\section{Difficulties}
Although I found the task difficult to understand at first, I tracked down a
partially-complete and well-commented version of a lab similar to this posted
by a former student on GitHub. I read that code's comments in order to
understand the correct structure of the program's logic in assembly, and then
was able to design my own solution to the problem in a way that avoided
several issues that I discovered while reading the alternate solution.
The ATMEGA128 datasheet was also extremely helpful, and provided examples of
large portions of the code almost completely ready to go.
\section{Conclusion}
This is yet another reminder of why we invented higher-level languages: a
simple robot like this requires hundreds of lines of assembly code, which
makes it nearly impossible to fit any reasonable amount of useful information
on the screen at a given time.
\section{Source Code}
Source code is printed separately and attached this week.
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment