1
COMP9032 Lab 4
Oct. 2024
1. Objective
In this lab, you will study how to detect 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.
OpEOpOMotPOT
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 in 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 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 (20 marks, due your lab session in Week 9)
Write an AVR assembly 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 Micronchip Studio and run it on the AVR Microcontroller
Board. Demonstrate your work to the lab tutor.
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 mark for this lab consists of 40% from the overall group work and 60% from your
individual presentation. All participating members have the same group marks.
Note: There is wrong labelling on the board for port D. For INT0 connect to
the pin labelled as RDX4 and for INT1 to RDX3. Labelling on the board is in
reverse order for port D.
RDX4 RDX3 RDX2 .................
INT0 INT1 INT2 .................