COMP9032 Lab 4
Oct. 2022
1. Objective
In this lab, you will study how to detect the motor speed.
2. Description
The DC motor on the AVR Microcontroller Board is DC (Direct Current) voltage driven.
The motor is attached to a disc and the disc has four holes, as highlighted in the figure
below.
OpE OpO Mot POT
Figure: DC Motor on the Lab Board
The speed of the motor is measured in revolutions per second (rps). To determine the
motor speed, we use a shaft encoder. The encoder uses the infrared light emitter and
detector that are each placed on the different side of the disc. When a hole of the disc is
situated between the emitter and the detector, the light can pass through the hole and
turn on the detector; otherwise, the light is blocked, and the detector is off.
The emitter is active high (i.e, it emits light when OpE=1) and the detector is active low
(i.e, OpO will go low when the detector can see the light). For further circuit information,
2
refer to the “I/O Connection Diagram” available on the References page of the course
website.
Power up the AVR Microcontroller board and connect the pin named as POT (output
from the potentiometer) to the Mot pin (input to the motor) on the lab board. As you turn
the potentiometer, the speed of the motor changes accordingly.
To measure the motor speed, you need to design to count the number of holes detected
by the shaft encoder per second and the motor speed is this value divided by 4.
3. Task (15 marks, due your lab session in Week 9)
Write an AVR assembly language program that measures the speed of the motor and
displays the speed on the LCD. The motor speed can be adjusted by the POT
(potentiometer) on the lab board.
Assemble your program using Atmel Studio and run it on the AVR Microcontroller Board.
Demonstrate your work to the lab assessor.
Assessment: The task will be accessed based on both overall group work and
individual presentation during the demonstration which is split into
1) One member demonstrates your group work with the lab board.
2) Other members each explain part of your assembly code.
Your marks of this lab consist of 60% from the overall group work and 40% from your
individual presentation. All participating members have the same group marks.