Monday, July 29, 2013

FHSS implemented in matlab




         Frequency-hopping spread spectrum
        (Matlab Implementation With An Example)
                      Hasan Mehmood ,Usama Zaka Khan
            Department Of Electrical Engineering, Institute Of Space Technology


Abstract: Frequency-hopping spread spectrum (FHSS) is a method of transmitting radio signals by rapidly switching a carrier among many frequency channels, using a pseudorandom sequence known to both transmitter and receiver. It is utilized as a multiple access method in the frequency-hopping code division multiple access (FH-CDMA) scheme.[2]
This phenomenon is implemented in matlab with help of an example to show how FHSS can be achieved. Necessary graphs and matlab code are included in the report.
1. Introduction: Spread spectrum is a digital modulation technology and a technique based on principals of spreading a signal among many frequencies to prevent interference and signal detection. As the name shows it is a technique to spread the transmitted spectrum over a wide range of frequencies. It started to be employed by military applications because of its Low Probability of Intercept (LPI) or demodulation, interference and anti-jamming (AJ) from enemy side. The idea of Spreading spectrum is to spread a signal over a large frequency band to use greater bandwidth than the Data bandwidth while the power remains the same. And as far as the spread signal looks like the noise signal in the same frequency band it will be difficult to recognize the signal which this feature of spreading provides security to the transmission.   Compared to a narrowband signal, spread spectrum spreads the signal power over a wideband and the overall SNR is improved because only a small part of spread spectrum signal will be affected by interference. In a communication system in sender and receiver sides’ one spreading generator has located which based on the spreading technique they synchronize the received modulated spectrum.[1]
2. Frequency Hopping spread spectrum: Frequency hopping spread spectrum is a transmission technology used in wireless networks and a technique to generate spread spectrum by hopping the carrier frequency. FHSS uses narrow band signal which is less than 1 MHz, Inthis method data signal is modulated with a narrowband carrier signal that "hops" in random and hopping happens in pseudo-random "predictable" sequence in a regular time from frequency to frequency which is synchronized at both ends. Using FHSS technology improves privacy, it is a powerful solution to avoid interference and multi path fading (distortion), it decreases narrowband interference, increases signal capacity, improve the signal to  noise ratio, efficiency of bandwidth is high and difficult to intercept also this transmission can share a frequency band with many types of conventional transmissions with minimal interference. For frequency hopping a mechanism must be defined to transmit data in a clear channel and to avoid the congested channels. Frequency hopping is the periodic change of transmission frequency and hopping happens over a frequency bandwidth which consists of numbers of channels. Channel which is used as a hopped channel is instantaneous bandwidth while the hopping spectrum is called total hopping bandwidth. Frequency hopping categorized into slow hopping and fast hopping which by slow hopping more than one data symbol is transmitted in same channel and by fast hopping frequency changes several times during one symbol. Hopping sequence means which next channel to hop; there are two types of hopping sequence: random hopping sequence and deterministic hopping sequence. The focus of this work is on slow and deterministic frequency hopping sequence. In a frequency hopping network, there can be different number of receivers which one sender is designed as Base that is responsible to transmit the synchronization data to the receivers.[2]
3.  Pseudo code for Implementation: following steps were undergone while making the code
1.      Random no. of bits were generated
2.      NRZ line coding was implemented
3.      BPSK modulation was done
4.      Random carrier frequencies were generated
5.      A spread signal was formed by randomly choosing the frequencies.
6.      Frequency hoped spread signal was formed.
NRZ was chosen to give 180 degree phase shift. And BPSK was used for simplicity. Choice of carrier frequencies was random.
4. Matlab Code’s Output: The code was implemented for random 25 bits message signal and following outputs were acquired from Matlab.



                                    Figure:1

Different steps in producing a frequency hopped signal are shown in figure 1.
For checking if our modulation in accurate we took FFT f the system. For a correct modulation there must be Six peaks n the FFT as the modulation is done on six different frequencies. The output acquired was as below



  


Figure:2

As shown above there are six clusters in the FFT of the FHSS modulated signal. This provides us the satisfaction that our design is accurate.
5. Matlab Code:



% Frequency Hopping Spread Spectrum
%------------------------------------------------------------%
clc
clear

% Generation of bit pattern
s=round(rand(1,25));    % Generating 25 bits
signal=[]; 
carrier=[];
t=[0:2*pi/119:2*pi];     % Creating 120 samples for one cosine
for k=1:25
    if s(1,k)==0
        sig=-ones(1,120);    % 120 minus ones for bit 0
    else
        sig=ones(1,120);     % 120 ones for bit 1
    end
    c=cos(t);  
    carrier=[carrier c];
    signal=[signal sig];
end
subplot(4,1,1);
plot(signal);
axis([-100 3100 -1.5 1.5]);
title('\bf\it Original Bit Sequence');

% BPSK Modulation of the signal
bpsk_sig=signal.*carrier;   % Modulating the signal
subplot(4,1,2);
plot(bpsk_sig)
axis([-100 3100 -1.5 1.5]);
title('\bf\it BPSK Modulated Signal');

% Preparation of 6 new carrier frequencies
t1=[0:2*pi/9:2*pi];
t2=[0:2*pi/19:2*pi];
t3=[0:2*pi/29:2*pi];
t4=[0:2*pi/39:2*pi];
t5=[0:2*pi/59:2*pi];
t6=[0:2*pi/119:2*pi];
c1=cos(t1);
c1=[c1 c1 c1 c1 c1 c1 c1 c1 c1 c1 c1 c1];
c2=cos(t2);
c2=[c2 c2 c2 c2 c2 c2];
c3=cos(t3);
c3=[c3 c3 c3 c3];
c4=cos(t4);
c4=[c4 c4 c4];
c5=cos(t5);
c5=[c5 c5];
c6=cos(t6);

% Random frequency hopps to form a spread signal
spread_signal=[];
for n=1:25
    c=randint(1,1,[1 6]);
    switch(c)
        case(1)
            spread_signal=[spread_signal c1];
        case(2)
            spread_signal=[spread_signal c2];
        case(3)
            spread_signal=[spread_signal c3];
        case(4)
            spread_signal=[spread_signal c4];
        case(5)       
            spread_signal=[spread_signal c5];
        case(6)
            spread_signal=[spread_signal c6];
    end
end
subplot(4,1,3)
plot([1:3000],spread_signal);
axis([-100 3100 -1.5 1.5]);
title('\bf Spread Signal with 6 frequencies');

% Spreading BPSK Signal into wider band with total of 5 frequencies
freq_hopped_sig=bpsk_sig.*spread_signal;
subplot(4,1,4)
plot([1:3000],freq_hopped_sig);
axis([-100 3100 -1.5 1.5]);
title('\bf Frequency Hopped Spread Spectrum Signal');

% Expressing the FFTs
figure,subplot(2,1,1)
plot([1:3000],freq_hopped_sig);
axis([-100 3100 -1.5 1.5]);
title('\bf Frequency Hopped Spread Spectrum signal and its FFT');
subplot(2,1,2);
plot([1:3000],abs(fft(freq_hopped_sig)));









6. Conclusion: Through whole the exercise, the basic concept of FHSS was gained. It’s implementation was learnt and the overall grasp on the topic was made stronger.
 7. Acknowledgement
The authors gratefully acknowledge Mrs. Salma Zainab and Mr. Adnan Zafar for their  valuable support and guidance in this work.
8. References:
[1] Frequency Hopping Spread Spectrum: An Effective Way to Improve Wireless Communication Performance
[2].  www.wikipedia.com

https://en.wikipedia.org/wiki/Frequency-hopping_spread_spectrum