Lab 7

A Programmable Function Generator

Before the Lab

Last week you explored the operation of parallel interface in a symbolic way, using lights and switches to demonstrate some kind of real-world activity.  Here you will experiment with a system that actually does something useful, a digital function generator that can produce any waveform over a range of frequencies that is user-programmable.  Since microprocessor systems are inherently digital and waveforms are inherently analog, the key element in this design is the digital-to-analog converter (D/A). You will use a National Semiconductor DAC0808. D/A conversion takes place on the satellite board with all components already in place. The D/A chip is connected to port C.

Use of the D/A is quite simple. When it is given a digital value, the analog correspondent of that value appears on the output (after an appropriate delay for settling usually a few microseconds). The span of the output voltage is designed to be +/- Vmax.

Write programs that:

  1. Loads the series 0,1,2...FE, FF, 0,1... into the D/A.  Sketch the output waveform. Estimate the period of this waveform. Other commonly used waveforms are the triangle, square and sine wave.  Modify the program above so it is useful for generating a triangle wave.  It should also be very easy to generate a square wave at the same frequency; do so.

  2. Write a program that generates a trapezoidal waveform such as 0,1,FE,FF, FF,FF,FE,FD,0,0. The duration of the constant region in the middle of ascending and descending parts should be variable.

  3. A sine wave may be approximated by a series of steps of the appropriate height. To do this, rather than generating the numbers to be sent to the D/A by mathematical progression (as above) you must use a table.  There are several approaches to tabular representation of waveforms.  A sine wave is, fortunately, symmetric about at least two points.  First, the negative portion of a sine wave is identical (but of opposite sign) to the positive portion. Using this characteristic, it is possible to synthesize a 64-point sine waveform with only 32 points.  Work out a table of integers that represent the positive half-cycle of a sine wave (remembering you wish to use this to generate voltages across only half the total range of the D/A).  These number should be representations of the function

    Sin((3.1416*K)/32) for K = 0, 1, 2...31

    When you have reached the end of this table, you must return to the beginning (table value = 0) and reread the table, negating each value to produce the second (negative) half of the sine wave.  This process is then repeated indefinitely.  Write a program that generates a sine wave from such a table as rapidly as possible.

    For the more valiant amongst you, a sine wave is also symmetric about its peak; both halves of a half-cycle are mirror images of one another.  Try writing a program that synthesizes a 64-point sine wave from only 16 points (you might find it actually requires 17 points....) This is not a formal assignment, but those successful will be awarded a gold star and public adulation.

    There are at least three ways of modifying the frequency generated by your program.  (1) Inserting a delay loop between successive loads of the D/A can slow the readout rate down.  (2) Skipping points in the number generation (e.g., 2,4,6...) can speed up the period.  (3) The readout rate can be controlled via external interrupts.  The next program exercises will explore the first two methods.

  4. Generate a triangle wave of variable frequency by counting down a number in a loop between each change of the value sent to the D/A.  Predict the alteration of the period of the triangle wave resulting from a change of one count in the delay loop.

  5. Increase the frequency of the sine wave by loading every other (or third, or fourth, etc.) point in the table. You might find the instruction ABX useful. Write it so that the number of points skipped can be changed.

  6. Bonus Program (20-point extra credit). This program simply combines the functionalities exercised in the previous programs into one, and the use of the DIP switch in the satellite board to write a variable-frequency function generator. The first two dip switches (MSB and MSB-1) will select the function to be generated according to the following table:

    DIP

    Function

    00 sine wave
    01 triangle
    10 square
    11 sum of all

    The settings of the remaining six dip switches will specify the frequency of the wave, where a value of 1 represents a base frequency of approximately 1 Hz (i.e., a dip switch setting of $3F will then display a 63-Hz sine wave). A zero frequency will output no signal. You must use three (or less) tables to store only the points needed to generate the first quadrant of every wave.

In the Lab

  1. Test the operation of the D/A using the MM and the MD commands in the BUFFALO monitor. Determine the value of Vmax. What affects the value of Vmax?
  2. Run and verify each of your programs. Draw the waveforms actually generated by your D/A, including information on voltage span, any DC offset and time. Are your predictions of waveform shape and period valid?

After the Lab

Make listings of your corrected, annotated programs. Include comments on the waveforms and frequencies generated. Discuss the frequency limitations offered by each of the "variable frequency" methods used above. What physical processes are responsible for these limitations? How would you design a function generator that would have continuously variable frequency over a wide range?


| EE-218  Homepage | Syllabus | Schedule | Lab News | Faculty | Contact Information | Lab Info | Project |


Department of Electrical Engineering and Computer Science
Box 1824 Station B
Nashville, TN 37235
Phone: 322-2771
Fax: 343-6702


 | Search | Site Index | People Finder | Phone Directory | VUnet | VUmail | VU Library | Help |


Last Updated: Monday, March 14, 2005

Juan J. Rodriguez-Moscoso

Copyright © 2003 Vanderbilt University