Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write an assembly program that allows a user to modify the speed of the TekBot by providing input via Port D. The speed itself will
Write an assembly program that allows a user to modify the speed of the TekBot by providing input via Port D. The speed itself will be modi- fied by using both of the 8-bit Timer/Counters in Fast PWM mode, and driving the right and left Motor Enable port pins with the PWM signals generated by the Timer/Counters. By varying the duty cycle of the PWM waveforms being generated, you will effectively be modifying the speed of the TekBots motors. You are not required to implement any BumpBot behavior in this lab, so the TekBot should just be configured to move forward indefinitely. Some design decisions have been left up to you for this lab (such as how to detect user input on the Port D pushbuttons), but you must adhere to the following requirements for full credit: 1. Your TekBot needs to have sixteen equidistant speed levels, with Speed Level 0 being completely stopped, Speed Level 15 being full speed, and Speed Levels 1 through 14 in between. Refer to Table 1 for more details. Speed Level TekBot Speed 15 100% (255/255) 14 93.3% (238/255) 13 86.7% (221/255) . . . . . . 2 13.3% (34/255) 1 6.7% (17/255) 0 0% (0/255) Table 1: Equidistant Speed Levels 2. A user must be able to modify the speed in 4 different ways: (1) increase speed by one level, (2) decrease speed by one level, (3) immediately increase speed to the highest level (full speed), and (4) immediately decrease speed to the lowest level (stopped). 3. A single button press on Port D must result in a single action; for example, if the user presses the decrease speed by one level button, your program should smoothly decrease the speed by just one level, not several levels in rapid succession. Keep in mind, the correct way to meet this requirement can depend on some of your previous design choices, especially regarding how to detect user input. 4. The speed levels must not wrap around from 15 0 or 0 15. In other words, if the user requests a speed increase and the TekBot is already at full speed, the speed must not wrap around to a lower speed (i.e., overflow). In a similar fashion, the TekBot must not go from stopped to a higher speed (i.e., underflow) if a decrease is requested by the user. 5. To allow the user to visually assess the current speed level of the TekBot, you must use the mega128 LEDs connected to the lower nibble (pins 3:0) of Port B to display a 4-bit indication of the current speed level. For example, you can use 0000 (all 4 LEDs off) to represent Speed Level 0, and 1111 (all 4 LEDs on) to represent Speed Level 15. This 4-bit indication of speed level must not interfere with the Move Forward motor control signals, which are also being output to Port B at the upper nibble (pins 7:4). ;*********************************************************** ;* ;* Enter Name of file here ;* ;* Enter the description of the program here ;* ;* This is the skeleton file for Lab 7 of ECE 375 ;* ;*********************************************************** ;* ;* Author: Enter your name ;* Date: Enter Date ;* ;*********************************************************** .include "m128def.inc" ; Include definition file ;*********************************************************** ;* Internal Register Definitions and Constants ;*********************************************************** .def mpr = r16 ; Multipurpose register .equ EngEnR = 4 ; right Engine Enable Bit .equ EngEnL = 7 ; left Engine Enable Bit .equ EngDirR = 5 ; right Engine Direction Bit .equ EngDirL = 6 ; left Engine Direction Bit ;*********************************************************** ;* Start of Code Segment ;*********************************************************** .cseg ; beginning of code segment ;*********************************************************** ;* Interrupt Vectors ;*********************************************************** .org $0000 rjmp INIT ; reset interrupt ; place instructions in interrupt vectors here, if needed .org $0046 ; end of interrupt vectors ;*********************************************************** ;* Program Initialization ;*********************************************************** INIT: ; Initialize the Stack Pointer ; Configure I/O ports ; Configure External Interrupts, if needed ; Configure 8-bit Timer/Counters ; no prescaling ; Set TekBot to Move Forward (1<
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started