CS-280 Lab 7: Interrupt-Driven Feedback Control

by Dr. Eric A. Durant
This lab was developed in conjunction with Dr. Henry L Welch.

Overview

In this lab, you will expand upon your work from lab 6 to develop a programmable "DC" power supply. Using assembly language you will develop an application that controls whether the capacitor in the RC circuit is charging or discharging in an attempt to generate a "constant" DC value in the range from 0–5 VDC. This is not the best way to implement a variable DC supply, but for our purposes it will introduce you to timing interrupts and the basic concepts of feedback control.

This is a 2-week assignment. You may work alone or with a partner and submit a group report.

Lab activity

As with lab 6 you should complete this assignment entirely in assembly language. You will reuse the getkey routine from lab 4.

(by Dr. Welch) RC lowpass filter connected to analog input. Digital output used to drive the circuit (charge vs. discharge)

Wire the circuit as shown to the right. You should recognize that it is essentially the same as the lab 6 circuit, except that the pushbutton has been replaced by one of the HC11’s digital outputs. Also, to have more agreeable time constants, the resistors have been swapped (at the cost of a higher minimum voltage – there are resistors on the Fox11 between your circuit and the HC11 pins that limit the minimum voltage, especially as RF1 becomes large).

Use fox11_portb (any one of the 8 pins) for your output. This will allow you to monitor your control pin via a built-in LED. These pins can be accessed using the large header just below the HC11 chip on your Fox11.

Modify your program from lab 6 so that in addition to monitoring the voltage using the A/D system and displaying the results (0–500, i.e. 0.00 V to 5.00 V) on the 2×16 character Microtips/Hitachi display, it also actively controls the analog voltage on the capacitor. This should work as follows:

  1. Accept user input of a desired voltage using up to three keypresses (0–500). “5” should be interpreted as 0.05 V, “50” or “050” should be interpreted as 0.50 V, and “23456” should have characters after the 3rd ignored and be interpreted as 2.34 V. You are not required to do special error handling for inputs such as “740”—this is just a voltage that is higher than attainable, so your algorithm should naturally seek out the maximum voltage when given such a large value.
  2. The display should show the actual voltage (using the averaging and scaling technique from lab 6) on the top line.

    The display should show either the voltage being entered or the target voltage (if the input buffer is empty) on the bottom line.

    The display should be updated about 10 times per second via a dedicated timer interrupt.

  3. Develop another ISR that monitors the analog voltage and either sets or clears the control pin as follows about 100 times per second:
    • If the voltage is too low output a 1
    • If the voltage is too high output a 0
  4. Continue to monitor the keypad (use a polling loop, i.e., the getkey function) with the following functionality:
    • "0–9" add a digit to the displayed entry if the 3-character input buffer is not full
    • "A" increases the desired output by 0.10 V. (do not go over limit of 9.99)
    • "B" decreases the desired output by 0.10 V. (do not go under limit of 0.00)
    • "E" enter the numeric entry in progress
    • "F" backspace—Be sure to handle the case where there is no entry in progress.
  5. Under all circumstances the program should continue to control the voltage; even in the middle of a numeric entry. You may find a DMM useful in determining this as well as the general accuracy of your voltage supply.

Note: When the program starts up, the target voltage should be 2.50 V.

The component values may vary somewhat without materially affecting operation of the circuit; RF2 should be small, but not so small as to draw too much current when the control pin goes to ground. The RC time constant RF1×CF should be between roughly 0.5 and 1.0 s.

Hints and Caveats

Report (due by Friday of Week 10, 11 P.M.)

Demo: The demo is due by Friday of week 10. You may demo your program in lab, during office hours, or make an appointment.

Note: No late reports will be accepted after 11 P.M. Wednesday of week 11.