EEE ECE365 Final Exam Summer 2021
EEE ECE365 Final Exam Summer 2021
N.B.
a. Your answers need to be hand-written, and you have to submit a single PDF file.
b. Answer all questions.
c. The right margin of each question indicates allocated marks.
d. Some required Registers’ bit patterns are attached (Page 3).
The sensor is interfaced with the ADC module, channel 4 of 16 MHz ATmega32
to measure the distance and generate an appropriate signal using an LED
connected to the microcontroller to warn the driver.
a. For maximum accuracy in ATmega32 ADC, what should be the value of (1+3)
ADC operating frequency, and to achieve below or equal to that frequency
what should be the Prescaler value in ADC?
b. Calculate the step size in Volt and the conversion factor in m/Volt. (4)
c. Write an embedded C program that will read the sensor output and convert (8+6)
that into the distance. If the measured distance is less than 10m, the
1/3
system will turn ON the LED, if the distance is less than 6m, it will cause
the LED to blink with a time interval of 1s, and if the distance goes below
3m, it will cause the LED to blink with a time interval of 0.1s.
Use the internal reference voltage for data conversion and right adjustment
to store the data. Use the delay() function to generate the required time
delays.
3. a. Explain the operation mechanism of the H-bridge in a DC motor driver with an (5)
appropriate diagram.
c. A servo motor needs to be rotated from 0 to 90 degree and back to 0 degree (13)
using two switches, Switch 1 and Switch 2, connected to an Atmega32
microcontroller.
Write an embedded C program so that the servo motor rotates gradually from
0 to +90 degree when Switch 1 is pressed, and then rotates back to 0 degree
when Switch 2 is pressed.
Consider the required PWM signal has a time period of 10 ms, a minimum on-
time of 1ms for 0 degree position, and a maximum on time of 2ms for +90 degree
position. The rotation needs to be performed gradually with a ’for’ loop. Consider
the operating frequency of ATmega32 as 8 MHz and a Prescaler of 1:8.
b. To have a 9600 Baud rate, calculate the decimal value of UBRR for an (2)
ATmega32 operating at 8 MHz.
c. Show the settings of the registers UCSRA, UCSRB, UCSRC, and UBRR to
(7)
transmit 8-bit data, with two stop bits, and even parity at 9600 Baud rate.
Assume an operating frequency of 8 MHz.
2/3
TCCR1A
TCCR1B
TCCR2
ADMUX
ADCSRA
UCSRA
UCSRB
UCSRC
3/3