ad space

Demodulation of standard AM signal with Square Law Detector in Matlab

Standard AM signal can be demodulated using two methods which is either to use square law detector method or using Hilbert filter method. The Hilbert transform method of demodulating standard AM signal was illustrated in the previous blog post. In this blog post, it is illustrated how to demodulate AM signal using the square law detector method in Matlab. 

See other Matlab tutorial on AM modulation:

- Standard AM signal generation in Matlab 

- Generate DSB-AM Signal in Matlab 

- SSB-SC AM signal generation in Matlab

Circuit Diagram

The following shows the square law detector circuit diagram for demodulation of standard AM signal.

 

standard AM demodulation with Square Law Detector

The message and carrier signal are defined as follows.

The message signal, \(m(t)\), is given by:
m(t)=Amcos⁡(2πfmt)

where  \(A_m\) is the amplitude of the message signal, and  \(f_m\) is the frequency of the message signal.

The carrier signal,  \(c(t)\), is given by:
c(t)=Accos⁡(2πfct)

where  \(A_c\) is the amplitude of the carrier signal, and \(f_c\) is the frequency of the carrier signal.

The standard AM signal equation is,

\(s(t) = A_c[1+k_a m(t)] cos(2 \pi f t)\)

where \(k_a\) is amplitude sensitivity of the AM modulator.

 The a(t) given below is called envelope of the standard AM.

\( a(t)=A_c|1+k_a m(t)| \)

The following is equation of percentage modulation,

\(percentage \space modulation = k_a m(t) \times 100\)

 Matlab Code

 The following is matlab code doe demodulation of standard AM signal with square law detector method.

Ac=input('enter carrier signal amplitude: ');
Am=input('enter message signal amplitude(Am<Ac): ');    
fc=input('enter carrier frequency: ');
fm=input('enter message frequency(fm<fc): ');
ka=input('enter amplitude sensitivity: '); 

% Ac=0.8;
% Am=0.5;    
% fc=1000;
% fm=200;
% ka=0.8; 

fs = 10*fc;      % sampling frequency
ts = 1/fs;     % sampling time

% Generate message signal
t = (0:ts:500*ts).';  % time vector
m = Am*cos(2*pi*fm*t); % message signal

% Generate carrier signal
c = Ac*cos(2*pi*fc*t); % carrier signal

% Perform DSB-SC AM modulation
stx = (1+ka*m).*c;

% Add channel noise
SNR = 30; % signal-to-noise ratio in dB
stx_noisy = awgn(stx, SNR, 'measured');

% Demodulate using square law detector
baseband = stx .* (cos(2*pi*fc*t));

% Apply low-pass filter to recover message signal
fcutoff = 2*fm; % cutoff frequency of filter
[b,a] = butter(4, fcutoff/(fs/2)); % design low-pass Butterworth filter
m_demod = filter(b,a,baseband);

% Plot the signals
subplot(4,1,1); plot(t,m); title('Message signal');
xlabel('Time (s)'); ylabel('Amplitude');

subplot(4,1,2); plot(t,stx); title('Carrier signal');
xlabel('Time (s)'); ylabel('Amplitude');

subplot(4,1,3); plot(t,stx_noisy); title('Noisy Standard AM signal');
xlabel('Time (s)'); ylabel('Amplitude');

subplot(4,1,4); plot(t,m_demod); title('Demodulated Standard AM signal');
xlabel('Time (s)'); ylabel('Amplitude');

This code generates an AM (amplitude modulation) signal and then applies noise and demodulation techniques to recover the original message signal. Here's a breakdown of the code:

  • The user is prompted to input various parameters for the AM signal, such as the carrier signal amplitude, message signal amplitude, carrier frequency, message frequency, and amplitude sensitivity.
  • The sampling frequency is set to 10 times the carrier frequency, and the sampling time is calculated based on the sampling frequency.
  • The message signal is generated as a cosine wave with a frequency of fm, and the carrier signal is generated as a cosine wave with a frequency of fc. The AM signal is then generated by multiplying the carrier signal by (1 + ka * m), where m is the message signal and ka is the amplitude sensitivity.
  • Noise is added to the AM signal using the awgn function, which adds white Gaussian noise to the signal at the specified signal-to-noise ratio (SNR).
  • The AM signal is demodulated using a square law detector, which involves multiplying the AM signal by a cosine wave at the carrier frequency.
  • A low-pass filter is applied to the resulting baseband signal to recover the original message signal. The cutoff frequency of the filter is set to 2 times the message frequency, and a Butterworth filter with a order of 4 is used.
  • The resulting message signal is plotted, along with the original message signal, the carrier signal, and the noisy AM signal.

Overall, this code demonstrates how to generate, modulate, add noise to, and demodulate an AM signal using a square law detector and low-pass filter.

The following shows the message signal, the transmitted AM modulated standard AM signal waveform, the noisy received AM signal and the recovered AM signal.

 

DSB-SC demodulation with square law detector circuit diagram

References:

[1] diode modulator circuit

[2] single balanced diode mixer

[3] am modulation circuit diagram

Post a Comment

Previous Post Next Post