realization of fsk modem in matlab and ti’s tms320c5510 dsp

19
REALIZATION OF FSK MODEM IN MATLAB AND TI’s TMS320C5510 DSP PROJECT MENTOR PROF.V.RAJBABU DEPARTMENT OF ELECTRICAL ENGINEERING I.I.T BOMBAY PREPARED BY ABRAR AHMAD TRAINEE (August 2010 –April 2011) For PROJECT SUPPORTED BY BHARTI CENTRE DEPARTMENT OF ELECTRICAL ENGINEERING, IIT BOMBAY

Upload: others

Post on 04-Dec-2021

14 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: REALIZATION OF FSK MODEM IN MATLAB AND TI’s TMS320C5510 DSP

REALIZATION OF FSK MODEM IN MATLAB

AND TI’s TMS320C5510 DSP

PROJECT MENTOR

PROF.V.RAJBABU

DEPARTMENT OF ELECTRICAL ENGINEERING

I.I.T BOMBAY

PREPARED BY

ABRAR AHMAD

TRAINEE (August 2010 –April 2011)

For PROJECT SUPPORTED BY BHARTI CENTRE

DEPARTMENT OF ELECTRICAL ENGINEERING,

IIT BOMBAY

Page 2: REALIZATION OF FSK MODEM IN MATLAB AND TI’s TMS320C5510 DSP

MATLAB IMPLEMENTATION OF FSK MODEM

Frequency shift keying Modulator/Demodulator also referred as v.21 by

International telecommunication union(ITU) is a system which uses 1650Hz and

1850Hz tone to transmit 1’s and 0’s respectively .The data rate of the system is

300bits/sec .The sampling rate is 9000Hz.

MODULATOR:

The data to be transmitted is the input by the user in decimal form. Sampling

frequency (Fs) and bit duration are also taken as input .The decimal string is

converted in the binary form and stored in an array. Two sinusoids X and Y of

frequency 1650Hz and 1850Hz respectively are generated. X is transmitted when

the bit is ‘1’ and Y when the bit is ‘0’. The end signal consists of 30 samples per bit

having two frequency components 1650Hz or 1850Hz depending upon the bit

pattern of the input signal.

The final signal is not a continuous sinusoid due to the change in phase after

every bit. This is because the two frequencies 1650Hz and 1850Hz are not

orthogonal frequencies i.e. they are not integer multiples of bit rate.

The modulator function returns sinusoid signal, sampling frequency (Fs) and the

length of the binary array.

Page 3: REALIZATION OF FSK MODEM IN MATLAB AND TI’s TMS320C5510 DSP

The figure above shows the generated signal for [7 7 6] as input from

120th

sample to 240th

sample. The change in phase is occurring when

the bit value changes from 0 to 1.

Page 4: REALIZATION OF FSK MODEM IN MATLAB AND TI’s TMS320C5510 DSP

The figure above is the frequency spectrum of the modulated signal.

The dominant frequencies are represented by the bright red color. The

maximum value on the y-axis is equal to half of the sampling frequency

so we can see that the frequencies present in the signal are around

1700 Hz.

Page 5: REALIZATION OF FSK MODEM IN MATLAB AND TI’s TMS320C5510 DSP

DEMODULATOR:

1. MIXER:

The first operation on the input signal to the demodulator is frequency shifting. It

is done by multiplying the signal with complex exponential e-j2πFct

.The mixer

output will consist of the sum and difference components of the centre frequency

and the two input frequencies. Fc is chosen as 1750Hz so that the two frequencies

1650Hz (F1) and 1850Hz (F2) are shifted down to +/-100Hz.

The figure above is the frequency spectrum of the mixer output .It consist of the

original frequencies (Fc ,F1, F2) and there sums and differences.

Page 6: REALIZATION OF FSK MODEM IN MATLAB AND TI’s TMS320C5510 DSP

DECIMATOR:

It consists of a down sampler and a low pass filter before the down sampler to

maintain the nyquist criteria. The original signal having 9000 samples per second

is down sampled by a factor of 6 i.e. the sampling frequency is now 1500

samples/sec. In order to prevent the signal from aliasing effect the maximum

frequency component in the signal cannot be greater than half of the sampling

rate (750Hz) .So the filter before the down sampler has a cut off frequency of

750Hz.

Magnitude vs. Frequency plot for the filter described above.

We can see that the cut off frequency is around 0.17 π rad/sample which is 750

Hz.

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9

-70

-60

-50

-40

-30

-20

-10

0

Normalized Frequency (×π rad/sample)

Ma

gn

itud

e (

dB

)

Magnitude Response (dB)

Page 7: REALIZATION OF FSK MODEM IN MATLAB AND TI’s TMS320C5510 DSP

SLICING:

The next operation is to measure the frequency of the received tone. Since we are

looking at one tone at a time we use a faster method for measuring frequency

called slicing. Slicing is defined as follows

s[n] =y[n] (y[n-1])*

If

y[n] =Ae jwn

Then

s[n]=A ejwn

A*e-jw(n-1)

s[n]=|A|2e

jwn

Taking the imaginary part of s[n],

imag_s =|A|2sin(w)

Now we define and array d[n] such that, if ‘imag_s’ is a negative value we store a

‘1’ in the array and if ‘imag_s ‘is positive we store a ‘0’ in the array.

So we conclude that when the frequency is negative, |A|2sin(w) is also negative

and we have a ‘1’. Similarly when frequency is positive the imaginary part of s[n]

is positive and we have a ‘0’

Page 8: REALIZATION OF FSK MODEM IN MATLAB AND TI’s TMS320C5510 DSP

The figure below is time domain plot of imaginary part of s[n] when the input is

[7 7 6] with an extra ‘0’ transmitted at the end.

The horizontal axis goes till 160 samples i.e. 5 samples per bit and altogether 32

bits. From the figure we can observe that for,

X=8; Y=0.09874 (positive value for symbol ‘0’)

& X=33; Y=-0.1106 (negative value for symbol‘1’)

The reason for this observation is that we had chosen the center frequency (Fc) as

1750Hz at the mixer stage and original frequencies 1650Hz and 1850Hz were

shifted to +/-100 Hz. So when the frequency is negative (i.e. when the symbol is 1)

the imaginary part of the slicer output (used for decoding) is negative and when

the frequency is positive (i.e. when the symbol is 0) the imaginary part of the

slicer output (used for decoding) is positive.

But what if the centre frequency was not 1750Hz .Say for example Fc was 1550Hz.

Then the frequencies 1650Hz and 1850Hz will be shifted to100Hz and 300Hz and

both of them are positive values.

Page 9: REALIZATION OF FSK MODEM IN MATLAB AND TI’s TMS320C5510 DSP

The figure below is the time domain plot of the imaginary part of the slicer output

s[n] for the same input [7 7 6], but the centre frequency (Fc) is 1550Hz at the

mixer stage.

From the figure we observe that for,

X=8; Y=0.2176

X=33; Y=0.1057

Both the 8th

and 33rd

samples are positive values .The reason for this is that, since

both the shifted frequencies are positive i.e. 100Hz (for ‘1’) and 300Hz (for ‘0’) the

imaginary part of slicer output will be positive .But we can see that the sample

values (used for decoding) are around 0.2 when a ’0’ is transmitted and around

0.1 when a‘1’ is transmitted .So in this case, threshold value for the decoding

purpose can be chosen as 0.15 ,instead of 0 as in the previous case for Fc=1750Hz

Page 10: REALIZATION OF FSK MODEM IN MATLAB AND TI’s TMS320C5510 DSP

DECODING OF BITS:

d[n] is an array of 1’s and 0’s with 5 bits per symbol as the signal was down

sampled by a factor of 6.The centre bit for every 5 bits i.e. 3rd

,8th

,13th

and so on

are taken as the final output as they are least effected by interference from

adjacent symbols.

The stem plot of the final decoded signal is shown below.

The final decoded output is,

[A]= [000001110000011100000110]

i.e. [7 7 6].

Page 11: REALIZATION OF FSK MODEM IN MATLAB AND TI’s TMS320C5510 DSP

REALTIME IMPLEMENTATION OF FSK MODEM

All the specifications described in the mat lab implementation part are same for

real time implementation same except of the sampling frequency which is

changed to 48000Hz

MODULATOR:

The data to be transmitted is modulated by using two sinusoids of different

frequencies. Modulated signal can be generated in two ways which are described

below.

1. Sine table method: Sine tables are arrays with stored values of samples of

one period of a sinusoid of given frequency. Two such tables are used to produce

two sinusoids, one for bit ‘1’ and other for bit ‘0’. But there is a limitation on this

method .Not all frequencies can be generated by using this method .This is

because the sampling rate on the board is fixed (8KHz, 16KHz, 32KHz or 48KHz).So

not all frequencies will have number of samples per period as integer. For

example say the sampling frequency is fixed at 48KHZ .So a frequency of 1700Hz

will have 28.23 samples per period which is not possible as it has to be an integer.

2. Difference equation method: This is a more efficient way of producing a

modulated wave as we can produce wave of any frequency. The sine wave and

cosine wave are described as

sine [n+1] = sine[n] + (w1/fs)* cosine[n]

cosine [n+1] = cosine[n] - (w1/fs)* sine[n+1]

Where ‘w1’ is the required angular frequency and ‘fs’ is the sampling rate.

Page 12: REALIZATION OF FSK MODEM IN MATLAB AND TI’s TMS320C5510 DSP

DEMODULATION:

1. MIXER

Mixing is multiplying the input signal with an exponential of frequency Fc. The

exponential consist of real part i.e. the cosine term and imaginary part i.e. the

sine term. The cosine and the sine waves of frequency Fc can be generated by the

above two described methods. The output of the mixer will consist of real part

and imaginary part. Further processing will be done independently on these two

parts.

//code for the mixer

for(i=11;i>0;i--) /*right shifting and storing the real and imaginary output of mixer which

will be used in filtering part*/

{

x[i]=x[i-1];

y[i]=y[i-1];

}

/*output[] is input to demodulator and mix_cos[] and mix_sine[] are two waves produced

using difference equation*/

x[0]=output[t1]*mix_cos[t2%160]; //real part of mixer output stored in x[]

y[0]=output[t1]*(-mix_sin[t2%160]); //imaginary part of mixer output stored in y[]

……….

Page 13: REALIZATION OF FSK MODEM IN MATLAB AND TI’s TMS320C5510 DSP

2. FILTER

Filtering is required to make sure that a nyquist criterion is maintained. A filter of

cut off 750Hz is designed in mat lab and the coefficients are used to implement

filter in real time using difference equation.

//filter

for(i=4;i>0;i--) /*right shifting and storing filtered data to be used in the next step*/

{

fx[i]=fx[i-1];

fy[i]=fy[i-1];

}

/*filter implementation using difference equation*/

// filtering of real part

fx[0]=0.0012200191904*x[0]+0.011597461978*x[1]+ 0.05083764*x[2]+

0.12316145132*x[3]+0.19806837823*x[4]+0.2302300980*x[5]+0.0012200191904*x[6]+0.011

597461978*x[7]+ 0.05083764*x[8]+ 0.12316145132*x[9]+ 0.19806837823*x[10];

// filtering of imaginary part

fy[0]=0.0012200191904*y[0]+0.011597461978*y[1]+ 0.05083764*y[2]+

0.12316145132*y[3]+0.19806837823*y[4]+0.2302300980*y[5]+0.0012200191904*y[6]+0.011

597461978*y[7]+ 0.05083764*y[8]+ 0.12316145132*y[9]+ 0.19806837823*y[10];

Page 14: REALIZATION OF FSK MODEM IN MATLAB AND TI’s TMS320C5510 DSP

DOWNSAMPLER:

Down sampling is reducing the number of samples which will undergo further

processing .In real time it is done by using a while loop which selects every fifth

sample for further processing .Hence sampling rate is reduced to one fifth of the

original rate.

//Code for down sampling

if(counter%5==0) //every fifth sample enters the loop

{

dfx[0]=fx[0];

dfy[0]=fy[0];

dfx[1]=fx[1];

dfy[1]=fy[1];

………..

Further processing will be done with in the ‘if’ loop i.e. on every fifth sample. This

‘if’ loop will close at the end.

Page 15: REALIZATION OF FSK MODEM IN MATLAB AND TI’s TMS320C5510 DSP

SLICING:

The next and the final step for demodulation is to measure the incoming frequency.

It is done using a method called Slicing which is described in the mat lab

implementation part. It is defined as

s[n] =y[n] (y[n-1])*

It is basically multiplication of the signal with its delayed conjugate.

// code for slicing

sdfx=(dfx[0]*dfx[1])+(dfy[0]*dfy[1]); //slicing done on real part of signal

sdfy=(dfy[0]*dfx[1])-(dfx[0]*dfy[1]); // slicing done on imaginary part of signal

Decision whether the data is ‘1’ of ‘0’ is done by checking the sign of the

imaginary part of the slicer output. Code for the same is described below.

if(sdfy<0)

{

final [counter1]=1;

sum++;

}

else

final[counter1]=0;

counter1++;

Page 16: REALIZATION OF FSK MODEM IN MATLAB AND TI’s TMS320C5510 DSP

CONCLUSION:

Matlab implementation of the modulator part as well as the demodulator part

worked satisfactorily. Data transmitted and received were the same. Real time

implementation of the modulator part using both the look up table and the

difference equation worked well. But demodulator didn’t work well because

reading data sample by sample and then processing it is not possible as during the

processing time, DSP will read any random data and, the data transmitted and

received will not be the same.

Page 17: REALIZATION OF FSK MODEM IN MATLAB AND TI’s TMS320C5510 DSP

FUTURE WORK:

Reading the data sample by sample and then processing it is not possible as during

the processing time, DSP will read any random data as mentioned earlier. So this

problem can be overcome by using two kits one for modulation and other for

demodulation. But using two kits will require synchronization between the two kits

and synchronization of the two kits is tough to achieve as the demodulator kit

needs to start processing as soon as it receives the data which is practically

difficult. So kit will read any random data when the actual data is not coming and

process it. And we need to transmit preamble along with the data to recognize the

starting of the data and a decoding algorithm has to be included in the demodulator

part that recognizes the preamble. Another possible solution is to make use of ping

pong buffers where we process a group of data instead of individual samples. In

this case one buffer (ping) receives the data and stores to its capacity. Once it is

full it transfers the data into the other buffer (pong) and collects the new data

coming in. The data in the pong buffer is processed.

Page 18: REALIZATION OF FSK MODEM IN MATLAB AND TI’s TMS320C5510 DSP

REFERENCES:

1. Sen M Kao, Bob H. Lee and Wenshun Tian , Real time Digital Signal

processing Implementation and Applications , 2nd

edition , John Wiley &

sons Ltd. , 2006

2. ALAN V.OPPENHEIM ,ALAN S.WILLSKY, “SIGNALS & SYSTEMS”

published by Prentice Hall , second edition,1997

3. Signal Processing First book ,lab 15:Digital Communication :FSK MODEM

Page 19: REALIZATION OF FSK MODEM IN MATLAB AND TI’s TMS320C5510 DSP