In this experiment, we will use the Analog Discovery's™ ability to import “custom” waveforms from a file. Custom waveforms do not fall into any particular category of common waveforms (e.g., sinusoids, square waves, and triangular waves all fall into broad categories—their names provide intrinsic information as to the basic shape of the waveform).
The Analog Discovery allows us to import waveforms from either .txt (text) or .csv (comma separated variable) files. These files can be created by other applications such as Microsoft Excel®, Microsoft Notepad®, or MathWorks MATLAB®. It is also common to record data in .csv or .txt format—thus, one can record a waveform using (for example) an oscilloscope and then use the AWG to re-generate the recorded signal. This allows ready testing of circuits under expected operating conditions.
In this project, we will import a waveform into the AWG which was created in Microsoft Notepad. The imported file will have a number of discrete “levels”—when we modulate the frequency of a sinusoid with this signal, we will get a signal which consists of a number of different frequencies. When we play this signal through our speaker, we will get a set of discrete tones which will sound somewhat like playing scales.
|Qty||Description||Typical Image||Schematic Symbol||Breadboard Image|
|The Buzzer/Speaker in the analog parts kit has two terminals. If a time-varying voltage is applied between the terminals a film in the speaker vibrates, converting the voltage waveform to a pressure waveform with a similar "shape." Note: The speaker in your parts kit may have different markings than the one pictured.|
If you have completed the Sinusoids and Swept Signals project and your circuit is still intact, feel free to skip to Step 2 of this exercise.
Connect one terminal of the speaker to the W1 terminal of your Analog Discovery.
Connect the other terminal of the speaker to a ground terminal on your Analog Discovery.
Insert the terminals of the speaker into your breadboard so that they are in different rows.
Connect W1 (the yellow wire) to one terminal of the speaker.
Connect ground (, the black wire) to the other speaker terminal.
Open WaveForms™ to view the main window.
Click on the WaveGen icon to open the waveform generator.
Open up the Microsoft Notepad program on your computer. Type, on successive lines, the values: 1, 2, 3, 4, 5, 6. Save the result as steps.txt. The result should look as shown in the figure below.
The steps.txt file does not contain information relative to the sampling rate of the data it contains (that is, the AWG does not know how far apart in time to put the data points—it only knows that there are six data points). The AWG assumes that the data points are evenly spaced throughout the buffer. Thus, the data created by the AWG consists of six different levels, each corresponding to one of the levels defined in the .txt file, and each occupying one-sixth of the total time period.
The above sequence of tones doesn't really constitute musical “scales”. The frequencies of our tones are equally spaced; in scales, the frequency doubles between successive notes. Try playing a set of real scales by creating a text file whose successive values double (e.g. the values 1, 2, 4, 8, ...) and using this file to modulate a sinusoid.