Lab 5: Amplitude Modulation and Demodulation

This lab introduces students to communications theory with amplitude modulation and demodulation. Students will explore the mathematical theory behind amplitude modulation and use the Analog Discovery Studio to visualize the effects of amplitude modulation in the time and frequency domains. Then, students will use LabVIEW to program an AM demodulator and use it to explore and visualize the effects of the modulation coefficient on the quality of the demodulated signal and the effects of different parameters (such as windowing and averaging) on the Fast Fourier Transform (FFT). Advanced students can challenge themselves to build a system to send data between two Analog Discovery Studios or to build an analog AM demodulator.


Introduction

In an amplitude modulation (AM) communications system, a device is used to convert data into an electrical signal, for example, a microphone is used to convert audio into an electrical signal. This signal, known as the message or baseband signal, is then used to modify (modulate) the amplitude of another signal, known as the carrier signal.

Learning Objectives

In this section, students will:

  • Investigate classical amplitude modulation theory in time and frequency domains.
  • Learn about the basic properties of FFTs.
  • See how modulation index affects AM signals in time and frequency domains.
  • Use LabVIEW to acquire and demodulate an AM signal.
  • See how modulation index affects am signals in time and frequency domains.

Part List

The following equipment is required for this experiment:


Amplitude Modulation

Amplitude Modulation Theory

The image to the right shows how the message modulates the carrier signal to produce the AM signal. Notice that the AM signal’s amplitude increases or decreases as the message signal increases or decreases – this is where the term amplitude modulation comes from. Even though we only need the amplitude to change, looking at the AM signal we can see that by modulating the amplitude, we have added frequency components to the carrier signal. In order to analyze these components, we will use the Fast Fourier Transform or FFT for short.

As the name suggests, the FFT allows us to apply a Fourier transform on the signal and convert the signal from its time-domain representation to its frequency domain representation. By converting to the frequency domain, we can see what frequencies have been added to the signal due to the modulation.

In this lab, we will explore amplitude modulation in the time and frequency domain, and see how the amplitudes of the message and carrier signals affect the modulated signal.

In telecommunications theory, amplitude modulation in its simplest form can be represented as a few signals. The first signal is the carrier signal, $c(t)$. This signal can be represented by the equation: $c(t)=Asin(2{\pi}f_ct)$, where $f_c$ is the frequency and $A$ is the amplitude of the carrier signal. For this lab, we will let $A=1$.

The second signal is the message signal, $m(t)$. This is represented by the equation: $m(t)=Mcos(2{\pi}f_mt+{\phi})$, where $f_m$ is the frequency and $M$ is the amplitude of the message signal. The message signal can also be referred to as the modulation signal. For this lab, we will assume that $M≤1$. This allows us to ensure that $(1+m(t))$ is always positive and prevents overmodulation of the signal.

From these two signals, an amplitude modulated signal, $y(t)$, can be defined as follows: $y(t)=[1+m(t)]c(t)=[1+Mcos(2{\pi}f_mt+{\phi})]Asin(2{\pi}f_ct)$.

Using trigonometric identities, $y(t)$ can be expanded in a sum of three sine waves: $y(t)=Asin(2{\pi}f_ct)+\frac{1}{2}Amsin[2{\pi}(f_c+f_m)t+{\phi}]+\frac{1}{2}Amsin[2{\pi}(f_c-f_m)t+{\phi}]$

The frequencies of the additional sine waves produced by amplitude modulation are called the upper (for the higher frequency) and lower (for the lower frequency) sidebands. The difference between the upper sideband and the lower sideband is referred to as the bandwidth of the AM signal.

Questions and Exercises
  • How do the frequencies of the three sine waves compare to the original message and carrier signal frequencies?
  • If we took an FFT of this signal, what would we ideally expect to see?
  • Given $f_c=100kHz$ and $f_m=1kHz$, find the upper sideband, the lower sideband, and the bandwidth of the AM signal.

Analysis with WaveForms

Now that we have an idea of what to expect given our theoretical signals, we will go ahead and experiment with amplitude modulation using the Analog Discovery Studio. Follow the steps below to output and read back an analog modulated signal in WaveForms.

Connect the function generator's W1 channel (yellow wire) to the oscilloscope's Channel 1+ (orange wire) and the function generator's W2 channel (yellow-white wire) to the Channel 2+ of the oscilloscope (blue wire). Connect together the 1- (orange-white wire) and 2- channels (blue-white wire) of the scope, and the grounds of the function generator channels.

Don't forget to turn the Scope Channel 1 and Scope Channel 2 switches towards the MTE headers.

You can download the wiring diagram here: wiring_diagram_scope.zip

Measurements in the Time Domain

Follow the instructions below to set up your instruments in WaveForms and acquire data for this experiment. We will first generate an amplitude modulated signal using the Wavegen and then read this waveform back in with the Scope. For comparison, we will also generate an unmodulated signal and read the waveform back in on the second channel of the Scope.

Launch WaveForms. Open the Scope instrument, enable both channels, and set the trigger to Channel 2. Start the instrument.

Open the Wavegen instrument, enable both channels and set synchronization mode to Synchronized. On the first channel set Modulation mode and uncheck the FM column. For the carrier signal set a sinusoidal signal with a frequency of 100kHz and an amplitude of 1V. For the modulating signal (AM) set a sinusoidal signal with a frequency of 1kHz and a modulation index of 10%.

On Channel 2 set the same parameters as for the modulating signal. Run the instrument. Adjust the Scope Time and Channel settings so that you can see 3–4 periods of the input waveform on Channel 2.

The envelope of an oscillating signal is the smooth curve outlining the signal peaks.

When discussing amplitude modulation, it can be important to talk about the modulation index ($m$) of a signal. The modulation index describes the extent to which a signal is modulated about the carrier and can be expressed with the equation: $m=\frac{M}{A}$, where $M$ is the amplitude of the message signal and $A$ is the amplitude of the carrier signal.

While we can compute the modulation index directly from a known carrier and message signal, it is more common to compute the modulation index from measurements taken from using the Scope. Using this method, the modulation index can be defined as: $m=\frac{V_{max}-V_{min}}{V_{max}+V_{min}}$, where $V_{max}$ is the maximum peak to peak value of the modulated signal and $V_{min}$ is the minimum peak to peak value of the modulated signal.

Questions and Exercises
  • The amplitude of the AM signal is given as a percentage of the carrier. What is the amplitude in volts of the AM signal as configured?
  • Describe the upper envelope of the AM signal. How do the upper envelope’s shape and amplitude compare to the message signal? The message signal can be seen as the AM signal in the Wavegen display window.
  • What is the theoretical modulation index of the modulated signal as configured?
  • Find $V_{max}$, $V_{min}$, and the observed value of $m$. How does the observed value compare to the theoretical value calculated before?
  • Go to the Wavegen instrument panel. Slowly increase the AM index value while observing changes on the Scope. How does the modulated signal change as the index approaches 100%? As it goes over 100%?

Measurements in the Frequency Domain

Now that we have looked at the modulated signal in the time domain, we will explore how different characteristics of the message and carrier signal can affect the modulated signal in the frequency domain. Follow the steps below to perform an FFT analysis using the Spectrum Analyzer (Spectrum).

In WaveForms, disable the second channel of the Wavegen instrument and close the Scope. Set the modulation index of the AM signal to 50% and the synchronization mode of the instrument to No Synchronization. Start generating the signal. Open and run the Spectrum instrument. You can disable the second channel.

Remember, the FFT allows us to transform a signal from its time-domain representation (where the independent variable represents time) to its frequency-domain representation (where the independent variable represents frequency).

Looking at the FFT, we can notice a few things. First, we notice that 1MHz is much higher than what we need to show for our modulated signal. Zoom into the Spectrum by making the following changes to the Spectrum configuration: set the start frequency to 70kHz and the stop frequency to 130kHz.

Now that we have zoomed into our signal area of interest, we can stabilize the image by changing the Trace configurations. Currently, Trace 1 is showing an FFT trace every time we take a sample. This results in an image that bounces a lot on the screen. In order to minimize the bounce, we can instead use an average to eliminate some of the noise. With an average trace, the trace is averaged across several samples, giving us a more stable picture. Set the Trace Type to use Exponential dB Average. Now that we have a better picture of what is going on, let us more closely examine the FFT.

As mentioned earlier, an FFT allows us to apply the Fourier transform. Another way of saying this is that the FFT is a digital implementation of the Fourier transform. Thus, the FFT does not yield a continuous spectrum of frequencies. Instead, the FFT returns a discrete spectrum, in which the frequency content of the signal is separated into a finite number of frequency lines, or bins. The number of bins in the FFT is half the number of samples acquired. $bins=\frac{N}{2}$, where $N$ is the number of samples acquired. Aside from the number of bins, the size of each bin is also important when considering FFTs. The bin size, also called the resolution of the FFT, gives us the smallest detectable change in frequency. For example, if our FFT resolution is 1.5kHz, we would not be able to detect the difference between a frequency component that is 1.1kHz and one that is 1.2kHz. Similarly, we would not be able to detect the difference between a frequency component that is 112.1kHz and one that is 113kHz. We define the FFT resolution using the expression below: $df=\frac{1}{T}$, where $df$ is the FFT resolution and $T$ is the total acquisition time for one period of data. $T$ can be defined as follows: $T=\frac{N}{f_s}$, where $N$ is the number of samples acquired and $f_s$ is the sampling rate on the FFT. From there it follows that: $df=\frac{f_s}{N}$.

Lastly, if we multiply the number of bins by the resolution, we can find the bandwidth of the FFT. The bandwidth of the FFT gives us the maximum frequency we can resolve. Using the equation for $df$ and $bins$ the formula for the bandwidth can be given as: $BW=df*bins=\frac{f_s}{N}\frac{N}{2}=\frac{f_s}{2}$.

Look back at the Spectrum display window. Click on the green arrow to see the advanced configuration options for the Spectrum.

Looking at the advanced configuration options, we see that the maximum number of bins we can have is 4097. We can also see that the number of samples acquired (given by Samples) is set and there is no way to change that. Thus, to increase our frequency resolution, we need to lower the sampling rate. Unfortunately, the Spectrum does not expose the sampling rate used to take the FFT. Instead, the sampling rate is automatically chosen based on the range specified by Freq. Range.

Aside from showing the frequency content of a signal, the FFT also gives us a glimpse into the relative power in each frequency. In this case, we can say that the carrier signal contains most of the power in an AM signal while the sidebands contain relatively equal amounts of power.

Questions and Exercises
  • Using the cursors, find the frequency where the largest spike occurs. What frequency does this correspond to in our modulated signal? How does the FFT compare to what we expected to see? Is it possible to identify the upper and lower sidebands?
  • Observing this equation for $df$, what are two ways we can increase the resolution of the FFT?
  • Observing the equation for $BW$, how can you increase the bandwidth of the FFT?
  • The BINs value gives us the number of bins in our FFT. Change the BINs value to 4097. What is the resolution of the FFT as configured? What is the bandwidth of the FFT?
  • How will the resolution of the FFT change if we lowered the number of bins?
  • Lower the frequency range to 94kHz-106kHz. What is the resolution of the FFT now? What is the new bandwidth of the FFT?
  • Using the cursors, what is the value of the lower and upper sidebands? How do they compare in amplitude to the carrier frequency?
  • Go back to the Wavegen and slowly increase the AM Index value while observing the Spectrum display. How does the modulation index affect the relative power of the sidebands and the carrier frequencies? What happens when the modulation index reaches 200%?

Amplitude Demodulation

Amplitude Demodulation Theory

In the first section of this lab, we used a 1kHz sine wave to amplitude modulate a 100kHz carrier. Going through the lab, we saw a key characteristic of an AM signal – the upper envelope of an AM signal is the same shape as the message as long as the modulation index is less than or equal to 1. Therefore, one way to recover the message signal from the modulated carrier (a process called demodulation), is to isolate just the envelope from the rest of the modulated signal.

This form of AM demodulation is called envelope detection and at its simplest involves two steps. The first step rectifies the modulated signal so that only the positive half remains. The second step filters out the high-frequency components of the carrier and leaves us the recovered message.

Traditionally, envelope detection was accomplished using analog components to perform each step. For example, the full-wave rectifier built in Lab 4: Full-Wave Rectifiers and the low-pass filters built in Lab 2: Active and Passive Filters would be used to rectify and filter the signal respectively. With the advent of better software, we can now accomplish the same thing digitally. In this section of the lab, we will use LabVIEW to acquire an AM signal and then demodulate it using envelope detection. We will also analyze the demodulated signal in both the time and frequency domain.


Analysis with LabVIEW

As mentioned earlier, in this section of the lab, we will be using LabVIEW to digitally demodulate an AM signal by implementing envelope detection. By taking advantage of LabVIEW’s ability to visualize data, we can see how each step in the envelope detection process changes the AM signal into the final demodulated signal.

In order to demodulate the signal, we will first acquire the signal using the Analog Discovery Studio, we will then use software to rectify the signal to receive only the positive half of the signal, finally, we will implement a digital filter to remove any of the high-frequency components and recover the original message. Along the way, we will look at the FFT of the rectified signal and the demodulated signal and compare them against what we saw in the first section of this lab.

This section of the lab will assume a working knowledge of the LabVIEW environment and basic programming conventions. For help with getting started in LabVIEW, including installation of the Digilent WaveForms VIs, please view the resources available here: Getting Started with LabVIEW and a Digilent Discovery Device.

Note: Before testing or running your LabVIEW code, make sure that you exit WaveForms. The Digilent WaveForms VIs will throw an error if Digilent WaveForms is still open when you run your code.

Note: If you don't know what a VI does, you can check the Context Help by pressing Ctrl+H, then highlighting the respective VI.


Objective

Design a VI in LabVIEW that will demodulate an AM signal using envelope detection. You can build your own VI, following the steps below, or you can download the VI used in this guide from here: am.zip

The Front Panel shows eight graphs. The first two show the carrier and the modulating signals. Three of the remaining graphs are in the time domain and show the modulated signal, the signal after rectification, and finally the recovered signal. The other three graphs are in the frequency domain and show the frequency content of the modulated signal, the signal after rectification, and the frequency content of the recovered signal. The Front Panel also contains controls that we can use to control the parameters of the carrier and of the modulating signals as well as the cut-off frequency of the low-pass filter and the range of the frequency domain graphs.

The Block Diagram contains, except the control and indicator elements, the blocks needed for signal generation, controlling the Wavegen, controlling the Scope, and data processing.

General Operation

This VI should generate the carrier and modulating signals required by the user, then output the modulated signal on the selected Wavegen channel. The selected Scope channel will be used to acquire the modulated signal. The received signal should be displayed, then rectified. The rectified signal should be displayed as well, then filtered with a low-pass filter. After the low-pass filter, the DC component of the resulting signal should be removed before displaying it. The FFT of the received, the rectified, and the resulting signal should be displayed on the required frequency range.

The image to the right presents the general program flow of this VI.


Hardware Setup

For testing the VI, use the same hardware setup as for the Analysis with WaveForms section.


Software Setup

Setup and Instrument Configuration

As a first step, the control and indicator elements should be placed by right-clicking on the Front Panel and selecting the required element. In this VI we need three Combo Boxes: one which sets the device type, with the elements “Analog Discovery Studio”, “Analog Discovery 2” and “Analog Discovery”, one which selects the used Scope channel, with the elements “mso/1” and “mso/2” and one which sets the used Wavegen channel, with the elements “fgen/1” and “fgen/2”. A Stop Button should also be placed on the Front Panel, to interrupt the program if needed.

Two Graphs and four Knobs are needed to set the amplitude and the frequency of the carrier, the frequency of the modulating signal and the modulation index, and to display the resulting signals.

The other three Knobs and six Graphs are used to set the frequency range on which the FFTs are displayed, to select the cut-off frequency of the low-pass filter in the demodulator, and to display the modulated signal, the rectified signal, the demodulated signal, and the spectrum of these.

Arrange everything on the Front Panel, then right-click on the y-axis of the time-domain graphs and deselect Autoscale. Set the range of these axes to make the signals visible. Rename the placed elements by double-clicking on their name. Rename the axes of the graphs by double-clicking on them and also set the multiplier of each axis to match with the labeled unit of measurement (for example: set the multiplier to 1e+06 if the labeled unit of measurement is μs).

In the Block diagram, initialize the Scope instrument (MSO), then configure the selected analog channel (mso/1 or mso/2) in DC mode, with 1X probe attenuation, set the vertical offset to 0 and the vertical range to 5V. Enable the channel with a True constant.

Configure the timing of the Scope to sampling mode, with a sampling rate of 12 times of the carrier frequency, the acquisition time of $\frac{1}{message frequency}$ and pretrigger time of 0s.

Initialize the Wavegen instrument (FGEN) and select the desired channel.

Amplitude Modulation

In a loop, generate two sinusoidal signals (the carrier and the modulating signal), with the required parameters, then create the modulated signal using the formula presented in the Amplitude Modulation Theory section. You can use the same sampling rate as for the Scope instrument and the number of samples should be equal with the sampling rate multiplied by the acquisition time of the Scope.

The resulting (modulated) signal should be outputted on the selected Wavegen channel.

Amplitude Demodulation

Measure with the Scope, then extract the data coming from the selected Scope channel from the result. This will be the modulated signal. You can rectify this signal by taking the absolute value of the whole signal. In this case, the absolute value function behaves like an ideal full-wave rectifier. Filter the rectified signal with a low-pass filter. You can even remove the DC component of the filtered signal to eliminate its offset.

To filter the rectified signal, use the Filter express VI. An Express VI is a VI that allows you to configure the parameters of the VI using a dialog box that pops up after the VI is placed. Express VIs are useful for providing multiple configuration options that abstract the required programming from the user.

In this VI, using a third-order, IIR (infinite impulse response) low-pass Butterworth filter is recommended. IIR filters allow us to implement digital filters that resemble traditional analog filters. The Butterworth filter topology maximizes passband flatness. By increasing the filter's order, the attenuation of the stopband increases, but the delay of the output increases as well.

FFT and Exiting the Program

Create property nodes for the x-axis range property of all frequency-domain graphs and change the minimum and maximum values to the ones required by the user.

Use the Spectral Measurement express VI to compute the FFT of the signals.

In this VI, configure the Spectral Measurements to display the magnitude of the output, and average the results (like previously in WaveForms).

From our initial exploration with FFTs, we are familiar with most of these terms. One thing that might be new is the idea of windows in the FFT. To understand windowing, we must first restate that the FFT is a computer implementation of the Discrete Fourier Transform (DFT). The DFT is the sampled implementation of the continuous-time Fourier Transform. As such, the DFT (and by extension, the FFT) always assumes that any signal acquired in one sample frame is periodic. When the two ends of the frame don’t line up, we introduce artificial discontinuities that affect the spectral content of the signal. Windowing helps us to reduce the effects of these artificial discontinuities.

Averaging should be restarted when one of the input signal (carrier or message) parameters changes. Use shift registers to compare the controls with their value from the previous iteration.

Exit the loop when the Stop button is pressed, or when an error appears. After exiting the loop, the used instruments must be stopped and closed, to make them available to other software, then errors should be handled.

Questions and Exercises
  • Set the message frequency to 1kHz, the modulation coefficient to 10%, the carrier frequency to 100kHz, and the carrier amplitude to 1V. Set the cut-off frequency of the low-pass filter to 20kHz. Compare the demodulated signal to the original message signal. What is similar between the two signals? What is different between the two signals?
  • Compare the demodulated signal to the rectified signal in the time-domain. What is similar between the two signals? What is different between the two signals?
  • Compare the demodulated signal to the rectified signal in the frequency-domain. What is similar between the two signals? What is different between the two signals? Use the cursors to find the peak frequencies in the FFT. Modify the axis ranges if necessary.
  • With the VI still running, change the cut-off frequency while observing the Demodulated Signal and the Demodulated Signal FFT. How does increasing the cut-off frequency of the low-pass filter affect the demodulated signal? How does decreasing the cut-off frequency of the low-pass filter affect the demodulated signal? What is the lowest cut-off frequency we can use to receive a clean signal? The highest?
  • Increase the Modulation Coefficient to 15% in steps of 1%. Observe the graphs as you do this. How does the modulation coefficient affect the demodulated signal? What happens to the demodulated signal as the modulation coefficient increases past 1?
  • The maximum buffer size for the Analog Discovery Studio is 8192 samples. This means that the largest number of samples we can acquire during a single read is 8192 samples. Since the number of samples has a set maximum, how else can we increase the resolution of the FFT? Recall the formula for $df$ discussed in the Measurements in the Frequency Domain section of this lab. What is the practical limitation of using this other method to increase the FFT resolution?

Further Exploration

The topics below go over two ways you can continue exploring after finishing this lab. The first topic looks into using multiple instruments to transmit and receive and the second topic goes into transmitting and receiving messages vs single tones.

Two Device Transmitter and Receiver

In this lab, we had both our transmitter and receiver on the same device. However, the vast majority of communications applications do not only involve one device. Partner with another group to use two Analog Discovery Studios. Designate one group as the receiver and the other group as the transmitter. Using jumper wires, connect the two Analog Discovery Studios together such that the transmitter group modulates and sends out the signal and the receiver group gets the signal and demodulates it to recover the original message.

Hint: If you are running the two Analog Discovery Studios from the same computer, make sure to give each device a unique identifier in WaveForms. This will let you call both devices without getting a conflicting resource error.

Analog AM Demodulation

In this lab, we decided to demodulate by implementing a method known as envelope detection in software. However, the steps in envelope detection (rectifying and filtering) can also be done using hardware. In our previous labs we have talked about both rectification (Lab 4: Full-Wave Rectifiers) and low-pass filtering (Lab 2: Active and Passive Filters). Use the knowledge and circuits you’ve built from these labs to put together a circuit that performs the same function as our software demodulator.

Compare the results of your hardware demodulator to the ones from our software demodulator. What are some considerations and trade-offs between using a hardware system and a software system?


Next Steps

For more complementary laboratories, return to the Complementary Labs for Electrical Engineering page of this wiki.

For technical support, please visit the Test and Measurement section of the Digilent Forums.