| ||||||||||||
| 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.
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.
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.
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.
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