AM Signal Demodulation and Playback

Introduction

This project generates an AM signal, records, and filters it to demodulate the audio signal being transmitted. Headphones can be used to listen to the original, the AM, and the demodulated signals. This project showcases WaveForms' ability to simulate the effects of circuits on a signal, and to play and record audio.

Inventory

  • A Digilent Test and Measurement device that supports WaveForms' Scope and Wavegen instruments.
  • Headphones with 3.5mm jack
  • WaveForms Installation
    • Includes a WaveForms workspace including a script that handles the loading, modulation, playback, and re-recording of audio files.

Description

An AM signal varies (modulates) the amplitude of a carrier signal. The envelope of the carrier signal represents the audio being transmitted, so a half-wave rectifier and low-pass filter is all that is necessary to demodulate the signal. This script uses the oscilloscope Math channels to simulate a rectifier and low-pass filter with the cutoff set to 2kHZ. Although humans can hear frequencies up to 20kHz, the majority of human speech occurs in the 85-255Hz range, so the filter will not attenuate voices. Notes over A6 may be affected, but most music will not be attenuated.

After recording the demodulated signal, the script plays back the original and the new signal to allow users to compare the quality of sound. Sound recordings or songs can be imported into the function generator, and script will automatically adjust the recording time to capture the entire signal.

Setup Instructions

1. Hardware Setup

This script requires that the following leads of the test and measurement device be connected to one another:

Table 1. Physical Connections

Connect this To this
Oscilloscope 1+ Waveform Generator Channel 1
Oscilloscope 2+ Waveform Generator Channel 2
Oscilloscope 1-/2- Ground

2. Software Setup

Start by downloading and extracting the WaveForms workspace from the ZIP Archive (also linked in the inventory section, above). Open the extracted workspace (AM-Demod-Script.dwf3work) in WaveForms.

The script needs some editing before being run for the first time. On line 1 of the script change the variable 'DIRECTORY' to the desired file path to save the demodulated AM signal. If on Windows and copy-pasting the path, be sure to reverse the slashes when entering it into the script. Note that the script will NOT show any errors if the file-path is not correctly entered.

If desired, change the variable 'FILENAME'. Several audio files are included in the workspace, but users may use their own through the use of the Import button in the Wavegen 1 instrument.


3. Running the Script

Once the file-path is set, plug in the headphones and click Run to run the script. The left ear will play the original signal, the right ear will play the AM signal. After the signal is played and demodulated, the script will play the demodulated signal through the right ear, and the original in the left ear again.

Each run of the script will yield a time-stamped .CSV file in the specified location, collected at a rate of 44.1kHz. If the CSV file does not appear in the specified location, the file path was entered incorrectly.

To import other audio samples, press the Import button under Channel 2. Select the desired file and in the next dialog make sure the waveform looks like the expected audio signal. Sometimes it's necessary to select the correct channel in the Column menu. Once the signal is ready to be imported, press “Ok.” Note the name of the file that was just imported, and change the variable 'SIGNAL' to the name of the file, replacing “Testing-123.m4a”. Be sure to keep the quotes.

If the workspace becomes sluggish as more trials are run, delete some of the demodulated signals labeled “AMSignal….” in Wavegen 1. Be sure to leave “Testing-123.m4a” and any other audio samples that have been imported for AM modulation.

Note: This script is resource-heavy, so if the audio only plays back through one headphone and the oscilloscope is unable to capture the AM signal, it is likely that the computer being used is not fast enough.

Figure 1. Original/AM/Demodulated Signals

Figure 2. Original/AM/Demodulated Signals, Zoomed In


Final Notes

For more guides and example projects for your Test and Measurement device, please visit its Resource Center, which can be found through this wiki's Instrumentation page.

For technical support, please visit the Digilent Forums.