Lab 8: Voltage Regulator

Overview

In this lab, you will develop a DC power supply whose voltage is regulated via the Timer/Counter subsystem of the ATmega32 microcontroller. The application will operate by supplying a specific charge at precise intervals to a capacitor in an RC circuit. By adjusting the charge, you can regulate the RC circuit to mainain a “constant” DC value in the range from about 0-5 VDC. Keep in mind that this is not the best way to implement a variable DC power supply, but it will allow us to make use of the ADC and Timer/Counter subsystems.

Lab activity

You will need to wire the circuit shown below on your breadboard. You can obtain the parts from Technical Support.

RC Circuit

The following hardware must be connected:

  • AnalogInput connected to an input pin (of your choosing) of the ADC subsystem.
  • ControlPin connected to the OC0 output pin of the Timer/Counter0 subsystem.
  • LCD attached to PORTC.
  • Keypad attached to PORTD.

Write a assembly program that implements the following requirements:

  • Configure the 8-bit Timer/Counter0 subsystem in Fast PWM mode to produce a PWM signal on OC0. Use two keys on the keypad control the duty cycle of the waveform generated on OC0. The duty cycle refers to the amount of time in every Counter period when OC0 is ON, which in turn is controlled by the value contained within the Output Compare register OCR0.
  • Configure the 16-bit Timer/Counter1 subsystem in Normal mode to generate an Overflow interrupt every 0.26214 seconds. This period is achieved by setting appropriate values to the Clock Select settings for Timer/Counter1. Whenever this interrupt occurs, have the corresponding ISR set PB0.
  • Configure the ADC subsystem (via SFIOR) such that whenever the Timer/Counter1 Overflow interrupt occurs, the A/D converter is automatically started and performs one conversion on the appropriate input pin. When the AD conversion completes, an ADC interrupt should be generated.
  • Whenever the ADC interrupt occurs upon AD conversion completion, both the current value of OCR0 and the result of the ADC should be displayed on the LCD via instructions executed from within the ADC ISR. For example, if the value contained in OCR0 is 255, and the AD converter measures 5v, the LCD should display the following “0x00FF:0x03FF”, where the first hex value is the OCR0 value and the second is the AD measurement value. Separate the two values by a colon, dash, or similar separator.
  • Poll the keypad from the “main” program. That is, after initializing the various subsystems, enter an endless loop that, at about 100ms intervals, repeatedly checks the status of the keypad. Pressing one key on the keypad decrements the value in OCR0, while pressing the second key increments that value. The 100ms interval should be implemented by a delay100ms subroutine as in earlier labs. Whenever you press the first key, set PB1. Whenever you press the second key, set PB2. Reset PB0, PB1, and PB2 whenever the loop repeats.

Design Constraints

Your program should be placed in lab8.asm and must:

  • Make use of the lcdlib.asm and delay.asm files from lab 5 to drive the LCD.
  • Make sure you save and restore the incoming value of all registers you modify before exiting your subroutines.
  • Include appropriate documentation.

Demonstration

You are required to demonstrate your program to your instructor in phases. Start by connecting the LED display to PORTB. This will provide you with a visual indication (via PB0, PB1, PB2, and PB3) that your program is somewhat functional. As you use the keypad to vary the duty cycle of OC0, you should observe a correspondingly varying degree of brightness on the LED connected to PB3 as it gets rapidly switched on and off. If this LED is completely off, it should correspond to a OCR0 value of 255; completely on corresponds to an OCR0 value of 0. Neither the automatic activation of the ADC by the T/C1 interrupt, nor the LCD display are required to be finished in this phase.

Complete this phase by the end of the first lab. This will count towards 20% of your overall grade for this lab.

For the second phase, which must be demonstrated by the end of the second lab, replace the LED board with the breadboard containing the RC circuitry. Connect the ADC input pin to the capacitor lead. Simultaneously connect the capacitor to the oscilloscope and display the voltage signal there. Complete the implementation of both the automatic initiation of the AD conversion as well as the LCD display logic, so that the LCD displays both the value contained within the OCR0 register as well as the voltage measured by the AD converter.

FAST Data

You should indicate how much time (in minutes) you spend on this assignment in the FAST database. You are encouraged to log your activity as you work on the project. At a minimum, you should log all of the time spent on this assignment before the due date given above. All time spent on this assignment should be entered into the week 9 and week 10 columns (even if you worked on it in week 8).

Lab Deliverables

You should follow your instructor's instructions for your lab submission.

Hornick Taylor

If you have any questions, consult your instructor.

ce2800labs/lab8.txt · Last modified: 2009/06/03 11:22 (external edit)
 

This website is not owned or managed by the Milwaukee School of Engineering.

© 2003-2010 Dr. Christopher C. Taylor, et. al. • Office: L-343 • Phone: 277-7339 • npǝ˙ǝosɯ@ɹolʎɐʇ • -> RSS <-