NAV BAr

Sunday, May 29, 2016

AM Radio Superhetrodryne Receiver (MATLAB Signal Extraction)

AM Radio Superhetrodryne Receiver (MATLAB Signal Extraction)

1. Objective:

The main purpose of this lab is to understand how Superhetrodryne Receiver works for AM radio. Also, to extract signal using MATLAB using this principle for the given center frequency.

2. Theory:

Whenever the signal is received by the antenna it receives bunch of AM signal. We can adjust the center frequency and hear the desired station we want. So, in order to hear the desired center frequency we have to eliminate other frequency components which involves step by step method. For Superhetrodryne Receiver this is the block diagram how it works on the receiver side.

f1 = 35.5 Khz, f2 = 48 KHz, f3 = 60.5 KHz and f4 = 71.5 KHz respectively is passed through 5 stages and described down below.

  • RF BPF:
  • After signal is received on antenna it goes to first filter called Radio frequency filter. This is band pass filter which filters the image station. A designer can design this filter in such a way that the upper cutoff frequency of the band pass filter should be less than

    F_up < fc+2If ---1

    Where f_up is the upper cut of frequency, fc is center frequency and If is intermediate frequency. In, this was we can make sure that image station (fc+2If) in cutoff. Whereas for lower cut off has to be at least

    F_lower =fc-B_band --- 2

    Where B_band is the baseband for voice. Since, voice has spectrum up to 4 KHz, B_band can be set as 4Khz. After the upper and lower limits are set up we can use butter function in MATLAB to create a bandpass filter to select the desired center frequency fc, and cutoff the image station.

  • Signal mixture
  • In this block output form RF band pass filter is mixed with and local oscillator. Local oscillator frequency is chosen in such a way that

    fL0 = fc + fIf ----3
    Where fL0 is oscillator frequency. The output of the mixer is in frequency domain is
    fIF = fL0 - fc ----4
    fIF = fL0 + fC -----5

    Equation 4 and 5 shows the amplitude spectrum of signal which is shifted to intermediate frequency. Equation 4 is desired station frequency whereas equation 5 is the image station created by the local oscillator. Also, during the state the amplitude of the signal is reduced in half, so we need amplifier to amplify the signal.

  • Intermediate Frequency band pass filter (IF BPF) :
  • The third part of the design is IF filter. This filter is responsible to filter out the noise and the neighboring station. The upper limit and lower limit of this band pass filter is chosen in such a way that it would filter out everything except the signal. For this filter the upper and lower cutoff frequency is given by

    fF_upper = fc + B_band ---6
    fF_lower= fc-B_band -----7

    The reason we need to add and subtract B_band which is voice signal spectrum because we can hear the voice signal up to 4 kHz. Due to this reason the B_band would have a bandwidth of

    f2*B_band= 8Khz ----9

    So the audible bandwidth of B_band is 8 Khz. Therefore, any signal after and before 4 KHz need to added and subtracted in order to remove noise and neighboring station.

  • Envelop Detector:
  • The fourth block of the design is Envelop detector. This block is made up of a diode and a RC circuit in parallel which acts a low pass filter. The output of the IF BPF filter is taken to diode. The reason we use diode because diode gets rid of the negative amplitude, since diode are forward biased. And during the negative cycle the charged capacitor is discharged through the resistor making a ripple effect, creating an envelope. Also, during this envelop detection process high frequency component is taken off by low pass filter.

    A+m2(t) cos(wIFt) ----10
    A+m2(t) ----11

    A is the DC component m2(t) is the signal need to be extracted and cos (wIFt) is the high frequency component. Here, equation 10 shows the signal before passing though envelop detector and after passing though the detector the high frequency cos (wIFt) is cut off.

  • Mean/ DC component:
  • In this part of the DC component is taken off. The reason we need to take DC component off because at the time of signal modulation the DC component was used to offset the amplitude so, the signal was shifted up in positive Y axis. In order to filter DC component we need to use capacitor since capacitor acts as open circuit for DC. And in MATLAB we can use mean function at the output of envelop detector to filter out the DC component. The average of data is DC so mean gives the DC component. Thus subtracting with equation 11 filters the desired signal. In this case m2(t) is the desired signal.

  • Sampling down
  • We need to sample down the given signal to human hearing frequency. IN order do that we need to down sample the given signal to 8000Hz. The reason we have 8 kHhz is because the bandwidth of base band of the sound is 4000K. As we know

    Fs=2B----12
    Fs=2*4000=8Khz
  • Sound play
  • After the signal is sampled down the signal is played with the function sound(x).

3 Matlab code

%%AM demodulation
%Superheterodyne Receiver
%Parameter Setting
%Lab4

clc; % Clear command window
clear all; %Clear variablesand functions from memory
close all;
load AM_DATA; %loading Matlab data samples
Fs=400*10^3; % sampling rate
N=length(x); %size of the data
f_if= 23.5*10^3; %intermediate Frequency
f2=48*10^3; %desired Am station frequency also centre freqeuncy
b_band=4*10^3 ; % baseband for voice
dt=1/Fs; %sampling interval
t=(0:N-1)*dt; %time duration for the data
%figure (1);
%plot(t,x);
%title('Time domain Signal ');
%xlabel('Time domain signal');
%ylabel ('Amplitude');
%grid on;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%seeing Amplitude Spectrum in frequncy domain
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

df=Fs/N; %FFT resolution
Nfft=Fs/df; %Total samples in freqeuncy domain based on FFT resolution
f=(0:Nfft-1)*df; %freqency vector for one period
X=fft(x,Nfft)/N; %calculating spectrum of x
figure (2);
title('Amplidute Spectrum of x in one period (Fs)');
xlabel('Frequency in Hz');
ylabel('Amplitude');
plot (f,abs(X));

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%RF Band pass filter taking image station off
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

L_cutoff_freq=(f2-f_if);
U_cuttoff_freq=(f2+f_if);
l_limit_coefficient= L_cutoff_freq/(Fs/2);
u_limit_coefficient= U_cuttoff_freq/(Fs/2);
[b,a]=butter(5,[l_limit_coefficient u_limit_coefficient]);
RF_out=filter(b,a,x);

%Checking if the signal is filtered or not
X1=fft(RF_out,N)/N; %fft with N samples for filtered signal
figure(3);
title('RF band pass filter response ');
xlabel('Frequency in Hz');
ylabel('Amplitude');
plot(f, abs(X1)); %plot magnitude of frequency spectrum; only positive ones

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%mixer containing oscillator and upper convertor
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

f_local_oscillator=f2+f_if; %local oscillator frequency
f_gen=cos(2*pi*f_local_oscillator*t);
f_mixer=3.*RF_out.*f_gen;
%verifying fft
X2=(1/N)*fft(f_mixer,N);
figure(4);
title('Response after mixing signals ');
xlabel('Frequency in Hz');
ylabel('Amplitude');
plot(f, abs(X2));

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%IF bandpass filter removing adjacent station
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

l_cutoff_cof= (f_if-b_band)/(Fs/2); %removing lower adjacent station
u_cutoff__cof= (f_if+b_band)/(Fs/2); %removing upper adjacent station
[b1, a1] = butter(6,[l_cutoff_cof,u_cutoff__cof]);
If_out = filter(b1,a1,f_mixer); %Remove the neighboring stations

%cheking in frequency domain
X3 = fft(If_out, N)/N; %Freq Response of Filtered Stations
figure(5)
plot(f, abs(X3));
title('IF Filter Response ')
xlabel('Frequency (Hz)')
ylabel('Magnitude')

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Envelope detector
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Diode_out=abs(If_out); %getting only positive values
Normalized_freq= (b_band)/(Fs/2); % Normalized cutoff frequency
[b2,a2] = butter(4,Normalized_freq,'low'); %
RC_LPF=filter(b2,a2,Diode_out); %low pass filter output

%cheking in frequency domain, verifying fft
X4 = fft(RC_LPF, N)/N; %Freq Response of Filtered Stations
figure(6);
plot(f, abs(X4));
title('Envelop detector output ')
xlabel('Frequency (Hz)')
ylabel('Magnitude')

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%take DC compnent off by capacitor
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Capacitor_out=RC_LPF-mean(RC_LPF); %Capacitor

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Down sample and play
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

sample_rate=(400*10^3)/(8*10^3); % sound sampling rate is 8Khz but this signal is sampled to 400Khz
extract_signal=downsample(Capacitor_out,sample_rate);
sound(extract_signal);%play sound

4. Result :

Figure 2 shows the time domain signal whereas figure 3 shows the amplitude spectrum of received signal at antenna. FFT function was used to convert the signal from time domain to frequency domain

Figure 4 shows the response of RF band pass filter. Here the image station is cut off which is at 95 KHz. So the required frequency f2 is filtered through here.

Figure 5 is the response when the signal is mixed with the oscillator in order to shift the given frequency f2 at the intermediate frequency which is at 23.5 KHz. So, in this case frequency component at 48 KHz is shifted to 23.5 KHz

This figure 6 and 7 shows the IF filter response which takes care of neighboring station and noise components off. As we can see two peaks which is the station frequency at Intermediate frequency and image frequency at 37.65 KHz

Figure 8 show the signal that we extracted for the desired station. Now the signal can down sampled so it can be in human audible range where high frequency components are taken off.

5. Conclusion:

If we change the center frequency at the code it is like tuning to next radio station.

No comments:

Post a Comment