Вы находитесь на странице: 1из 4

LAB 3: PWM and Timer

In this lab, you will learn how to use Pulse Width Modulator (PWM) unit to control a motor
driver. You will also investigate the applications of timers.

1 Lab Objectives

Employing PWM to control motor drivers


Guide the robot through various paths
Control LED blinking using timers

This lab will require one week.

2 Pre-Lab
Get yourself familiar with the architecture of PWM and general purpose modules.
Read chapter 9 and 18 of Stellaris LM3S9B92 datasheet to learn how to setup PWM and
Timers.

2.1 Tool Requirements

Software: Code Composer Studio v5


Hardware:
The Stellaris Robotic Evaluation Board (EVALBOT)

3 Lab Procedure
Create a new project and add all resources you are using in this lab.

3.1 Move forward


Add \StellarisWare\boards\ek-evalbot\drivers\motor.c to your project. Using the available
functions, run both motors to go forward. You might use these functions:
MotorsInit()
MotorDir()
MotorRun()

3.2 Turing right with stop


While both wheels are going forward, manipulate the right motor to create a sharp right
turn. This will require to completely stop the motor. Continue going forward in new
direction. You can use empty loops to create delay. The path will look like this:

3.3 Turing left while moving


This time robot should turn left. But do not stop a wheel to turn, just decrease the speed. So
the robot will create a pattern like this:

In order to change the speed of motors you can use MotorSpeed(). In this function, find the
actual values of register that sets pulse width for both motors.

3.4 Blinking LED with Timer


Configure TIMER_0 in periodic mode to create a 500ms delay. Enable corresponding
interrupt and add the interrupt handler for it. Include the proper startup file to the project.

Toggle LED in the interrupt handler. You can use TIMER_0 in full-width mode to
generate longer delay. Use functions in \StellarisWare\driverlib\timer.c. Some example
codes demonstrating application of timers are available at:
\StellarisWare\examples\peripherals\timer
Note : Ensure timer interrupt flag is cleared after running interrupt handler.
Make LED blink while robot is turning left (section 3.3).

4 Lab Questions (to be answered in your report)


o How does speed change according to frequency of PWM?
o What other PWM modes are supported in LM3S9B92? Is it possible to use other
modes to control motors?
o What is the fault handling in PWMs modules?
o What was the polarity of PWM? Which register determines the polarity of PWM?
Show the robots path when the polarity is inverted in section 3.3.
o Modify the MotorSpeed() to work in inverted mode but with the same functionality.
o If you want to use another timer to control motor timings while LEDs are blinking,
which timer mode do you pick? How timer should be configured for this mode?

5 Lab Report
Include the following items in your report:

Answers to Questions
Create a zip file for your codes for Sections 3.1, 3.2, 3.3 and 3.4 and email it to the
TAs along with the report.

6 Documents
There are many useful documents you will need as references for this lab including:
o Stellaris Robotic Evaluation Board (EVALBOT) User's Manual This document
contains all the information about the EVALBOT you will be using, some of which will
be reproduced here. Designated spmu166 and available at the following URL
http://www.ti.com/lit/ug/spmu166/spmu166.pdf
o Stellaris LM3S9B92 Microcontroller Data Sheet - This document contains hardware
information about the LM3S9B92 device itself and its specifications. In this document
you can also find all registers, modules and peripherals information.
http://www.ti.com/lit/ds/symlink/lm3s9b92.pdf

o Stellaris Peripheral Driver Library Users Guide This document describes set a set
of drivers for accessing the peripherals found on the Stellaris family of ARM Cortex M
based microcontrollers.
http://www.ti.com/lit/ug/spmu019m/spmu019m.pdf
o DMOS Full-Bridge Motor Driver (DRV8801) Data Sheet This document describes
how to control dc motors by using pulse width modulation with DRV8801.
http://www.ti.com/lit/ds/symlink/drv8801.pdf

Вам также может понравиться